source: branches/parallel/src/STTcal.cpp@ 2123

Last change on this file since 2123 was 1391, checked in by Malte Marquarding, 17 years ago

merge from alma branch to get alma/GBT support. Commented out fluxUnit changes as they are using a chnaged interface to PKSreader/writer. Also commented out progress meter related code.

File size: 3.0 KB
Line 
1
2//
3// C++ Implementation: STTcal
4//
5// Description:
6//
7//
8// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006
9//
10// Copyright: See COPYING file that comes with this distribution
11//
12//
13#include <casa/Exceptions/Error.h>
14#include <tables/Tables/TableDesc.h>
15#include <tables/Tables/SetupNewTab.h>
16#include <tables/Tables/ScaColDesc.h>
17#include <tables/Tables/ArrColDesc.h>
18#include <tables/Tables/TableRecord.h>
19#include <tables/Tables/TableParse.h>
20#include <tables/Tables/TableRow.h>
21#include <casa/Containers/RecordField.h>
22
23#include "STTcal.h"
24
25
26using namespace casa;
27
28namespace asap {
29
30const casa::String STTcal::name_ = "TCAL";
31
32STTcal::STTcal(const Scantable& parent) :
33 STSubTable( parent, name_ )
34{
35 setup();
36}
37
38STTcal& asap::STTcal::operator =( const STTcal & other )
39{
40 if ( this != &other ) {
41 static_cast<STSubTable&>(*this) = other;
42 timeCol_.attach(table_,"TIME");
43 tcalCol_.attach(table_,"TCAL");
44 }
45 return *this;
46}
47
48asap::STTcal::STTcal( casa::Table tab ) : STSubTable(tab, name_)
49{
50 timeCol_.attach(table_,"TIME");
51 tcalCol_.attach(table_,"TCAL");
52
53}
54
55STTcal::~STTcal()
56{
57}
58
59void asap::STTcal::setup( )
60{
61 // add to base class table
62 table_.addColumn(ScalarColumnDesc<String>("TIME"));
63 table_.addColumn(ArrayColumnDesc<Float>("TCAL"));
64
65 // new cached columns
66 timeCol_.attach(table_,"TIME");
67 tcalCol_.attach(table_,"TCAL");
68}
69
70/*** rewrite this for handling of GBT data
71uInt STTcal::addEntry( const String& time, const Vector<Float>& cal)
72{
73 // test if this already exists
74 Table result = table_( table_.col("TIME") == time );
75 uInt resultid = 0;
76 if ( result.nrow() > 0) {
77 ROScalarColumn<uInt> c(result, "ID");
78 c.get(0, resultid);
79 } else {
80 uInt rno = table_.nrow();
81 table_.addRow();
82 // get last assigned tcal_id and increment
83 if ( rno > 0 ) {
84 idCol_.get(rno-1, resultid);
85 resultid++;
86 }
87 tcalCol_.put(rno, cal);
88 timeCol_.put(rno, time);
89 idCol_.put(rno, resultid);
90 }
91 return resultid;
92}
93***/
94
95uInt STTcal::addEntry( const String& time, const Vector<Float>& cal)
96{
97 // test if this already exists
98 // TT - different Tcal values for each polarization, feed, and
99 // data description. So there may be multiple entries for the same
100 // time stamp.
101 uInt resultid;
102 uInt rno = table_.nrow();
103 //table_.addRow();
104 // get last assigned tcal_id and increment
105 if ( rno == 0 ) {
106 resultid = 0;
107 }
108 else {
109 idCol_.get(rno-1, resultid);
110 resultid++;
111 }
112 table_.addRow();
113 tcalCol_.put(rno, cal);
114 timeCol_.put(rno, time);
115 idCol_.put(rno, resultid);
116 return resultid;
117}
118
119
120void STTcal::getEntry( String& time, Vector<Float>& tcal, uInt id )
121{
122 Table t = table_(table_.col("ID") == Int(id) );
123 if (t.nrow() == 0 ) {
124 throw(AipsError("STTcal::getEntry - id out of range"));
125 }
126 ROTableRow row(t);
127 // get first row - there should only be one matching id
128 const TableRecord& rec = row.get(0);
129 time = rec.asString("TIME");
130 tcal.resize();
131 Vector<Float> out;
132 rec.get("TCAL",out);
133 tcal = out;
134}
135
136} //namespace
Note: See TracBrowser for help on using the repository browser.