source: trunk/src/STFocus.cpp@ 828

Last change on this file since 828 was 807, checked in by mar637, 19 years ago

Focus subtable for Scantable. Initial revision.

File size: 1.7 KB
Line 
1//
2// C++ Implementation: STFocus
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/TableRecord.h>
17#include <tables/Tables/TableParse.h>
18#include <tables/Tables/TableRow.h>
19#include <casa/Containers/RecordField.h>
20
21#include "STFocus.h"
22
23
24using namespace casa;
25
26namespace asap {
27
28const casa::String STFocus::name_ = "FOCUS";
29
30STFocus::STFocus(casa::Table::TableType tt) :
31 STSubTable( name_, tt )
32{
33 setup();
34}
35
36
37STFocus::~STFocus()
38{
39}
40
41void asap::STFocus::setup( )
42{
43 // add to base class table
44 table_.addColumn(ScalarColumnDesc<Float>("ROTATION"));
45 table_.addColumn(ScalarColumnDesc<Float>("ANGLE"));
46 table_.addColumn(ScalarColumnDesc<Float>("TAN"));
47
48 // new cached columns
49 rotationCol_.attach(table_,"ROTATION");
50 angleCol_.attach(table_,"ANGLE");
51 tanCol_.attach(table_,"TAN");
52}
53
54uInt STFocus::addEntry( Float rotation, Float angle, Float ftan)
55{
56 Table result = table_( near(table_.col("ROTATION"), rotation)
57 && near(table_.col("ANGLE"), angle)
58 && near(table_.col("TAN"), ftan) );
59 uInt resultid = 0;
60 if ( result.nrow() > 0) {
61 ROScalarColumn<uInt> c(result, "ID");
62 c.get(0, resultid);
63 } else {
64 uInt rno = table_.nrow();
65 table_.addRow();
66 // get last assigned _id and increment
67 if ( rno > 0 ) {
68 idCol_.get(rno-1, resultid);
69 resultid++;
70 }
71 rotationCol_.put(rno, rotation);
72 angleCol_.put(rno, angle);
73 tanCol_.put(rno, ftan);
74 idCol_.put(rno, resultid);
75 }
76 return resultid;
77}
78
79}
Note: See TracBrowser for help on using the repository browser.