source: branches/casa-prerelease/pre-asap/src/NROFiller.cpp@ 2156

Last change on this file since 2156 was 2019, checked in by Takeshi Nakazato, 14 years ago

New Development: No

JIRA Issue: Yes CAS-2718

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...

Bug fix

1) supporting variable shaped array input to some column (SPECTRAL DATA, TSYS, and TCAL)

2) put [1.0] instead of empty array as default TCAL in NROFiller

3) Check if some subtables have any effective rows in MSWriter


File size: 6.7 KB
Line 
1//
2// C++ Interface: NROFiller
3//
4// Description:
5// This class is a concrete class that derives from FillerBase class.
6// The class implements the following methods to be able to read NRO
7// data (45m and ASTE).
8//
9// open()
10// close()
11// fill()
12//
13//
14// Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2010
15//
16// Copyright: See COPYING file that comes with this distribution
17//
18//
19
20#include "NROFiller.h"
21#include "STHeader.h"
22#include <casa/Containers/Record.h>
23#include <casa/Quanta/MVTime.h>
24#include <atnf/PKSIO/SrcType.h>
25
26using namespace casa;
27
28namespace asap
29{
30NROFiller::NROFiller(CountedPtr<Scantable> stable)
31 : FillerBase(stable)
32{
33}
34
35NROFiller::~NROFiller()
36{
37 close() ;
38}
39
40 bool NROFiller::open(const std::string& filename, const Record& rec)
41{
42 bool status = true ;
43
44 // get appropriate reader object
45 String format ;
46 reader_ = getNROReader( filename, format ) ;
47 if ( reader_.null() == True ) {
48 status = false ;
49 return status ;
50 }
51
52 // get header information
53 STHeader hdr ;
54 if ( reader_->getHeaderInfo( hdr.nchan,
55 hdr.npol,
56 hdr.nif,
57 hdr.nbeam,
58 hdr.observer,
59 hdr.project,
60 hdr.obstype,
61 hdr.antennaname,
62 hdr.antennaposition,
63 hdr.equinox,
64 hdr.freqref,
65 hdr.reffreq,
66 hdr.bandwidth,
67 hdr.utc,
68 hdr.fluxunit,
69 hdr.epoch,
70 hdr.poltype ) ) {
71 status = false ;
72 return status ;
73 }
74
75 // 2010/07/30 TBD: Do we need to set frame here?
76 table_->frequencies().setFrame( hdr.freqref, true ) ;
77 table_->frequencies().setFrame( String("LSRK"), false ) ;
78
79 // set Header
80 setHeader( hdr ) ;
81
82 return status ;
83}
84
85void NROFiller::fill()
86{
87 // for each row
88 uInt nRow = reader_->getRowNum() ;
89 vector< vector<double > > freqs ;
90 uInt scanno ;
91 uInt cycleno ;
92 uInt beamno ;
93 uInt polno ;
94 vector<double> fqs ;
95 Vector<Double> restfreq ;
96 uInt refbeamno ;
97 Double scantime ;
98 Double interval ;
99 String srcname ;
100 String fieldname ;
101 Array<Float> spectra ;
102 Array<uChar> flagtra ;
103 Array<Float> tsys ;
104 Array<Double> direction ;
105 Float azimuth ;
106 Float elevation ;
107 Float parangle ;
108 Float opacity ;
109 uInt tcalid ;
110 Int fitid ;
111 uInt focusid ;
112 Float temperature ;
113 Float pressure ;
114 Float humidity ;
115 Float windvel ;
116 Float winddir ;
117 Double srcvel ;
118 Array<Double> propermotion ;
119 Vector<Double> srcdir ;
120 Array<Double> scanrate ;
121 Int rowCount = 0 ;
122
123 STHeader header = table_->getHeader() ;
124 String obsType = header.obstype.substr( 0, 3 ) ;
125 Vector<Float> defaultTcal( 1, 1.0 ) ;
126 String tcalTime = MVTime( header.utc ).string( MVTime::YMD ) ;
127 for ( Int irow = 0 ; irow < (Int)nRow ; irow++ ) {
128 // check scan intent
129 string scanType = reader_->getScanType( irow ) ;
130 SrcType::type srcType = SrcType::NOTYPE ;
131
132 // skip "ZERO" scan
133 if ( scanType.compare( 0, 4, "ZERO" ) == 0 ) {
134 continue ;
135 }
136
137 // set srcType
138 if ( obsType == "POS" || obsType == "BEA" ) {
139 if ( scanType.compare( 0, 2, "ON" ) == 0 )
140 srcType = SrcType::PSON ;
141 else if ( scanType.compare( 0, 3, "OFF" ) == 0 )
142 srcType = SrcType::PSOFF ;
143 }
144 else if ( obsType == "FRE" ) {
145 if ( scanType.compare( 0, 2, "ON" ) == 0 )
146 srcType = SrcType::FSON ;
147 else if ( scanType.compare( 0, 3, "OFF" ) == 0 )
148 srcType = SrcType::FSOFF ;
149 }
150
151 // get scan ifnromation
152 if ( reader_->getScanInfo( irow,
153 scanno,
154 cycleno,
155 beamno,
156 polno,
157 fqs,
158 restfreq,
159 refbeamno,
160 scantime,
161 interval,
162 srcname,
163 fieldname,
164 spectra,
165 flagtra,
166 tsys,
167 direction,
168 azimuth,
169 elevation,
170 parangle,
171 opacity,
172 tcalid,
173 fitid,
174 focusid,
175 temperature,
176 pressure,
177 humidity,
178 windvel,
179 winddir,
180 srcvel,
181 propermotion,
182 srcdir,
183 scanrate ) ) {
184 throw AipsError( "Failed to read scan record" ) ;
185 return ;
186 }
187
188 // set IDs and subtable rows
189 // FREQUENCIES subtable row
190 setFrequency( (Double)fqs[0], (Double)fqs[1], (Double)fqs[2] ) ;
191
192 // MOLECULES subtable row
193 setMolecule( restfreq ) ;
194
195 // FOCUS subtable row
196 setFocus( parangle ) ;
197
198 // WEATHER subtable row
199 setWeather( temperature, pressure, humidity, windvel, winddir ) ;
200
201 // TCAL subtable row
202 // use default since NRO input is calibrated data
203 setTcal( tcalTime, defaultTcal ) ;
204
205
206 // set row attributes
207 // SPECTRA, FLAGTRA, and TSYS
208 Vector<Float> spectrum( spectra );
209 Vector<uChar> flags( flagtra ) ;
210 Vector<Float> Tsys( tsys ) ;
211 setSpectrum( spectrum, flags, Tsys ) ;
212
213 // SCANNO, CYCLENO, IFNO, POLNO, and BEAMNO
214 uInt ifno = table_->frequencies().addEntry( (Double)fqs[0], (Double)fqs[1], (Double)fqs[2] ) ;
215 setIndex( scanno, cycleno, ifno, polno, beamno ) ;
216
217 // REFBEAMNO
218 setReferenceBeam( (Int)refbeamno ) ;
219
220 // DIRECTION
221 Vector<Double> dir( direction ) ;
222 setDirection(dir, azimuth, elevation ) ;
223
224 // TIME and INTERVAL
225 setTime( scantime, interval ) ;
226
227 // SRCNAME, SRCTYPE, FIELDNAME, SRCDIRECTION, SRCPROPERMOTION, and SRCVELOCITY
228 Vector<Double> propermot( propermotion ) ;
229 setSource( srcname, srcType, fieldname, srcdir, propermot, srcvel ) ;
230
231 // SCANRATE
232 Vector<Double> srate( scanrate ) ;
233 setScanRate( srate ) ;
234
235 // OPACITY
236 setOpacity( opacity ) ;
237
238 // finally, commit row
239 commitRow() ;
240
241 // count up number of row committed
242 rowCount++ ;
243 }
244}
245
246void NROFiller::close()
247{
248 if (reader_.null() != False) {
249 reader_ = 0;
250 }
251 table_ = 0;
252}
253
254};
255
Note: See TracBrowser for help on using the repository browser.