source: branches/polybatch/src/NROFiller.cpp@ 3096

Last change on this file since 3096 was 1904, checked in by Malte Marquarding, 14 years ago

pass down record for filler options

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