source: trunk/src/STCalTsysTable.cpp@ 2740

Last change on this file since 2740 was 2724, checked in by Takeshi Nakazato, 12 years ago

New Development: Yes/No

JIRA Issue: No/Yes List JIRA ticket.

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

Fix for assert

File size: 2.9 KB
RevLine 
[2703]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//
[2724]12#include <assert.h>
13
[2703]14#include <casa/Exceptions/Error.h>
15#include <tables/Tables/TableDesc.h>
16#include <tables/Tables/SetupNewTab.h>
17#include <tables/Tables/ArrColDesc.h>
18#include <tables/Tables/ScaColDesc.h>
19#include <tables/Tables/TableRecord.h>
20#include <measures/TableMeasures/TableMeasDesc.h>
21#include <measures/TableMeasures/TableMeasRefDesc.h>
22#include <measures/TableMeasures/TableMeasValueDesc.h>
23
24#include "Scantable.h"
25#include "STCalTsysTable.h"
26
27
28using namespace casa;
29
30namespace asap {
31
32const String STCalTsysTable::name_ = "APPLY_TSYS";
33
34STCalTsysTable::STCalTsysTable(const Scantable& parent)
35 : STApplyTable(parent, name_)
36{
37 setup();
38}
39
[2720]40STCalTsysTable::STCalTsysTable(const String &name)
41 : STApplyTable(name)
42{
43 attachOptionalColumns();
44}
45
[2703]46STCalTsysTable::~STCalTsysTable()
47{
48}
49
50void STCalTsysTable::setup()
51{
52 table_.addColumn(ArrayColumnDesc<Float>("TSYS"));
53 table_.addColumn(ScalarColumnDesc<Float>("ELEVATION"));
54
[2720]55 table_.rwKeywordSet().define("ApplyType", "CALTSYS");
[2703]56
57 attachOptionalColumns();
58}
59
60void STCalTsysTable::attachOptionalColumns()
61{
62 tsysCol_.attach(table_, "TSYS");
63 elCol_.attach(table_,"ELEVATION");
64
65}
66
67void STCalTsysTable::setdata(uInt irow, uInt scanno, uInt cycleno,
[2720]68 uInt beamno, uInt ifno, uInt polno, uInt freqid,
69 Double time, Float elevation, Vector<Float> tsys)
[2703]70{
71 if (irow >= (uInt)nrow()) {
72 throw AipsError("row index out of range");
73 }
74
75 if (!sel_.empty()) {
76 os_.origin(LogOrigin("STCalTsysTable","setdata",WHERE));
77 os_ << LogIO::WARN << "Data selection is effective. Specified row index may be wrong." << LogIO::POST;
78 }
79
[2720]80 setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time);
[2703]81 elCol_.put(irow, elevation);
82 tsysCol_.put(irow, tsys);
83}
84
85void STCalTsysTable::appenddata(uInt scanno, uInt cycleno,
[2720]86 uInt beamno, uInt ifno, uInt polno, uInt freqid,
87 Double time, Float elevation, Vector<Float> tsys)
[2703]88{
89 uInt irow = nrow();
90 table_.addRow(1, True);
[2720]91 setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation, tsys);
[2703]92}
[2720]93
94uInt STCalTsysTable::nchan(uInt ifno)
95{
96 STSelector org = sel_;
97 STSelector sel;
98 sel.setIFs(vector<int>(1,(int)ifno));
99 setSelection(sel);
100 uInt n = tsysCol_(0).nelements();
101 unsetSelection();
102 if (!org.empty())
103 setSelection(org);
104 return n;
[2703]105}
[2720]106
107Vector<Double> STCalTsysTable::getBaseFrequency(uInt whichrow)
108{
109 assert(whichrow < nrow());
110 uInt freqid = freqidCol_(whichrow);
111 uInt nc = tsysCol_(whichrow).nelements();
112 Block<Double> f = getFrequenciesRow(freqid);
113 Vector<Double> freqs(nc);
114 indgen(freqs, f[1]-f[0]*f[2], f[2]);
115 return freqs;
116}
117}
Note: See TracBrowser for help on using the repository browser.