source: trunk/external-alma/asdm2ASAP/ASDMReader.h @ 2225

Last change on this file since 2225 was 2225, 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...

Frequency is stored as LSRK value although raw frequency value is
in arbitrary frequency frame.
Also, direction is stored as J2000 value independently of original
direction reference code.


File size: 14.6 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
13class ASDMReader
14{
15public:
16  /**
17   * constructor
18   **/
19  ASDMReader() ;
20
21  /**
22   * destructor
23   **/
24  ~ASDMReader() ;
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   **/
186  void getFrequency( unsigned int idx,
187                     double &refpix,
188                     double &refval,
189                     double &incr ) ;
190
191  /**
192   * get rest frequencies for given index
193   *
194   * @param idx for vmsData_
195   * @return rest frequencies
196   **/
197  vector<double> getRestFrequency( unsigned int idx ) ;
198
199  /**
200   * get MJD time in day for given index
201   *
202   * @param idx for vmsData_
203   * @return MJD time in day
204   **/
205  double getTime( unsigned int idx ) ;
206
207  /**
208   * get integration time in sec for given index
209   *
210   * @param idx for vmsData_
211   * @return integration time in sec
212   **/
213  double getInterval( unsigned int idx ) ;
214
215  /**
216   * get source name for given index
217   *
218   * @param idx for vmsData_
219   * @return source name
220   **/
221  string getSourceName( unsigned int idx ) ;
222
223  /**
224   * get field name for given index
225   * field name = fieldName + "__" + fieldId
226   *
227   * @param idx for vmsData_
228   * @return field name
229   **/
230  string getFieldName( unsigned int idx ) ;
231
232  /**
233   * get source direction for given index
234   *
235   * @param idx for vmsData_
236   * @return source direction as vector<double>
237   **/
238  std::vector<double> getSourceDirection( unsigned int idx ) ;
239  void getSourceDirection( unsigned int idx,
240                           std::vector<double> &dir,
241                           std::string &ref  ) ;
242
243  /**
244   * get source direction with reference
245   *
246   * @param dir source direction
247   * @param reference frame
248   * @param idx for Source table
249   **/
250  void getSourceDirection( std::vector<double> &dir, std::string &ref ) ;
251 
252  /**
253   * get source proper motion for given index
254   *
255   * @param idx for vmsData_
256   * @return source proper motion as vector<double>
257   **/
258  std::vector<double> getSourceProperMotion( unsigned int idx ) ;
259
260  /**
261   * get systemic velocity of the source for given index
262   * at the moment return 0-th element of sysVel vector
263   *
264   * @param idx for vmsData_
265   * @return systemic velocity of the source
266   **/
267  double getSysVel( unsigned int idx ) ;
268
269  /**
270   * get row-based flag for given index
271   *
272   * @param idx for vmsData_
273   * @return row-based flag
274   **/
275  unsigned int getFlagRow( unsigned int idx ) ;
276
277  /**
278   * get data shape (nPol, nChan, nApc=1) for given index
279   *
280   * @param idx for vmsData_
281   * @return data shape
282   **/
283  std::vector<unsigned int> getDataShape( unsigned int idx ) ;
284
285  /**
286   * get spectral data for given index
287   *
288   * @param idx for vmsData_
289   * @return spectral data
290   **/
291  float *getSpectrum( unsigned int idx ) ;
292
293  /**
294   * get channel flag data for given index
295   *
296   * @param idx for vmsData_
297   * @return channel flag
298   **/
299  //bool *getFlagChannel( unsigned int idx ) ;
300 
301  /**
302   * get Tsys for given index
303   *
304   * @param idx for vmsData_
305   * @return Tsys
306   **/
307  std::vector< std::vector<float> > getTsys( unsigned int idx ) ;
308 
309  /**
310   * get Tcal for given index
311   *
312   * @param idx for vmsData_
313   * @return Tcal
314   **/
315  std::vector< std::vector<float> > getTcal( unsigned int idx ) ;
316 
317  /**
318   * get opacity for given index
319   *
320   * @param idx for vmsData_
321   * @return opacity
322   **/
323  std::vector<float> getOpacity( unsigned int idx ) ;
324 
325  /**
326   * get weather information for given index
327   *
328   * @param idx for vmsData_
329   * @param temperature
330   * @param pressure
331   * @param humidity
332   * @param windspeed
333   * @param windaz
334   **/
335  void getWeatherInfo( unsigned int idx,
336                       float &temperature,
337                       float &pressure,
338                       float &humidity,
339                       float &windspeed,
340                       float &windaz ) ;
341
342  /**
343   * get pointing information for given index
344   *
345   * @param idx for vmsData_
346   * @param dir direction
347   * @param az azimuth
348   * @param el elevation
349   * @param srate scan rate
350   **/
351  void getPointingInfo( unsigned int idx,
352                        std::vector<double> &dir,
353                        double &az,
354                        double &el,
355                        std::vector<double> &srate ) ;
356
357  /**
358   * get source type enum (int) for given scan and subscan
359   *
360   * @param scan scan No.
361   * @param subscan subscan No.
362   * @return source type as int
363   **/
364  int getSrcType( unsigned int scan,
365                  unsigned int subscan ) ;
366
367  /**
368   * get list of dataDescId for given configDescId
369   *
370   * @param configDescId
371   * @return list of dataDescId
372   **/
373//   casa::Vector<casa::uInt> getDataDescIdList( casa::uInt cdid ) ;
374
375  /**
376   * get list of switchCycleId for given configDescId
377   *
378   * @param configDescId
379   * @return list of dataDescId
380   **/
381//   casa::Vector<casa::uInt> getSwitchCycleIdList( casa::uInt cdid ) ;
382
383  /**
384   * get list of feedId for given configDescId
385   *
386   * only return list of feedId that corresponds to specified antenna.
387   *
388   * @param configDescId
389   * @return list of valid feedId
390   **/
391//   casa::Vector<casa::uInt> getFeedIdList( casa::uInt cdid ) ;
392
393  /**
394   * set binary data to MSData object
395   *
396   * @return boolean status
397   **/
398  casa::Bool setData() ;
399
400  /**
401   * get number of data in the current row
402   *
403   * @return number of data
404   **/
405  unsigned int getNumData() { return numData_ ; } ;
406
407  /**
408   * get frequency frame
409   *
410   * @return string representating frequency frame
411   **/
412  std::string getFrame() ;
413
414  /**
415   * set Logger
416   *
417   * @param logger (LogSinkInterface)
418   **/
419  void setLogger( casa::CountedPtr<casa::LogSinkInterface> &logsink ) ;
420
421
422private:
423
424  /**
425   * pick up valid configDescriptionId
426   *
427   * only retrieve configDescriptionId with correlationMode of
428   * AUTO_ONLY or CROSS_AND_AUTO.
429   **/
430  void selectConfigDescription() ;
431
432  /**
433   * pick up valid feedId
434   *
435   * only retrieve feedId that has corresponding row for antennaId_
436   **/
437  void selectFeed() ;
438
439  /**
440   * clear mainRow_
441   **/
442  void clearMainRow() ;
443
444  /**
445   * determine IFNO for each SpectralWindow rows
446   *
447   * SpectralWindow row is identified as WVR when basebandName is "NOBB" and numChan is 4.
448   * All WVR SpectralWindow is merged into one IFNO.
449   **/
450  void setupIFNO() ;
451
452  /**
453   * check if given SpectralWindow is WVR or not
454   **/
455  bool isWVR( asdm::SpectralWindowRow *row ) ;
456 
457  /**
458   * process Station table
459   *
460   * classify station Ids by its type
461   **/
462  void processStation() ;
463
464  /**
465   * get the closest weather station for given antenna pad
466   *
467   * @return stationId for weather station
468   **/
469  int getClosestWeatherStation() ;
470
471  /**
472   * get mid-point of ArrayTimeInterval
473   *
474   * @param time interval as ArrayTimeInterval
475   * @return time of mid-point as ArrayTime
476   **/
477  asdm::ArrayTime getMidTime( const asdm::ArrayTimeInterval &t ) ;
478
479  /**
480   * get start-point of ArrayTimeInterval
481   *
482   * @param time interval as ArrayTimeInterval
483   * @return time of start-point as ArrayTime
484   **/
485  asdm::ArrayTime getStartTime( const asdm::ArrayTimeInterval &t ) ;
486
487  /**
488   * get end-point of ArrayTimeInterval
489   *
490   * @param time interval as ArrayTimeInterval
491   * @return time of end-point as ArrayTime
492   **/
493  asdm::ArrayTime getEndTime( const asdm::ArrayTimeInterval &t ) ;
494
495  /**
496   *  AZEL to J2000
497   *
498   * @param dir pointing direction
499   * @param az azimuth
500   * @param el elevation
501   * @param mjd reference time
502   * @param antpos antenna position vector
503   **/
504  void toJ2000( std::vector<double> &dir,
505                double az,
506                double el,
507                double mjd,
508                casa::Vector<casa::Double> antpos ) ;
509
510  /**
511  * to J2000
512  *
513  * @param dir pointing direction
514  * @param dirref direction reference
515  * @param mjd reference time
516  * @param antpos antenna position vector
517  * @return new direction
518  **/
519  std::vector<double> toJ2000( std::vector<double> dir,
520                               casa::String dirref,
521                               double mjd,
522                               casa::Vector<casa::Double> antpos ) ;
523  /**
524   * get nIF
525   *
526   * @return number of IFs
527   **/
528  int getNumIFs() ;
529
530  asdm::ASDM *asdm_ ; // pointer to ASDM object
531  sdmbin::SDMBinData *sdmBin_ ; // pointer to ASDM binary data
532  /**
533   * vmsData_ is a pointer to binary data
534   *
535   * VMSData contents
536   *
537   * int processorId
538   * vector< double > v_time MJD time in sec
539   * vector< int > v_fieldId
540   * vector< double > v_interval interval in sec
541   * vector< AtmPhaseCorrection > v_atmPhaseCorrection
542   * int binNum
543   * vector< unsigned int > v_projectPath
544   * vector< int > v_antennaId1 antennaId in int
545   * vector< int > v_antennaId2 antennaId in int
546   * vector< int > v_feedId1 feedId in int
547   * vector< int > v_feedId2 feedId in int
548   * vector< int > v_dataDescId dataDescriptionId in int
549   * vector< double > v_timeCentroid
550   * vector< double > exposure
551   * vector< int > v_numData
552   * vector< vector< unsigned int > > vv_dataShape (nPol,nChan,nApc=1)
553   * vector< map< AtmPhaseCorrection, float *> > v_m_data actual data
554   * vector< vector< vector< Angle > > > v_pahseDir direction
555   * vector< int > v_stateId
556   * vector< MSState > v_msState
557   * vector< unsigned int > v_flag
558   **/
559  const sdmbin::VMSData *vmsData_ ;
560  casa::Int antennaId_ ; // antenna id
561  casa::String antennaName_ ; // antenna name
562  casa::Vector<asdm::MainRow *> mainRow_ ; // list of pointers to all Main rows
563  casa::Vector<casa::uInt> configDescIdList_ ; // list of valid configDescriptionId
564  casa::Vector<casa::uInt> feedIdList_ ; // list of valid feedId
565  casa::Vector<casa::uInt> fieldIdList_ ; // list of fieldId
566  casa::Int row_ ; // current row index
567  map<asdm::Tag,casa::uInt> ifno_ ; // list of IFNO for each SpectralWindow rows
568  unsigned int numData_ ; // number of valid data in vmsData_ where v_antennaId equals antennaId_
569  vector<unsigned int> dataIdList_ ; // list of valid data indexes in vmsData_ 
570  vector<asdm::Tag> antennaPad_ ; // list of Station Tags for ANTENNA_PAD
571  vector<asdm::Tag> weatherStation_ ; // list of Station Tags for WEATHER_STATION
572  int weatherStationId_ ; // closest weather station for antennaId_
573  AtmPhaseCorrectionMod::AtmPhaseCorrection apc_ ; // ATM phase correction
574  EnumSet<CorrelationModeMod::CorrelationMode> corrMode_ ; // input correlation mode
575  EnumSet<TimeSamplingMod::TimeSampling> timeSampling_ ; // time sampling
576  EnumSet<SpectralResolutionTypeMod::SpectralResolutionType> resolutionType_ ; // spectral resolution type
577  casa::CountedPtr<casa::LogSinkInterface> logsink_ ; // Logger
578  casa::String className_ ;
579} ;
580#endif // ASAP_ASDM_READER_H
Note: See TracBrowser for help on using the repository browser.