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

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

Number of IFs is not a number of rows of SpectralWindow table,
but a number of frequency groups.
When freqGroup is not defined, number of IFs is set to number
of non-WVR spectral windows plus 1 (WVR spectral window).


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