source: trunk/src/STCalTsysTable.cpp@ 2782

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

New Development: No

JIRA Issue: Yes CAS-4770

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: test_sdcal2

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Replace assert with casa::assert_ to avoid aborting casapy session.


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