source: trunk/src/NROFiller.cpp@ 2225

Last change on this file since 2225 was 2201, checked in by Takeshi Nakazato, 13 years ago

New Development: No

JIRA Issue: Yes CAS-2819

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

IFNO is taken from ARRAY number.
Bug fix on checking if spectrometer is AOS or not.


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