source: trunk/external-alma/oldasdm2ASAP/OldASDMReader.h@ 2296

Last change on this file since 2296 was 2273, checked in by Takeshi Nakazato, 13 years ago

New Development: No

JIRA Issue: Yes CAS-1913

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Support latest ASDM definition in asdm2ASAP.
Now asdm2ASAP is linked to libalma_v3.so to be able to read latest ASDM.

The importasdm task invokes asdm2ASAP when singledish is True.

Older version of asdm2ASAP is renamec as oldasdm2ASAP.
The oldasdm2ASAP and related classes are built by linking to libalma.so.
It is installed but not used by any tasks.


File size: 15.7 KB
Line 
1#ifndef ASAP_OLD_ASDM_READER_H
2#define ASAP_OLD_ASDM_READER_H
3
4#include <string>
5#include <map>
6
7#include <casa/Utilities/CountedPtr.h>
8#include <casa/Containers/Record.h>
9#include <casa/Logging/LogSinkInterface.h>
10#include <ASDMAll.h>
11#include <SDMBinData.h>
12
13class OldASDMReader
14{
15public:
16 /**
17 * constructor
18 **/
19 OldASDMReader() ;
20
21 /**
22 * destructor
23 **/
24 ~OldASDMReader() ;
25
26 /**
27 * open data
28 *
29 * @param filename input ASDM name
30 * @param processing options as casa record
31 * @return boolean status (true or false)
32 **/
33 bool open( const std::string &filename, const casa::Record &rec ) ;
34
35 /**
36 * fill data
37 **/
38// void fill() ;
39
40 /**
41 * close data
42 **/
43 void close() ;
44
45 /**
46 * get antenna id
47 **/
48 casa::Int getAntennaId() { return antennaId_ ; } ;
49
50 /**
51 * get antenna name
52 **/
53 casa::String getAntennaName() { return antennaName_ ; } ;
54
55 /**
56 * fill header
57 *
58 * @param nchan (maximum) number of channel
59 * @param npol (maximum) number of polarization
60 * @param nif number of IFs
61 * @param nbeam number of beam
62 * @param observer observer name
63 * @param project name
64 * @param obstype observation type
65 * @param antennaname antenna name
66 * @param antennaposition antenna position
67 * @param equinox equinox (numerical value)
68 * @param freqref frequency frame
69 * @param reffreq reference frequency
70 * @param bandwidth (maximum) bandwidth
71 * @param utc start time of observation
72 * @param fluxunit flux unit (K or Jy)
73 * @param epoch epoch (UTC)
74 * @param poltype polarization type
75 **/
76 void fillHeader( casa::Int &nchan,
77 casa::Int &npol,
78 casa::Int &nif,
79 casa::Int &nbeam,
80 casa::String &observer,
81 casa::String &project,
82 casa::String &obstype,
83 casa::String &antennaname,
84 casa::Vector<casa::Double> &antennaposition,
85 casa::Float &equinox,
86 casa::String &freqref,
87 casa::Double &reffreq,
88 casa::Double &bandwidth,
89 casa::Double &utc,
90 casa::String &fluxunit,
91 casa::String &epoch,
92 casa::String &poltype ) ;
93
94 /**
95 * get list of valid configDescriptionId
96 *
97 * only return list of configDescriptionId with correlationMode of
98 * AUTO_ONLY or CROSS_AND_AUTO.
99 *
100 * @return list of valid configDescriptionId
101 **/
102 casa::Vector<casa::uInt> getConfigDescriptionIdList() { return configDescIdList_ ; } ;
103
104 /**
105 * get list of fieldId
106 *
107 * @return list of fieldId as casa::uInt
108 **/
109 casa::Vector<casa::uInt> getFieldIdList() ;
110
111 /**
112 * get number of rows in Main table
113 *
114 * @return number of rows in Main table
115 **/
116 casa::uInt getNumMainRow() ;
117
118 /**
119 * binary data selection
120 **/
121 void select() ;
122
123 /**
124 * set Main rows that matches given context (configDescId and fieldId)
125 * to mainRow_
126 *
127 * @param configDescId
128 * @param fieldId
129 **/
130 casa::Bool setMainRow( casa::uInt configDescId, casa::uInt fieldId ) ;
131
132 /**
133 * set Main row to SDMBinData object
134 *
135 * @param irow row index
136 * @return boolean indicating the row is valid or not
137 **/
138 casa::Bool setMainRow( casa::uInt irow ) ;
139
140 /**
141 * get scan number of current row
142 *
143 * @return scan number
144 **/
145 unsigned int getScanNo() { return (unsigned int)(mainRow_[row_]->getScanNumber()) ; } ;
146
147 /**
148 * get subscan number of current row
149 *
150 * @return subscan number
151 **/
152 unsigned int getSubscanNo() { return (unsigned int)(mainRow_[row_]->getSubscanNumber()) ; } ;
153
154 /**
155 * get subscan number for given index
156 *
157 * @param idx for vmsData_
158 * @return subscan number
159 **/
160 unsigned int getSubscanNo( unsigned int idx ) ;
161
162 /**
163 * get IF number for given index
164 *
165 * @param idx for vmsData_
166 * @return IF number
167 **/
168 casa::uInt getIFNo( unsigned int idx ) ;
169
170 /**
171 * get number of polarization for given index
172 *
173 * @param idx for vmsData_
174 * @return number of polarizations
175 **/
176 int getNumPol( unsigned int idx ) ;
177
178 /**
179 * get REFPIX, REFVAL, INCREMENT for given index
180 *
181 * @param idx for vmsData_
182 * @param refpix REFPIX
183 * @param refval REFVAL
184 * @param incr INCREMENT
185 * @param freqref frequency reference
186 **/
187 void getFrequency( unsigned int idx,
188 double &refpix,
189 double &refval,
190 double &incr,
191 std::string &freqref ) ;
192
193 /**
194 * get rest frequencies for given index
195 *
196 * @param idx for vmsData_
197 * @return rest frequencies
198 **/
199 vector<double> getRestFrequency( unsigned int idx ) ;
200
201 /**
202 * get MJD time in day for given index
203 *
204 * @param idx for vmsData_
205 * @return MJD time in day
206 **/
207 double getTime( unsigned int idx ) ;
208
209 /**
210 * get integration time in sec for given index
211 *
212 * @param idx for vmsData_
213 * @return integration time in sec
214 **/
215 double getInterval( unsigned int idx ) ;
216
217 /**
218 * get source name for given index
219 *
220 * @param idx for vmsData_
221 * @return source name
222 **/
223 string getSourceName( unsigned int idx ) ;
224
225 /**
226 * get field name for given index
227 * field name = fieldName + "__" + fieldId
228 *
229 * @param idx for vmsData_
230 * @return field name
231 **/
232 string getFieldName( unsigned int idx ) ;
233
234 /**
235 * get source direction for given index
236 *
237 * @param idx for vmsData_
238 * @return source direction as vector<double>
239 **/
240 std::vector<double> getSourceDirection( unsigned int idx ) ;
241 void getSourceDirection( unsigned int idx,
242 std::vector<double> &dir,
243 std::string &ref ) ;
244
245 /**
246 * get source direction with reference
247 *
248 * @param dir source direction
249 * @param reference frame
250 * @param idx for Source table
251 **/
252 void getSourceDirection( std::vector<double> &dir, std::string &ref ) ;
253
254 /**
255 * get source proper motion for given index
256 *
257 * @param idx for vmsData_
258 * @return source proper motion as vector<double>
259 **/
260 std::vector<double> getSourceProperMotion( unsigned int idx ) ;
261
262 /**
263 * get systemic velocity of the source for given index
264 * at the moment return 0-th element of sysVel vector
265 *
266 * @param idx for vmsData_
267 * @return systemic velocity of the source
268 **/
269 double getSysVel( unsigned int idx ) ;
270
271 /**
272 * get row-based flag for given index
273 *
274 * @param idx for vmsData_
275 * @return row-based flag
276 **/
277 unsigned int getFlagRow( unsigned int idx ) ;
278
279 /**
280 * get data shape (nPol, nChan, nApc=1) for given index
281 *
282 * @param idx for vmsData_
283 * @return data shape
284 **/
285 std::vector<unsigned int> getDataShape( unsigned int idx ) ;
286
287 /**
288 * get spectral data for given index
289 *
290 * @param idx for vmsData_
291 * @return spectral data
292 **/
293 float *getSpectrum( unsigned int idx ) ;
294
295 /**
296 * get channel flag data for given index
297 *
298 * @param idx for vmsData_
299 * @return channel flag
300 **/
301 //bool *getFlagChannel( unsigned int idx ) ;
302
303 /**
304 * get Tsys for given index
305 *
306 * @param idx for vmsData_
307 * @return Tsys
308 **/
309 std::vector< std::vector<float> > getTsys( unsigned int idx ) ;
310
311 /**
312 * get Tcal for given index
313 *
314 * @param idx for vmsData_
315 * @return Tcal
316 **/
317 std::vector< std::vector<float> > getTcal( unsigned int idx ) ;
318
319 /**
320 * get Tcal and Tsys for given index
321 *
322 * @param idx for vmsData_
323 * @param tcal Tcal
324 * @param tsys Tsys
325 **/
326 void getTcalAndTsys( unsigned int idx,
327 std::vector< std::vector<float> > &tcal,
328 std::vector< std::vector<float> > &tsys ) ;
329
330 /**
331 * get opacity for given index
332 *
333 * @param idx for vmsData_
334 * @return opacity
335 **/
336 std::vector<float> getOpacity( unsigned int idx ) ;
337
338 /**
339 * get weather information for given index
340 *
341 * @param idx for vmsData_
342 * @param temperature
343 * @param pressure
344 * @param humidity
345 * @param windspeed
346 * @param windaz
347 **/
348 void getWeatherInfo( unsigned int idx,
349 float &temperature,
350 float &pressure,
351 float &humidity,
352 float &windspeed,
353 float &windaz ) ;
354
355 /**
356 * get pointing information for given index
357 *
358 * @param idx for vmsData_
359 * @param dir direction
360 * @param az azimuth
361 * @param el elevation
362 * @param srate scan rate
363 **/
364 void getPointingInfo( unsigned int idx,
365 std::vector<double> &dir,
366 double &az,
367 double &el,
368 std::vector<double> &srate ) ;
369
370 /**
371 * get source type enum (int) for given scan and subscan
372 *
373 * @param scan scan No.
374 * @param subscan subscan No.
375 * @return source type as int
376 **/
377 int getSrcType( unsigned int scan,
378 unsigned int subscan ) ;
379
380 /**
381 * get list of dataDescId for given configDescId
382 *
383 * @param configDescId
384 * @return list of dataDescId
385 **/
386// casa::Vector<casa::uInt> getDataDescIdList( casa::uInt cdid ) ;
387
388 /**
389 * get list of switchCycleId for given configDescId
390 *
391 * @param configDescId
392 * @return list of dataDescId
393 **/
394// casa::Vector<casa::uInt> getSwitchCycleIdList( casa::uInt cdid ) ;
395
396 /**
397 * get list of feedId for given configDescId
398 *
399 * only return list of feedId that corresponds to specified antenna.
400 *
401 * @param configDescId
402 * @return list of valid feedId
403 **/
404// casa::Vector<casa::uInt> getFeedIdList( casa::uInt cdid ) ;
405
406 /**
407 * set binary data to MSData object
408 *
409 * @return boolean status
410 **/
411 casa::Bool setData() ;
412
413 /**
414 * get number of data in the current row
415 *
416 * @return number of data
417 **/
418 unsigned int getNumData() { return numData_ ; } ;
419
420 /**
421 * get frequency frame
422 *
423 * @return string representating frequency frame
424 **/
425 std::string getFrame() ;
426
427 /**
428 * set Logger
429 *
430 * @param logger (LogSinkInterface)
431 **/
432 void setLogger( casa::CountedPtr<casa::LogSinkInterface> &logsink ) ;
433
434
435private:
436
437 /**
438 * pick up valid configDescriptionId
439 *
440 * only retrieve configDescriptionId with correlationMode of
441 * AUTO_ONLY or CROSS_AND_AUTO.
442 **/
443 void selectConfigDescription() ;
444
445 /**
446 * pick up valid feedId
447 *
448 * only retrieve feedId that has corresponding row for antennaId_
449 **/
450 void selectFeed() ;
451
452 /**
453 * clear mainRow_
454 **/
455 void clearMainRow() ;
456
457 /**
458 * determine IFNO for each SpectralWindow rows
459 *
460 * SpectralWindow row is identified as WVR when basebandName is "NOBB" and numChan is 4.
461 * All WVR SpectralWindow is merged into one IFNO.
462 **/
463 void setupIFNO() ;
464
465 /**
466 * check if given SpectralWindow is WVR or not
467 **/
468 bool isWVR( asdm::SpectralWindowRow *row ) ;
469
470 /**
471 * process Station table
472 *
473 * classify station Ids by its type
474 **/
475 void processStation() ;
476
477 /**
478 * get the closest weather station for given antenna pad
479 *
480 * @return stationId for weather station
481 **/
482 int getClosestWeatherStation() ;
483
484 /**
485 * get mid-point of ArrayTimeInterval
486 *
487 * @param time interval as ArrayTimeInterval
488 * @return time of mid-point as ArrayTime
489 **/
490 asdm::ArrayTime getMidTime( const asdm::ArrayTimeInterval &t ) ;
491
492 /**
493 * get start-point of ArrayTimeInterval
494 *
495 * @param time interval as ArrayTimeInterval
496 * @return time of start-point as ArrayTime
497 **/
498 asdm::ArrayTime getStartTime( const asdm::ArrayTimeInterval &t ) ;
499
500 /**
501 * get end-point of ArrayTimeInterval
502 *
503 * @param time interval as ArrayTimeInterval
504 * @return time of end-point as ArrayTime
505 **/
506 asdm::ArrayTime getEndTime( const asdm::ArrayTimeInterval &t ) ;
507
508 /**
509 * AZEL to J2000
510 *
511 * @param dir pointing direction
512 * @param az azimuth
513 * @param el elevation
514 * @param mjd reference time
515 * @param antpos antenna position vector
516 **/
517 void toJ2000( std::vector<double> &dir,
518 double az,
519 double el,
520 double mjd,
521 casa::Vector<casa::Double> antpos ) ;
522
523 /**
524 * to J2000
525 *
526 * @param dir pointing direction
527 * @param dirref direction reference
528 * @param mjd reference time
529 * @param antpos antenna position vector
530 * @return new direction
531 **/
532 std::vector<double> toJ2000( std::vector<double> dir,
533 casa::String dirref,
534 double mjd,
535 casa::Vector<casa::Double> antpos ) ;
536 /**
537 * get nIF
538 *
539 * @return number of IFs
540 **/
541 int getNumIFs() ;
542
543 /**
544 * get appropriate row from SysCal table
545 *
546 * @param idx for vmsData_
547 * @return pointer to SysCalRow object (0 when no appropriate row)
548 **/
549 asdm::SysCalRow *getSysCalRow( unsigned int idx ) ;
550
551 /**
552 * limit angule in radian within [-pi,pi]
553 *
554 * @param any angule in radian
555 * @return equivalent angle that satisfies [-pi,pi]
556 **/
557 double limitedAngle( double angle ) ;
558
559 /**
560 * retrieve pointing direction from pointingDirection column
561 * or from target+offset
562 *
563 * @param row pointer to PointingRow object
564 * @return pointing direction vector (matrix)
565 **/
566 std::vector< std::vector<double> > pointingDir( asdm::PointingRow *row ) ;
567
568 asdm::ASDM *asdm_ ; // pointer to ASDM object
569 sdmbin::SDMBinData *sdmBin_ ; // pointer to ASDM binary data
570 /**
571 * vmsData_ is a pointer to binary data
572 *
573 * VMSData contents
574 *
575 * int processorId
576 * vector< double > v_time MJD time in sec
577 * vector< int > v_fieldId
578 * vector< double > v_interval interval in sec
579 * vector< AtmPhaseCorrection > v_atmPhaseCorrection
580 * int binNum
581 * vector< unsigned int > v_projectPath
582 * vector< int > v_antennaId1 antennaId in int
583 * vector< int > v_antennaId2 antennaId in int
584 * vector< int > v_feedId1 feedId in int
585 * vector< int > v_feedId2 feedId in int
586 * vector< int > v_dataDescId dataDescriptionId in int
587 * vector< double > v_timeCentroid
588 * vector< double > exposure
589 * vector< int > v_numData
590 * vector< vector< unsigned int > > vv_dataShape (nPol,nChan,nApc=1)
591 * vector< map< AtmPhaseCorrection, float *> > v_m_data actual data
592 * vector< vector< vector< Angle > > > v_pahseDir direction
593 * vector< int > v_stateId
594 * vector< MSState > v_msState
595 * vector< unsigned int > v_flag
596 **/
597 const sdmbin::VMSData *vmsData_ ;
598 casa::Int antennaId_ ; // antenna id
599 casa::String antennaName_ ; // antenna name
600 casa::Vector<asdm::MainRow *> mainRow_ ; // list of pointers to all Main rows
601 casa::Vector<casa::uInt> configDescIdList_ ; // list of valid configDescriptionId
602 casa::Vector<casa::uInt> feedIdList_ ; // list of valid feedId
603 casa::Vector<casa::uInt> fieldIdList_ ; // list of fieldId
604 casa::Int row_ ; // current row index
605 map<asdm::Tag,casa::uInt> ifno_ ; // list of IFNO for each SpectralWindow rows
606 unsigned int numData_ ; // number of valid data in vmsData_ where v_antennaId equals antennaId_
607 vector<unsigned int> dataIdList_ ; // list of valid data indexes in vmsData_
608 vector<asdm::Tag> antennaPad_ ; // list of Station Tags for ANTENNA_PAD
609 vector<asdm::Tag> weatherStation_ ; // list of Station Tags for WEATHER_STATION
610 int weatherStationId_ ; // closest weather station for antennaId_
611 AtmPhaseCorrectionMod::AtmPhaseCorrection apc_ ; // ATM phase correction
612 EnumSet<CorrelationModeMod::CorrelationMode> corrMode_ ; // input correlation mode
613 EnumSet<TimeSamplingMod::TimeSampling> timeSampling_ ; // time sampling
614 EnumSet<SpectralResolutionTypeMod::SpectralResolutionType> resolutionType_ ; // spectral resolution type
615 casa::CountedPtr<casa::LogSinkInterface> logsink_ ; // Logger
616 casa::String className_ ;
617} ;
618#endif // ASAP_OLD_ASDM_READER_H
Note: See TracBrowser for help on using the repository browser.