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