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

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

Added selection by spectral resolution type.


File size: 13.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
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 * set Logger
397 *
398 * @param logger (LogSinkInterface)
399 **/
400 void setLogger( casa::CountedPtr<casa::LogSinkInterface> &logsink ) ;
401
402
403private:
404
405 /**
406 * pick up valid configDescriptionId
407 *
408 * only retrieve configDescriptionId with correlationMode of
409 * AUTO_ONLY or CROSS_AND_AUTO.
410 **/
411 void selectConfigDescription() ;
412
413 /**
414 * pick up valid feedId
415 *
416 * only retrieve feedId that has corresponding row for antennaId_
417 **/
418 void selectFeed() ;
419
420 /**
421 * clear mainRow_
422 **/
423 void clearMainRow() ;
424
425 /**
426 * determine IFNO for each SpectralWindow rows
427 *
428 * SpectralWindow row is identified as WVR when basebandName is "NOBB" and numChan is 4.
429 * All WVR SpectralWindow is merged into one IFNO.
430 **/
431 void setupIFNO() ;
432
433 /**
434 * check if given SpectralWindow is WVR or not
435 **/
436 bool isWVR( asdm::SpectralWindowRow *row ) ;
437
438 /**
439 * process Station table
440 *
441 * classify station Ids by its type
442 **/
443 void processStation() ;
444
445 /**
446 * get the closest weather station for given antenna pad
447 *
448 * @return stationId for weather station
449 **/
450 int getClosestWeatherStation() ;
451
452 /**
453 * get mid-point of ArrayTimeInterval
454 *
455 * @param time interval as ArrayTimeInterval
456 * @return time of mid-point as ArrayTime
457 **/
458 asdm::ArrayTime getMidTime( const asdm::ArrayTimeInterval &t ) ;
459
460 /**
461 * get start-point of ArrayTimeInterval
462 *
463 * @param time interval as ArrayTimeInterval
464 * @return time of start-point as ArrayTime
465 **/
466 asdm::ArrayTime getStartTime( const asdm::ArrayTimeInterval &t ) ;
467
468 /**
469 * get end-point of ArrayTimeInterval
470 *
471 * @param time interval as ArrayTimeInterval
472 * @return time of end-point as ArrayTime
473 **/
474 asdm::ArrayTime getEndTime( const asdm::ArrayTimeInterval &t ) ;
475
476 /**
477 * AZEL to J2000
478 *
479 * @param dir pointing direction
480 * @param az azimuth
481 * @param el elevation
482 * @param mjd reference time
483 * @param antpos antenna position vector
484 **/
485 void toJ2000( std::vector<double> &dir,
486 double az,
487 double el,
488 double mjd,
489 casa::Vector<casa::Double> antpos ) ;
490
491 asdm::ASDM *asdm_ ; // pointer to ASDM object
492 sdmbin::SDMBinData *sdmBin_ ; // pointer to ASDM binary data
493 /**
494 * vmsData_ is a pointer to binary data
495 *
496 * VMSData contents
497 *
498 * int processorId
499 * vector< double > v_time MJD time in sec
500 * vector< int > v_fieldId
501 * vector< double > v_interval interval in sec
502 * vector< AtmPhaseCorrection > v_atmPhaseCorrection
503 * int binNum
504 * vector< unsigned int > v_projectPath
505 * vector< int > v_antennaId1 antennaId in int
506 * vector< int > v_antennaId2 antennaId in int
507 * vector< int > v_feedId1 feedId in int
508 * vector< int > v_feedId2 feedId in int
509 * vector< int > v_dataDescId dataDescriptionId in int
510 * vector< double > v_timeCentroid
511 * vector< double > exposure
512 * vector< int > v_numData
513 * vector< vector< unsigned int > > vv_dataShape (nPol,nChan,nApc=1)
514 * vector< map< AtmPhaseCorrection, float *> > v_m_data actual data
515 * vector< vector< vector< Angle > > > v_pahseDir direction
516 * vector< int > v_stateId
517 * vector< MSState > v_msState
518 * vector< unsigned int > v_flag
519 **/
520 const sdmbin::VMSData *vmsData_ ;
521 casa::Int antennaId_ ; // antenna id
522 casa::String antennaName_ ; // antenna name
523 casa::Vector<asdm::MainRow *> mainRow_ ; // list of pointers to all Main rows
524 casa::Vector<casa::uInt> configDescIdList_ ; // list of valid configDescriptionId
525 casa::Vector<casa::uInt> feedIdList_ ; // list of valid feedId
526 casa::Vector<casa::uInt> fieldIdList_ ; // list of fieldId
527 casa::Int row_ ; // current row index
528 map<asdm::Tag,casa::uInt> ifno_ ; // list of IFNO for each SpectralWindow rows
529 unsigned int numData_ ; // number of valid data in vmsData_ where v_antennaId equals antennaId_
530 vector<unsigned int> dataIdList_ ; // list of valid data indexes in vmsData_
531 vector<asdm::Tag> antennaPad_ ; // list of Station Tags for ANTENNA_PAD
532 vector<asdm::Tag> weatherStation_ ; // list of Station Tags for WEATHER_STATION
533 int weatherStationId_ ; // closest weather station for antennaId_
534 AtmPhaseCorrectionMod::AtmPhaseCorrection apc_ ; // ATM phase correction
535 EnumSet<CorrelationModeMod::CorrelationMode> corrMode_ ; // input correlation mode
536 EnumSet<TimeSamplingMod::TimeSampling> timeSampling_ ; // time sampling
537 EnumSet<SpectralResolutionTypeMod::SpectralResolutionType> resolutionType_ ; // spectral resolution type
538 casa::CountedPtr<casa::LogSinkInterface> logsink_ ; // Logger
539 casa::String className_ ;
540} ;
541#endif // ASAP_ASDM_READER_H
Note: See TracBrowser for help on using the repository browser.