source: branches/alma/src/NROFiller.cpp@ 2900

Last change on this file since 2900 was 1818, checked in by Kana Sugimoto, 14 years ago

New Development: Yes

JIRA Issue: No (merge)

Ready for Test: Yes

Interface Changes: No

Description:

Merged changes -r1774:1817 in newfiller branch to alma branch


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