source: trunk/src/NROFiller.cpp@ 2762

Last change on this file since 2762 was 2761, checked in by Takeshi Nakazato, 12 years ago

New Development: No

JIRA Issue: No

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

Added new option, freqref, to NRO filler. Posible values are:
1) 'rest' to import frequency in REST frame, which results in an exactly
same frequency label as NEWSTAR, and 2) 'vref' to import frequency
in the frame that source velocity refers, which results in the same
velocity label as NEWSTAR. The option must be given to scantable
constructor.


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