Changeset 1603 for branches/alma/src/STFiller.cpp
- Timestamp:
- 07/18/09 06:35:47 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/src/STFiller.cpp
r1533 r1603 5 5 // 6 6 // 7 // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006 7 // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006-2007 8 8 // 9 9 // Copyright: See COPYING file that comes with this distribution … … 28 28 #include <measures/Measures/MeasConvert.h> 29 29 30 #include <atnf/PKSIO/PKSrecord.h> 30 31 #include <atnf/PKSIO/PKSreader.h> 32 #ifdef HAS_ALMA 33 #include <casa/System/ProgressMeter.h> 34 #endif 31 35 #include <casa/System/ProgressMeter.h> 32 36 #include <atnf/PKSIO/NROReader.h> 33 37 34 38 #include <time.h> 39 35 40 36 41 #include "STDefs.h" … … 48 53 header_(0), 49 54 table_(0), 55 refRx_(".*(e|w|_R)$"), 50 56 nreader_(0) 51 57 { … … 56 62 header_(0), 57 63 table_(stbl), 64 refRx_(".*(e|w|_R)$"), 58 65 nreader_(0) 59 66 { … … 64 71 header_(0), 65 72 table_(0), 73 refRx_(".*(e|w|_R)$"), 66 74 nreader_(0) 67 75 { … … 141 149 Int status = reader_->getHeader(header_->observer, header_->project, 142 150 header_->antennaname, header_->antennaposition, 143 header_->obstype,header_->equinox, 151 header_->obstype, 152 header_->fluxunit, 153 header_->equinox, 144 154 header_->freqref, 145 155 header_->utc, header_->reffreq, 146 header_->bandwidth, 147 header_->fluxunit); 156 header_->bandwidth); 148 157 149 158 if (status) { … … 166 175 Bool throwIt = False; 167 176 Instrument inst = STAttr::convertInstrument(header_->antennaname, throwIt); 168 //header_->fluxunit = "Jy"; 177 169 178 if (inst==ATMOPRA || inst==TIDBINBILLA) { 170 header_->fluxunit = "K"; 179 header_->fluxunit = "K"; 180 } else { 181 // downcase for use with Quanta 182 if (header_->fluxunit == "JY") { 183 header_->fluxunit = "Jy"; 184 } 171 185 } 172 186 STAttr stattr; … … 275 289 // 276 290 291 /** 277 292 Int beamNo, IFno, refBeam, scanNo, cycleNo; 278 293 Float azimuth, elevation, focusAxi, focusRot, focusTan, … … 287 302 Complex xCalFctr; 288 303 Vector<Complex> xPol; 304 **/ 305 289 306 Double min = 0.0; 290 307 Double max = nInDataRow; 308 #ifdef HAS_ALMA 291 309 ProgressMeter fillpm(min, max, "Data importing progress"); 310 #endif 311 PKSrecord pksrec; 292 312 int n = 0; 293 313 while ( status == 0 ) { 294 status = reader_->read(scanNo, cycleNo, mjd, interval, fieldName, 295 srcName, srcDir, srcPM, srcVel, obsType, IFno, 296 refFreq, bandwidth, freqInc, restFreq, tcal, tcalTime, 297 azimuth, elevation, parAngle, focusAxi, 298 focusTan, focusRot, temperature, pressure, 299 humidity, windSpeed, windAz, refBeam, 300 beamNo, direction, scanRate, 301 tsys, sigma, calFctr, baseLin, baseSub, 302 spectra, flagtra, xCalFctr, xPol); 314 status = reader_->read(pksrec); 303 315 if ( status != 0 ) break; 304 316 n += 1; 305 317 306 318 Regex filterrx(".*[SL|PA]$"); 307 319 Regex obsrx("^AT.+"); 308 if ( header_->antennaname.matches(obsrx) && obsType.matches(filterrx)) { 320 if ( header_->antennaname.matches(obsrx) && 321 pksrec.obsType.matches(filterrx)) { 309 322 //cerr << "ignoring paddle scan" << endl; 310 323 continue; … … 314 327 // fields that don't get used and are just passed through asap 315 328 RecordFieldPtr<Array<Double> > srateCol(rec, "SCANRATE"); 316 *srateCol = scanRate; 329 // MRC changed type from double to float 330 Vector<Double> sratedbl(pksrec.scanRate.nelements()); 331 convertArray(sratedbl, pksrec.scanRate); 332 *srateCol = sratedbl; 317 333 RecordFieldPtr<Array<Double> > spmCol(rec, "SRCPROPERMOTION"); 318 *spmCol = srcPM;334 *spmCol = pksrec.srcPM; 319 335 RecordFieldPtr<Array<Double> > sdirCol(rec, "SRCDIRECTION"); 320 *sdirCol = srcDir;336 *sdirCol = pksrec.srcDir; 321 337 RecordFieldPtr<Double> svelCol(rec, "SRCVELOCITY"); 322 *svelCol = srcVel;338 *svelCol = pksrec.srcVel; 323 339 // the real stuff 324 340 RecordFieldPtr<Int> fitCol(rec, "FIT_ID"); 325 341 *fitCol = -1; 326 342 RecordFieldPtr<uInt> scanoCol(rec, "SCANNO"); 327 *scanoCol = scanNo-1;343 *scanoCol = pksrec.scanNo-1; 328 344 RecordFieldPtr<uInt> cyclenoCol(rec, "CYCLENO"); 329 *cyclenoCol = cycleNo-1;345 *cyclenoCol = pksrec.cycleNo-1; 330 346 RecordFieldPtr<Double> mjdCol(rec, "TIME"); 331 *mjdCol = mjd;347 *mjdCol = pksrec.mjd; 332 348 RecordFieldPtr<Double> intCol(rec, "INTERVAL"); 333 *intCol = interval;349 *intCol = pksrec.interval; 334 350 RecordFieldPtr<String> srcnCol(rec, "SRCNAME"); 335 351 RecordFieldPtr<Int> srctCol(rec, "SRCTYPE"); 336 352 RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME"); 337 *fieldnCol = fieldName;353 *fieldnCol = pksrec.fieldName; 338 354 // try to auto-identify if it is on or off. 339 Regex rx( ".*[e|w|_R]$");355 Regex rx(refRx_); 340 356 Regex rx2("_S$"); 341 Int match = srcName.matches(rx);357 Int match = pksrec.srcName.matches(rx); 342 358 if (match) { 343 *srcnCol = srcName;359 *srcnCol = pksrec.srcName; 344 360 } else { 345 *srcnCol = srcName.before(rx2);346 } 347 //*srcnCol = srcName;//.before(rx2);361 *srcnCol = pksrec.srcName.before(rx2); 362 } 363 //*srcnCol = pksrec.srcName;//.before(rx2); 348 364 *srctCol = match; 349 365 RecordFieldPtr<uInt> beamCol(rec, "BEAMNO"); 350 *beamCol = beamNo-beamOffset_-1;366 *beamCol = pksrec.beamNo-beamOffset_-1; 351 367 RecordFieldPtr<Int> rbCol(rec, "REFBEAMNO"); 352 368 Int rb = -1; 353 if (nBeam_ > 1 ) rb = refBeam-1;369 if (nBeam_ > 1 ) rb = pksrec.refBeam-1; 354 370 *rbCol = rb; 355 371 RecordFieldPtr<uInt> ifCol(rec, "IFNO"); 356 *ifCol = IFno-ifOffset_- 1;372 *ifCol = pksrec.IFno-ifOffset_- 1; 357 373 uInt id; 358 374 /// @todo this has to change when nchan isn't global anymore 359 375 id = table_->frequencies().addEntry(Double(header_->nchan/2), 360 refFreq,freqInc);376 pksrec.refFreq, pksrec.freqInc); 361 377 RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID"); 362 378 *mfreqidCol = id; 363 379 364 id = table_->molecules().addEntry( restFreq);380 id = table_->molecules().addEntry(pksrec.restFreq); 365 381 RecordFieldPtr<uInt> molidCol(rec, "MOLECULE_ID"); 366 382 *molidCol = id; 367 383 368 id = table_->tcal().addEntry( tcalTime,tcal);384 id = table_->tcal().addEntry(pksrec.tcalTime, pksrec.tcal); 369 385 RecordFieldPtr<uInt> mcalidCol(rec, "TCAL_ID"); 370 386 *mcalidCol = id; 371 id = table_->weather().addEntry(temperature, pressure, humidity, 372 windSpeed, windAz); 387 id = table_->weather().addEntry(pksrec.temperature, pksrec.pressure, 388 pksrec.humidity, pksrec.windSpeed, 389 pksrec.windAz); 373 390 RecordFieldPtr<uInt> mweatheridCol(rec, "WEATHER_ID"); 374 391 *mweatheridCol = id; 375 392 RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID"); 376 id = table_->focus().addEntry(focusAxi, focusTan, focusRot); 393 id = table_->focus().addEntry(pksrec.focusAxi, pksrec.focusTan, 394 pksrec.focusRot); 377 395 *mfocusidCol = id; 378 396 RecordFieldPtr<Array<Double> > dirCol(rec, "DIRECTION"); 379 *dirCol = direction;397 *dirCol = pksrec.direction; 380 398 RecordFieldPtr<Float> azCol(rec, "AZIMUTH"); 381 *azCol = azimuth;399 *azCol = pksrec.azimuth; 382 400 RecordFieldPtr<Float> elCol(rec, "ELEVATION"); 383 *elCol = elevation;401 *elCol = pksrec.elevation; 384 402 385 403 RecordFieldPtr<Float> parCol(rec, "PARANGLE"); 386 *parCol = p arAngle;404 *parCol = pksrec.parAngle; 387 405 388 406 RecordFieldPtr< Array<Float> > specCol(rec, "SPECTRA"); … … 395 413 Vector<Float> tsysvec(1); 396 414 // Why is spectra.ncolumn() == 3 for haveXPol_ == True 397 uInt npol = ( spectra.ncolumn()==1 ? 1: 2);415 uInt npol = (pksrec.spectra.ncolumn()==1 ? 1: 2); 398 416 for ( uInt i=0; i< npol; ++i ) { 399 tsysvec = tsys(i);417 tsysvec = pksrec.tsys(i); 400 418 *tsysCol = tsysvec; 401 419 *polnoCol = i; 402 420 403 *specCol = spectra.column(i);404 *flagCol = flagtra.column(i);421 *specCol = pksrec.spectra.column(i); 422 *flagCol = pksrec.flagged.column(i); 405 423 table_->table().addRow(); 406 424 row.put(table_->table().nrow()-1, rec); … … 408 426 if ( haveXPol_[0] ) { 409 427 // no tsys given for xpol, so emulate it 410 tsysvec = sqrt( tsys[0]*tsys[1]);428 tsysvec = sqrt(pksrec.tsys[0]*pksrec.tsys[1]); 411 429 *tsysCol = tsysvec; 412 430 // add real part of cross pol 413 431 *polnoCol = 2; 414 Vector<Float> r(real( xPol));432 Vector<Float> r(real(pksrec.xPol)); 415 433 *specCol = r; 416 434 // make up flags from linears 417 435 /// @fixme this has to be a bitwise or of both pols 418 *flagCol = flagtra.column(0);// | flagtra.column(1);436 *flagCol = pksrec.flagged.column(0);// | pksrec.flagged.column(1); 419 437 table_->table().addRow(); 420 438 row.put(table_->table().nrow()-1, rec); 421 439 // ad imaginary part of cross pol 422 440 *polnoCol = 3; 423 Vector<Float> im(imag( xPol));441 Vector<Float> im(imag(pksrec.xPol)); 424 442 *specCol = im; 425 443 table_->table().addRow(); 426 444 row.put(table_->table().nrow()-1, rec); 427 445 } 446 #ifdef HAS_ALMA 428 447 fillpm._update(n); 448 #endif 429 449 } 430 450 if (status > 0) { … … 432 452 throw(AipsError("Reading error occured, data possibly corrupted.")); 433 453 } 454 #ifdef HAS_ALMA 434 455 fillpm.done(); 456 #endif 435 457 return status; 436 458 }
Note: See TracChangeset
for help on using the changeset viewer.