source: trunk/src/STCalTsysTable.cpp @ 2720

Last change on this file since 2720 was 2720, checked in by Takeshi Nakazato, 11 years ago

New Development: Yes

JIRA Issue: Yes CAS-4770 and its sub-tickets

Ready for Test: Yes

Interface Changes: 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...

First version of applycal for single dish calibration.
Added new classes for the operation (STApplyCal, Calibrator, PSAlmaCalibrator,
Locator, BisectionLocator?, Interpolator1D, NearestInterpolator1D).
Also, modified existing classes to fit with implementation of applycal.


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