source: branches/casa-release-4_3-test/src/STCalTsysTable.cpp@ 3062

Last change on this file since 3062 was 2955, checked in by Takeshi Nakazato, 10 years ago

New Development: No

JIRA Issue: Yes CAS-6585, CAS-6571

Ready for Test: Yes

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Added FLAGTRA column to sky and Tsys caltable.
To support previous versions of caltabls that don't have FLAGTRA
column, the code automatically add FLAGTRA column and initialize
it with initial value (uChar)0 if no FLAGTRA exists.


File size: 3.9 KB
Line 
1//
2// C++ Implementation: STCalTsysTable
3//
4// Description:
5//
6//
7// Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp> (C) 2012
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#include <assert.h>
13
14#include <casa/Exceptions/Error.h>
15#include <casa/Utilities/Assert.h>
16#include <tables/Tables/TableDesc.h>
17#include <tables/Tables/SetupNewTab.h>
18#include <tables/Tables/ArrColDesc.h>
19#include <tables/Tables/ScaColDesc.h>
20#include <tables/Tables/TableRecord.h>
21#include <tables/Tables/TableIter.h>
22#include <measures/TableMeasures/TableMeasDesc.h>
23#include <measures/TableMeasures/TableMeasRefDesc.h>
24#include <measures/TableMeasures/TableMeasValueDesc.h>
25
26#include "Scantable.h"
27#include "STCalTsysTable.h"
28
29
30using namespace casa;
31
32namespace asap {
33
34const String STCalTsysTable::name_ = "APPLY_TSYS";
35
36STCalTsysTable::STCalTsysTable(const Scantable& parent)
37 : STApplyTable(parent, name_)
38{
39 setup();
40}
41
42STCalTsysTable::STCalTsysTable(const String &name)
43 : STApplyTable(name)
44{
45 if (!table_.tableDesc().isColumn("FLAGTRA")) {
46 LogIO os(LogOrigin("STCalTsysTable", "STCalTsysTable", WHERE));
47 os << "Adding FLAGTRA column to " << name << " with initial value of 0 (all data valid)." << LogIO::POST;
48 table_.addColumn(ArrayColumnDesc<uChar>("FLAGTRA"));
49 TableIterator iter(table_, "IFNO");
50 while (!iter.pastEnd()) {
51 Table t = iter.table();
52 ArrayColumn<Float> tsysCol(t, "TSYS");
53 IPosition shape(2, tsysCol.shape(0)[0], t.nrow());
54 ArrayColumn<uChar> flagtraCol(t, "FLAGTRA");
55 Array<uChar> flagtra(shape, (uChar)0);
56 flagtraCol.putColumn(flagtra);
57 iter.next();
58 }
59 }
60
61 attachOptionalColumns();
62}
63
64STCalTsysTable::~STCalTsysTable()
65{
66}
67
68void STCalTsysTable::setup()
69{
70 table_.addColumn(ArrayColumnDesc<Float>("TSYS"));
71 table_.addColumn(ArrayColumnDesc<uChar>("FLAGTRA"));
72 table_.addColumn(ScalarColumnDesc<Float>("ELEVATION"));
73
74 table_.rwKeywordSet().define("ApplyType", "CALTSYS");
75
76 attachOptionalColumns();
77}
78
79void STCalTsysTable::attachOptionalColumns()
80{
81 tsysCol_.attach(table_, "TSYS");
82 flagtraCol_.attach(table_, "FLAGTRA");
83 elCol_.attach(table_,"ELEVATION");
84
85}
86
87void STCalTsysTable::setdata(uInt irow, uInt scanno, uInt cycleno,
88 uInt beamno, uInt ifno, uInt polno, uInt freqid,
89 Double time, Float elevation,
90 const Vector<Float> &tsys,
91 const Vector<uChar> &flagtra)
92{
93 if (irow >= (uInt)nrow()) {
94 throw AipsError("row index out of range");
95 }
96
97 if (!sel_.empty()) {
98 os_.origin(LogOrigin("STCalTsysTable","setdata",WHERE));
99 os_ << LogIO::WARN << "Data selection is effective. Specified row index may be wrong." << LogIO::POST;
100 }
101
102 setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time);
103 elCol_.put(irow, elevation);
104 tsysCol_.put(irow, tsys);
105 flagtraCol_.put(irow, flagtra);
106}
107
108void STCalTsysTable::appenddata(uInt scanno, uInt cycleno,
109 uInt beamno, uInt ifno, uInt polno, uInt freqid,
110 Double time, Float elevation,
111 const Vector<Float> &tsys,
112 const Vector<uChar> &flagtra)
113{
114 uInt irow = nrow();
115 table_.addRow(1, True);
116 setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation,
117 tsys, flagtra);
118}
119
120uInt STCalTsysTable::nchan(uInt ifno)
121{
122 STSelector org = sel_;
123 STSelector sel;
124 sel.setIFs(vector<int>(1,(int)ifno));
125 setSelection(sel);
126 uInt n = tsysCol_(0).nelements();
127 unsetSelection();
128 if (!org.empty())
129 setSelection(org);
130 return n;
131}
132
133Vector<Double> STCalTsysTable::getBaseFrequency(uInt whichrow)
134{
135 //assert(whichrow < nrow());
136 assert_<AipsError>(whichrow < nrow(), "row index out of range.");
137 uInt freqid = freqidCol_(whichrow);
138 uInt nc = tsysCol_(whichrow).nelements();
139 Block<Double> f = getFrequenciesRow(freqid);
140 Vector<Double> freqs(nc);
141 indgen(freqs, f[1]-f[0]*f[2], f[2]);
142 return freqs;
143}
144}
Note: See TracBrowser for help on using the repository browser.