Changeset 1427 for trunk/external/atnf/PKSIO/PKSFITSreader.cc
- Timestamp:
- 07/04/08 13:23:49 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external/atnf/PKSIO/PKSFITSreader.cc
r1399 r1427 1 1 //# PKSFITSreader.cc: Class to read Parkes multibeam data from a FITS file. 2 2 //#--------------------------------------------------------------------------- 3 //# Copyright (C) 2000-200 73 //# Copyright (C) 2000-2008 4 4 //# Associated Universities, Inc. Washington DC, USA. 5 5 //# … … 25 25 //# Charlottesville, VA 22903-2475 USA 26 26 //# 27 //# $Id: PKSFITSreader.cc,v 19.1 3 2007/11/12 03:37:56cal103 Exp $27 //# $Id: PKSFITSreader.cc,v 19.14 2008-06-26 02:07:21 cal103 Exp $ 28 28 //#--------------------------------------------------------------------------- 29 29 //# Original: 2000/08/02, Mark Calabretta, ATNF … … 50 50 const Bool interpolate) 51 51 { 52 c MBrec.setNIFs(1);52 cFITSMBrec.setNIFs(1); 53 53 54 54 if (fitsType == "SDFITS") { … … 321 321 // Read the next data record. 322 322 323 Int PKSFITSreader::read( 324 Int &scanNo, 325 Int &cycleNo, 326 Double &mjd, 327 Double &interval, 328 String &fieldName, 329 String &srcName, 330 Vector<Double> &srcDir, 331 Vector<Double> &srcPM, 332 Double &srcVel, 333 String &obsType, 334 Int &IFno, 335 Double &refFreq, 336 Double &bandwidth, 337 Double &freqInc, 338 Double &restFreq, 339 Vector<Float> &tcal, 340 String &tcalTime, 341 Float &azimuth, 342 Float &elevation, 343 Float &parAngle, 344 Float &focusAxi, 345 Float &focusTan, 346 Float &focusRot, 347 Float &temperature, 348 Float &pressure, 349 Float &humidity, 350 Float &windSpeed, 351 Float &windAz, 352 Int &refBeam, 353 Int &beamNo, 354 Vector<Double> &direction, 355 Vector<Double> &scanRate, 356 Vector<Float> &tsys, 357 Vector<Float> &sigma, 358 Vector<Float> &calFctr, 359 Matrix<Float> &baseLin, 360 Matrix<Float> &baseSub, 361 Matrix<Float> &spectra, 362 Matrix<uChar> &flagged, 363 Complex &xCalFctr, 364 Vector<Complex> &xPol) 323 Int PKSFITSreader::read(MBrecord &MBrec) 365 324 { 366 325 Int status; 367 326 368 if ((status = cReader->read(c MBrec))) {327 if ((status = cReader->read(cFITSMBrec))) { 369 328 if (status != -1) { 370 329 status = 1; … … 375 334 376 335 377 uInt nChan = c MBrec.nChan[0];378 uInt nPol = c MBrec.nPol[0];379 380 scanNo = cMBrec.scanNo;381 cycleNo = cMBrec.cycleNo;336 uInt nChan = cFITSMBrec.nChan[0]; 337 uInt nPol = cFITSMBrec.nPol[0]; 338 339 MBrec.scanNo = cFITSMBrec.scanNo; 340 MBrec.cycleNo = cFITSMBrec.cycleNo; 382 341 383 342 // Extract MJD. 384 343 Int day, month, year; 385 sscanf(cMBrec.datobs, "%4d-%2d-%2d", &year, &month, &day); 386 mjd = MVTime(year, month, Double(day)).day() + cMBrec.utc/86400.0; 387 388 interval = cMBrec.exposure; 389 390 fieldName = trim(cMBrec.srcName); 391 srcName = fieldName; 392 srcDir(0) = cMBrec.srcRA; 393 srcDir(1) = cMBrec.srcDec; 394 srcPM(0) = 0.0; 395 srcPM(1) = 0.0; 396 srcVel = 0.0; 397 obsType = trim(cMBrec.obsType); 398 399 IFno = cMBrec.IFno[0]; 400 Double chanWidth = fabs(cMBrec.fqDelt[0]); 401 refFreq = cMBrec.fqRefVal[0]; 402 bandwidth = chanWidth * nChan; 403 freqInc = cMBrec.fqDelt[0]; 404 restFreq = cMBrec.restFreq; 405 406 tcal.resize(nPol); 344 sscanf(cFITSMBrec.datobs, "%4d-%2d-%2d", &year, &month, &day); 345 MBrec.mjd = MVTime(year, month, Double(day)).day() + cFITSMBrec.utc/86400.0; 346 347 MBrec.interval = cFITSMBrec.exposure; 348 349 MBrec.fieldName = trim(cFITSMBrec.srcName); 350 MBrec.srcName = MBrec.fieldName; 351 352 MBrec.srcDir.resize(2); 353 MBrec.srcDir(0) = cFITSMBrec.srcRA; 354 MBrec.srcDir(1) = cFITSMBrec.srcDec; 355 356 MBrec.srcPM.resize(2); 357 MBrec.srcPM(0) = 0.0; 358 MBrec.srcPM(1) = 0.0; 359 MBrec.srcVel = 0.0; 360 MBrec.obsType = trim(cFITSMBrec.obsType); 361 362 MBrec.IFno = cFITSMBrec.IFno[0]; 363 Double chanWidth = fabs(cFITSMBrec.fqDelt[0]); 364 MBrec.refFreq = cFITSMBrec.fqRefVal[0]; 365 MBrec.bandwidth = chanWidth * nChan; 366 MBrec.freqInc = cFITSMBrec.fqDelt[0]; 367 MBrec.restFreq = cFITSMBrec.restFreq; 368 369 MBrec.tcal.resize(nPol); 407 370 for (uInt ipol = 0; ipol < nPol; ipol++) { 408 tcal(ipol) = cMBrec.tcal[0][ipol]; 409 } 410 tcalTime = trim(cMBrec.tcalTime); 411 azimuth = cMBrec.azimuth; 412 elevation = cMBrec.elevation; 413 parAngle = cMBrec.parAngle; 414 focusAxi = cMBrec.focusAxi; 415 focusTan = cMBrec.focusTan; 416 focusRot = cMBrec.focusRot; 417 418 temperature = cMBrec.temp; 419 pressure = cMBrec.pressure; 420 humidity = cMBrec.humidity; 421 windSpeed = cMBrec.windSpeed; 422 windAz = cMBrec.windAz; 423 424 refBeam = cMBrec.refBeam; 425 beamNo = cMBrec.beamNo; 426 427 direction(0) = cMBrec.ra; 428 direction(1) = cMBrec.dec; 429 scanRate(0) = cMBrec.raRate; 430 scanRate(1) = cMBrec.decRate; 431 432 tsys.resize(nPol); 433 sigma.resize(nPol); 434 calFctr.resize(nPol); 371 MBrec.tcal(ipol) = cFITSMBrec.tcal[0][ipol]; 372 } 373 MBrec.tcalTime = trim(cFITSMBrec.tcalTime); 374 MBrec.azimuth = cFITSMBrec.azimuth; 375 MBrec.elevation = cFITSMBrec.elevation; 376 MBrec.parAngle = cFITSMBrec.parAngle; 377 MBrec.focusAxi = cFITSMBrec.focusAxi; 378 MBrec.focusTan = cFITSMBrec.focusTan; 379 MBrec.focusRot = cFITSMBrec.focusRot; 380 381 MBrec.temperature = cFITSMBrec.temp; 382 MBrec.pressure = cFITSMBrec.pressure; 383 MBrec.humidity = cFITSMBrec.humidity; 384 MBrec.windSpeed = cFITSMBrec.windSpeed; 385 MBrec.windAz = cFITSMBrec.windAz; 386 387 MBrec.refBeam = cFITSMBrec.refBeam; 388 MBrec.beamNo = cFITSMBrec.beamNo; 389 390 MBrec.direction.resize(2); 391 MBrec.direction(0) = cFITSMBrec.ra; 392 MBrec.direction(1) = cFITSMBrec.dec; 393 394 MBrec.scanRate.resize(2); 395 MBrec.scanRate(0) = cFITSMBrec.raRate; 396 MBrec.scanRate(1) = cFITSMBrec.decRate; 397 MBrec.rateAge = cFITSMBrec.rateAge; 398 MBrec.rateson = cFITSMBrec.rateson; 399 400 MBrec.tsys.resize(nPol); 401 MBrec.sigma.resize(nPol); 402 MBrec.calFctr.resize(nPol); 435 403 for (uInt ipol = 0; ipol < nPol; ipol++) { 436 tsys(ipol) = cMBrec.tsys[0][ipol]; 437 sigma(ipol) = tsys(ipol) / 0.81 / sqrt(interval * chanWidth); 438 calFctr(ipol) = cMBrec.calfctr[0][ipol]; 439 } 440 441 if (cMBrec.haveBase) { 442 baseLin.resize(2,nPol); 443 baseSub.resize(9,nPol); 404 MBrec.tsys(ipol) = cFITSMBrec.tsys[0][ipol]; 405 MBrec.sigma(ipol) = (MBrec.tsys(ipol) / 0.81) / 406 sqrt(MBrec.interval * chanWidth); 407 MBrec.calFctr(ipol) = cFITSMBrec.calfctr[0][ipol]; 408 } 409 410 if (cFITSMBrec.haveBase) { 411 MBrec.baseLin.resize(2,nPol); 412 MBrec.baseSub.resize(9,nPol); 444 413 445 414 for (uInt ipol = 0; ipol < nPol; ipol++) { 446 baseLin(0,ipol) = cMBrec.baseLin[0][ipol][0];447 baseLin(1,ipol) = cMBrec.baseLin[0][ipol][1];415 MBrec.baseLin(0,ipol) = cFITSMBrec.baseLin[0][ipol][0]; 416 MBrec.baseLin(1,ipol) = cFITSMBrec.baseLin[0][ipol][1]; 448 417 449 418 for (uInt j = 0; j < 9; j++) { 450 baseSub(j,ipol) = cMBrec.baseSub[0][ipol][j];419 MBrec.baseSub(j,ipol) = cFITSMBrec.baseSub[0][ipol][j]; 451 420 } 452 421 } 453 422 454 423 } else { 455 baseLin.resize(0,0); 456 baseSub.resize(0,0); 457 } 458 459 if (cGetSpectra && cMBrec.haveSpectra) { 460 spectra.resize(nChan,nPol); 461 spectra.takeStorage(IPosition(2,nChan,nPol), cMBrec.spectra[0], SHARE); 462 463 flagged.resize(nChan,nPol); 464 flagged.takeStorage(IPosition(2,nChan,nPol), cMBrec.flagged[0], SHARE); 424 MBrec.baseLin.resize(0,0); 425 MBrec.baseSub.resize(0,0); 426 } 427 428 if (cGetSpectra && cFITSMBrec.haveSpectra) { 429 MBrec.spectra.resize(nChan,nPol); 430 MBrec.spectra.takeStorage(IPosition(2,nChan,nPol), cFITSMBrec.spectra[0], 431 SHARE); 432 433 MBrec.flagged.resize(nChan,nPol); 434 MBrec.flagged.takeStorage(IPosition(2,nChan,nPol), cFITSMBrec.flagged[0], 435 SHARE); 465 436 466 437 } else { 467 spectra.resize(0,0);468 flagged.resize(0,0);438 MBrec.spectra.resize(0,0); 439 MBrec.flagged.resize(0,0); 469 440 } 470 441 471 442 if (cGetXPol) { 472 xCalFctr = Complex(cMBrec.xcalfctr[0][0], cMBrec.xcalfctr[0][1]); 473 xPol.resize(nChan); 474 xPol.takeStorage(IPosition(1,nChan), (Complex *)cMBrec.xpol[0], SHARE); 443 MBrec.xCalFctr = Complex(cFITSMBrec.xcalfctr[0][0], 444 cFITSMBrec.xcalfctr[0][1]); 445 MBrec.xPol.resize(nChan); 446 MBrec.xPol.takeStorage(IPosition(1,nChan), (Complex *)cFITSMBrec.xpol[0], 447 SHARE); 475 448 } 476 449 … … 493 466 Int status; 494 467 495 if ((status = cReader->read(c MBrec))) {468 if ((status = cReader->read(cFITSMBrec))) { 496 469 if (status != -1) { 497 470 status = 1; … … 501 474 } 502 475 503 IFno = c MBrec.IFno[0];504 505 uInt nChan = c MBrec.nChan[0];506 uInt nPol = c MBrec.nPol[0];476 IFno = cFITSMBrec.IFno[0]; 477 478 uInt nChan = cFITSMBrec.nChan[0]; 479 uInt nPol = cFITSMBrec.nPol[0]; 507 480 508 481 tsys.resize(nPol); 509 482 calFctr.resize(nPol); 510 483 for (uInt ipol = 0; ipol < nPol; ipol++) { 511 tsys(ipol) = c MBrec.tsys[0][ipol];512 calFctr(ipol) = c MBrec.calfctr[0][ipol];513 } 514 515 if (c MBrec.haveBase) {484 tsys(ipol) = cFITSMBrec.tsys[0][ipol]; 485 calFctr(ipol) = cFITSMBrec.calfctr[0][ipol]; 486 } 487 488 if (cFITSMBrec.haveBase) { 516 489 baseLin.resize(2,nPol); 517 490 baseSub.resize(9,nPol); 518 491 519 492 for (uInt ipol = 0; ipol < nPol; ipol++) { 520 baseLin(0,ipol) = c MBrec.baseLin[0][ipol][0];521 baseLin(1,ipol) = c MBrec.baseLin[0][ipol][1];493 baseLin(0,ipol) = cFITSMBrec.baseLin[0][ipol][0]; 494 baseLin(1,ipol) = cFITSMBrec.baseLin[0][ipol][1]; 522 495 523 496 for (uInt j = 0; j < 9; j++) { 524 baseSub(j,ipol) = c MBrec.baseSub[0][ipol][j];497 baseSub(j,ipol) = cFITSMBrec.baseSub[0][ipol][j]; 525 498 } 526 499 } … … 531 504 } 532 505 533 if (cGetSpectra && c MBrec.haveSpectra) {506 if (cGetSpectra && cFITSMBrec.haveSpectra) { 534 507 spectra.resize(nChan,nPol); 535 spectra.takeStorage(IPosition(2,nChan,nPol), cMBrec.spectra[0], SHARE); 508 spectra.takeStorage(IPosition(2,nChan,nPol), cFITSMBrec.spectra[0], 509 SHARE); 536 510 537 511 flagged.resize(nChan,nPol); 538 flagged.takeStorage(IPosition(2,nChan,nPol), cMBrec.flagged[0], SHARE); 512 flagged.takeStorage(IPosition(2,nChan,nPol), cFITSMBrec.flagged[0], 513 SHARE); 539 514 540 515 } else {
Note: See TracChangeset
for help on using the changeset viewer.