source: trunk/src/STTcal.cpp@ 829

Last change on this file since 829 was 810, checked in by mar637, 19 years ago

Tcal subtable for Scantable. Initial revision.

File size: 1.6 KB
RevLine 
[810]1//
2// C++ Implementation: STTcal
3//
4// Description:
5//
6//
7// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006
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/ScaColDesc.h>
16#include <tables/Tables/ArrColDesc.h>
17#include <tables/Tables/TableRecord.h>
18#include <tables/Tables/TableParse.h>
19#include <tables/Tables/TableRow.h>
20#include <casa/Containers/RecordField.h>
21
22#include "STTcal.h"
23
24
25using namespace casa;
26
27namespace asap {
28
29const casa::String STTcal::name_ = "TCAL";
30
31STTcal::STTcal(casa::Table::TableType tt) :
32 STSubTable( name_, tt )
33{
34 setup();
35}
36
37
38STTcal::~STTcal()
39{
40}
41
42void asap::STTcal::setup( )
43{
44 // add to base class table
45 table_.addColumn(ScalarColumnDesc<String>("TIME"));
46 table_.addColumn(ArrayColumnDesc<Float>("TCAL"));
47
48 // new cached columns
49 timeCol_.attach(table_,"TIME");
50 tcalCol_.attach(table_,"TCAL");
51}
52
53uInt STTcal::addEntry( const String& time, const Vector<Float>& cal)
54{
55 // test if this already exists
56 Table result = table_( table_.col("TIME") == time );
57 uInt resultid = 0;
58 if ( result.nrow() > 0) {
59 ROScalarColumn<uInt> c(result, "ID");
60 c.get(0, resultid);
61 } else {
62 uInt rno = table_.nrow();
63 table_.addRow();
64 // get last assigned tcal_id and increment
65 if ( rno > 0 ) {
66 idCol_.get(rno-1, resultid);
67 resultid++;
68 }
69 tcalCol_.put(rno, cal);
70 timeCol_.put(rno, time);
71 idCol_.put(rno, resultid);
72 }
73 return resultid;
74}
75
76}
77
Note: See TracBrowser for help on using the repository browser.