source: branches/casa-release-4_3-test02/src/STCalSkyTable.cpp@ 3012

Last change on this file since 3012 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: 4.0 KB
Line 
1//
2// C++ Implementation: STCalSkyTable
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/Logging/LogIO.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 "STCalSkyTable.h"
28
29
30using namespace casa;
31
32namespace asap {
33
34const String STCalSkyTable::name_ = "APPLY_SKY";
35
36STCalSkyTable::STCalSkyTable(const Scantable& parent, const String &caltype)
37 : STApplyTable(parent, name_),
38 caltype_(caltype)
39{
40 setup();
41}
42
43STCalSkyTable::STCalSkyTable(const String &name)
44 : STApplyTable(name)
45{
46 if (!table_.tableDesc().isColumn("FLAGTRA")) {
47 LogIO os(LogOrigin("STCalSkyTable", "STCalSkyTable", WHERE));
48 os << "Adding FLAGTRA column to " << name << " with initial value of 0 (all data valid)." << LogIO::POST;
49 table_.addColumn(ArrayColumnDesc<uChar>("FLAGTRA"));
50 TableIterator iter(table_, "IFNO");
51 while (!iter.pastEnd()) {
52 Table t = iter.table();
53 ArrayColumn<Float> spectraCol(t, "SPECTRA");
54 IPosition shape(2, spectraCol.shape(0)[0], t.nrow());
55 ArrayColumn<uChar> flagtraCol(t, "FLAGTRA");
56 Array<uChar> flagtra(shape, (uChar)0);
57 flagtraCol.putColumn(flagtra);
58 iter.next();
59 }
60 }
61
62 attachOptionalColumns();
63}
64
65STCalSkyTable::~STCalSkyTable()
66{
67}
68
69void STCalSkyTable::setup()
70{
71 table_.addColumn(ArrayColumnDesc<Float>("SPECTRA"));
72 table_.addColumn(ArrayColumnDesc<uChar>("FLAGTRA"));
73 table_.addColumn(ScalarColumnDesc<Float>("ELEVATION"));
74
75 //table_.rwKeywordSet().define("ApplyType", "SKY");
76 String caltype = "CALSKY_" + caltype_;
77 caltype.upcase();
78 table_.rwKeywordSet().define("ApplyType", caltype);
79
80 attachOptionalColumns();
81}
82
83void STCalSkyTable::attachOptionalColumns()
84{
85 spectraCol_.attach(table_, "SPECTRA");
86 flagtraCol_.attach(table_, "FLAGTRA");
87 elCol_.attach(table_,"ELEVATION");
88}
89
90void STCalSkyTable::setdata(uInt irow, uInt scanno, uInt cycleno,
91 uInt beamno, uInt ifno, uInt polno, uInt freqid,
92 Double time, Float elevation,
93 const Vector<Float> &spectra,
94 const Vector<uChar> &flagtra)
95{
96 if (irow >= (uInt)nrow()) {
97 throw AipsError("row index out of range");
98 }
99
100 if (!sel_.empty()) {
101 os_.origin(LogOrigin("STCalSkyTable","setdata",WHERE));
102 os_ << LogIO::WARN << "Data selection is effective. Specified row index may be wrong." << LogIO::POST;
103 }
104
105 setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time);
106 elCol_.put(irow, elevation);
107 spectraCol_.put(irow, spectra);
108 flagtraCol_.put(irow, flagtra);
109}
110
111void STCalSkyTable::appenddata(uInt scanno, uInt cycleno,
112 uInt beamno, uInt ifno, uInt polno, uInt freqid,
113 Double time, Float elevation,
114 const Vector<Float> &spectra,
115 const Vector<uChar> &flagtra)
116{
117 uInt irow = nrow();
118 table_.addRow(1, True);
119 setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation,
120 spectra, flagtra);
121}
122
123uInt STCalSkyTable::nchan(uInt ifno)
124{
125 STSelector org = sel_;
126 STSelector sel;
127 sel.setIFs(vector<int>(1,(int)ifno));
128 setSelection(sel);
129 uInt n = spectraCol_(0).nelements();
130 unsetSelection();
131 if (!org.empty())
132 setSelection(org);
133 return n;
134}
135
136// Vector<Double> STCalSkyTable::getBaseFrequency(uInt whichrow)
137// {
138// assert(whichrow < nrow());
139// uInt freqid = freqidCol_(whichrow);
140// uInt nc = spectraCol_(whichrow).nelements();
141// Block<Double> f = getFrequenciesRow(freqid);
142// Vector<Double> freqs(nc);
143// indgen(freqs, f[1]-f[0]*f[2], f[2]);
144// return freqs;
145// }
146}
Note: See TracBrowser for help on using the repository browser.