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

Last change on this file since 2249 was 2227, 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 original frequency is
in an arbitrary frequency frame (e.g. TOPO). Conversion is done
in filler if necessary.


File size: 14.7 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 * @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 opacity for given index
321 *
322 * @param idx for vmsData_
323 * @return opacity
324 **/
325 std::vector<float> getOpacity( unsigned int idx ) ;
326
327 /**
328 * get weather information for given index
329 *
330 * @param idx for vmsData_
331 * @param temperature
332 * @param pressure
333 * @param humidity
334 * @param windspeed
335 * @param windaz
336 **/
337 void getWeatherInfo( unsigned int idx,
338 float &temperature,
339 float &pressure,
340 float &humidity,
341 float &windspeed,
342 float &windaz ) ;
343
344 /**
345 * get pointing information for given index
346 *
347 * @param idx for vmsData_
348 * @param dir direction
349 * @param az azimuth
350 * @param el elevation
351 * @param srate scan rate
352 **/
353 void getPointingInfo( unsigned int idx,
354 std::vector<double> &dir,
355 double &az,
356 double &el,
357 std::vector<double> &srate ) ;
358
359 /**
360 * get source type enum (int) for given scan and subscan
361 *
362 * @param scan scan No.
363 * @param subscan subscan No.
364 * @return source type as int
365 **/
366 int getSrcType( unsigned int scan,
367 unsigned int subscan ) ;
368
369 /**
370 * get list of dataDescId for given configDescId
371 *
372 * @param configDescId
373 * @return list of dataDescId
374 **/
375// casa::Vector<casa::uInt> getDataDescIdList( casa::uInt cdid ) ;
376
377 /**
378 * get list of switchCycleId for given configDescId
379 *
380 * @param configDescId
381 * @return list of dataDescId
382 **/
383// casa::Vector<casa::uInt> getSwitchCycleIdList( casa::uInt cdid ) ;
384
385 /**
386 * get list of feedId for given configDescId
387 *
388 * only return list of feedId that corresponds to specified antenna.
389 *
390 * @param configDescId
391 * @return list of valid feedId
392 **/
393// casa::Vector<casa::uInt> getFeedIdList( casa::uInt cdid ) ;
394
395 /**
396 * set binary data to MSData object
397 *
398 * @return boolean status
399 **/
400 casa::Bool setData() ;
401
402 /**
403 * get number of data in the current row
404 *
405 * @return number of data
406 **/
407 unsigned int getNumData() { return numData_ ; } ;
408
409 /**
410 * get frequency frame
411 *
412 * @return string representating frequency frame
413 **/
414 std::string getFrame() ;
415
416 /**
417 * set Logger
418 *
419 * @param logger (LogSinkInterface)
420 **/
421 void setLogger( casa::CountedPtr<casa::LogSinkInterface> &logsink ) ;
422
423
424private:
425
426 /**
427 * pick up valid configDescriptionId
428 *
429 * only retrieve configDescriptionId with correlationMode of
430 * AUTO_ONLY or CROSS_AND_AUTO.
431 **/
432 void selectConfigDescription() ;
433
434 /**
435 * pick up valid feedId
436 *
437 * only retrieve feedId that has corresponding row for antennaId_
438 **/
439 void selectFeed() ;
440
441 /**
442 * clear mainRow_
443 **/
444 void clearMainRow() ;
445
446 /**
447 * determine IFNO for each SpectralWindow rows
448 *
449 * SpectralWindow row is identified as WVR when basebandName is "NOBB" and numChan is 4.
450 * All WVR SpectralWindow is merged into one IFNO.
451 **/
452 void setupIFNO() ;
453
454 /**
455 * check if given SpectralWindow is WVR or not
456 **/
457 bool isWVR( asdm::SpectralWindowRow *row ) ;
458
459 /**
460 * process Station table
461 *
462 * classify station Ids by its type
463 **/
464 void processStation() ;
465
466 /**
467 * get the closest weather station for given antenna pad
468 *
469 * @return stationId for weather station
470 **/
471 int getClosestWeatherStation() ;
472
473 /**
474 * get mid-point of ArrayTimeInterval
475 *
476 * @param time interval as ArrayTimeInterval
477 * @return time of mid-point as ArrayTime
478 **/
479 asdm::ArrayTime getMidTime( const asdm::ArrayTimeInterval &t ) ;
480
481 /**
482 * get start-point of ArrayTimeInterval
483 *
484 * @param time interval as ArrayTimeInterval
485 * @return time of start-point as ArrayTime
486 **/
487 asdm::ArrayTime getStartTime( const asdm::ArrayTimeInterval &t ) ;
488
489 /**
490 * get end-point of ArrayTimeInterval
491 *
492 * @param time interval as ArrayTimeInterval
493 * @return time of end-point as ArrayTime
494 **/
495 asdm::ArrayTime getEndTime( const asdm::ArrayTimeInterval &t ) ;
496
497 /**
498 * AZEL to J2000
499 *
500 * @param dir pointing direction
501 * @param az azimuth
502 * @param el elevation
503 * @param mjd reference time
504 * @param antpos antenna position vector
505 **/
506 void toJ2000( std::vector<double> &dir,
507 double az,
508 double el,
509 double mjd,
510 casa::Vector<casa::Double> antpos ) ;
511
512 /**
513 * to J2000
514 *
515 * @param dir pointing direction
516 * @param dirref direction reference
517 * @param mjd reference time
518 * @param antpos antenna position vector
519 * @return new direction
520 **/
521 std::vector<double> toJ2000( std::vector<double> dir,
522 casa::String dirref,
523 double mjd,
524 casa::Vector<casa::Double> antpos ) ;
525 /**
526 * get nIF
527 *
528 * @return number of IFs
529 **/
530 int getNumIFs() ;
531
532 asdm::ASDM *asdm_ ; // pointer to ASDM object
533 sdmbin::SDMBinData *sdmBin_ ; // pointer to ASDM binary data
534 /**
535 * vmsData_ is a pointer to binary data
536 *
537 * VMSData contents
538 *
539 * int processorId
540 * vector< double > v_time MJD time in sec
541 * vector< int > v_fieldId
542 * vector< double > v_interval interval in sec
543 * vector< AtmPhaseCorrection > v_atmPhaseCorrection
544 * int binNum
545 * vector< unsigned int > v_projectPath
546 * vector< int > v_antennaId1 antennaId in int
547 * vector< int > v_antennaId2 antennaId in int
548 * vector< int > v_feedId1 feedId in int
549 * vector< int > v_feedId2 feedId in int
550 * vector< int > v_dataDescId dataDescriptionId in int
551 * vector< double > v_timeCentroid
552 * vector< double > exposure
553 * vector< int > v_numData
554 * vector< vector< unsigned int > > vv_dataShape (nPol,nChan,nApc=1)
555 * vector< map< AtmPhaseCorrection, float *> > v_m_data actual data
556 * vector< vector< vector< Angle > > > v_pahseDir direction
557 * vector< int > v_stateId
558 * vector< MSState > v_msState
559 * vector< unsigned int > v_flag
560 **/
561 const sdmbin::VMSData *vmsData_ ;
562 casa::Int antennaId_ ; // antenna id
563 casa::String antennaName_ ; // antenna name
564 casa::Vector<asdm::MainRow *> mainRow_ ; // list of pointers to all Main rows
565 casa::Vector<casa::uInt> configDescIdList_ ; // list of valid configDescriptionId
566 casa::Vector<casa::uInt> feedIdList_ ; // list of valid feedId
567 casa::Vector<casa::uInt> fieldIdList_ ; // list of fieldId
568 casa::Int row_ ; // current row index
569 map<asdm::Tag,casa::uInt> ifno_ ; // list of IFNO for each SpectralWindow rows
570 unsigned int numData_ ; // number of valid data in vmsData_ where v_antennaId equals antennaId_
571 vector<unsigned int> dataIdList_ ; // list of valid data indexes in vmsData_
572 vector<asdm::Tag> antennaPad_ ; // list of Station Tags for ANTENNA_PAD
573 vector<asdm::Tag> weatherStation_ ; // list of Station Tags for WEATHER_STATION
574 int weatherStationId_ ; // closest weather station for antennaId_
575 AtmPhaseCorrectionMod::AtmPhaseCorrection apc_ ; // ATM phase correction
576 EnumSet<CorrelationModeMod::CorrelationMode> corrMode_ ; // input correlation mode
577 EnumSet<TimeSamplingMod::TimeSampling> timeSampling_ ; // time sampling
578 EnumSet<SpectralResolutionTypeMod::SpectralResolutionType> resolutionType_ ; // spectral resolution type
579 casa::CountedPtr<casa::LogSinkInterface> logsink_ ; // Logger
580 casa::String className_ ;
581} ;
582#endif // ASAP_ASDM_READER_H
Note: See TracBrowser for help on using the repository browser.