[805] | 1 | //
|
---|
| 2 | // C++ Implementation: STFiller
|
---|
| 3 | //
|
---|
| 4 | // Description:
|
---|
| 5 | //
|
---|
| 6 | //
|
---|
[1410] | 7 | // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006-2007
|
---|
[805] | 8 | //
|
---|
| 9 | // Copyright: See COPYING file that comes with this distribution
|
---|
| 10 | //
|
---|
| 11 | //
|
---|
[404] | 12 | #include <casa/iostream.h>
|
---|
| 13 | #include <casa/iomanip.h>
|
---|
| 14 |
|
---|
[125] | 15 | #include <casa/Exceptions.h>
|
---|
[284] | 16 | #include <casa/OS/Path.h>
|
---|
[290] | 17 | #include <casa/OS/File.h>
|
---|
[338] | 18 | #include <casa/Quanta/Unit.h>
|
---|
[805] | 19 | #include <casa/Arrays/ArrayMath.h>
|
---|
[1060] | 20 | #include <casa/Arrays/ArrayLogical.h>
|
---|
[805] | 21 | #include <casa/Utilities/Regex.h>
|
---|
| 22 |
|
---|
| 23 | #include <casa/Containers/RecordField.h>
|
---|
| 24 |
|
---|
| 25 | #include <tables/Tables/TableRow.h>
|
---|
| 26 |
|
---|
[1789] | 27 | #include <measures/Measures/MDirection.h>
|
---|
| 28 | #include <measures/Measures/MeasConvert.h>
|
---|
| 29 |
|
---|
[1450] | 30 | #include <atnf/PKSIO/PKSrecord.h>
|
---|
[2] | 31 | #include <atnf/PKSIO/PKSreader.h>
|
---|
[1438] | 32 | #ifdef HAS_ALMA
|
---|
| 33 | #include <casa/System/ProgressMeter.h>
|
---|
| 34 | #endif
|
---|
[1789] | 35 | #include <casa/System/ProgressMeter.h>
|
---|
| 36 | #include <atnf/PKSIO/NROReader.h>
|
---|
| 37 | #include <casa/Logging/LogIO.h>
|
---|
[125] | 38 |
|
---|
[1789] | 39 | #include <time.h>
|
---|
| 40 |
|
---|
| 41 |
|
---|
[835] | 42 | #include "STDefs.h"
|
---|
[878] | 43 | #include "STAttr.h"
|
---|
[2] | 44 |
|
---|
[805] | 45 | #include "STFiller.h"
|
---|
[901] | 46 | #include "STHeader.h"
|
---|
[805] | 47 |
|
---|
[125] | 48 | using namespace casa;
|
---|
[2] | 49 |
|
---|
[805] | 50 | namespace asap {
|
---|
| 51 |
|
---|
| 52 | STFiller::STFiller() :
|
---|
[2] | 53 | reader_(0),
|
---|
[405] | 54 | header_(0),
|
---|
[1504] | 55 | table_(0),
|
---|
[1789] | 56 | refRx_(".*(e|w|_R)$"),
|
---|
| 57 | nreader_(0)
|
---|
[420] | 58 | {
|
---|
[2] | 59 | }
|
---|
[805] | 60 |
|
---|
| 61 | STFiller::STFiller( CountedPtr< Scantable > stbl ) :
|
---|
[46] | 62 | reader_(0),
|
---|
[405] | 63 | header_(0),
|
---|
[1504] | 64 | table_(stbl),
|
---|
[1789] | 65 | refRx_(".*(e|w|_R)$"),
|
---|
| 66 | nreader_(0)
|
---|
[420] | 67 | {
|
---|
[46] | 68 | }
|
---|
[2] | 69 |
|
---|
[855] | 70 | STFiller::STFiller(const std::string& filename, int whichIF, int whichBeam ) :
|
---|
[2] | 71 | reader_(0),
|
---|
[405] | 72 | header_(0),
|
---|
[1504] | 73 | table_(0),
|
---|
[1789] | 74 | refRx_(".*(e|w|_R)$"),
|
---|
| 75 | nreader_(0)
|
---|
[420] | 76 | {
|
---|
[1789] | 77 | open(filename, "", whichIF, whichBeam);
|
---|
[2] | 78 | }
|
---|
| 79 |
|
---|
[805] | 80 | STFiller::~STFiller()
|
---|
| 81 | {
|
---|
| 82 | close();
|
---|
[2] | 83 | }
|
---|
[1789] | 84 |
|
---|
| 85 | void STFiller::open( const std::string& filename, const std::string& antenna, int whichIF, int whichBeam, casa::Bool getPt )
|
---|
[805] | 86 | {
|
---|
[846] | 87 | if (table_.null()) {
|
---|
| 88 | table_ = new Scantable();
|
---|
| 89 | }
|
---|
[805] | 90 | if (reader_) { delete reader_; reader_ = 0; }
|
---|
| 91 | Bool haveBase, haveSpectra;
|
---|
[2] | 92 |
|
---|
| 93 | String inName(filename);
|
---|
[284] | 94 | Path path(inName);
|
---|
| 95 | inName = path.expandedName();
|
---|
[405] | 96 |
|
---|
[290] | 97 | File file(inName);
|
---|
[805] | 98 | if ( !file.exists() ) {
|
---|
[290] | 99 | throw(AipsError("File does not exist"));
|
---|
| 100 | }
|
---|
[87] | 101 | filename_ = inName;
|
---|
[332] | 102 |
|
---|
[405] | 103 | // Create reader and fill in values for arguments
|
---|
[2] | 104 | String format;
|
---|
[1060] | 105 | Vector<Bool> beams, ifs;
|
---|
| 106 | Vector<uInt> nchans,npols;
|
---|
[1789] | 107 |
|
---|
| 108 | //
|
---|
| 109 | // if isNRO_ is true, try NROReader
|
---|
| 110 | //
|
---|
| 111 | // 2008/11/11 Takeshi Nakazato
|
---|
| 112 | isNRO_ = fileCheck() ;
|
---|
| 113 | if ( isNRO_ ) {
|
---|
| 114 | if ( (nreader_ = getNROReader( inName, format )) == 0 ) {
|
---|
| 115 | throw(AipsError("Creation of NROReader failed")) ;
|
---|
| 116 | }
|
---|
| 117 | else {
|
---|
| 118 | openNRO( whichIF, whichBeam ) ;
|
---|
| 119 | return ;
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 | //
|
---|
| 123 |
|
---|
| 124 | if ( (reader_ = getPKSreader(inName, antenna, 0, 0, format, beams, ifs,
|
---|
[1060] | 125 | nchans, npols, haveXPol_,haveBase, haveSpectra
|
---|
| 126 | )) == 0 ) {
|
---|
[405] | 127 | throw(AipsError("Creation of PKSreader failed"));
|
---|
[2] | 128 | }
|
---|
| 129 | if (!haveSpectra) {
|
---|
| 130 | delete reader_;
|
---|
| 131 | reader_ = 0;
|
---|
[87] | 132 | throw(AipsError("No spectral data in file."));
|
---|
[2] | 133 | return;
|
---|
| 134 | }
|
---|
| 135 | nBeam_ = beams.nelements();
|
---|
[1060] | 136 | nIF_ = ifs.nelements();
|
---|
[2] | 137 | // Get basic parameters.
|
---|
[1060] | 138 | if ( anyEQ(haveXPol_, True) ) {
|
---|
[717] | 139 | pushLog("Cross polarization present");
|
---|
[1060] | 140 | for (uInt i=0; i< npols.nelements();++i) {
|
---|
| 141 | if (npols[i] < 3) npols[i] += 2;// Convert Complex -> 2 Floats
|
---|
| 142 | }
|
---|
[110] | 143 | }
|
---|
[405] | 144 | if (header_) delete header_;
|
---|
[901] | 145 | header_ = new STHeader();
|
---|
[1060] | 146 | header_->nchan = max(nchans);
|
---|
| 147 | header_->npol = max(npols);
|
---|
[405] | 148 | header_->nbeam = nBeam_;
|
---|
[1789] | 149 |
|
---|
[405] | 150 | Int status = reader_->getHeader(header_->observer, header_->project,
|
---|
| 151 | header_->antennaname, header_->antennaposition,
|
---|
[1410] | 152 | header_->obstype,
|
---|
| 153 | header_->fluxunit,
|
---|
| 154 | header_->equinox,
|
---|
[405] | 155 | header_->freqref,
|
---|
| 156 | header_->utc, header_->reffreq,
|
---|
| 157 | header_->bandwidth);
|
---|
| 158 |
|
---|
[2] | 159 | if (status) {
|
---|
| 160 | delete reader_;
|
---|
| 161 | reader_ = 0;
|
---|
[805] | 162 | delete header_;
|
---|
| 163 | header_ = 0;
|
---|
[87] | 164 | throw(AipsError("Failed to get header."));
|
---|
[2] | 165 | }
|
---|
[405] | 166 | if ((header_->obstype).matches("*SW*")) {
|
---|
[2] | 167 | // need robust way here - probably read ahead of next timestamp
|
---|
[717] | 168 | pushLog("Header indicates frequency switched observation.\n"
|
---|
[754] | 169 | "setting # of IFs = 1 ");
|
---|
[2] | 170 | nIF_ = 1;
|
---|
[805] | 171 | header_->obstype = String("fswitch");
|
---|
[2] | 172 | }
|
---|
[405] | 173 | // Determine Telescope and set brightness unit
|
---|
[342] | 174 |
|
---|
[1391] | 175 |
|
---|
[342] | 176 | Bool throwIt = False;
|
---|
[878] | 177 | Instrument inst = STAttr::convertInstrument(header_->antennaname, throwIt);
|
---|
[1410] | 178 |
|
---|
[342] | 179 | if (inst==ATMOPRA || inst==TIDBINBILLA) {
|
---|
[1410] | 180 | header_->fluxunit = "K";
|
---|
| 181 | } else {
|
---|
| 182 | // downcase for use with Quanta
|
---|
| 183 | if (header_->fluxunit == "JY") {
|
---|
| 184 | header_->fluxunit = "Jy";
|
---|
| 185 | }
|
---|
[342] | 186 | }
|
---|
[1188] | 187 | STAttr stattr;
|
---|
| 188 | header_->poltype = stattr.feedPolType(inst);
|
---|
[405] | 189 | header_->nif = nIF_;
|
---|
| 190 | header_->epoch = "UTC";
|
---|
[805] | 191 | // *** header_->frequnit = "Hz"
|
---|
[2] | 192 | // Apply selection criteria.
|
---|
| 193 | Vector<Int> ref;
|
---|
[332] | 194 | ifOffset_ = 0;
|
---|
| 195 | if (whichIF>=0) {
|
---|
| 196 | if (whichIF>=0 && whichIF<nIF_) {
|
---|
[1060] | 197 | ifs = False;
|
---|
| 198 | ifs(whichIF) = True;
|
---|
[805] | 199 | header_->nif = 1;
|
---|
| 200 | nIF_ = 1;
|
---|
| 201 | ifOffset_ = whichIF;
|
---|
[332] | 202 | } else {
|
---|
[805] | 203 | delete reader_;
|
---|
| 204 | reader_ = 0;
|
---|
| 205 | delete header_;
|
---|
| 206 | header_ = 0;
|
---|
| 207 | throw(AipsError("Illegal IF selection"));
|
---|
[332] | 208 | }
|
---|
| 209 | }
|
---|
| 210 | beamOffset_ = 0;
|
---|
| 211 | if (whichBeam>=0) {
|
---|
[805] | 212 | if (whichBeam>=0 && whichBeam<nBeam_) {
|
---|
[1060] | 213 | beams = False;
|
---|
| 214 | beams(whichBeam) = True;
|
---|
[805] | 215 | header_->nbeam = 1;
|
---|
| 216 | nBeam_ = 1;
|
---|
| 217 | beamOffset_ = whichBeam;
|
---|
| 218 | } else {
|
---|
| 219 | delete reader_;
|
---|
| 220 | reader_ = 0;
|
---|
| 221 | delete header_;
|
---|
| 222 | header_ = 0;
|
---|
| 223 | throw(AipsError("Illegal Beam selection"));
|
---|
| 224 | }
|
---|
[332] | 225 | }
|
---|
| 226 | Vector<Int> start(nIF_, 1);
|
---|
| 227 | Vector<Int> end(nIF_, 0);
|
---|
[1789] | 228 | reader_->select(beams, ifs, start, end, ref, True, haveXPol_[0], False, getPt);
|
---|
[846] | 229 | table_->setHeader(*header_);
|
---|
[1391] | 230 | //For MS, add the location of POINTING of the input MS so one get
|
---|
| 231 | //pointing data from there, if necessary.
|
---|
| 232 | //Also find nrow in MS
|
---|
| 233 | nInDataRow = 0;
|
---|
| 234 | if (format == "MS2") {
|
---|
| 235 | Path datapath(inName);
|
---|
| 236 | String ptTabPath = datapath.absoluteName();
|
---|
| 237 | Table inMS(ptTabPath);
|
---|
| 238 | nInDataRow = inMS.nrow();
|
---|
| 239 | ptTabPath.append("/POINTING");
|
---|
| 240 | table_->table().rwKeywordSet().define("POINTING", ptTabPath);
|
---|
| 241 | if ((header_->antennaname).matches("GBT")) {
|
---|
| 242 | String GOTabPath = datapath.absoluteName();
|
---|
| 243 | GOTabPath.append("/GBT_GO");
|
---|
| 244 | table_->table().rwKeywordSet().define("GBT_GO", GOTabPath);
|
---|
| 245 | }
|
---|
| 246 | }
|
---|
[1789] | 247 | String freqFrame = header_->freqref;
|
---|
| 248 | //translate frequency reference frame back to
|
---|
| 249 | //MS style (as PKSMS2reader converts the original frame
|
---|
| 250 | //in FITS standard style)
|
---|
| 251 | if (freqFrame == "TOPOCENT") {
|
---|
| 252 | freqFrame = "TOPO";
|
---|
| 253 | } else if (freqFrame == "GEOCENER") {
|
---|
| 254 | freqFrame = "GEO";
|
---|
| 255 | } else if (freqFrame == "BARYCENT") {
|
---|
| 256 | freqFrame = "BARY";
|
---|
| 257 | } else if (freqFrame == "GALACTOC") {
|
---|
| 258 | freqFrame = "GALACTO";
|
---|
| 259 | } else if (freqFrame == "LOCALGRP") {
|
---|
| 260 | freqFrame = "LGROUP";
|
---|
| 261 | } else if (freqFrame == "CMBDIPOL") {
|
---|
| 262 | freqFrame = "CMB";
|
---|
| 263 | } else if (freqFrame == "SOURCE") {
|
---|
| 264 | freqFrame = "REST";
|
---|
| 265 | }
|
---|
| 266 | // set both "FRAME" and "BASEFRAME"
|
---|
| 267 | table_->frequencies().setFrame(freqFrame, false);
|
---|
| 268 | table_->frequencies().setFrame(freqFrame,true);
|
---|
[1586] | 269 | //table_->focus().setParallactify(true);
|
---|
[805] | 270 | }
|
---|
[405] | 271 |
|
---|
[805] | 272 | void STFiller::close( )
|
---|
| 273 | {
|
---|
| 274 | delete reader_;reader_=0;
|
---|
[1789] | 275 | delete nreader_;nreader_=0;
|
---|
[805] | 276 | delete header_;header_=0;
|
---|
| 277 | table_ = 0;
|
---|
[2] | 278 | }
|
---|
| 279 |
|
---|
[805] | 280 | int asap::STFiller::read( )
|
---|
| 281 | {
|
---|
[87] | 282 | int status = 0;
|
---|
| 283 |
|
---|
[1789] | 284 | //
|
---|
| 285 | // for NRO data
|
---|
| 286 | //
|
---|
| 287 | // 2008/11/12 Takeshi Nakazato
|
---|
| 288 | if ( isNRO_ ) {
|
---|
| 289 | status = readNRO() ;
|
---|
| 290 | return status ;
|
---|
| 291 | }
|
---|
| 292 | //
|
---|
| 293 |
|
---|
| 294 | /**
|
---|
| 295 | Int beamNo, IFno, refBeam, scanNo, cycleNo;
|
---|
| 296 | Float azimuth, elevation, focusAxi, focusRot, focusTan,
|
---|
| 297 | humidity, parAngle, pressure, temperature, windAz, windSpeed;
|
---|
| 298 | Double bandwidth, freqInc, interval, mjd, refFreq, srcVel;
|
---|
| 299 | String fieldName, srcName, tcalTime, obsType;
|
---|
| 300 | Vector<Float> calFctr, sigma, tcal, tsys;
|
---|
| 301 | Matrix<Float> baseLin, baseSub;
|
---|
| 302 | Vector<Double> direction(2), scanRate(2), srcDir(2), srcPM(2), restFreq(1);
|
---|
| 303 | Matrix<Float> spectra;
|
---|
| 304 | Matrix<uChar> flagtra;
|
---|
| 305 | Complex xCalFctr;
|
---|
| 306 | Vector<Complex> xPol;
|
---|
| 307 | **/
|
---|
| 308 |
|
---|
[1391] | 309 | Double min = 0.0;
|
---|
| 310 | Double max = nInDataRow;
|
---|
[1438] | 311 | #ifdef HAS_ALMA
|
---|
| 312 | ProgressMeter fillpm(min, max, "Data importing progress");
|
---|
| 313 | #endif
|
---|
[1450] | 314 | PKSrecord pksrec;
|
---|
[1789] | 315 | pksrec.srcType=-1;
|
---|
[1391] | 316 | int n = 0;
|
---|
[1789] | 317 | bool isGBTFITS = false ;
|
---|
| 318 | if ((header_->antennaname.find( "GBT" ) != String::npos) && File(filename_).isRegular()) {
|
---|
| 319 | FILE *fp = fopen( filename_.c_str(), "r" ) ;
|
---|
| 320 | fseek( fp, 640, SEEK_SET ) ;
|
---|
| 321 | char buf[81] ;
|
---|
| 322 | fread( buf, 80, 1, fp ) ;
|
---|
| 323 | buf[80] = '\0' ;
|
---|
| 324 | if ( strstr( buf, "NRAO_GBT" ) != NULL ) {
|
---|
| 325 | isGBTFITS = true ;
|
---|
| 326 | }
|
---|
| 327 | fclose( fp ) ;
|
---|
| 328 | }
|
---|
[805] | 329 | while ( status == 0 ) {
|
---|
[1450] | 330 | status = reader_->read(pksrec);
|
---|
[805] | 331 | if ( status != 0 ) break;
|
---|
[1391] | 332 | n += 1;
|
---|
[1081] | 333 | Regex filterrx(".*[SL|PA]$");
|
---|
[1110] | 334 | Regex obsrx("^AT.+");
|
---|
[1450] | 335 | if ( header_->antennaname.matches(obsrx) &&
|
---|
| 336 | pksrec.obsType.matches(filterrx)) {
|
---|
[1110] | 337 | //cerr << "ignoring paddle scan" << endl;
|
---|
[1081] | 338 | continue;
|
---|
| 339 | }
|
---|
[805] | 340 | TableRow row(table_->table());
|
---|
| 341 | TableRecord& rec = row.record();
|
---|
[999] | 342 | // fields that don't get used and are just passed through asap
|
---|
| 343 | RecordFieldPtr<Array<Double> > srateCol(rec, "SCANRATE");
|
---|
[1462] | 344 | // MRC changed type from double to float
|
---|
[1467] | 345 | Vector<Double> sratedbl(pksrec.scanRate.nelements());
|
---|
[1462] | 346 | convertArray(sratedbl, pksrec.scanRate);
|
---|
| 347 | *srateCol = sratedbl;
|
---|
[999] | 348 | RecordFieldPtr<Array<Double> > spmCol(rec, "SRCPROPERMOTION");
|
---|
[1450] | 349 | *spmCol = pksrec.srcPM;
|
---|
[999] | 350 | RecordFieldPtr<Array<Double> > sdirCol(rec, "SRCDIRECTION");
|
---|
[1450] | 351 | *sdirCol = pksrec.srcDir;
|
---|
[999] | 352 | RecordFieldPtr<Double> svelCol(rec, "SRCVELOCITY");
|
---|
[1450] | 353 | *svelCol = pksrec.srcVel;
|
---|
[999] | 354 | // the real stuff
|
---|
[972] | 355 | RecordFieldPtr<Int> fitCol(rec, "FIT_ID");
|
---|
| 356 | *fitCol = -1;
|
---|
[805] | 357 | RecordFieldPtr<uInt> scanoCol(rec, "SCANNO");
|
---|
[1450] | 358 | *scanoCol = pksrec.scanNo-1;
|
---|
[805] | 359 | RecordFieldPtr<uInt> cyclenoCol(rec, "CYCLENO");
|
---|
[1450] | 360 | *cyclenoCol = pksrec.cycleNo-1;
|
---|
[805] | 361 | RecordFieldPtr<Double> mjdCol(rec, "TIME");
|
---|
[1450] | 362 | *mjdCol = pksrec.mjd;
|
---|
[805] | 363 | RecordFieldPtr<Double> intCol(rec, "INTERVAL");
|
---|
[1450] | 364 | *intCol = pksrec.interval;
|
---|
[805] | 365 | RecordFieldPtr<String> srcnCol(rec, "SRCNAME");
|
---|
| 366 | RecordFieldPtr<Int> srctCol(rec, "SRCTYPE");
|
---|
[1391] | 367 | RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME");
|
---|
[1450] | 368 | *fieldnCol = pksrec.fieldName;
|
---|
[805] | 369 | // try to auto-identify if it is on or off.
|
---|
[1504] | 370 | Regex rx(refRx_);
|
---|
[942] | 371 | Regex rx2("_S$");
|
---|
[1450] | 372 | Int match = pksrec.srcName.matches(rx);
|
---|
[805] | 373 | if (match) {
|
---|
[1450] | 374 | *srcnCol = pksrec.srcName;
|
---|
[805] | 375 | } else {
|
---|
[1450] | 376 | *srcnCol = pksrec.srcName.before(rx2);
|
---|
[805] | 377 | }
|
---|
[1450] | 378 | //*srcnCol = pksrec.srcName;//.before(rx2);
|
---|
[805] | 379 | *srctCol = match;
|
---|
[1789] | 380 | if ( pksrec.srcType != -1 ) {
|
---|
| 381 | *srctCol = pksrec.srcType ;
|
---|
| 382 | }
|
---|
[805] | 383 | RecordFieldPtr<uInt> beamCol(rec, "BEAMNO");
|
---|
[1450] | 384 | *beamCol = pksrec.beamNo-beamOffset_-1;
|
---|
[805] | 385 | RecordFieldPtr<Int> rbCol(rec, "REFBEAMNO");
|
---|
| 386 | Int rb = -1;
|
---|
[1450] | 387 | if (nBeam_ > 1 ) rb = pksrec.refBeam-1;
|
---|
[805] | 388 | *rbCol = rb;
|
---|
| 389 | RecordFieldPtr<uInt> ifCol(rec, "IFNO");
|
---|
[1450] | 390 | *ifCol = pksrec.IFno-ifOffset_- 1;
|
---|
[805] | 391 | uInt id;
|
---|
| 392 | /// @todo this has to change when nchan isn't global anymore
|
---|
[1789] | 393 | //id = table_->frequencies().addEntry(Double(header_->nchan/2),
|
---|
| 394 | // pksrec.refFreq, pksrec.freqInc);
|
---|
| 395 | if ( pksrec.nchan == 1 ) {
|
---|
| 396 | id = table_->frequencies().addEntry(Double(0),
|
---|
| 397 | pksrec.refFreq, pksrec.freqInc);
|
---|
| 398 | }
|
---|
| 399 | else {
|
---|
| 400 | id = table_->frequencies().addEntry(Double(pksrec.nchan/2),
|
---|
| 401 | pksrec.refFreq, pksrec.freqInc);
|
---|
| 402 | }
|
---|
[805] | 403 | RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID");
|
---|
| 404 | *mfreqidCol = id;
|
---|
[1789] | 405 | //*ifCol = id;
|
---|
[25] | 406 |
|
---|
[1450] | 407 | id = table_->molecules().addEntry(pksrec.restFreq);
|
---|
[805] | 408 | RecordFieldPtr<uInt> molidCol(rec, "MOLECULE_ID");
|
---|
| 409 | *molidCol = id;
|
---|
[414] | 410 |
|
---|
[1450] | 411 | id = table_->tcal().addEntry(pksrec.tcalTime, pksrec.tcal);
|
---|
[805] | 412 | RecordFieldPtr<uInt> mcalidCol(rec, "TCAL_ID");
|
---|
| 413 | *mcalidCol = id;
|
---|
[1450] | 414 | id = table_->weather().addEntry(pksrec.temperature, pksrec.pressure,
|
---|
| 415 | pksrec.humidity, pksrec.windSpeed,
|
---|
| 416 | pksrec.windAz);
|
---|
[805] | 417 | RecordFieldPtr<uInt> mweatheridCol(rec, "WEATHER_ID");
|
---|
| 418 | *mweatheridCol = id;
|
---|
[1586] | 419 |
|
---|
[805] | 420 | RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID");
|
---|
[1586] | 421 | id = table_->focus().addEntry(pksrec.parAngle, pksrec.focusAxi,
|
---|
| 422 | pksrec.focusTan, pksrec.focusRot);
|
---|
[805] | 423 | *mfocusidCol = id;
|
---|
| 424 | RecordFieldPtr<Array<Double> > dirCol(rec, "DIRECTION");
|
---|
[1450] | 425 | *dirCol = pksrec.direction;
|
---|
[922] | 426 | RecordFieldPtr<Float> azCol(rec, "AZIMUTH");
|
---|
[1450] | 427 | *azCol = pksrec.azimuth;
|
---|
[922] | 428 | RecordFieldPtr<Float> elCol(rec, "ELEVATION");
|
---|
[1450] | 429 | *elCol = pksrec.elevation;
|
---|
[405] | 430 |
|
---|
[805] | 431 | RecordFieldPtr< Array<Float> > specCol(rec, "SPECTRA");
|
---|
| 432 | RecordFieldPtr< Array<uChar> > flagCol(rec, "FLAGTRA");
|
---|
| 433 | RecordFieldPtr< uInt > polnoCol(rec, "POLNO");
|
---|
[405] | 434 |
|
---|
[805] | 435 | RecordFieldPtr< Array<Float> > tsysCol(rec, "TSYS");
|
---|
| 436 | // Turn the (nchan,npol) matrix and possible complex xPol vector
|
---|
| 437 | // into 2-4 rows in the scantable
|
---|
| 438 | Vector<Float> tsysvec(1);
|
---|
[1789] | 439 | // Why is spectra.ncolumn() == 3 for haveXPol_ == True
|
---|
[1450] | 440 | uInt npol = (pksrec.spectra.ncolumn()==1 ? 1: 2);
|
---|
[805] | 441 | for ( uInt i=0; i< npol; ++i ) {
|
---|
[1450] | 442 | tsysvec = pksrec.tsys(i);
|
---|
[805] | 443 | *tsysCol = tsysvec;
|
---|
[1789] | 444 | if (isGBTFITS)
|
---|
| 445 | *polnoCol = pksrec.polNo ;
|
---|
| 446 | else
|
---|
| 447 | *polnoCol = i;
|
---|
[405] | 448 |
|
---|
[1450] | 449 | *specCol = pksrec.spectra.column(i);
|
---|
[1462] | 450 | *flagCol = pksrec.flagged.column(i);
|
---|
[805] | 451 | table_->table().addRow();
|
---|
| 452 | row.put(table_->table().nrow()-1, rec);
|
---|
[2] | 453 | }
|
---|
[1789] | 454 |
|
---|
| 455 | RecordFieldPtr< uInt > flagrowCol(rec, "FLAGROW");
|
---|
| 456 | *flagrowCol = pksrec.flagrow;
|
---|
| 457 |
|
---|
[1060] | 458 | if ( haveXPol_[0] ) {
|
---|
[805] | 459 | // no tsys given for xpol, so emulate it
|
---|
[1450] | 460 | tsysvec = sqrt(pksrec.tsys[0]*pksrec.tsys[1]);
|
---|
[805] | 461 | *tsysCol = tsysvec;
|
---|
| 462 | // add real part of cross pol
|
---|
| 463 | *polnoCol = 2;
|
---|
[1450] | 464 | Vector<Float> r(real(pksrec.xPol));
|
---|
[805] | 465 | *specCol = r;
|
---|
| 466 | // make up flags from linears
|
---|
| 467 | /// @fixme this has to be a bitwise or of both pols
|
---|
[1462] | 468 | *flagCol = pksrec.flagged.column(0);// | pksrec.flagged.column(1);
|
---|
[805] | 469 | table_->table().addRow();
|
---|
| 470 | row.put(table_->table().nrow()-1, rec);
|
---|
| 471 | // ad imaginary part of cross pol
|
---|
| 472 | *polnoCol = 3;
|
---|
[1450] | 473 | Vector<Float> im(imag(pksrec.xPol));
|
---|
[805] | 474 | *specCol = im;
|
---|
| 475 | table_->table().addRow();
|
---|
| 476 | row.put(table_->table().nrow()-1, rec);
|
---|
[2] | 477 | }
|
---|
[1438] | 478 | #ifdef HAS_ALMA
|
---|
| 479 | fillpm._update(n);
|
---|
| 480 | #endif
|
---|
[805] | 481 | }
|
---|
| 482 | if (status > 0) {
|
---|
| 483 | close();
|
---|
| 484 | throw(AipsError("Reading error occured, data possibly corrupted."));
|
---|
| 485 | }
|
---|
[1438] | 486 | #ifdef HAS_ALMA
|
---|
| 487 | fillpm.done();
|
---|
| 488 | #endif
|
---|
[2] | 489 | return status;
|
---|
| 490 | }
|
---|
[805] | 491 |
|
---|
[1789] | 492 | /**
|
---|
| 493 | * For NRO data
|
---|
| 494 | *
|
---|
| 495 | * 2008/11/11 Takeshi Nakazato
|
---|
| 496 | **/
|
---|
| 497 | void STFiller::openNRO( int whichIF, int whichBeam )
|
---|
| 498 | {
|
---|
| 499 | // open file
|
---|
| 500 | // DEBUG
|
---|
| 501 | time_t t0 ;
|
---|
| 502 | time( &t0 ) ;
|
---|
| 503 | tm *ttm = localtime( &t0 ) ;
|
---|
| 504 | LogIO os( LogOrigin( "STFiller", "openNRO()", WHERE ) ) ;
|
---|
| 505 | // cout << "STFiller::openNRO() Start time = " << t0
|
---|
| 506 | // << " ("
|
---|
| 507 | // << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
|
---|
| 508 | // << " "
|
---|
| 509 | // << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
|
---|
| 510 | // << ")" << endl ;
|
---|
| 511 | os << "Start time = " << t0
|
---|
| 512 | << " ("
|
---|
| 513 | << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
|
---|
| 514 | << " "
|
---|
| 515 | << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
|
---|
| 516 | << ")" << LogIO::POST ;
|
---|
| 517 |
|
---|
| 518 | // fill STHeader
|
---|
| 519 | header_ = new STHeader() ;
|
---|
| 520 |
|
---|
| 521 | if ( nreader_->getHeaderInfo( header_->nchan,
|
---|
| 522 | header_->npol,
|
---|
| 523 | nIF_,
|
---|
| 524 | nBeam_,
|
---|
| 525 | header_->observer,
|
---|
| 526 | header_->project,
|
---|
| 527 | header_->obstype,
|
---|
| 528 | header_->antennaname,
|
---|
| 529 | header_->antennaposition,
|
---|
| 530 | header_->equinox,
|
---|
| 531 | header_->freqref,
|
---|
| 532 | header_->reffreq,
|
---|
| 533 | header_->bandwidth,
|
---|
| 534 | header_->utc,
|
---|
| 535 | header_->fluxunit,
|
---|
| 536 | header_->epoch,
|
---|
| 537 | header_->poltype ) ) {
|
---|
| 538 | // cout << "STFiller::openNRO() Failed to get header information." << endl ;
|
---|
| 539 | // return ;
|
---|
| 540 | throw( AipsError("Failed to get header information.") ) ;
|
---|
| 541 | }
|
---|
| 542 |
|
---|
| 543 | // set FRAME and BASEFRAME keyword of FREQUENCIES table
|
---|
| 544 | if ( header_->freqref != "TOPO" ) {
|
---|
| 545 | table_->frequencies().setFrame( header_->freqref, false ) ;
|
---|
| 546 | table_->frequencies().setFrame( header_->freqref, true ) ;
|
---|
| 547 | }
|
---|
| 548 |
|
---|
| 549 | ifOffset_ = 0;
|
---|
| 550 | vector<Bool> ifs = nreader_->getIFs() ;
|
---|
| 551 | if ( whichIF >= 0 ) {
|
---|
| 552 | if ( whichIF >= 0 && whichIF < nIF_ ) {
|
---|
| 553 | for ( int i = 0 ; i < nIF_ ; i++ )
|
---|
| 554 | ifs[i] = False ;
|
---|
| 555 | ifs[whichIF] = True ;
|
---|
| 556 | header_->nif = 1;
|
---|
| 557 | nIF_ = 1;
|
---|
| 558 | ifOffset_ = whichIF;
|
---|
| 559 | } else {
|
---|
| 560 | delete reader_;
|
---|
| 561 | reader_ = 0;
|
---|
| 562 | delete header_;
|
---|
| 563 | header_ = 0;
|
---|
| 564 | throw(AipsError("Illegal IF selection"));
|
---|
| 565 | }
|
---|
| 566 | }
|
---|
| 567 |
|
---|
| 568 | beamOffset_ = 0;
|
---|
| 569 | vector<Bool> beams = nreader_->getBeams() ;
|
---|
| 570 | if (whichBeam>=0) {
|
---|
| 571 | if (whichBeam>=0 && whichBeam<nBeam_) {
|
---|
| 572 | for ( int i = 0 ; i < nBeam_ ; i++ )
|
---|
| 573 | beams[i] = False ;
|
---|
| 574 | beams[whichBeam] = True;
|
---|
| 575 | header_->nbeam = 1;
|
---|
| 576 | nBeam_ = 1;
|
---|
| 577 | beamOffset_ = whichBeam;
|
---|
| 578 | } else {
|
---|
| 579 | delete reader_;
|
---|
| 580 | reader_ = 0;
|
---|
| 581 | delete header_;
|
---|
| 582 | header_ = 0;
|
---|
| 583 | throw(AipsError("Illegal Beam selection"));
|
---|
| 584 | }
|
---|
| 585 | }
|
---|
| 586 |
|
---|
| 587 | header_->nbeam = nBeam_ ;
|
---|
| 588 | header_->nif = nIF_ ;
|
---|
| 589 |
|
---|
| 590 | // set header
|
---|
| 591 | table_->setHeader( *header_ ) ;
|
---|
| 592 |
|
---|
| 593 | // DEBUG
|
---|
| 594 | time_t t1 ;
|
---|
| 595 | time( &t1 ) ;
|
---|
| 596 | ttm = localtime( &t1 ) ;
|
---|
| 597 | // cout << "STFiller::openNRO() End time = " << t1
|
---|
| 598 | // << " ("
|
---|
| 599 | // << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
|
---|
| 600 | // << " "
|
---|
| 601 | // << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
|
---|
| 602 | // << ")" << endl ;
|
---|
| 603 | // cout << "STFiller::openNRO() Elapsed time = " << t1 - t0 << " sec" << endl ;
|
---|
| 604 | os << "End time = " << t1
|
---|
| 605 | << " ("
|
---|
| 606 | << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
|
---|
| 607 | << " "
|
---|
| 608 | << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
|
---|
| 609 | << ")" << endl ;
|
---|
| 610 | os << "Elapsed time = " << t1 - t0 << " sec" << endl ;
|
---|
| 611 | os.post() ;
|
---|
| 612 | //
|
---|
| 613 |
|
---|
| 614 | return ;
|
---|
| 615 | }
|
---|
| 616 |
|
---|
| 617 | int STFiller::readNRO()
|
---|
| 618 | {
|
---|
| 619 | // DEBUG
|
---|
| 620 | time_t t0 ;
|
---|
| 621 | time( &t0 ) ;
|
---|
| 622 | tm *ttm = localtime( &t0 ) ;
|
---|
| 623 | LogIO os( LogOrigin( "STFiller", "readNRO()", WHERE ) ) ;
|
---|
| 624 | // cout << "STFiller::readNRO() Start time = " << t0
|
---|
| 625 | // << " ("
|
---|
| 626 | // << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
|
---|
| 627 | // << " "
|
---|
| 628 | // << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
|
---|
| 629 | // << ")" << endl ;
|
---|
| 630 | os << "Start time = " << t0
|
---|
| 631 | << " ("
|
---|
| 632 | << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
|
---|
| 633 | << " "
|
---|
| 634 | << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
|
---|
| 635 | << ")" << LogIO::POST ;
|
---|
| 636 | //
|
---|
| 637 |
|
---|
| 638 | // fill row
|
---|
| 639 | uInt id ;
|
---|
| 640 | uInt imax = nreader_->getRowNum() ;
|
---|
| 641 | vector< vector<double > > freqs ;
|
---|
| 642 | uInt i = 0 ;
|
---|
| 643 | int count = 0 ;
|
---|
| 644 | uInt scanno ;
|
---|
| 645 | uInt cycleno ;
|
---|
| 646 | uInt beamno ;
|
---|
| 647 | uInt polno ;
|
---|
| 648 | vector<double> fqs ;
|
---|
| 649 | Vector<Double> restfreq ;
|
---|
| 650 | uInt refbeamno ;
|
---|
| 651 | Double scantime ;
|
---|
| 652 | Double interval ;
|
---|
| 653 | String srcname ;
|
---|
| 654 | String fieldname ;
|
---|
| 655 | Array<Float> spectra ;
|
---|
| 656 | Array<uChar> flagtra ;
|
---|
| 657 | Array<Float> tsys ;
|
---|
| 658 | Array<Double> direction ;
|
---|
| 659 | Float azimuth ;
|
---|
| 660 | Float elevation ;
|
---|
| 661 | Float parangle ;
|
---|
| 662 | Float opacity ;
|
---|
| 663 | uInt tcalid ;
|
---|
| 664 | Int fitid ;
|
---|
| 665 | uInt focusid ;
|
---|
| 666 | Float temperature ;
|
---|
| 667 | Float pressure ;
|
---|
| 668 | Float humidity ;
|
---|
| 669 | Float windvel ;
|
---|
| 670 | Float winddir ;
|
---|
| 671 | Double srcvel ;
|
---|
| 672 | Array<Double> propermotion ;
|
---|
| 673 | Vector<Double> srcdir ;
|
---|
| 674 | Array<Double> scanrate ;
|
---|
| 675 | for ( i = 0 ; i < imax ; i++ ) {
|
---|
| 676 | string scanType = nreader_->getScanType( i ) ;
|
---|
| 677 | Int srcType = -1 ;
|
---|
| 678 | if ( scanType.compare( 0, 2, "ON") == 0 ) {
|
---|
| 679 | // os << "ON srcType: " << i << LogIO::POST ;
|
---|
| 680 | srcType = 0 ;
|
---|
| 681 | }
|
---|
| 682 | else if ( scanType.compare( 0, 3, "OFF" ) == 0 ) {
|
---|
| 683 | //os << "OFF srcType: " << i << LogIO::POST ;
|
---|
| 684 | srcType = 1 ;
|
---|
| 685 | }
|
---|
| 686 | else if ( scanType.compare( 0, 4, "ZERO" ) == 0 ) {
|
---|
| 687 | //os << "ZERO srcType: " << i << LogIO::POST ;
|
---|
| 688 | srcType = 2 ;
|
---|
| 689 | }
|
---|
| 690 | else {
|
---|
| 691 | //os << "Undefined srcType: " << i << LogIO::POST ;
|
---|
| 692 | srcType = 3 ;
|
---|
| 693 | }
|
---|
| 694 |
|
---|
| 695 | // if srcType is 2 (ZERO scan), ignore scan
|
---|
| 696 | if ( srcType != 2 && srcType != -1 && srcType != 3 ) {
|
---|
| 697 | TableRow row( table_->table() ) ;
|
---|
| 698 | TableRecord& rec = row.record();
|
---|
| 699 |
|
---|
| 700 | if ( nreader_->getScanInfo( i,
|
---|
| 701 | scanno,
|
---|
| 702 | cycleno,
|
---|
| 703 | beamno,
|
---|
| 704 | polno,
|
---|
| 705 | fqs,
|
---|
| 706 | restfreq,
|
---|
| 707 | refbeamno,
|
---|
| 708 | scantime,
|
---|
| 709 | interval,
|
---|
| 710 | srcname,
|
---|
| 711 | fieldname,
|
---|
| 712 | spectra,
|
---|
| 713 | flagtra,
|
---|
| 714 | tsys,
|
---|
| 715 | direction,
|
---|
| 716 | azimuth,
|
---|
| 717 | elevation,
|
---|
| 718 | parangle,
|
---|
| 719 | opacity,
|
---|
| 720 | tcalid,
|
---|
| 721 | fitid,
|
---|
| 722 | focusid,
|
---|
| 723 | temperature,
|
---|
| 724 | pressure,
|
---|
| 725 | humidity,
|
---|
| 726 | windvel,
|
---|
| 727 | winddir,
|
---|
| 728 | srcvel,
|
---|
| 729 | propermotion,
|
---|
| 730 | srcdir,
|
---|
| 731 | scanrate ) ) {
|
---|
| 732 | // cerr << "STFiller::readNRO() Failed to get scan information." << endl ;
|
---|
| 733 | // return 1 ;
|
---|
| 734 | throw( AipsError("Failed to get scan information.") ) ;
|
---|
| 735 | }
|
---|
| 736 |
|
---|
| 737 | RecordFieldPtr<uInt> scannoCol( rec, "SCANNO" ) ;
|
---|
| 738 | *scannoCol = scanno ;
|
---|
| 739 | RecordFieldPtr<uInt> cyclenoCol(rec, "CYCLENO") ;
|
---|
| 740 | *cyclenoCol = cycleno ;
|
---|
| 741 | RecordFieldPtr<uInt> beamCol(rec, "BEAMNO") ;
|
---|
| 742 | *beamCol = beamno ;
|
---|
| 743 | RecordFieldPtr<uInt> ifCol(rec, "IFNO") ;
|
---|
| 744 | RecordFieldPtr< uInt > polnoCol(rec, "POLNO") ;
|
---|
| 745 | *polnoCol = polno ;
|
---|
| 746 | RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID") ;
|
---|
| 747 | if ( freqs.size() == 0 ) {
|
---|
| 748 | id = table_->frequencies().addEntry( Double( fqs[0] ),
|
---|
| 749 | Double( fqs[1] ),
|
---|
| 750 | Double( fqs[2] ) ) ;
|
---|
| 751 | *mfreqidCol = id ;
|
---|
| 752 | *ifCol = id ;
|
---|
| 753 | freqs.push_back( fqs ) ;
|
---|
| 754 | }
|
---|
| 755 | else {
|
---|
| 756 | int iadd = -1 ;
|
---|
| 757 | for ( uInt iif = 0 ; iif < freqs.size() ; iif++ ) {
|
---|
| 758 | //os << "freqs[" << iif << "][1] = " << freqs[iif][1] << LogIO::POST ;
|
---|
| 759 | double fdiff = abs( freqs[iif][1] - fqs[1] ) / freqs[iif][1] ;
|
---|
| 760 | //os << "fdiff = " << fdiff << LogIO::POST ;
|
---|
| 761 | if ( fdiff < 1.0e-8 ) {
|
---|
| 762 | iadd = iif ;
|
---|
| 763 | break ;
|
---|
| 764 | }
|
---|
| 765 | }
|
---|
| 766 | if ( iadd == -1 ) {
|
---|
| 767 | id = table_->frequencies().addEntry( Double( fqs[0] ),
|
---|
| 768 | Double( fqs[1] ),
|
---|
| 769 | Double( fqs[2] ) ) ;
|
---|
| 770 | *mfreqidCol = id ;
|
---|
| 771 | *ifCol = id ;
|
---|
| 772 | freqs.push_back( fqs ) ;
|
---|
| 773 | }
|
---|
| 774 | else {
|
---|
| 775 | *mfreqidCol = iadd ;
|
---|
| 776 | *ifCol = iadd ;
|
---|
| 777 | }
|
---|
| 778 | }
|
---|
| 779 | RecordFieldPtr<uInt> molidCol(rec, "MOLECULE_ID") ;
|
---|
| 780 | id = table_->molecules().addEntry( restfreq ) ;
|
---|
| 781 | *molidCol = id ;
|
---|
| 782 | RecordFieldPtr<Int> rbCol(rec, "REFBEAMNO") ;
|
---|
| 783 | *rbCol = refbeamno ;
|
---|
| 784 | RecordFieldPtr<Double> mjdCol( rec, "TIME" ) ;
|
---|
| 785 | *mjdCol = scantime ;
|
---|
| 786 | RecordFieldPtr<Double> intervalCol( rec, "INTERVAL" ) ;
|
---|
| 787 | *intervalCol = interval ;
|
---|
| 788 | RecordFieldPtr<String> srcnCol(rec, "SRCNAME") ;
|
---|
| 789 | *srcnCol = srcname ;
|
---|
| 790 | RecordFieldPtr<Int> srctCol(rec, "SRCTYPE") ;
|
---|
| 791 | *srctCol = srcType ;
|
---|
| 792 | RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME");
|
---|
| 793 | *fieldnCol = fieldname ;
|
---|
| 794 | RecordFieldPtr< Array<Float> > specCol(rec, "SPECTRA") ;
|
---|
| 795 | *specCol = spectra ;
|
---|
| 796 | RecordFieldPtr< Array<uChar> > flagCol(rec, "FLAGTRA") ;
|
---|
| 797 | *flagCol = flagtra ;
|
---|
| 798 | RecordFieldPtr< Array<Float> > tsysCol(rec, "TSYS") ;
|
---|
| 799 | *tsysCol = tsys ;
|
---|
| 800 | RecordFieldPtr< Array<Double> > dirCol(rec, "DIRECTION") ;
|
---|
| 801 | *dirCol = direction ;
|
---|
| 802 | RecordFieldPtr<Float> azCol(rec, "AZIMUTH") ;
|
---|
| 803 | *azCol = azimuth ;
|
---|
| 804 | RecordFieldPtr<Float> elCol(rec, "ELEVATION") ;
|
---|
| 805 | *elCol = elevation ;
|
---|
| 806 | RecordFieldPtr<Float> parCol(rec, "PARANGLE") ;
|
---|
| 807 | *parCol = parangle ;
|
---|
| 808 | RecordFieldPtr<Float> tauCol(rec, "OPACITY") ;
|
---|
| 809 | *tauCol = opacity ;
|
---|
| 810 | RecordFieldPtr<uInt> mcalidCol(rec, "TCAL_ID") ;
|
---|
| 811 | *mcalidCol = tcalid ;
|
---|
| 812 | RecordFieldPtr<Int> fitCol(rec, "FIT_ID") ;
|
---|
| 813 | *fitCol = fitid ;
|
---|
| 814 | RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID") ;
|
---|
| 815 | *mfocusidCol = focusid ;
|
---|
| 816 | RecordFieldPtr<uInt> mweatheridCol(rec, "WEATHER_ID") ;
|
---|
| 817 | id = table_->weather().addEntry( temperature,
|
---|
| 818 | pressure,
|
---|
| 819 | humidity,
|
---|
| 820 | windvel,
|
---|
| 821 | winddir ) ;
|
---|
| 822 | *mweatheridCol = id ;
|
---|
| 823 | RecordFieldPtr<Double> svelCol(rec, "SRCVELOCITY") ;
|
---|
| 824 | *svelCol = srcvel ;
|
---|
| 825 | RecordFieldPtr<Array<Double> > spmCol(rec, "SRCPROPERMOTION") ;
|
---|
| 826 | *spmCol = propermotion ;
|
---|
| 827 | RecordFieldPtr<Array<Double> > sdirCol(rec, "SRCDIRECTION") ;
|
---|
| 828 | *sdirCol = srcdir ;
|
---|
| 829 | RecordFieldPtr<Array<Double> > srateCol(rec, "SCANRATE");
|
---|
| 830 | *srateCol = scanrate ;
|
---|
| 831 |
|
---|
| 832 | table_->table().addRow() ;
|
---|
| 833 | row.put(table_->table().nrow()-1, rec) ;
|
---|
| 834 | }
|
---|
| 835 | else {
|
---|
| 836 | count++ ;
|
---|
| 837 | }
|
---|
| 838 | // DEBUG
|
---|
| 839 | //int rownum = nreader_->getRowNum() ;
|
---|
| 840 | //os << "Finished row " << i << "/" << rownum << LogIO::POST ;
|
---|
| 841 | //
|
---|
| 842 | }
|
---|
| 843 |
|
---|
| 844 | // DEBUG
|
---|
| 845 | time_t t1 ;
|
---|
| 846 | time( &t1 ) ;
|
---|
| 847 | ttm = localtime( &t1 ) ;
|
---|
| 848 | // cout << "STFiller::readNRO() Processed " << i << " rows" << endl ;
|
---|
| 849 | // cout << "STFiller::readNRO() Added " << i - count << " rows (ignored "
|
---|
| 850 | // << count << " \"ZERO\" scans)" << endl ;
|
---|
| 851 | // cout << "STFiller::readNRO() End time = " << t1
|
---|
| 852 | // << " ("
|
---|
| 853 | // << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
|
---|
| 854 | // << " "
|
---|
| 855 | // << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
|
---|
| 856 | // << ")" << endl ;
|
---|
| 857 | // cout << "STFiller::readNRO() Elapsed time = " << t1 - t0 << " sec" << endl ;
|
---|
| 858 | os << "Processed " << i << " rows" << endl ;
|
---|
| 859 | os << "Added " << i - count << " rows (ignored "
|
---|
| 860 | << count << " \"ZERO\" scans)" << endl ;
|
---|
| 861 | os.post() ;
|
---|
| 862 | os << "End time = " << t1
|
---|
| 863 | << " ("
|
---|
| 864 | << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
|
---|
| 865 | << " "
|
---|
| 866 | << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
|
---|
| 867 | << ")" << endl ;
|
---|
| 868 | os << "Elapsed time = " << t1 - t0 << " sec" << endl ;
|
---|
| 869 | os.post() ;
|
---|
| 870 | //
|
---|
| 871 |
|
---|
| 872 | return 0 ;
|
---|
| 873 | }
|
---|
| 874 |
|
---|
| 875 | Bool STFiller::fileCheck()
|
---|
| 876 | {
|
---|
| 877 | bool bval = false ;
|
---|
| 878 |
|
---|
| 879 | // if filename_ is directory, return false
|
---|
| 880 | File inFile( filename_ ) ;
|
---|
| 881 | if ( inFile.isDirectory() )
|
---|
| 882 | return bval ;
|
---|
| 883 |
|
---|
| 884 | // if beginning of header data is "RW", return true
|
---|
| 885 | // otherwise, return false ;
|
---|
| 886 | FILE *fp = fopen( filename_.c_str(), "r" ) ;
|
---|
| 887 | char buf[9] ;
|
---|
| 888 | char buf2[80] ;
|
---|
| 889 | fread( buf, 4, 1, fp ) ;
|
---|
| 890 | buf[4] = '\0' ;
|
---|
| 891 | fseek( fp, 640, SEEK_SET ) ;
|
---|
| 892 | fread( buf2, 80, 1, fp ) ;
|
---|
| 893 | if ( ( strncmp( buf, "RW", 2 ) == 0 ) || ( strstr( buf2, "NRO45M" ) != NULL ) ) {
|
---|
| 894 | bval = true ;
|
---|
| 895 | }
|
---|
| 896 | fclose( fp ) ;
|
---|
| 897 | return bval ;
|
---|
| 898 | }
|
---|
| 899 |
|
---|
[805] | 900 | }//namespace asap
|
---|