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