source: branches/casa-release-4_3-test/external-alma/asdm2ASAP/ASDMReader.h@ 3028

Last change on this file since 3028 was 2979, checked in by Takeshi Nakazato, 10 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes/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...

Forward declaration using namespace.


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