source: trunk/src/STCalSkyTable.cpp@ 3130

Last change on this file since 3130 was 3106, checked in by Takeshi Nakazato, 8 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes/No

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...


Check-in asap modifications from Jim regarding casacore namespace conversion.

File size: 4.0 KB
RevLine 
[2703]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//
[2727]12#include <assert.h>
13
[2703]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>
[2955]21#include <tables/Tables/TableIter.h>
[2703]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
[3106]30using namespace casacore;
[2703]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
[2720]43STCalSkyTable::STCalSkyTable(const String &name)
44 : STApplyTable(name)
45{
[2955]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
[2720]62 attachOptionalColumns();
63}
64
[2703]65STCalSkyTable::~STCalSkyTable()
66{
67}
68
69void STCalSkyTable::setup()
70{
71 table_.addColumn(ArrayColumnDesc<Float>("SPECTRA"));
[2955]72 table_.addColumn(ArrayColumnDesc<uChar>("FLAGTRA"));
[2703]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");
[2955]86 flagtraCol_.attach(table_, "FLAGTRA");
[2703]87 elCol_.attach(table_,"ELEVATION");
88}
89
90void STCalSkyTable::setdata(uInt irow, uInt scanno, uInt cycleno,
[2720]91 uInt beamno, uInt ifno, uInt polno, uInt freqid,
[2955]92 Double time, Float elevation,
93 const Vector<Float> &spectra,
94 const Vector<uChar> &flagtra)
[2703]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
[2720]105 setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time);
[2703]106 elCol_.put(irow, elevation);
107 spectraCol_.put(irow, spectra);
[2955]108 flagtraCol_.put(irow, flagtra);
[2703]109}
110
111void STCalSkyTable::appenddata(uInt scanno, uInt cycleno,
[2720]112 uInt beamno, uInt ifno, uInt polno, uInt freqid,
[2955]113 Double time, Float elevation,
114 const Vector<Float> &spectra,
115 const Vector<uChar> &flagtra)
[2703]116{
117 uInt irow = nrow();
118 table_.addRow(1, True);
[2955]119 setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation,
120 spectra, flagtra);
[2703]121}
[2720]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;
[2703]134}
[2720]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.