source: trunk/src/MSFiller.cpp@ 2744

Last change on this file since 2744 was 2744, checked in by Takeshi Nakazato, 12 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: test_sdsave, fls regression test

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Fixed too many warnings when compiling. Also, added some features
to prepare for known bug.


File size: 68.0 KB
RevLine 
[2291]1
[1974]2//
3// C++ Interface: MSFiller
4//
5// Description:
6//
[2291]7// This class is specific filler for MS format
8// New version that is implemented using TableVisitor instead of TableIterator
[1974]9//
[2291]10// Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2011
[1974]11//
12// Copyright: See COPYING file that comes with this distribution
13//
14//
15
[2291]16#include <assert.h>
[1974]17#include <iostream>
18#include <map>
19
20#include <tables/Tables/ExprNode.h>
21#include <tables/Tables/TableIter.h>
[1987]22#include <tables/Tables/TableColumn.h>
[1974]23#include <tables/Tables/ScalarColumn.h>
24#include <tables/Tables/ArrayColumn.h>
[1987]25#include <tables/Tables/TableParse.h>
[2002]26#include <tables/Tables/TableRow.h>
[1974]27
[2002]28#include <casa/Containers/RecordField.h>
[1974]29#include <casa/Logging/LogIO.h>
30#include <casa/Arrays/Slicer.h>
31#include <casa/Quanta/MVTime.h>
[1987]32#include <casa/OS/Path.h>
[1974]33
34#include <measures/Measures/Stokes.h>
35#include <measures/Measures/MEpoch.h>
[1987]36#include <measures/Measures/MCEpoch.h>
37#include <measures/Measures/MFrequency.h>
38#include <measures/Measures/MCFrequency.h>
39#include <measures/Measures/MPosition.h>
40#include <measures/Measures/MCPosition.h>
41#include <measures/Measures/MDirection.h>
42#include <measures/Measures/MCDirection.h>
43#include <measures/Measures/MeasConvert.h>
[1974]44#include <measures/TableMeasures/ScalarMeasColumn.h>
[1987]45#include <measures/TableMeasures/ArrayMeasColumn.h>
46#include <measures/TableMeasures/ScalarQuantColumn.h>
47#include <measures/TableMeasures/ArrayQuantColumn.h>
[1974]48
[2021]49#include <ms/MeasurementSets/MSAntennaIndex.h>
50
[1974]51#include <atnf/PKSIO/SrcType.h>
52
53#include "MSFiller.h"
54#include "STHeader.h"
55
[2258]56#include "MathUtils.h"
57
[2017]58using namespace casa ;
59using namespace std ;
60
61namespace asap {
[1988]62
[2291]63class BaseMSFillerVisitor: public TableVisitor {
64 uInt lastRecordNo ;
65 Int lastObservationId ;
66 Int lastFeedId ;
67 Int lastFieldId ;
68 Int lastDataDescId ;
69 Int lastScanNo ;
70 Int lastStateId ;
71 Double lastTime ;
72protected:
73 const Table &table;
74 uInt count;
75public:
76 BaseMSFillerVisitor(const Table &table)
77 : table(table)
78 {
79 count = 0;
80 }
81
[2744]82 virtual void enterObservationId(const uInt /*recordNo*/, Int /*columnValue*/) { }
83 virtual void leaveObservationId(const uInt /*recordNo*/, Int /*columnValue*/) { }
84 virtual void enterFeedId(const uInt /*recordNo*/, Int /*columnValue*/) { }
85 virtual void leaveFeedId(const uInt /*recordNo*/, Int /*columnValue*/) { }
86 virtual void enterFieldId(const uInt /*recordNo*/, Int /*columnValue*/) { }
87 virtual void leaveFieldId(const uInt /*recordNo*/, Int /*columnValue*/) { }
88 virtual void enterDataDescId(const uInt /*recordNo*/, Int /*columnValue*/) { }
89 virtual void leaveDataDescId(const uInt /*recordNo*/, Int /*columnValue*/) { }
90 virtual void enterScanNo(const uInt /*recordNo*/, Int /*columnValue*/) { }
91 virtual void leaveScanNo(const uInt /*recordNo*/, Int /*columnValue*/) { }
92 virtual void enterStateId(const uInt /*recordNo*/, Int /*columnValue*/) { }
93 virtual void leaveStateId(const uInt /*recordNo*/, Int /*columnValue*/) { }
94 virtual void enterTime(const uInt /*recordNo*/, Double /*columnValue*/) { }
95 virtual void leaveTime(const uInt /*recordNo*/, Double /*columnValue*/) { }
[2291]96
[2744]97 virtual Bool visitRecord(const uInt /*recordNo*/,
98 const Int /*ObservationId*/,
99 const Int /*feedId*/,
100 const Int /*fieldId*/,
101 const Int /*dataDescId*/,
102 const Int /*scanNo*/,
103 const Int /*stateId*/,
104 const Double /*time*/) { return True ; }
[2291]105
106 virtual Bool visit(Bool isFirst, const uInt recordNo,
107 const uInt nCols, void const *const colValues[]) {
108 Int observationId, feedId, fieldId, dataDescId, scanNo, stateId;
109 Double time;
110 { // prologue
111 uInt i = 0;
112 {
113 const Int *col = (const Int *)colValues[i++];
114 observationId = col[recordNo];
115 }
116 {
117 const Int *col = (const Int *)colValues[i++];
118 feedId = col[recordNo];
119 }
120 {
121 const Int *col = (const Int *)colValues[i++];
122 fieldId = col[recordNo];
123 }
124 {
125 const Int *col = (const Int *)colValues[i++];
126 dataDescId = col[recordNo];
127 }
128 {
129 const Int *col = (const Int *)colValues[i++];
130 scanNo = col[recordNo];
131 }
132 {
133 const Int *col = (const Int *)colValues[i++];
134 stateId = col[recordNo];
135 }
136 {
137 const Double *col = (const Double *)colValues[i++];
138 time = col[recordNo];
139 }
140 assert(nCols == i);
141 }
142
143 if (isFirst) {
144 enterObservationId(recordNo, observationId);
145 enterFeedId(recordNo, feedId);
146 enterFieldId(recordNo, fieldId);
147 enterDataDescId(recordNo, dataDescId);
148 enterScanNo(recordNo, scanNo);
149 enterStateId(recordNo, stateId);
150 enterTime(recordNo, time);
151 } else {
152 if (lastObservationId != observationId) {
153 leaveTime(lastRecordNo, lastTime);
154 leaveStateId(lastRecordNo, lastStateId);
155 leaveScanNo(lastRecordNo, lastScanNo);
156 leaveDataDescId(lastRecordNo, lastDataDescId);
157 leaveFieldId(lastRecordNo, lastFieldId);
158 leaveFeedId(lastRecordNo, lastFeedId);
159 leaveObservationId(lastRecordNo, lastObservationId);
160
161 enterObservationId(recordNo, observationId);
162 enterFeedId(recordNo, feedId);
163 enterFieldId(recordNo, fieldId);
164 enterDataDescId(recordNo, dataDescId);
165 enterScanNo(recordNo, scanNo);
166 enterStateId(recordNo, stateId);
167 enterTime(recordNo, time);
168 } else if (lastFeedId != feedId) {
169 leaveTime(lastRecordNo, lastTime);
170 leaveStateId(lastRecordNo, lastStateId);
171 leaveScanNo(lastRecordNo, lastScanNo);
172 leaveDataDescId(lastRecordNo, lastDataDescId);
173 leaveFieldId(lastRecordNo, lastFieldId);
174 leaveFeedId(lastRecordNo, lastFeedId);
175
176 enterFeedId(recordNo, feedId);
177 enterFieldId(recordNo, fieldId);
178 enterDataDescId(recordNo, dataDescId);
179 enterScanNo(recordNo, scanNo);
180 enterStateId(recordNo, stateId);
181 enterTime(recordNo, time);
182 } else if (lastFieldId != fieldId) {
183 leaveTime(lastRecordNo, lastTime);
184 leaveStateId(lastRecordNo, lastStateId);
185 leaveScanNo(lastRecordNo, lastScanNo);
186 leaveDataDescId(lastRecordNo, lastDataDescId);
187 leaveFieldId(lastRecordNo, lastFieldId);
188
189 enterFieldId(recordNo, fieldId);
190 enterDataDescId(recordNo, dataDescId);
191 enterScanNo(recordNo, scanNo);
192 enterStateId(recordNo, stateId);
193 enterTime(recordNo, time);
194 } else if (lastDataDescId != dataDescId) {
195 leaveTime(lastRecordNo, lastTime);
196 leaveStateId(lastRecordNo, lastStateId);
197 leaveScanNo(lastRecordNo, lastScanNo);
198 leaveDataDescId(lastRecordNo, lastDataDescId);
199
200 enterDataDescId(recordNo, dataDescId);
201 enterScanNo(recordNo, scanNo);
202 enterStateId(recordNo, stateId);
203 enterTime(recordNo, time);
204 } else if (lastScanNo != scanNo) {
205 leaveTime(lastRecordNo, lastTime);
206 leaveStateId(lastRecordNo, lastStateId);
207 leaveScanNo(lastRecordNo, lastScanNo);
208
209 enterScanNo(recordNo, scanNo);
210 enterStateId(recordNo, stateId);
211 enterTime(recordNo, time);
212 } else if (lastStateId != stateId) {
213 leaveTime(lastRecordNo, lastTime);
214 leaveStateId(lastRecordNo, lastStateId);
215
216 enterStateId(recordNo, stateId);
217 enterTime(recordNo, time);
218 } else if (lastTime != time) {
219 leaveTime(lastRecordNo, lastTime);
220 enterTime(recordNo, time);
221 }
222 }
223 count++;
224 Bool result = visitRecord(recordNo, observationId, feedId, fieldId, dataDescId,
225 scanNo, stateId, time);
226
227 { // epilogue
228 lastRecordNo = recordNo;
229
230 lastObservationId = observationId;
231 lastFeedId = feedId;
232 lastFieldId = fieldId;
233 lastDataDescId = dataDescId;
234 lastScanNo = scanNo;
235 lastStateId = stateId;
236 lastTime = time;
237 }
238 return result ;
239 }
240
241 virtual void finish() {
242 if (count > 0) {
243 leaveTime(lastRecordNo, lastTime);
244 leaveStateId(lastRecordNo, lastStateId);
245 leaveScanNo(lastRecordNo, lastScanNo);
246 leaveDataDescId(lastRecordNo, lastDataDescId);
247 leaveFieldId(lastRecordNo, lastFieldId);
248 leaveFeedId(lastRecordNo, lastFeedId);
249 leaveObservationId(lastRecordNo, lastObservationId);
250 }
251 }
252};
253
254class MSFillerVisitor: public BaseMSFillerVisitor, public MSFillerUtils {
255public:
256 MSFillerVisitor(const Table &from, Scantable &to)
257 : BaseMSFillerVisitor(from),
258 scantable( to )
259 {
260 antennaId = 0 ;
261 rowidx = 0 ;
262 tablerow = TableRow( scantable.table() ) ;
263 feedEntry = Vector<Int>( 64, -1 ) ;
264 nbeam = 0 ;
265 ifmap.clear() ;
266 const TableDesc &desc = table.tableDesc() ;
267 if ( desc.isColumn( "DATA" ) )
268 dataColumnName = "DATA" ;
269 else if ( desc.isColumn( "FLOAT_DATA" ) )
270 dataColumnName = "FLOAT_DATA" ;
271 getpt = False ;
272 isWeather = False ;
273 isSysCal = False ;
[2295]274 isTcal = False ;
[2291]275 cycleNo = 0 ;
276 numSysCalRow = 0 ;
277 header = scantable.getHeader() ;
278 fluxUnit( header.fluxunit ) ;
279
280 // MS subtables
281 const TableRecord &hdr = table.keywordSet();
282 obstab = hdr.asTable( "OBSERVATION" ) ;
283 spwtab = hdr.asTable( "SPECTRAL_WINDOW" ) ;
284 statetab = hdr.asTable( "STATE" ) ;
285 ddtab = hdr.asTable( "DATA_DESCRIPTION" ) ;
286 poltab = hdr.asTable( "POLARIZATION" ) ;
287 fieldtab = hdr.asTable( "FIELD" ) ;
288 anttab = hdr.asTable( "ANTENNA" ) ;
[2292]289 if ( hdr.isDefined( "SYSCAL" ) )
290 sctab = hdr.asTable( "SYSCAL" ) ;
291 if ( hdr.isDefined( "SOURCE" ) )
292 srctab = hdr.asTable( "SOURCE" ) ;
[2291]293
294 // attach to columns
295 // MS MAIN
296 intervalCol.attach( table, "INTERVAL" ) ;
297 flagRowCol.attach( table, "FLAG_ROW" ) ;
298 flagCol.attach( table, "FLAG" ) ;
299 if ( dataColumnName.compare( "DATA" ) == 0 )
300 dataCol.attach( table, dataColumnName ) ;
301 else
302 floatDataCol.attach( table, dataColumnName ) ;
303
304 // set dummy epoch
305 mf.set( currentTime ) ;
306
307 //
308 // add rows to scantable
309 //
310 // number of polarization is up to 4
311 uInt addrow = table.nrow() * maxNumPol() ;
312 scantable.table().addRow( addrow ) ;
313
314 // attach to columns
315 // Scantable MAIN
316 TableRecord &r = tablerow.record() ;
317 timeRF.attachToRecord( r, "TIME" ) ;
318 intervalRF.attachToRecord( r, "INTERVAL" ) ;
319 directionRF.attachToRecord( r, "DIRECTION" ) ;
320 azimuthRF.attachToRecord( r, "AZIMUTH" ) ;
321 elevationRF.attachToRecord( r, "ELEVATION" ) ;
322 scanRateRF.attachToRecord( r, "SCANRATE" ) ;
323 weatherIdRF.attachToRecord( r, "WEATHER_ID" ) ;
324 cycleNoRF.attachToRecord( r, "CYCLENO" ) ;
325 flagRowRF.attachToRecord( r, "FLAGROW" ) ;
326 polNoRF.attachToRecord( r, "POLNO" ) ;
327 tcalIdRF.attachToRecord( r, "TCAL_ID" ) ;
328 spectraRF.attachToRecord( r, "SPECTRA" ) ;
329 flagtraRF.attachToRecord( r, "FLAGTRA" ) ;
330 tsysRF.attachToRecord( r, "TSYS" ) ;
331 beamNoRF.attachToRecord( r, "BEAMNO" ) ;
332 ifNoRF.attachToRecord( r, "IFNO" ) ;
333 freqIdRF.attachToRecord( r, "FREQ_ID" ) ;
334 moleculeIdRF.attachToRecord( r, "MOLECULE_ID" ) ;
335 sourceNameRF.attachToRecord( r, "SRCNAME" ) ;
336 sourceProperMotionRF.attachToRecord( r, "SRCPROPERMOTION" ) ;
337 sourceDirectionRF.attachToRecord( r, "SRCDIRECTION" ) ;
338 sourceVelocityRF.attachToRecord( r, "SRCVELOCITY" ) ;
339 focusIdRF.attachToRecord( r, "FOCUS_ID" ) ;
340 fieldNameRF.attachToRecord( r, "FIELDNAME" ) ;
341 sourceTypeRF.attachToRecord( r, "SRCTYPE" ) ;
342 scanNoRF.attachToRecord( r, "SCANNO" ) ;
343
344 // put values
345 RecordFieldPtr<Int> refBeamNoRF( r, "REFBEAMNO" ) ;
346 *refBeamNoRF = -1 ;
347 RecordFieldPtr<Int> fitIdRF( r, "FIT_ID" ) ;
348 *fitIdRF = -1 ;
349 RecordFieldPtr<Float> opacityRF( r, "OPACITY" ) ;
350 *opacityRF = 0.0 ;
351 }
352
[2744]353 virtual void enterObservationId(const uInt /*recordNo*/, Int columnValue) {
[2291]354 //printf("%u: ObservationId: %d\n", recordNo, columnValue);
355 // update header
356 if ( header.observer.empty() )
357 getScalar( String("OBSERVER"), (uInt)columnValue, obstab, header.observer ) ;
358 if ( header.project.empty() )
359 getScalar( "PROJECT", (uInt)columnValue, obstab, header.project ) ;
360 if ( header.utc == 0.0 ) {
361 Vector<MEpoch> amp ;
362 getArrayMeas( "TIME_RANGE", (uInt)columnValue, obstab, amp ) ;
[2710]363 obsEpoch = amp[0];
364 header.utc = obsEpoch.get( "d" ).getValue() ;
[2291]365 }
366 if ( header.antennaname.empty() )
367 getScalar( "TELESCOPE_NAME", (uInt)columnValue, obstab, header.antennaname ) ;
368 }
[2744]369 virtual void leaveObservationId(const uInt /*recordNo*/, Int /*columnValue*/) {
[2291]370 // update header
371 header.nbeam = max( header.nbeam, (Int)nbeam ) ;
372
373 nbeam = 0 ;
374 feedEntry = -1 ;
375 }
[2744]376 virtual void enterFeedId(const uInt /*recordNo*/, Int columnValue) {
[2291]377 //printf("%u: FeedId: %d\n", recordNo, columnValue);
378
379 // update feed entry
380 if ( allNE( feedEntry, columnValue ) ) {
381 feedEntry[nbeam] = columnValue ;
382 nbeam++ ;
383 }
384
385 // put values
386 *beamNoRF = (uInt)columnValue ;
387 *focusIdRF = (uInt)0 ;
388 }
[2744]389 virtual void leaveFeedId(const uInt /*recordNo*/, Int /*columnValue*/) {
390 uInt nelem = feedEntry.nelements() ;
[2291]391 if ( nbeam > nelem ) {
392 feedEntry.resize( nelem+64, True ) ;
393 Slicer slice( IPosition( 1, nelem ), IPosition( 1, feedEntry.nelements()-1 ) ) ;
394 feedEntry( slice ) = -1 ;
395 }
396 }
[2744]397 virtual void enterFieldId(const uInt /*recordNo*/, Int columnValue) {
[2291]398 //printf("%u: FieldId: %d\n", recordNo, columnValue);
399 // update sourceId and fieldName
400 getScalar( "SOURCE_ID", (uInt)columnValue, fieldtab, sourceId ) ;
401 String fieldName ;
402 getScalar( "NAME", (uInt)columnValue, fieldtab, fieldName ) ;
403 fieldName += "__" + String::toString( columnValue ) ;
404
405 // put values
406 *fieldNameRF = fieldName ;
407 }
[2744]408 virtual void leaveFieldId(const uInt /*recordNo*/, Int /*columnValue*/) {
[2291]409 sourceId = -1 ;
410 }
[2744]411 virtual void enterDataDescId(const uInt /*recordNo*/, Int columnValue) {
[2291]412 //printf("%u: DataDescId: %d\n", recordNo, columnValue);
413 // update polarization and spectral window ids
414 getScalar( "POLARIZATION_ID", (uInt)columnValue, ddtab, polId ) ;
415 getScalar( "SPECTRAL_WINDOW_ID", (uInt)columnValue, ddtab, spwId ) ;
416
417 // polarization setup
418 getScalar( "NUM_CORR", (uInt)polId, poltab, npol ) ;
419 Vector<Int> corrtype ;
420 getArray( "CORR_TYPE", (uInt)polId, poltab, corrtype ) ;
421 polnos = getPolNos( corrtype ) ;
422
423 // process SOURCE table
424 String sourceName ;
425 Vector<Double> sourcePM, restFreqs, sysVels ;
426 Vector<String> transition ;
427 processSource( sourceId, spwId, sourceName, sourceDir, sourcePM,
428 restFreqs, transition, sysVels ) ;
429
430 // spectral setup
431 uInt freqId ;
432 Double reffreq, bandwidth ;
433 String freqref ;
434 getScalar( "NUM_CHAN", (uInt)spwId, spwtab, nchan ) ;
435 Bool iswvr = (Bool)(nchan == 4) ;
436 map<Int,uInt>::iterator iter = ifmap.find( spwId ) ;
437 if ( iter == ifmap.end() ) {
[2710]438 //MEpoch me ;
439 //getScalarMeas( "TIME", recordNo, table, me ) ;
440 //spectralSetup( spwId, me, antpos, sourceDir,
441 spectralSetup(spwId, obsEpoch, antpos, sourceDir,
442 freqId, nchan,
443 freqref, reffreq, bandwidth);
[2291]444 ifmap.insert( pair<Int,uInt>(spwId,freqId) ) ;
445 }
446 else {
447 freqId = iter->second ;
448 }
449 sp.resize( npol, nchan ) ;
450 fl.resize( npol, nchan ) ;
451
452
453 // molecular setup
454 STMolecules mtab = scantable.molecules() ;
455 uInt molId = mtab.addEntry( restFreqs, transition, transition ) ;
456
457 // process SYSCAL table
458 if ( isSysCal )
459 processSysCal( spwId ) ;
460
461 // update header
462 if ( !iswvr ) {
463 header.nchan = max( header.nchan, nchan ) ;
464 header.bandwidth = max( header.bandwidth, bandwidth ) ;
465 if ( header.reffreq == -1.0 )
466 header.reffreq = reffreq ;
467 header.npol = max( header.npol, npol ) ;
468 if ( header.poltype.empty() )
469 header.poltype = getPolType( corrtype[0] ) ;
470 if ( header.freqref.empty() )
471 header.freqref = freqref ;
472 }
473
474 // put values
475 *ifNoRF = (uInt)spwId ;
476 *freqIdRF = freqId ;
477 *moleculeIdRF = molId ;
478 *sourceNameRF = sourceName ;
479 sourceProperMotionRF.define( sourcePM ) ;
480 Vector<Double> srcD = sourceDir.getAngle().getValue( "rad" ) ;
481 sourceDirectionRF.define( srcD ) ;
482 if ( !sysVels.empty() )
483 *sourceVelocityRF = sysVels[0] ;
484 else {
485 *sourceVelocityRF = (Double)0.0 ;
486 }
487 }
[2744]488 virtual void leaveDataDescId(const uInt /*recordNo*/, Int /*columnValue*/) {
[2291]489 npol = 0 ;
490 nchan = 0 ;
491 numSysCalRow = 0 ;
492 }
[2744]493 virtual void enterScanNo(const uInt /*recordNo*/, Int columnValue) {
[2291]494 //printf("%u: ScanNo: %d\n", recordNo, columnValue);
495 // put value
496 // scan number is 1-based in MS while 0-based in Scantable
497 *scanNoRF = (uInt)columnValue - 1 ;
498 }
[2744]499 virtual void leaveScanNo(const uInt /*recordNo*/, Int /*columnValue*/) {
[2291]500 cycleNo = 0 ;
501 }
[2744]502 virtual void enterStateId(const uInt /*recordNo*/, Int columnValue) {
[2291]503 //printf("%u: StateId: %d\n", recordNo, columnValue);
504 // SRCTYPE
505 Int srcType = getSrcType( columnValue ) ;
506
507 // update header
508 if ( header.obstype.empty() )
509 getScalar( "OBS_MODE", (uInt)columnValue, statetab, header.obstype ) ;
510
511 // put value
512 *sourceTypeRF = srcType ;
513 }
[2744]514 virtual void leaveStateId(const uInt /*recordNo*/, Int /*columnValue*/) { }
[2291]515 virtual void enterTime(const uInt recordNo, Double columnValue) {
516 //printf("%u: Time: %f\n", recordNo, columnValue);
517 currentTime = MEpoch( Quantity( columnValue, "s" ), MEpoch::UTC ) ;
518
519 // DIRECTION, AZEL, and SCANRATE
520 Vector<Double> direction, azel ;
521 Vector<Double> scanrate( 2, 0.0 ) ;
522 if ( getpt )
523 getDirection( direction, azel, scanrate ) ;
524 else
525 getSourceDirection( direction, azel, scanrate ) ;
526
527 // INTERVAL
528 Double interval = intervalCol.asdouble( recordNo ) ;
529
530 // WEATHER_ID
531 uInt wid = 0 ;
532 if ( isWeather )
533 wid = getWeatherId() ;
534
535 // put value
536 Double t = currentTime.get( "d" ).getValue() ;
537 *timeRF = t ;
538 *intervalRF = interval ;
539 directionRF.define( direction ) ;
540 *azimuthRF = (Float)azel[0] ;
541 *elevationRF = (Float)azel[1] ;
542 scanRateRF.define( scanrate ) ;
543 *weatherIdRF = wid ;
544 }
[2744]545 virtual void leaveTime(const uInt /*recordNo*/, Double /*columnValue*/) { }
[2291]546 virtual Bool visitRecord(const uInt recordNo,
[2744]547 const Int /*observationId*/,
548 const Int /*feedId*/,
549 const Int /*fieldId*/,
550 const Int /*dataDescId*/,
551 const Int /*scanNo*/,
552 const Int /*stateId*/,
553 const Double /*time*/)
[2291]554 {
555 //printf("%u: %d, %d, %d, %d, %d, %d, %f\n", recordNo,
556 //observationId, feedId, fieldId, dataDescId, scanNo, stateId, time);
557
558 // SPECTRA and FLAGTRA
559 //Matrix<Float> sp;
560 //Matrix<uChar> fl;
561 spectraAndFlagtra( recordNo, sp, fl ) ;
562
563 // FLAGROW
564 Bool flr = flagRowCol.asBool( recordNo ) ;
565
566 // TSYS
567 Matrix<Float> tsys ;
568 uInt scIdx = getSysCalIndex() ;
569 if ( numSysCalRow > 0 ) {
570 tsys = sysCalTsysCol( syscalRow[scIdx] ) ;
571 }
572 else {
573 tsys.resize( npol, 1 ) ;
574 tsys = 1.0 ;
575 }
576
577 // TCAL_ID
578 Block<uInt> tcalids( npol, 0 ) ;
579 if ( numSysCalRow > 0 ) {
580 tcalids = getTcalId( syscalTime[scIdx] ) ;
581 }
[2744]582// else {
583// tcalids = getDummyTcalId( spwId ) ;
584// }
[2291]585
586 // put value
587 *cycleNoRF = cycleNo ;
588 *flagRowRF = (uInt)flr ;
589
590 // for each polarization component
591 for ( Int ipol = 0 ; ipol < npol ; ipol++ ) {
592 // put value depending on polarization component
593 *polNoRF = polnos[ipol] ;
594 *tcalIdRF = tcalids[ipol] ;
595 spectraRF.define( sp.row( ipol ) ) ;
596 flagtraRF.define( fl.row( ipol ) ) ;
597 tsysRF.define( tsys.row( ipol ) ) ;
598
599 // commit row
600 tablerow.put( rowidx ) ;
601 rowidx++ ;
602 }
603
604 // increment CYCLENO
605 cycleNo++ ;
606
607 return True ;
608 }
609 virtual void finish()
610 {
611 BaseMSFillerVisitor::finish();
612 //printf("Total: %u\n", count);
613 // remove redundant rows
614 //cout << "filled " << rowidx << " rows out of " << scantable.nrow() << " rows" << endl ;
[2744]615 if ( scantable.nrow() > (Int)rowidx ) {
[2291]616 uInt numRemove = scantable.nrow() - rowidx ;
617 //cout << "numRemove = " << numRemove << endl ;
618 Vector<uInt> rows( numRemove ) ;
619 indgen( rows, rowidx ) ;
620 scantable.table().removeRow( rows ) ;
621 }
622
623 // antenna name and station name
624 String antennaName ;
625 getScalar( "NAME", (uInt)antennaId, anttab, antennaName ) ;
626 String stationName ;
627 getScalar( "STATION", (uInt)antennaId, anttab, stationName ) ;
628
629 // update header
630 header.nif = ifmap.size() ;
631 header.antennaposition = antpos.get( "m" ).getValue() ;
632 if ( header.antennaname.empty() || header.antennaname == antennaName )
633 header.antennaname = antennaName ;
634 else
635 header.antennaname += "//" + antennaName ;
636 if ( !stationName.empty() && stationName != antennaName )
637 header.antennaname += "@" + stationName ;
638 if ( header.fluxunit.empty() || header.fluxunit == "CNTS" )
639 header.fluxunit = "K" ;
640 header.epoch = "UTC" ;
641 header.equinox = 2000.0 ;
642 if (header.freqref == "TOPO") {
643 header.freqref = "TOPOCENT";
644 } else if (header.freqref == "GEO") {
645 header.freqref = "GEOCENTR";
646 } else if (header.freqref == "BARY") {
647 header.freqref = "BARYCENT";
648 } else if (header.freqref == "GALACTO") {
649 header.freqref = "GALACTOC";
650 } else if (header.freqref == "LGROUP") {
651 header.freqref = "LOCALGRP";
652 } else if (header.freqref == "CMB") {
653 header.freqref = "CMBDIPOL";
654 } else if (header.freqref == "REST") {
655 header.freqref = "SOURCE";
656 }
657 scantable.setHeader( header ) ;
658 }
659 void setAntenna( Int id )
660 {
661 antennaId = id ;
662
663 Vector< Quantum<Double> > pos ;
664 getArrayQuant( "POSITION", (uInt)antennaId, anttab, pos ) ;
665 antpos = MPosition( MVPosition( pos ), MPosition::ITRF ) ;
666 mf.set( antpos ) ;
667 }
668 void setPointingTable( const Table &tab, String columnToUse="DIRECTION" )
669 {
670 // input POINTING table must be
671 // 1) selected by antenna
672 // 2) sorted by TIME
673 ROScalarColumn<Double> tcol( tab, "TIME" ) ;
674 ROArrayColumn<Double> dcol( tab, columnToUse ) ;
675 tcol.getColumn( pointingTime ) ;
676 dcol.getColumn( pointingDirection ) ;
677 const TableRecord &rec = dcol.keywordSet() ;
678 String pointingRef = rec.asRecord( "MEASINFO" ).asString( "Ref" ) ;
679 MDirection::getType( dirType, pointingRef ) ;
680 getpt = True ;
[2580]681
682 // initialize toj2000 and toazel
683 initConvert() ;
[2291]684 }
685 void setWeatherTime( const Vector<Double> &t, const Vector<Double> &it )
686 {
687 isWeather = True ;
688 weatherTime = t ;
689 weatherInterval = it ;
690 }
691 void setSysCalRecord( const Record &r )
692 //void setSysCalRecord( const map< String,Vector<uInt> > &r )
693 {
694 isSysCal = True ;
[2295]695 isTcal = True ;
[2291]696 syscalRecord = r ;
[2295]697 if ( syscalRecord.nfields() == 0 )
698 isTcal = False ;
[2291]699
700 const TableDesc &desc = sctab.tableDesc() ;
701 uInt nrow = sctab.nrow() ;
702 syscalRow.resize( nrow ) ;
703 syscalTime.resize( nrow ) ;
704 syscalInterval.resize( nrow ) ;
705 String tsysCol = "NONE" ;
706 Vector<String> tsysCols = stringToVector( "TSYS_SPECTRUM,TSYS" ) ;
707 for ( uInt i = 0 ; i < tsysCols.nelements() ; i++ ) {
708 if ( tsysCol == "NONE" && desc.isColumn( tsysCols[i] ) )
709 tsysCol = tsysCols[i] ;
710 }
711 sysCalTsysCol.attach( sctab, tsysCol ) ;
712 }
713 STHeader getHeader() { return header ; }
714 uInt getNumBeam() { return nbeam ; }
715 uInt getFilledRowNum() { return rowidx ; }
716private:
[2580]717 void initConvert()
718 {
719 toj2000 = MDirection::Convert( dirType, MDirection::Ref( MDirection::J2000, mf ) ) ;
720 toazel = MDirection::Convert( dirType, MDirection::Ref( MDirection::AZELGEO, mf ) ) ;
721 }
722
[2291]723 void fluxUnit( String &u )
724 {
725 ROTableColumn col( table, dataColumnName ) ;
726 const TableRecord &rec = col.keywordSet() ;
727 if ( rec.isDefined( "UNIT" ) )
728 u = rec.asString( "UNIT" ) ;
729 else if ( rec.isDefined( "QuantumUnits" ) )
730 u = rec.asString( "QuantumUnits" ) ;
731 if ( u.empty() )
732 u = "K" ;
733 }
734 void processSource( Int sourceId, Int spwId,
735 String &name, MDirection &dir, Vector<Double> &pm,
736 Vector<Double> &rf, Vector<String> &trans, Vector<Double> &vel )
737 {
738 // find row
739 uInt nrow = srctab.nrow() ;
740 Int idx = -1 ;
741 ROTableRow row( srctab ) ;
742 for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
743 const TableRecord &r = row.get( irow ) ;
744 if ( r.asInt( "SOURCE_ID" ) == sourceId ) {
745 Int tmpSpwId = r.asInt( "SPECTRAL_WINDOW_ID" ) ;
746 if ( tmpSpwId == spwId || tmpSpwId == -1 ) {
747 idx = (Int)irow ;
748 break ;
749 }
750 }
751 }
752
753 // fill
754 Int numLines = 0 ;
755 if ( idx != -1 ) {
756 const TableRecord &r = row.get( idx ) ;
757 name = r.asString( "NAME" ) ;
758 getScalarMeas( "DIRECTION", idx, srctab, dir ) ;
759 pm = r.toArrayDouble( "PROPER_MOTION" ) ;
760 numLines = r.asInt( "NUM_LINES" ) ;
761 }
762 else {
763 name = "" ;
764 pm = Vector<Double>( 2, 0.0 ) ;
765 dir = MDirection( Quantum<Double>(0.0,Unit("rad")), Quantum<Double>(0.0,Unit("rad")) ) ;
766 }
767 if ( !getpt ) {
768 String ref = dir.getRefString() ;
769 MDirection::getType( dirType, ref ) ;
[2580]770
771 // initialize toj2000 and toazel
772 initConvert() ;
[2291]773 }
774
775 rf.resize( numLines ) ;
776 trans.resize( numLines ) ;
777 vel.resize( numLines ) ;
778 if ( numLines > 0 ) {
779 Block<Bool> isDefined = row.getDefined() ;
780 Vector<String> colNames = row.columnNames() ;
781 Vector<Int> indexes( 3, -1 ) ;
782 Vector<String> cols = stringToVector( "REST_FREQUENCY,TRANSITION,SYSVEL" ) ;
783 for ( uInt icol = 0 ; icol < colNames.nelements() ; icol++ ) {
784 if ( anyEQ( indexes, -1 ) ) {
785 for ( uInt jcol = 0 ; jcol < cols.nelements() ; jcol++ ) {
786 if ( colNames[icol] == cols[jcol] )
787 indexes[jcol] = icol ;
788 }
789 }
790 }
791 if ( indexes[0] != -1 && isDefined[indexes[0]] == True ) {
792 Vector< Quantum<Double> > qrf ;
793 getArrayQuant( "REST_FREQUENCY", idx, srctab, qrf ) ;
794 for ( int i = 0 ; i < numLines ; i++ )
795 rf[i] = qrf[i].getValue( "Hz" ) ;
796 }
797 if ( indexes[1] != -1 && isDefined[indexes[1]] == True ) {
798 getArray( "TRANSITION", idx, srctab, trans ) ;
799 }
800 if ( indexes[2] != -1 && isDefined[indexes[2]] == True ) {
801 Vector< Quantum<Double> > qsv ;
802 getArrayQuant( "SYSVEL", idx, srctab, qsv ) ;
803 for ( int i = 0 ; i < numLines ; i++ )
804 vel[i] = qsv[i].getValue( "m/s" ) ;
805 }
806 }
807 }
808 void spectralSetup( Int &spwId, MEpoch &me, MPosition &mp, MDirection &md,
809 uInt &freqId, Int &nchan,
810 String &freqref, Double &reffreq, Double &bandwidth )
811 {
812 // fill
813 Int measFreqRef ;
814 getScalar( "MEAS_FREQ_REF", spwId, spwtab, measFreqRef ) ;
815 MFrequency::Types freqRef = MFrequency::castType( measFreqRef ) ;
816 //freqref = MFrequency::showType( freqRef ) ;
817 freqref = "LSRK" ;
818 Quantum<Double> q ;
819 getScalarQuant( "TOTAL_BANDWIDTH", spwId, spwtab, q ) ;
820 bandwidth = q.getValue( "Hz" ) ;
821 getScalarQuant( "REF_FREQUENCY", spwId, spwtab, q ) ;
822 reffreq = q.getValue( "Hz" ) ;
823 Double refpix = 0.5 * ( (Double)nchan-1.0 ) ;
824 Int refchan = ( nchan - 1 ) / 2 ;
825 Bool even = (Bool)( nchan % 2 == 0 ) ;
826 Vector< Quantum<Double> > qa ;
827 getArrayQuant( "CHAN_WIDTH", spwId, spwtab, qa ) ;
[2554]828// Double increment = qa[refchan].getValue( "Hz" ) ;
829 Double increment = abs(qa[refchan].getValue( "Hz" )) ;
[2291]830 getArrayQuant( "CHAN_FREQ", spwId, spwtab, qa ) ;
831 if ( nchan == 1 ) {
832 Int netSideband ;
833 getScalar( "NET_SIDEBAND", spwId, spwtab, netSideband ) ;
834 if ( netSideband == 1 ) increment *= -1.0 ;
835 }
836 else {
837 if ( qa[0].getValue( "Hz" ) > qa[1].getValue( "Hz" ) )
838 increment *= -1.0 ;
839 }
840 Double refval = qa[refchan].getValue( "Hz" ) ;
841 if ( even )
842 refval = 0.5 * ( refval + qa[refchan+1].getValue( "Hz" ) ) ;
843 if ( freqRef != MFrequency::LSRK ) {
844 MeasFrame mframe( me, mp, md ) ;
845 MFrequency::Convert tolsr( freqRef, MFrequency::Ref( MFrequency::LSRK, mframe ) ) ;
846 refval = tolsr( Quantum<Double>( refval, "Hz" ) ).get( "Hz" ).getValue() ;
847 }
848
849 // add new row to FREQUENCIES
850 Table ftab = scantable.frequencies().table() ;
851 freqId = ftab.nrow() ;
852 ftab.addRow() ;
853 TableRow row( ftab ) ;
854 TableRecord &r = row.record() ;
855 RecordFieldPtr<uInt> idRF( r, "ID" ) ;
856 *idRF = freqId ;
857 RecordFieldPtr<Double> refpixRF( r, "REFPIX" ) ;
858 RecordFieldPtr<Double> refvalRF( r, "REFVAL" ) ;
859 RecordFieldPtr<Double> incrRF( r, "INCREMENT" ) ;
860 *refpixRF = refpix ;
861 *refvalRF = refval ;
862 *incrRF = increment ;
863 row.put( freqId ) ;
864 }
865 void spectraAndFlagtra( uInt recordNo, Matrix<Float> &sp, Matrix<uChar> &fl )
866 {
867 Matrix<Bool> b = flagCol( recordNo ) ;
868 if ( dataColumnName.compare( "FLOAT_DATA" ) == 0 ) {
869 sp = floatDataCol( recordNo ) ;
870 convertArray( fl, b ) ;
871 }
872 else {
873 Bool notyet = True ;
874 Matrix<Complex> c = dataCol( recordNo ) ;
875 for ( Int ipol = 0 ; ipol < npol ; ipol++ ) {
876 if ( ( header.poltype == "linear" || header.poltype == "circular" )
877 && ( polnos[ipol] == 2 || polnos[ipol] == 3 ) ) {
878 if ( notyet ) {
879 Vector<Float> tmp = ComplexToReal( c.row( ipol ) ) ;
880 IPosition start( 1, 0 ) ;
881 IPosition end( 1, 2*nchan-1 ) ;
882 IPosition inc( 1, 2 ) ;
883 if ( polnos[ipol] == 2 ) {
884 sp.row( ipol ) = tmp( start, end, inc ) ;
885 Vector<Bool> br = b.row( ipol ) ;
886 Vector<uChar> flr = fl.row( ipol ) ;
887 convertArray( flr, br ) ;
888 start = IPosition( 1, 1 ) ;
889 Int jpol = ipol+1 ;
890 while( polnos[jpol] != 3 && jpol < npol )
891 jpol++ ;
892 sp.row( jpol ) = tmp( start, end, inc ) ;
893 flr.reference( fl.row( jpol ) ) ;
894 convertArray( flr, br ) ;
895 }
896 else if ( polnos[ipol] == 3 ) {
897 sp.row( ipol ) = sp.row( ipol ) * (Float)(-1.0) ;
898 Int jpol = ipol+1 ;
899 while( polnos[jpol] != 2 && jpol < npol )
900 jpol++ ;
901 Vector<Bool> br = b.row( ipol ) ;
902 Vector<uChar> flr = fl.row( jpol ) ;
903 sp.row( jpol ) = tmp( start, end, inc ) ;
904 convertArray( flr, br ) ;
905 start = IPosition( 1, 1 ) ;
906 sp.row( ipol ) = tmp( start, end, inc ) * (Float)(-1.0) ;
907 flr.reference( fl.row( ipol ) ) ;
908 convertArray( flr, br ) ;
909 }
910 notyet = False ;
911 }
912 }
913 else {
914 Vector<Float> tmp = ComplexToReal( c.row( ipol ) ) ;
915 IPosition start( 1, 0 ) ;
916 IPosition end( 1, 2*nchan-1 ) ;
917 IPosition inc( 1, 2 ) ;
918 sp.row( ipol ) = tmp( start, end, inc ) ;
919 Vector<Bool> br = b.row( ipol ) ;
920 Vector<uChar> flr = fl.row( ipol ) ;
921 convertArray( flr, br ) ;
922 }
923 }
924 }
925 }
926 uInt binarySearch( Vector<Double> &timeList, Double target )
927 {
928 Int low = 0 ;
929 Int high = timeList.nelements() ;
930 uInt idx = 0 ;
931
932 while ( low <= high ) {
933 idx = (Int)( 0.5 * ( low + high ) ) ;
934 Double t = timeList[idx] ;
935 if ( t < target )
936 low = idx + 1 ;
937 else if ( t > target )
938 high = idx - 1 ;
939 else {
940 return idx ;
941 }
942 }
943
944 idx = max( 0, min( low, high ) ) ;
945 return idx ;
946 }
947 void getDirection( Vector<Double> &dir, Vector<Double> &azel, Vector<Double> &srate )
948 {
949 // @todo At the moment, do binary search every time
950 // if this is bottleneck, frequency of binary search must be reduced
951 Double t = currentTime.get( "s" ).getValue() ;
952 uInt idx = min( binarySearch( pointingTime, t ), pointingTime.nelements()-1 ) ;
953 Matrix<Double> d ;
954 if ( pointingTime[idx] == t )
955 d = pointingDirection.xyPlane( idx ) ;
956 else if ( pointingTime[idx] < t ) {
957 if ( idx == pointingTime.nelements()-1 )
958 d = pointingDirection.xyPlane( idx ) ;
959 else
960 d = interp( pointingTime[idx], pointingTime[idx+1], t,
961 pointingDirection.xyPlane( idx ), pointingDirection.xyPlane( idx+1 ) ) ;
962 }
963 else {
964 if ( idx == 0 )
965 d = pointingDirection.xyPlane( idx ) ;
966 else
967 d = interp( pointingTime[idx-1], pointingTime[idx], t,
968 pointingDirection.xyPlane( idx-1 ), pointingDirection.xyPlane( idx ) ) ;
969 }
[2580]970 mf.set( currentTime ) ;
[2291]971 Quantum< Vector<Double> > tmp( d.column( 0 ), Unit( "rad" ) ) ;
972 if ( dirType != MDirection::J2000 ) {
973 dir = toj2000( tmp ).getAngle( "rad" ).getValue() ;
974 }
975 else {
976 dir = d.column( 0 ) ;
977 }
978 if ( dirType != MDirection::AZELGEO ) {
979 azel = toazel( tmp ).getAngle( "rad" ).getValue() ;
980 }
981 else {
982 azel = d.column( 0 ) ;
983 }
984 if ( d.ncolumn() > 1 )
985 srate = d.column( 1 ) ;
986 }
[2744]987 void getSourceDirection( Vector<Double> &dir, Vector<Double> &azel, Vector<Double> &/*srate*/ )
[2291]988 {
989 dir = sourceDir.getAngle( "rad" ).getValue() ;
[2580]990 mf.set( currentTime ) ;
[2291]991 azel = toazel( Quantum< Vector<Double> >( dir, Unit("rad") ) ).getAngle( "rad" ).getValue() ;
992 if ( dirType != MDirection::J2000 ) {
993 dir = toj2000( Quantum< Vector<Double> >( dir, Unit("rad") ) ).getAngle( "rad" ).getValue() ;
994 }
995 }
996 String detectSeparator( String &s )
997 {
998 String tmp = s.substr( 0, s.find_first_of( "," ) ) ;
999 Char *separators[] = { ":", "#", ".", "_" } ;
1000 uInt nsep = 4 ;
1001 for ( uInt i = 0 ; i < nsep ; i++ ) {
1002 if ( tmp.find( separators[i] ) != String::npos )
1003 return separators[i] ;
1004 }
1005 return "" ;
1006 }
1007 Int getSrcType( Int stateId )
1008 {
1009 // get values
1010 Bool sig ;
1011 getScalar( "SIG", stateId, statetab, sig ) ;
1012 Bool ref ;
1013 getScalar( "REF", stateId, statetab, ref ) ;
1014 Double cal ;
1015 getScalar( "CAL", stateId, statetab, cal ) ;
1016 String obsmode ;
1017 getScalar( "OBS_MODE", stateId, statetab, obsmode ) ;
1018 String sep = detectSeparator( obsmode ) ;
1019
1020 Int srcType = SrcType::NOTYPE ;
1021 if ( sep == ":" )
1022 srcTypeGBT( srcType, sep, obsmode, sig, ref, cal ) ;
1023 else if ( sep == "." || sep == "#" )
1024 srcTypeALMA( srcType, sep, obsmode ) ;
1025 else if ( sep == "_" )
1026 srcTypeOldALMA( srcType, sep, obsmode, sig, ref ) ;
1027 else
1028 srcTypeDefault( srcType, sig, ref ) ;
1029
1030 return srcType ;
1031 }
1032 void srcTypeDefault( Int &st, Bool &sig, Bool &ref )
1033 {
1034 if ( sig ) st = SrcType::SIG ;
1035 else if ( ref ) st = SrcType::REF ;
1036 }
1037 void srcTypeGBT( Int &st, String &sep, String &mode, Bool &sig, Bool &ref, Double &cal )
1038 {
1039 Int epos = mode.find_first_of( sep ) ;
1040 Int nextpos = mode.find_first_of( sep, epos+1 ) ;
1041 String m1 = mode.substr( 0, epos ) ;
1042 String m2 = mode.substr( epos+1, nextpos-epos-1 ) ;
1043 if ( m1 == "Nod" ) {
1044 st = SrcType::NOD ;
1045 }
1046 else if ( m1 == "OffOn" ) {
1047 if ( m2 == "PSWITCHON" ) st = SrcType::PSON ;
1048 if ( m2 == "PSWITCHOFF" ) st = SrcType::PSOFF ;
1049 }
1050 else {
1051 if ( m2 == "FSWITCH" ) {
1052 if ( sig ) st = SrcType::FSON ;
1053 else if ( ref ) st = SrcType::FSOFF ;
1054 }
1055 }
1056 if ( cal > 0.0 ) {
1057 if ( st == SrcType::NOD )
1058 st = SrcType::NODCAL ;
1059 else if ( st == SrcType::PSON )
1060 st = SrcType::PONCAL ;
1061 else if ( st == SrcType::PSOFF )
1062 st = SrcType::POFFCAL ;
1063 else if ( st == SrcType::FSON )
1064 st = SrcType::FONCAL ;
1065 else if ( st == SrcType::FSOFF )
1066 st = SrcType::FOFFCAL ;
1067 else
1068 st = SrcType::CAL ;
1069 }
1070 }
1071 void srcTypeALMA( Int &st, String &sep, String &mode )
1072 {
1073 Int epos = mode.find_first_of( "," ) ;
1074 String first = mode.substr( 0, epos ) ;
1075 epos = first.find_first_of( sep ) ;
1076 Int nextpos = first.find_first_of( sep, epos+1 ) ;
1077 String m1 = first.substr( 0, epos ) ;
1078 String m2 = first.substr( epos+1, nextpos-epos-1 ) ;
1079 if ( m1.find( "CALIBRATE_" ) == 0 ) {
1080 if ( m2.find( "ON_SOURCE" ) == 0 )
1081 st = SrcType::PONCAL ;
1082 else if ( m2.find( "OFF_SOURCE" ) == 0 )
1083 st = SrcType::POFFCAL ;
1084 }
1085 else if ( m1.find( "OBSERVE_TARGET" ) == 0 ) {
1086 if ( m2.find( "ON_SOURCE" ) == 0 )
1087 st = SrcType::PSON ;
1088 else if ( m2.find( "OFF_SOURCE" ) == 0 )
1089 st = SrcType::PSOFF ;
1090 }
1091 }
1092 void srcTypeOldALMA( Int &st, String &sep, String &mode, Bool &sig, Bool &ref )
1093 {
1094 Int epos = mode.find_first_of( "," ) ;
1095 String first = mode.substr( 0, epos ) ;
1096 string substr[4] ;
1097 int numSubstr = split( first, substr, 4, sep ) ;
1098 String m1( substr[0] ) ;
1099 String m2( substr[2] ) ;
1100 if ( numSubstr == 4 ) {
1101 if ( m1.find( "CALIBRATE" ) == 0 ) {
1102 if ( m2.find( "ON" ) == 0 )
1103 st = SrcType::PONCAL ;
1104 else if ( m2.find( "OFF" ) == 0 )
1105 st = SrcType::POFFCAL ;
1106 }
1107 else if ( m1.find( "OBSERVE" ) == 0 ) {
1108 if ( m2.find( "ON" ) == 0 )
1109 st = SrcType::PSON ;
1110 else if ( m2.find( "OFF" ) == 0 )
1111 st = SrcType::PSOFF ;
1112 }
1113 }
1114 else {
1115 if ( sig ) st = SrcType::SIG ;
1116 else if ( ref ) st = SrcType::REF ;
1117 }
1118 }
1119 Block<uInt> getPolNos( Vector<Int> &corr )
1120 {
1121 Block<uInt> polnos( npol ) ;
1122 for ( Int ipol = 0 ; ipol < npol ; ipol++ ) {
1123 if ( corr[ipol] == Stokes::I || corr[ipol] == Stokes::RR || corr[ipol] == Stokes::XX )
1124 polnos[ipol] = 0 ;
1125 else if ( corr[ipol] == Stokes::Q || corr[ipol] == Stokes::LL || corr[ipol] == Stokes::YY )
1126 polnos[ipol] = 1 ;
1127 else if ( corr[ipol] == Stokes::U || corr[ipol] == Stokes::RL || corr[ipol] == Stokes::XY )
1128 polnos[ipol] = 2 ;
1129 else if ( corr[ipol] == Stokes::V || corr[ipol] == Stokes::LR || corr[ipol] == Stokes::YX )
1130 polnos[ipol] = 3 ;
1131 }
1132 return polnos ;
1133 }
1134 String getPolType( Int &corr )
1135 {
1136 String poltype = "" ;
1137 if ( corr == Stokes::I || corr == Stokes::Q || corr == Stokes::U || corr == Stokes::V )
1138 poltype = "stokes" ;
1139 else if ( corr == Stokes::XX || corr == Stokes::YY || corr == Stokes::XY || corr == Stokes::YX )
1140 poltype = "linear" ;
1141 else if ( corr == Stokes::RR || corr == Stokes::LL || corr == Stokes::RL || corr == Stokes::LR )
1142 poltype = "circular" ;
1143 else if ( corr == Stokes::Plinear || corr == Stokes::Pangle )
1144 poltype = "linpol" ;
1145 return poltype ;
1146 }
1147 uInt getWeatherId()
1148 {
1149 // if only one row, return 0
1150 if ( weatherTime.nelements() == 1 )
1151 return 0 ;
1152
1153 // @todo At the moment, do binary search every time
1154 // if this is bottleneck, frequency of binary search must be reduced
1155 Double t = currentTime.get( "s" ).getValue() ;
1156 uInt idx = min( binarySearch( weatherTime, t ), weatherTime.nelements()-1 ) ;
1157 if ( weatherTime[idx] < t ) {
1158 if ( idx != weatherTime.nelements()-1 ) {
1159 if ( weatherTime[idx+1] - t < 0.5 * weatherInterval[idx+1] )
1160 idx++ ;
1161 }
1162 }
1163 else if ( weatherTime[idx] > t ) {
1164 if ( idx != 0 ) {
1165 if ( weatherTime[idx] - t > 0.5 * weatherInterval[idx] )
1166 idx-- ;
1167 }
1168 }
1169 return idx ;
1170 }
1171 void processSysCal( Int &spwId )
1172 {
1173 // get feedId from row
1174 Int feedId = (Int)tablerow.record().asuInt( "BEAMNO" ) ;
1175
1176 uInt nrow = sctab.nrow() ;
1177 ROScalarColumn<Int> col( sctab, "ANTENNA_ID" ) ;
1178 Vector<Int> aids = col.getColumn() ;
1179 col.attach( sctab, "FEED_ID" ) ;
1180 Vector<Int> fids = col.getColumn() ;
1181 col.attach( sctab, "SPECTRAL_WINDOW_ID" ) ;
1182 Vector<Int> sids = col.getColumn() ;
1183 ROScalarColumn<Double> timeCol( sctab, "TIME" ) ;
1184 ROScalarColumn<Double> intCol( sctab, "INTERVAL" ) ;
1185 for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
1186 if ( aids[irow] == antennaId
1187 && fids[irow] == feedId
1188 && sids[irow] == spwId ) {
1189 syscalRow[numSysCalRow] = irow ;
1190 syscalTime[numSysCalRow] = timeCol( irow ) ;
1191 syscalInterval[numSysCalRow] = intCol( irow ) ;
1192 numSysCalRow++ ;
1193 }
1194 }
1195 }
1196 uInt getSysCalIndex()
1197 {
1198 // if only one row, return 0
1199 if ( numSysCalRow == 1 || !isSysCal )
1200 return 0 ;
1201
1202 // @todo At the moment, do binary search every time
1203 // if this is bottleneck, frequency of binary search must be reduced
1204 Double t = currentTime.get( "s" ).getValue() ;
1205 Vector<Double> tslice = syscalTime( Slice(0, numSysCalRow) ) ;
1206 uInt idx = min( binarySearch( tslice, t ), numSysCalRow-1 ) ;
1207 if ( syscalTime[idx] < t ) {
1208 if ( idx != numSysCalRow-1 ) {
1209 if ( syscalTime[idx+1] - t < 0.5 * syscalInterval[idx+1] )
1210 idx++ ;
1211 }
1212 }
1213 else if ( syscalTime[idx] > t ) {
1214 if ( idx != 0 ) {
1215 if ( syscalTime[idx] - t > 0.5 * syscalInterval[idx] )
1216 idx-- ;
1217 }
1218 }
1219 return idx ;
1220 }
1221 Block<uInt> getTcalId( Double &t )
1222 {
1223 // return 0 if no SysCal table
[2295]1224 if ( !isSysCal or !isTcal ) {
[2291]1225 return Block<uInt>( 4, 0 ) ;
1226 }
1227
1228 // get feedId from row
1229 Int feedId = (Int)tablerow.record().asuInt( "BEAMNO" ) ;
1230
1231 // key
1232 String key = keyTcal( feedId, spwId, t ) ;
1233
1234 // retrieve ids
1235 Vector<uInt> ids = syscalRecord.asArrayuInt( key ) ;
1236 //Vector<uInt> ids = syscalRecord[key] ;
1237 uInt np = ids[1] - ids[0] + 1 ;
1238 Block<uInt> tcalids( np ) ;
1239 if ( np > 0 ) {
1240 tcalids[0] = ids[0] ;
1241 if ( np > 1 ) {
1242 tcalids[1] = ids[1] ;
1243 for ( uInt ip = 2 ; ip < np ; ip++ )
1244 tcalids[ip] = ids[0] + ip - 1 ;
1245 }
1246 }
1247 return tcalids ;
1248 }
[2744]1249 Block<uInt> getDummyTcalId( Int spwId )
1250 {
1251 Block<uInt> idList(4, 0);
1252 uInt nfields = syscalRecord.nfields();
1253 Int idx = -1;
1254 for (uInt i = 0; i< nfields ; i++ ) {
1255 String spw = "SPW" + String::toString(spwId);
1256 if (syscalRecord.name(i).find(spw) != String::npos) {
1257 idx = i;
1258 break;
1259 }
1260 }
1261 if ( idx > -1) {
1262 Vector<uInt> tmp = syscalRecord.asArrayuInt(idx);
1263 for (uInt j = 0 ; j < 4 ; j++) {
1264 idList[j] = tmp[0];
1265 }
1266 cout << "tmp=" << tmp << endl;
1267 }
1268 return idList;
1269 }
[2291]1270 uInt maxNumPol()
1271 {
1272 ROScalarColumn<Int> numCorrCol( poltab, "NUM_CORR" ) ;
1273 return max( numCorrCol.getColumn() ) ;
1274 }
1275
1276 Scantable &scantable;
1277 Int antennaId;
1278 uInt rowidx;
1279 String dataColumnName;
1280 TableRow tablerow;
1281 STHeader header;
1282 Vector<Int> feedEntry;
1283 uInt nbeam;
1284 Int npol;
1285 Int nchan;
1286 Int sourceId;
1287 Int polId;
1288 Int spwId;
1289 uInt cycleNo;
1290 MDirection sourceDir;
1291 MPosition antpos;
1292 MEpoch currentTime;
[2710]1293 MEpoch obsEpoch;
[2580]1294 MeasFrame mf;
1295 MDirection::Convert toj2000;
1296 MDirection::Convert toazel;
[2291]1297 map<Int,uInt> ifmap;
1298 Block<uInt> polnos;
1299 Bool getpt;
1300 Vector<Double> pointingTime;
1301 Cube<Double> pointingDirection;
1302 MDirection::Types dirType;
1303 Bool isWeather;
1304 Vector<Double> weatherTime;
1305 Vector<Double> weatherInterval;
1306 Bool isSysCal;
[2295]1307 Bool isTcal;
[2291]1308 Record syscalRecord;
1309 //map< String,Vector<uInt> > syscalRecord;
1310 uInt numSysCalRow ;
1311 Vector<uInt> syscalRow;
1312 Vector<Double> syscalTime;
1313 Vector<Double> syscalInterval;
1314 //String tsysCol;
1315 //String tcalCol;
1316
1317 // MS subtables
1318 Table obstab;
1319 Table sctab;
1320 Table spwtab;
1321 Table statetab;
1322 Table ddtab;
1323 Table poltab;
1324 Table fieldtab;
1325 Table anttab;
1326 Table srctab;
1327 Matrix<Float> sp;
1328 Matrix<uChar> fl;
1329
1330 // MS MAIN columns
1331 ROTableColumn intervalCol;
1332 ROTableColumn flagRowCol;
1333 ROArrayColumn<Float> floatDataCol;
1334 ROArrayColumn<Complex> dataCol;
1335 ROArrayColumn<Bool> flagCol;
1336
1337 // MS SYSCAL columns
1338 ROArrayColumn<Float> sysCalTsysCol;
1339
1340 // Scantable MAIN columns
1341 RecordFieldPtr<Double> timeRF,intervalRF,sourceVelocityRF;
1342 RecordFieldPtr< Vector<Double> > directionRF,scanRateRF,
1343 sourceProperMotionRF,sourceDirectionRF;
1344 RecordFieldPtr<Float> azimuthRF,elevationRF;
1345 RecordFieldPtr<uInt> weatherIdRF,cycleNoRF,flagRowRF,polNoRF,tcalIdRF,
1346 ifNoRF,freqIdRF,moleculeIdRF,beamNoRF,focusIdRF,scanNoRF;
1347 RecordFieldPtr< Vector<Float> > spectraRF,tsysRF;
1348 RecordFieldPtr< Vector<uChar> > flagtraRF;
1349 RecordFieldPtr<String> sourceNameRF,fieldNameRF;
1350 RecordFieldPtr<Int> sourceTypeRF;
1351};
1352
1353class BaseTcalVisitor: public TableVisitor {
1354 uInt lastRecordNo ;
1355 Int lastAntennaId ;
1356 Int lastFeedId ;
1357 Int lastSpwId ;
1358 Double lastTime ;
1359protected:
1360 const Table &table;
1361 uInt count;
1362public:
1363 BaseTcalVisitor(const Table &table)
1364 : table(table)
1365 {
1366 count = 0;
1367 }
1368
[2744]1369 virtual void enterAntennaId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1370 virtual void leaveAntennaId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1371 virtual void enterFeedId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1372 virtual void leaveFeedId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1373 virtual void enterSpwId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1374 virtual void leaveSpwId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1375 virtual void enterTime(const uInt /*recordNo*/, Double /*columnValue*/) { }
1376 virtual void leaveTime(const uInt /*recordNo*/, Double /*columnValue*/) { }
[2291]1377
[2744]1378 virtual Bool visitRecord(const uInt /*recordNo*/,
1379 const Int /*antennaId*/,
1380 const Int /*feedId*/,
1381 const Int /*spwId*/,
1382 const Double /*time*/) { return True ; }
[2291]1383
1384 virtual Bool visit(Bool isFirst, const uInt recordNo,
1385 const uInt nCols, void const *const colValues[]) {
1386 Int antennaId, feedId, spwId;
1387 Double time;
1388 { // prologue
1389 uInt i = 0;
1390 {
1391 const Int *col = (const Int *)colValues[i++];
1392 antennaId = col[recordNo];
1393 }
1394 {
1395 const Int *col = (const Int *)colValues[i++];
1396 feedId = col[recordNo];
1397 }
1398 {
1399 const Int *col = (const Int *)colValues[i++];
1400 spwId = col[recordNo];
1401 }
1402 {
1403 const Double *col = (const Double *)colValues[i++];
1404 time = col[recordNo];
1405 }
1406 assert(nCols == i);
1407 }
1408
1409 if (isFirst) {
1410 enterAntennaId(recordNo, antennaId);
1411 enterFeedId(recordNo, feedId);
1412 enterSpwId(recordNo, spwId);
1413 enterTime(recordNo, time);
1414 } else {
1415 if ( lastAntennaId != antennaId ) {
1416 leaveTime(lastRecordNo, lastTime);
1417 leaveSpwId(lastRecordNo, lastSpwId);
1418 leaveFeedId(lastRecordNo, lastFeedId);
1419 leaveAntennaId(lastRecordNo, lastAntennaId);
1420
1421 enterAntennaId(recordNo, antennaId);
1422 enterFeedId(recordNo, feedId);
1423 enterSpwId(recordNo, spwId);
1424 enterTime(recordNo, time);
1425 }
1426 else if (lastFeedId != feedId) {
1427 leaveTime(lastRecordNo, lastTime);
1428 leaveSpwId(lastRecordNo, lastSpwId);
1429 leaveFeedId(lastRecordNo, lastFeedId);
1430
1431 enterFeedId(recordNo, feedId);
1432 enterSpwId(recordNo, spwId);
1433 enterTime(recordNo, time);
1434 } else if (lastSpwId != spwId) {
1435 leaveTime(lastRecordNo, lastTime);
1436 leaveSpwId(lastRecordNo, lastSpwId);
1437
1438 enterSpwId(recordNo, spwId);
1439 enterTime(recordNo, time);
1440 } else if (lastTime != time) {
1441 leaveTime(lastRecordNo, lastTime);
1442 enterTime(recordNo, time);
1443 }
1444 }
1445 count++;
1446 Bool result = visitRecord(recordNo, antennaId, feedId, spwId, time);
1447
1448 { // epilogue
1449 lastRecordNo = recordNo;
1450
1451 lastAntennaId = antennaId;
1452 lastFeedId = feedId;
1453 lastSpwId = spwId;
1454 lastTime = time;
1455 }
1456 return result ;
1457 }
1458
1459 virtual void finish() {
1460 if (count > 0) {
1461 leaveTime(lastRecordNo, lastTime);
1462 leaveSpwId(lastRecordNo, lastSpwId);
1463 leaveFeedId(lastRecordNo, lastFeedId);
1464 leaveAntennaId(lastRecordNo, lastAntennaId);
1465 }
1466 }
1467};
1468
1469class TcalVisitor: public BaseTcalVisitor, public MSFillerUtils {
1470public:
1471 TcalVisitor(const Table &table, Table &tcaltab, Record &r, Int aid )
1472 //TcalVisitor(const Table &table, Table &tcaltab, map< String,Vector<uInt> > &r, Int aid )
1473 : BaseTcalVisitor( table ),
1474 tcal(tcaltab),
1475 rec(r),
1476 antenna(aid)
1477 {
1478 process = False ;
1479 rowidx = 0 ;
1480
1481 // attach to SYSCAL columns
1482 timeCol.attach( table, "TIME" ) ;
1483
1484 // add rows
1485 uInt addrow = table.nrow() * 4 ;
1486 tcal.addRow( addrow ) ;
1487
1488 // attach to TCAL columns
1489 row = TableRow( tcal ) ;
1490 TableRecord &trec = row.record() ;
1491 idRF.attachToRecord( trec, "ID" ) ;
1492 timeRF.attachToRecord( trec, "TIME" ) ;
1493 tcalRF.attachToRecord( trec, "TCAL" ) ;
1494 }
1495
[2744]1496 virtual void enterAntennaId(const uInt /*recordNo*/, Int columnValue) {
[2291]1497 if ( columnValue == antenna )
1498 process = True ;
1499 }
[2744]1500 virtual void leaveAntennaId(const uInt /*recordNo*/, Int /*columnValue*/) {
[2291]1501 process = False ;
1502 }
[2744]1503 virtual void enterFeedId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1504 virtual void leaveFeedId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1505 virtual void enterSpwId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1506 virtual void leaveSpwId(const uInt /*recordNo*/, Int /*columnValue*/) { }
1507 virtual void enterTime(const uInt recordNo, Double /*columnValue*/) {
[2291]1508 qtime = timeCol( recordNo ) ;
1509 }
[2744]1510 virtual void leaveTime(const uInt /*recordNo*/, Double /*columnValue*/) { }
[2291]1511 virtual Bool visitRecord(const uInt recordNo,
[2744]1512 const Int /*antennaId*/,
[2291]1513 const Int feedId,
1514 const Int spwId,
[2744]1515 const Double /*time*/)
[2291]1516 {
1517 //cout << "(" << recordNo << "," << antennaId << "," << feedId << "," << spwId << ")" << endl ;
1518 if ( process ) {
1519 String sTime = MVTime( qtime ).string( MVTime::YMD ) ;
1520 *timeRF = sTime ;
1521 uInt oldidx = rowidx ;
1522 Matrix<Float> subtcal = tcalCol( recordNo ) ;
1523 Vector<uInt> idminmax( 2 ) ;
1524 for ( uInt ipol = 0 ; ipol < subtcal.nrow() ; ipol++ ) {
1525 *idRF = rowidx ;
1526 tcalRF.define( subtcal.row( ipol ) ) ;
1527
1528 // commit row
1529 row.put( rowidx ) ;
1530 rowidx++ ;
1531 }
1532
1533 idminmax[0] = oldidx ;
1534 idminmax[1] = rowidx - 1 ;
1535
1536 String key = keyTcal( feedId, spwId, sTime ) ;
1537 rec.define( key, idminmax ) ;
1538 //rec[key] = idminmax ;
1539 }
1540 return True ;
1541 }
1542 virtual void finish()
1543 {
1544 BaseTcalVisitor::finish() ;
1545
1546 if ( tcal.nrow() > rowidx ) {
1547 uInt numRemove = tcal.nrow() - rowidx ;
1548 //cout << "numRemove = " << numRemove << endl ;
1549 Vector<uInt> rows( numRemove ) ;
1550 indgen( rows, rowidx ) ;
1551 tcal.removeRow( rows ) ;
1552 }
1553
1554 }
1555 void setTcalColumn( String &col )
1556 {
1557 //colName = col ;
1558 tcalCol.attach( table, col ) ;
1559 }
1560private:
1561 Table &tcal;
1562 Record &rec;
1563 //map< String,Vector<uInt> > &rec;
1564 Int antenna;
1565 uInt rowidx;
1566 Bool process;
1567 Quantum<Double> qtime;
1568 TableRow row;
1569 String colName;
1570
1571 // MS SYSCAL columns
1572 ROScalarQuantColumn<Double> timeCol;
1573 ROArrayColumn<Float> tcalCol;
1574
1575 // TCAL columns
1576 RecordFieldPtr<uInt> idRF;
1577 RecordFieldPtr<String> timeRF;
1578 RecordFieldPtr< Vector<Float> > tcalRF;
1579};
1580
[1974]1581MSFiller::MSFiller( casa::CountedPtr<Scantable> stable )
1582 : table_( stable ),
[1987]1583 tablename_( "" ),
[1974]1584 antenna_( -1 ),
[2021]1585 antennaStr_(""),
[2206]1586 getPt_( True ),
[1974]1587 isFloatData_( False ),
1588 isData_( False ),
1589 isDoppler_( False ),
1590 isFlagCmd_( False ),
1591 isFreqOffset_( False ),
1592 isHistory_( False ),
1593 isProcessor_( False ),
1594 isSysCal_( False ),
[1993]1595 isWeather_( False ),
1596 colTsys_( "TSYS_SPECTRUM" ),
1597 colTcal_( "TCAL_SPECTRUM" )
[1974]1598{
1599 os_ = LogIO() ;
1600 os_.origin( LogOrigin( "MSFiller", "MSFiller()", WHERE ) ) ;
1601}
1602
1603MSFiller::~MSFiller()
1604{
1605 os_.origin( LogOrigin( "MSFiller", "~MSFiller()", WHERE ) ) ;
1606}
1607
1608bool MSFiller::open( const std::string &filename, const casa::Record &rec )
1609{
1610 os_.origin( LogOrigin( "MSFiller", "open()", WHERE ) ) ;
[2258]1611 //double startSec = mathutil::gettimeofday_sec() ;
[2237]1612 //os_ << "start MSFiller::open() startsec=" << startSec << LogIO::POST ;
[1974]1613 //os_ << " filename = " << filename << endl ;
1614
1615 // parsing MS options
1616 if ( rec.isDefined( "ms" ) ) {
1617 Record msrec = rec.asRecord( "ms" ) ;
1618 if ( msrec.isDefined( "getpt" ) ) {
1619 getPt_ = msrec.asBool( "getpt" ) ;
1620 }
1621 if ( msrec.isDefined( "antenna" ) ) {
1622 if ( msrec.type( msrec.fieldNumber( "antenna" ) ) == TpInt ) {
1623 antenna_ = msrec.asInt( "antenna" ) ;
1624 }
1625 else {
[2021]1626 //antenna_ = atoi( msrec.asString( "antenna" ).c_str() ) ;
1627 antennaStr_ = msrec.asString( "antenna" ) ;
[1974]1628 }
1629 }
1630 else {
1631 antenna_ = 0 ;
1632 }
1633 }
1634
[1987]1635 MeasurementSet *tmpMS = new MeasurementSet( filename, Table::Old ) ;
1636 tablename_ = tmpMS->tableName() ;
[2021]1637 if ( antenna_ == -1 && antennaStr_.size() > 0 ) {
1638 MSAntennaIndex msAntIdx( tmpMS->antenna() ) ;
1639 Vector<Int> id = msAntIdx.matchAntennaName( antennaStr_ ) ;
1640 if ( id.size() > 0 )
1641 antenna_ = id[0] ;
[2303]1642 else {
1643 delete tmpMS ;
1644 //throw( AipsError( "Antenna " + antennaStr_ + " doesn't exist." ) ) ;
1645 os_ << LogIO::SEVERE << "Antenna " << antennaStr_ << " doesn't exist." << LogIO::POST ;
1646 return False ;
1647 }
[2021]1648 }
[2025]1649
1650 os_ << "Parsing MS options" << endl ;
1651 os_ << " getPt = " << getPt_ << endl ;
1652 os_ << " antenna = " << antenna_ << endl ;
1653 os_ << " antennaStr = " << antennaStr_ << LogIO::POST ;
1654
[1987]1655 mstable_ = MeasurementSet( (*tmpMS)( tmpMS->col("ANTENNA1") == antenna_
1656 && tmpMS->col("ANTENNA1") == tmpMS->col("ANTENNA2") ) ) ;
[2291]1657
[1987]1658 delete tmpMS ;
[1974]1659
1660 // check which data column exists
[1987]1661 isFloatData_ = mstable_.tableDesc().isColumn( "FLOAT_DATA" ) ;
1662 isData_ = mstable_.tableDesc().isColumn( "DATA" ) ;
[1974]1663
[2258]1664 //double endSec = mathutil::gettimeofday_sec() ;
[2237]1665 //os_ << "end MSFiller::open() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
[1974]1666 return true ;
1667}
1668
1669void MSFiller::fill()
1670{
[2258]1671 //double startSec = mathutil::gettimeofday_sec() ;
[2237]1672 //os_ << "start MSFiller::fill() startSec=" << startSec << LogIO::POST ;
[1974]1673
[2291]1674 os_.origin( LogOrigin( "MSFiller", "fill()", WHERE ) ) ;
[1990]1675
[1974]1676 // Initialize header
1677 STHeader sdh ;
[2237]1678 initHeader( sdh ) ;
[2291]1679 table_->setHeader( sdh ) ;
[1974]1680
1681 // check if optional table exists
[2291]1682 const TableRecord &msrec = mstable_.keywordSet() ;
[1974]1683 isDoppler_ = msrec.isDefined( "DOPPLER" ) ;
[2004]1684 if ( isDoppler_ )
1685 if ( mstable_.doppler().nrow() == 0 )
1686 isDoppler_ = False ;
[1974]1687 isFlagCmd_ = msrec.isDefined( "FLAG_CMD" ) ;
[2004]1688 if ( isFlagCmd_ )
1689 if ( mstable_.flagCmd().nrow() == 0 )
1690 isFlagCmd_ = False ;
[1974]1691 isFreqOffset_ = msrec.isDefined( "FREQ_OFFSET" ) ;
[2004]1692 if ( isFreqOffset_ )
1693 if ( mstable_.freqOffset().nrow() == 0 )
1694 isFreqOffset_ = False ;
[1974]1695 isHistory_ = msrec.isDefined( "HISTORY" ) ;
[2004]1696 if ( isHistory_ )
1697 if ( mstable_.history().nrow() == 0 )
1698 isHistory_ = False ;
[1974]1699 isProcessor_ = msrec.isDefined( "PROCESSOR" ) ;
[2004]1700 if ( isProcessor_ )
1701 if ( mstable_.processor().nrow() == 0 )
1702 isProcessor_ = False ;
[1974]1703 isSysCal_ = msrec.isDefined( "SYSCAL" ) ;
[2004]1704 if ( isSysCal_ )
1705 if ( mstable_.sysCal().nrow() == 0 )
1706 isSysCal_ = False ;
[1974]1707 isWeather_ = msrec.isDefined( "WEATHER" ) ;
[2004]1708 if ( isWeather_ )
1709 if ( mstable_.weather().nrow() == 0 )
1710 isWeather_ = False ;
1711
[2291]1712 // column name for Tsys and Tcal
1713 if ( isSysCal_ ) {
1714 const MSSysCal &caltab = mstable_.sysCal() ;
[2159]1715 if ( !caltab.tableDesc().isColumn( colTcal_ ) ) {
[1993]1716 colTcal_ = "TCAL" ;
[2159]1717 if ( !caltab.tableDesc().isColumn( colTcal_ ) )
1718 colTcal_ = "NONE" ;
1719 }
1720 if ( !caltab.tableDesc().isColumn( colTsys_ ) ) {
[1993]1721 colTsys_ = "TSYS" ;
[2159]1722 if ( !caltab.tableDesc().isColumn( colTcal_ ) )
1723 colTsys_ = "NONE" ;
1724 }
[1993]1725 }
[2291]1726 else {
1727 colTcal_ = "NONE" ;
1728 colTsys_ = "NONE" ;
1729 }
[1974]1730
[2291]1731 // Access to MS subtables
1732 //MSField &fieldtab = mstable_.field() ;
1733 //MSPolarization &poltab = mstable_.polarization() ;
1734 //MSDataDescription &ddtab = mstable_.dataDescription() ;
1735 //MSObservation &obstab = mstable_.observation() ;
1736 //MSSource &srctab = mstable_.source() ;
1737 //MSSpectralWindow &spwtab = mstable_.spectralWindow() ;
1738 //MSSysCal &caltab = mstable_.sysCal() ;
1739 MSPointing &pointtab = mstable_.pointing() ;
1740 //MSState &stattab = mstable_.state() ;
1741 //MSAntenna &anttab = mstable_.antenna() ;
[1974]1742
[1987]1743 // SUBTABLES: FREQUENCIES
[2222]1744 //string freqFrame = getFrame() ;
1745 string freqFrame = "LSRK" ;
[2217]1746 table_->frequencies().setFrame( freqFrame ) ;
1747 table_->frequencies().setFrame( freqFrame, True ) ;
[1974]1748
1749 // SUBTABLES: WEATHER
[2004]1750 fillWeather() ;
[1974]1751
1752 // SUBTABLES: FOCUS
1753 fillFocus() ;
1754
1755 // SUBTABLES: TCAL
[2291]1756 fillTcal() ;
[1974]1757
1758 // SUBTABLES: FIT
1759 //fillFit() ;
1760
1761 // SUBTABLES: HISTORY
1762 //fillHistory() ;
1763
[2291]1764 /***
1765 * Start iteration using TableVisitor
1766 ***/
1767 Table stab = table_->table() ;
1768 {
1769 static const char *cols[] = {
1770 "OBSERVATION_ID", "FEED1", "FIELD_ID", "DATA_DESC_ID", "SCAN_NUMBER",
1771 "STATE_ID", "TIME",
1772 NULL
1773 };
1774 static const TypeManagerImpl<Int> tmInt;
1775 static const TypeManagerImpl<Double> tmDouble;
1776 static const TypeManager *const tms[] = {
1777 &tmInt, &tmInt, &tmInt, &tmInt, &tmInt, &tmInt, &tmDouble, NULL
1778 };
1779 //double t0 = mathutil::gettimeofday_sec() ;
1780 MSFillerVisitor myVisitor(mstable_, *table_ );
1781 //double t1 = mathutil::gettimeofday_sec() ;
1782 //cout << "MSFillerVisitor(): elapsed time " << t1-t0 << " sec" << endl ;
1783 myVisitor.setAntenna( antenna_ ) ;
1784 //myVisitor.setHeader( sdh ) ;
1785 if ( getPt_ ) {
1786 Table ptsel = pointtab( pointtab.col("ANTENNA_ID")==antenna_ ).sort( "TIME" ) ;
1787 myVisitor.setPointingTable( ptsel ) ;
[1987]1788 }
[2291]1789 if ( isWeather_ )
1790 myVisitor.setWeatherTime( mwTime_, mwInterval_ ) ;
1791 if ( isSysCal_ )
1792 myVisitor.setSysCalRecord( tcalrec_ ) ;
1793
1794 //double t2 = mathutil::gettimeofday_sec() ;
1795 traverseTable(mstable_, cols, tms, &myVisitor);
1796 //double t3 = mathutil::gettimeofday_sec() ;
1797 //cout << "traverseTable(): elapsed time " << t3-t2 << " sec" << endl ;
1798
1799 sdh = myVisitor.getHeader() ;
[1974]1800 }
[2291]1801 /***
1802 * End iteration using TableVisitor
1803 ***/
[1974]1804
[2291]1805 // set header
1806 //sdh = myVisitor.getHeader() ;
1807 //table_->setHeader( sdh ) ;
[1987]1808
1809 // save path to POINTING table
[2207]1810 // 2011/07/06 TN
1811 // Path to POINTING table in original MS will not be written
1812 // if getPt_ is True
[1987]1813 Path datapath( tablename_ ) ;
[2207]1814 if ( !getPt_ ) {
1815 String pTabName = datapath.absoluteName() + "/POINTING" ;
1816 stab.rwKeywordSet().define( "POINTING", pTabName ) ;
1817 }
[1987]1818
1819 // for GBT
[2291]1820 if ( sdh.antennaname.contains( "GBT" ) ) {
[1987]1821 String goTabName = datapath.absoluteName() + "/GBT_GO" ;
[1990]1822 stab.rwKeywordSet().define( "GBT_GO", goTabName ) ;
[1987]1823 }
[2022]1824
1825 // for MS created from ASDM
1826 const TableRecord &msKeys = mstable_.keywordSet() ;
1827 uInt nfields = msKeys.nfields() ;
1828 for ( uInt ifield = 0 ; ifield < nfields ; ifield++ ) {
1829 String name = msKeys.name( ifield ) ;
1830 //os_ << "name = " << name << LogIO::POST ;
1831 if ( name.find( "ASDM" ) != String::npos ) {
1832 String asdmpath = msKeys.asTable( ifield ).tableName() ;
1833 os_ << "ASDM table: " << asdmpath << LogIO::POST ;
1834 stab.rwKeywordSet().define( name, asdmpath ) ;
1835 }
1836 }
1837
[2258]1838 //double endSec = mathutil::gettimeofday_sec() ;
[2237]1839 //os_ << "end MSFiller::fill() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
[1974]1840}
1841
1842void MSFiller::close()
1843{
[1987]1844 //tablesel_.closeSubTables() ;
[1974]1845 mstable_.closeSubTables() ;
[1987]1846 //tablesel_.unlock() ;
[1974]1847 mstable_.unlock() ;
1848}
1849
1850void MSFiller::fillWeather()
1851{
[2258]1852 //double startSec = mathutil::gettimeofday_sec() ;
[2237]1853 //os_ << "start MSFiller::fillWeather() startSec=" << startSec << LogIO::POST ;
[2004]1854
1855 if ( !isWeather_ ) {
1856 // add dummy row
1857 table_->weather().table().addRow(1,True) ;
1858 return ;
1859 }
1860
[1987]1861 Table mWeather = mstable_.weather() ;
1862 //Table mWeatherSel = mWeather( mWeather.col("ANTENNA_ID") == antenna_ ).sort("TIME") ;
1863 Table mWeatherSel( mWeather( mWeather.col("ANTENNA_ID") == antenna_ ).sort("TIME") ) ;
[1974]1864 //os_ << "mWeatherSel.nrow() = " << mWeatherSel.nrow() << LogIO::POST ;
1865 if ( mWeatherSel.nrow() == 0 ) {
[2025]1866 os_ << "No rows with ANTENNA_ID = " << antenna_ << " in WEATHER table, Try -1..." << LogIO::POST ;
[1987]1867 mWeatherSel = Table( MSWeather( mWeather( mWeather.col("ANTENNA_ID") == -1 ) ) ) ;
[1974]1868 if ( mWeatherSel.nrow() == 0 ) {
1869 os_ << "No rows in WEATHER table" << LogIO::POST ;
1870 }
1871 }
[1987]1872 uInt wnrow = mWeatherSel.nrow() ;
[1974]1873 //os_ << "wnrow = " << wnrow << LogIO::POST ;
1874
1875 if ( wnrow == 0 )
1876 return ;
1877
1878 Table wtab = table_->weather().table() ;
1879 wtab.addRow( wnrow ) ;
1880
[2234]1881 Bool stationInfoExists = mWeatherSel.tableDesc().isColumn( "NS_WX_STATION_ID" ) ;
1882 Int stationId = -1 ;
1883 if ( stationInfoExists ) {
1884 // determine which station is closer
1885 ROScalarColumn<Int> stationCol( mWeatherSel, "NS_WX_STATION_ID" ) ;
1886 ROArrayColumn<Double> stationPosCol( mWeatherSel, "NS_WX_STATION_POSITION" ) ;
1887 Vector<Int> stationIds = stationCol.getColumn() ;
1888 Vector<Int> stationIdList( 0 ) ;
1889 Matrix<Double> stationPosList( 0, 3, 0.0 ) ;
1890 uInt numStation = 0 ;
1891 for ( uInt i = 0 ; i < stationIds.size() ; i++ ) {
1892 if ( !anyEQ( stationIdList, stationIds[i] ) ) {
1893 numStation++ ;
1894 stationIdList.resize( numStation, True ) ;
1895 stationIdList[numStation-1] = stationIds[i] ;
1896 stationPosList.resize( numStation, 3, True ) ;
1897 stationPosList.row( numStation-1 ) = stationPosCol( i ) ;
1898 }
1899 }
1900 //os_ << "staionIdList = " << stationIdList << endl ;
1901 Table mAntenna = mstable_.antenna() ;
1902 ROArrayColumn<Double> antposCol( mAntenna, "POSITION" ) ;
1903 Vector<Double> antpos = antposCol( antenna_ ) ;
1904 Double minDiff = -1.0 ;
1905 for ( uInt i = 0 ; i < stationIdList.size() ; i++ ) {
1906 Double diff = sum( square( antpos - stationPosList.row( i ) ) ) ;
1907 if ( minDiff < 0.0 || minDiff > diff ) {
1908 minDiff = diff ;
1909 stationId = stationIdList[i] ;
1910 }
1911 }
1912 }
1913 //os_ << "stationId = " << stationId << endl ;
1914
[1987]1915 ScalarColumn<Float> *fCol ;
1916 ROScalarColumn<Float> *sharedFloatCol ;
1917 if ( mWeatherSel.tableDesc().isColumn( "TEMPERATURE" ) ) {
1918 fCol = new ScalarColumn<Float>( wtab, "TEMPERATURE" ) ;
1919 sharedFloatCol = new ROScalarColumn<Float>( mWeatherSel, "TEMPERATURE" ) ;
1920 fCol->putColumn( *sharedFloatCol ) ;
1921 delete sharedFloatCol ;
1922 delete fCol ;
1923 }
1924 if ( mWeatherSel.tableDesc().isColumn( "PRESSURE" ) ) {
1925 fCol = new ScalarColumn<Float>( wtab, "PRESSURE" ) ;
1926 sharedFloatCol = new ROScalarColumn<Float>( mWeatherSel, "PRESSURE" ) ;
1927 fCol->putColumn( *sharedFloatCol ) ;
1928 delete sharedFloatCol ;
1929 delete fCol ;
1930 }
1931 if ( mWeatherSel.tableDesc().isColumn( "REL_HUMIDITY" ) ) {
1932 fCol = new ScalarColumn<Float>( wtab, "HUMIDITY" ) ;
1933 sharedFloatCol = new ROScalarColumn<Float>( mWeatherSel, "REL_HUMIDITY" ) ;
1934 fCol->putColumn( *sharedFloatCol ) ;
1935 delete sharedFloatCol ;
1936 delete fCol ;
1937 }
1938 if ( mWeatherSel.tableDesc().isColumn( "WIND_SPEED" ) ) {
1939 fCol = new ScalarColumn<Float>( wtab, "WINDSPEED" ) ;
1940 sharedFloatCol = new ROScalarColumn<Float>( mWeatherSel, "WIND_SPEED" ) ;
1941 fCol->putColumn( *sharedFloatCol ) ;
1942 delete sharedFloatCol ;
1943 delete fCol ;
1944 }
1945 if ( mWeatherSel.tableDesc().isColumn( "WIND_DIRECTION" ) ) {
1946 fCol = new ScalarColumn<Float>( wtab, "WINDAZ" ) ;
1947 sharedFloatCol = new ROScalarColumn<Float>( mWeatherSel, "WIND_DIRECTION" ) ;
1948 fCol->putColumn( *sharedFloatCol ) ;
1949 delete sharedFloatCol ;
1950 delete fCol ;
1951 }
[1974]1952 ScalarColumn<uInt> idCol( wtab, "ID" ) ;
[1987]1953 for ( uInt irow = 0 ; irow < wnrow ; irow++ )
1954 idCol.put( irow, irow ) ;
[1974]1955
[1987]1956 ROScalarQuantColumn<Double> tqCol( mWeatherSel, "TIME" ) ;
1957 ROScalarColumn<Double> tCol( mWeatherSel, "TIME" ) ;
1958 String tUnit = tqCol.getUnits() ;
[2234]1959 Vector<Double> mwTime = tCol.getColumn() ;
[1974]1960 if ( tUnit == "d" )
[2234]1961 mwTime *= 86400.0 ;
[1987]1962 tqCol.attach( mWeatherSel, "INTERVAL" ) ;
1963 tCol.attach( mWeatherSel, "INTERVAL" ) ;
1964 String iUnit = tqCol.getUnits() ;
[2234]1965 Vector<Double> mwInterval = tCol.getColumn() ;
[1974]1966 if ( iUnit == "d" )
[2234]1967 mwInterval *= 86400.0 ;
1968
1969 if ( stationId > 0 ) {
1970 ROScalarColumn<Int> stationCol( mWeatherSel, "NS_WX_STATION_ID" ) ;
1971 Vector<Int> stationVec = stationCol.getColumn() ;
1972 uInt wsnrow = ntrue( stationVec == stationId ) ;
1973 mwTime_.resize( wsnrow ) ;
1974 mwInterval_.resize( wsnrow ) ;
1975 mwIndex_.resize( wsnrow ) ;
1976 uInt wsidx = 0 ;
1977 for ( uInt irow = 0 ; irow < wnrow ; irow++ ) {
1978 if ( stationId == stationVec[irow] ) {
1979 mwTime_[wsidx] = mwTime[irow] ;
1980 mwInterval_[wsidx] = mwInterval[irow] ;
1981 mwIndex_[wsidx] = irow ;
1982 wsidx++ ;
1983 }
1984 }
1985 }
1986 else {
1987 mwTime_ = mwTime ;
1988 mwInterval_ = mwInterval ;
1989 mwIndex_.resize( mwTime_.size() ) ;
1990 indgen( mwIndex_ ) ;
1991 }
[1974]1992 //os_ << "mwTime[0] = " << mwTime_[0] << " mwInterval[0] = " << mwInterval_[0] << LogIO::POST ;
[2258]1993 //double endSec = mathutil::gettimeofday_sec() ;
[2237]1994 //os_ << "end MSFiller::fillWeather() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
[1974]1995}
1996
1997void MSFiller::fillFocus()
1998{
[2258]1999 //double startSec = mathutil::gettimeofday_sec() ;
[2237]2000 //os_ << "start MSFiller::fillFocus() startSec=" << startSec << LogIO::POST ;
[1974]2001 // tentative
[2228]2002 table_->focus().addEntry( 0.0, 0.0, 0.0, 0.0 ) ;
[2258]2003 //double endSec = mathutil::gettimeofday_sec() ;
[2237]2004 //os_ << "end MSFiller::fillFocus() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
[1974]2005}
2006
[2291]2007void MSFiller::fillTcal()
[1974]2008{
[2258]2009 //double startSec = mathutil::gettimeofday_sec() ;
[2237]2010 //os_ << "start MSFiller::fillTcal() startSec=" << startSec << LogIO::POST ;
[1987]2011
[2004]2012 if ( !isSysCal_ ) {
2013 // add dummy row
[2025]2014 os_ << "No SYSCAL rows" << LogIO::POST ;
[2004]2015 table_->tcal().table().addRow(1,True) ;
[2021]2016 Vector<Float> defaultTcal( 1, 1.0 ) ;
2017 ArrayColumn<Float> tcalCol( table_->tcal().table(), "TCAL" ) ;
2018 tcalCol.put( 0, defaultTcal ) ;
[2004]2019 return ;
2020 }
2021
[2159]2022 if ( colTcal_ == "NONE" ) {
2023 // add dummy row
2024 os_ << "No TCAL column" << LogIO::POST ;
2025 table_->tcal().table().addRow(1,True) ;
2026 Vector<Float> defaultTcal( 1, 1.0 ) ;
2027 ArrayColumn<Float> tcalCol( table_->tcal().table(), "TCAL" ) ;
2028 tcalCol.put( 0, defaultTcal ) ;
2029 return ;
2030 }
2031
[2291]2032 Table &sctab = mstable_.sysCal() ;
[1974]2033 if ( sctab.nrow() == 0 ) {
[2025]2034 os_ << "No SYSCAL rows" << LogIO::POST ;
[1974]2035 return ;
2036 }
[2291]2037 ROScalarColumn<Int> antCol( sctab, "ANTENNA_ID" ) ;
2038 Vector<Int> ant = antCol.getColumn() ;
2039 if ( allNE( ant, antenna_ ) ) {
[2025]2040 os_ << "No SYSCAL rows" << LogIO::POST ;
[1974]2041 return ;
2042 }
[2291]2043 ROTableColumn tcalCol( sctab, colTcal_ ) ;
[2164]2044 Bool notDefined = False ;
[2291]2045 for ( uInt irow = 0 ; irow < sctab.nrow() ; irow++ ) {
2046 if ( ant[irow] == antenna_ && !tcalCol.isDefined( irow ) ) {
[2164]2047 notDefined = True ;
2048 break ;
2049 }
2050 }
2051 if ( notDefined ) {
2052 os_ << "No TCAL value" << LogIO::POST ;
2053 table_->tcal().table().addRow(1,True) ;
2054 Vector<Float> defaultTcal( 1, 1.0 ) ;
2055 ArrayColumn<Float> tcalCol( table_->tcal().table(), "TCAL" ) ;
2056 tcalCol.put( 0, defaultTcal ) ;
2057 return ;
2058 }
[2291]2059
2060 static const char *cols[] = {
2061 "ANTENNA_ID", "FEED_ID", "SPECTRAL_WINDOW_ID", "TIME",
2062 NULL
2063 };
2064 static const TypeManagerImpl<Int> tmInt;
2065 static const TypeManagerImpl<Double> tmDouble;
2066 static const TypeManager *const tms[] = {
2067 &tmInt, &tmInt, &tmInt, &tmDouble, NULL
2068 };
[1974]2069 Table tab = table_->tcal().table() ;
[2291]2070 TcalVisitor visitor( sctab, tab, tcalrec_, antenna_ ) ;
2071 visitor.setTcalColumn( colTcal_ ) ;
2072
2073 traverseTable(sctab, cols, tms, &visitor);
[2002]2074
[2744]2075 infillTcal();
2076
[1974]2077 //tcalrec_.print( std::cout ) ;
[2258]2078 //double endSec = mathutil::gettimeofday_sec() ;
[2237]2079 //os_ << "end MSFiller::fillTcal() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
[1974]2080}
2081
[2744]2082void MSFiller::infillTcal()
2083{
2084 uInt nfields = tcalrec_.nfields() ;
2085 set<Int> spwAvailable;
2086 for (uInt i = 0; i < nfields; i++) {
2087 String name = tcalrec_.name(i);
2088 size_t pos1 = name.find(':') + 4;
2089 size_t pos2 = name.find(':',pos1);
2090 Int spwid = String::toInt(name.substr(pos1,pos2-pos1));
2091 //cout << "spwid=" << spwid << endl;
2092 spwAvailable.insert(spwid);
2093 }
2094 Table spwtab = mstable_.spectralWindow();
2095 Table tcaltab = table_->tcal().table();
2096 ScalarColumn<uInt> idCol(tcaltab, "ID");
2097 ScalarColumn<String> timeCol(tcaltab, "TIME");
2098 ArrayColumn<Float> tcalCol(tcaltab, "TCAL");
2099 ROScalarColumn<Int> numChanCol(spwtab, "NUM_CHAN");
2100 Int numSpw = spwtab.nrow();
2101 Int dummyFeed = 0;
2102 Double dummyTime = 0.0;
2103 Vector<uInt> idminmax(2);
2104 for (Int i = 0; i < numSpw; i++) {
2105 if (spwAvailable.find(i) == spwAvailable.end()) {
2106 String key = keyTcal(dummyFeed, i, dummyTime);
2107 Vector<Float> tcal(numChanCol(i), 1.0);
2108 uInt nrow = tcaltab.nrow();
2109 tcaltab.addRow(1);
2110 idCol.put(nrow, nrow);
2111 timeCol.put(nrow, "");
2112 tcalCol.put(nrow, tcal);
2113 idminmax = nrow;
2114 tcalrec_.define(key, idminmax);
2115 }
2116 }
2117 //tcalrec_.print(cout);
2118}
2119
[2217]2120string MSFiller::getFrame()
2121{
2122 MFrequency::Types frame = MFrequency::DEFAULT ;
2123 ROTableColumn numChanCol( mstable_.spectralWindow(), "NUM_CHAN" ) ;
2124 ROTableColumn measFreqRefCol( mstable_.spectralWindow(), "MEAS_FREQ_REF" ) ;
2125 uInt nrow = numChanCol.nrow() ;
2126 Vector<Int> measFreqRef( nrow, MFrequency::DEFAULT ) ;
2127 uInt nref = 0 ;
2128 for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
2129 if ( numChanCol.asInt( irow ) != 4 ) { // exclude WVR
2130 measFreqRef[nref] = measFreqRefCol.asInt( irow ) ;
2131 nref++ ;
2132 }
2133 }
2134 if ( nref > 0 )
2135 frame = (MFrequency::Types)measFreqRef[0] ;
2136
2137 return MFrequency::showType( frame ) ;
2138}
[2237]2139
2140void MSFiller::initHeader( STHeader &header )
2141{
2142 header.nchan = 0 ;
2143 header.npol = 0 ;
2144 header.nif = 0 ;
2145 header.nbeam = 0 ;
2146 header.observer = "" ;
2147 header.project = "" ;
2148 header.obstype = "" ;
2149 header.antennaname = "" ;
[2291]2150 header.antennaposition.resize( 3 ) ;
[2237]2151 header.equinox = 0.0 ;
2152 header.freqref = "" ;
2153 header.reffreq = -1.0 ;
2154 header.bandwidth = 0.0 ;
2155 header.utc = 0.0 ;
2156 header.fluxunit = "" ;
2157 header.epoch = "" ;
2158 header.poltype = "" ;
2159}
2160
[2291]2161};
Note: See TracBrowser for help on using the repository browser.