Changeset 3021


Ignore:
Timestamp:
12/15/14 20:22:00 (10 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-7193

Ready for Test: Yes

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: test_sdcal2

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Fix for proper flag handling when input applytables are invalid/empty.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STApplyCal.cpp

    r3020 r3021  
    230230  }
    231231};
     232
     233inline void flagSpectrum(uInt &flagrow, Vector<uChar> &flagchan) {
     234  flagrow = 1;
     235  flagchan = (uChar)(1 << 7);
     236}
     237
     238inline void flagSpectra(Table &tab, const Vector<uInt> &rows) {
     239  //os_ << LogIO::WARN << "No valid sky data in sky caltable. Completely flag Beam " << beamno << " Spw " << ifno << " Pol " << polno << LogIO::POST;
     240  // Given sky tables are all empty
     241  // So, flag all data
     242  //Table tab = work_->table();
     243  ArrayColumn<uChar> flCol(tab, "FLAGTRA");
     244  ScalarColumn<uInt> frCol(tab, "FLAGROW");
     245  Vector<uChar> flag;
     246  uInt flagrow;
     247  for (uInt i = 0; i < rows.nelements(); i++) {
     248    uInt irow = rows[i];
     249    flCol.get(irow, flag);
     250    frCol.get(irow, flagrow);
     251    flagSpectrum(flagrow, flag);
     252    //flag = (uChar)(1 << 7);
     253    flCol.put(irow, flag);
     254    frCol.put(irow, flagrow);
     255  }
     256}
     257
    232258}
    233259
     
    454480
    455481  // Skip IFNO without sky data
    456   if (nrowSkyTotal == 0)
     482  if (nrowSkyTotal == 0) {
     483    if (skytable_.size() > 0) {
     484      os_ << LogIO::WARN << "No data in sky caltable. Completely flag Beam " << beamno << " Spw " << ifno << " Pol " << polno << LogIO::POST;
     485      // Given sky tables are all empty
     486      // So, flag all data
     487      flagSpectra(work_->table(), rows);
     488    }
    457489    return;
     490  }
    458491
    459492  uInt nchanTsys = 0;
    460493  Vector<Double> ftsys;
    461494  uInt tsysifno = getIFForTsys(ifno);
     495  Bool onlyInvalidTsys = False;
    462496  os_ << "tsysifno=" << (Int)tsysifno << LogIO::POST;
    463497  if (tsystable_.size() == 0) {
     
    483517      }
    484518    }
     519    if (nrowTsysTotal == 0) {
     520      os_ << "No valid Tsys measurement. for Beam " << beamno << " Spw " << ifno << " Pol " << polno << ". Skip Tsys calibration." << LogIO::POST;
     521      doTsys = False;
     522      onlyInvalidTsys = True;
     523    }
    485524  }
    486525
     
    493532                                  nrowSkyTotal, nchanSp,
    494533                                  timeSky, spoff, flagoff);
     534  if (allNE(flagoff, (uChar)0)) {
     535    os_ << LogIO::WARN << "No valid sky data in sky caltable. Completely flag Beam " << beamno << " Spw " << ifno << " Pol " << polno << LogIO::POST;
     536    // Given sky tables are all invalid
     537    // So, flag all data
     538    flagSpectra(work_->table(), rows);
     539  }
    495540  nrowSky = timeSky.nelements();
    496541
     
    509554
    510555    if (allNE(flagtsys, (uChar)0)) {
    511       os_ << LogIO::WARN << "No valid Tsys measurement. Skip Tsys calibration." << LogIO::POST;
     556      os_ << LogIO::WARN << "No valid Tsys measurement for Beam " << beamno << " Spw " << ifno << " Pol " << polno << ". Skip Tsys calibration." << LogIO::POST;
    512557      doTsys = False;
     558      onlyInvalidTsys = True;
    513559    }
    514560  }
     
    519565  ArrayColumn<Float> tsysCol(tab, "TSYS");
    520566  ScalarColumn<Double> timeCol(tab, "TIME");
     567  ScalarColumn<uInt> frCol(tab, "FLAGROW");
    521568
    522569  // Array for scaling factor (aka Tsys)
     
    547594    spCol.get(irow, on);
    548595    flCol.get(irow, flag);
     596    uInt flagrow = frCol(irow);
    549597    //os_ << "on=" << on[0] << LogIO::POST;
    550598    calibrator_->setSource(on);
     
    605653    calibrator_->calibrate();
    606654
     655    // flag spectrum if no valid Tsys measurement available
     656    if (onlyInvalidTsys) {
     657      flagSpectrum(flagrow, flag);
     658    }
     659
    607660    // update table
    608661    //os_ << "calibrated=" << calibrator_->getCalibrated()[0] << LogIO::POST;
    609662    spCol.put(irow, calibrator_->getCalibrated());
    610663    flCol.put(irow, flag);
    611     if (filltsys)
     664    frCol.put(irow, flagrow);
     665    if (filltsys && !onlyInvalidTsys)
    612666      tsysCol.put(irow, iTsys);
    613667  }
Note: See TracChangeset for help on using the changeset viewer.