Changeset 2923


Ignore:
Timestamp:
04/08/14 11:28:23 (11 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-6382

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: test_tsdcal2

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Implement averaged Tsys calibration.


Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/CalibrationManager.cpp

    r2922 r2923  
    3737    calmode_(""),
    3838    spwlist_(0),
    39     spwlist_withrange_()
     39    spwlist_withrange_(),
     40    do_average_(false)
    4041{
    4142  applicator_ = new STApplyCal();
     
    155156  os_ << LogIO::DEBUGGING << ((average) ? "with averaging" : "without averaging") << LogIO::POST;
    156157  spwlist_withrange_ = spwlist;
     158  do_average_ = average;
    157159}
    158160
     
    165167  spwlist_.clear();
    166168  spwlist_withrange_ = Record();
     169  do_average_ = false;
    167170}
    168171
     
    175178  spwlist_.clear();
    176179  spwlist_withrange_ = Record();
     180  do_average_ = false;
    177181}
    178182
     
    192196    }
    193197    else {
    194       uInt nfield = spwlist_withrange_.nfields();
    195       vector<int> spwlist(nfield);
    196       for (uInt i = 0; i < nfield; ++i) {
    197         spwlist[i] = std::atoi(spwlist_withrange_.name(i).c_str());
    198       }
    199       STCalTsys cal(target_, spwlist);
     198      STCalTsys cal(target_, spwlist_withrange_, do_average_);
    200199      cal.calibrate();
    201200      tsystables_.push_back(cal.applytable());
  • trunk/src/CalibrationManager.h

    r2922 r2923  
    7676  std::vector<int> spwlist_;
    7777  casa::Record spwlist_withrange_;
     78  bool do_average_;
    7879
    7980  casa::LogIO os_;
  • trunk/src/STCalTsys.cpp

    r2915 r2923  
    2525
    2626namespace asap {
    27   STCalTsys::STCalTsys(CountedPtr<Scantable> &s, vector<int> &iflist)
    28     : STCalibration(s, "TSYS"),
    29       iflist_(iflist)
     27STCalTsys::STCalTsys(CountedPtr<Scantable> &s, vector<int> &iflist)
     28  : STCalibration(s, "TSYS"),
     29    iflist_(iflist),
     30    tsysspw_(),
     31    do_average_(false)
    3032{
     33  applytable_ = new STCalTsysTable(*s);
     34}
     35
     36STCalTsys::STCalTsys(CountedPtr<Scantable> &s, Record &iflist, bool average)
     37  : STCalibration(s, "TSYS"),
     38    iflist_(),
     39    tsysspw_(iflist),
     40    do_average_(average)
     41{
     42  iflist_.resize(tsysspw_.nfields());
     43  for (uInt i = 0; i < tsysspw_.nfields(); ++i) {
     44    iflist_[i] = std::atoi(tsysspw_.name(i).c_str());
     45  }
    3146  applytable_ = new STCalTsysTable(*s);
    3247}
     
    6378{
    6479  STCalTsysTable *p = dynamic_cast<STCalTsysTable *>(&(*applytable_));
    65   p->appenddata(scanno, cycleno, beamno, ifno, polno,
    66                 freqid, time, elevation, any_data);
     80  if (do_average_ && tsysspw_.isDefined(String::toString(ifno))) {
     81    LogIO os(LogOrigin("STCalTsys", "appenddata", WHERE));
     82    Vector<Float> averaged_data(any_data.size());
     83    Float averaged_value = 0.0;
     84    uInt num_value = 0;
     85    Vector<Double> channel_range = tsysspw_.asArrayDouble(String::toString(ifno));
     86    os << LogIO::DEBUGGING << "do averaging: channel range for IFNO " << ifno << " is " << channel_range << LogIO::POST;
     87    for (uInt i = 1; i < channel_range.size(); i += 2) {
     88      uInt start = (uInt)channel_range[i-1];
     89      uInt end = std::min((uInt)channel_range[i] + 1, (uInt)averaged_data.size());
     90      os << LogIO::DEBUGGING << "start=" << start << ", end=" << end << LogIO::POST;
     91      for (uInt j = start; j < end; ++j) {
     92        averaged_value += any_data[j];
     93        num_value++;
     94      }
     95    }
     96    averaged_value /= (Float)num_value;
     97    averaged_data = averaged_value;
     98    os << LogIO::DEBUGGING << "averaged_data = " << averaged_data << LogIO::POST;
     99    os << LogIO::DEBUGGING << "any_data = " << any_data << LogIO::POST;
     100    p->appenddata(scanno, cycleno, beamno, ifno, polno,
     101                  freqid, time, elevation, averaged_data);
     102  }
     103  else {
     104    p->appenddata(scanno, cycleno, beamno, ifno, polno,
     105                  freqid, time, elevation, any_data);
     106  }
    67107}
    68108
  • trunk/src/STCalTsys.h

    r2915 r2923  
    2020#include <casa/BasicSL/String.h>
    2121#include <casa/Utilities/CountedPtr.h>
     22#include <casa/Containers/Record.h>
    2223
    2324#include <scimath/Mathematics/InterpolateArray1D.h>
     
    3940public:
    4041  STCalTsys(casa::CountedPtr<Scantable> &s, vector<int> &iflist);
     42  STCalTsys(casa::CountedPtr<Scantable> &s, casa::Record &iflist, bool average=false);
    4143
    4244  ~STCalTsys() {;}
     
    5052
    5153  vector<int> iflist_;
     54  casa::Record tsysspw_;
     55  bool do_average_;
    5256};
    5357
Note: See TracChangeset for help on using the changeset viewer.