Changeset 2923 for trunk/src/STCalTsys.cpp
- Timestamp:
- 04/08/14 11:28:23 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STCalTsys.cpp
r2915 r2923 25 25 26 26 namespace asap { 27 STCalTsys::STCalTsys(CountedPtr<Scantable> &s, vector<int> &iflist) 28 : STCalibration(s, "TSYS"), 29 iflist_(iflist) 27 STCalTsys::STCalTsys(CountedPtr<Scantable> &s, vector<int> &iflist) 28 : STCalibration(s, "TSYS"), 29 iflist_(iflist), 30 tsysspw_(), 31 do_average_(false) 30 32 { 33 applytable_ = new STCalTsysTable(*s); 34 } 35 36 STCalTsys::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 } 31 46 applytable_ = new STCalTsysTable(*s); 32 47 } … … 63 78 { 64 79 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 } 67 107 } 68 108
Note: See TracChangeset
for help on using the changeset viewer.