source: branches/parallelCasa3.3/src/NROFiller.cpp@ 2580

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

New Development: No

JIRA Issue: No

Ready for Test: No

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

Tuning NROFiller.
Filler is about 6 times faster than before (~660sec->~110sec).

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