source: trunk/src/STFocus.cpp@ 928

Last change on this file since 928 was 896, checked in by mar637, 19 years ago

enable polarimetry in asap2

File size: 2.7 KB
RevLine 
[807]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
[849]30STFocus::STFocus(const Scantable& parent ) :
31 STSubTable( parent, name_ )
[807]32{
33 setup();
34}
35
[856]36asap::STFocus::STFocus( casa::Table tab ) : STSubTable(tab, name_)
[849]37{
38 rotationCol_.attach(table_,"ROTATION");
39 angleCol_.attach(table_,"ANGLE");
40 tanCol_.attach(table_,"TAN");
41}
[807]42
43STFocus::~STFocus()
44{
45}
46
[896]47STFocus& asap::STFocus::operator =( const STFocus & other )
[849]48{
49 if (this != &other) {
50 static_cast<STSubTable&>(*this) = other;
51 rotationCol_.attach(table_,"ROTATION");
52 angleCol_.attach(table_,"ANGLE");
53 tanCol_.attach(table_,"TAN");
54 }
55 return *this;
56}
[807]57void asap::STFocus::setup( )
58{
59 // add to base class table
60 table_.addColumn(ScalarColumnDesc<Float>("ROTATION"));
61 table_.addColumn(ScalarColumnDesc<Float>("ANGLE"));
62 table_.addColumn(ScalarColumnDesc<Float>("TAN"));
63
64 // new cached columns
65 rotationCol_.attach(table_,"ROTATION");
66 angleCol_.attach(table_,"ANGLE");
67 tanCol_.attach(table_,"TAN");
68}
69
70uInt STFocus::addEntry( Float rotation, Float angle, Float ftan)
71{
72 Table result = table_( near(table_.col("ROTATION"), rotation)
73 && near(table_.col("ANGLE"), angle)
74 && near(table_.col("TAN"), ftan) );
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 _id and increment
83 if ( rno > 0 ) {
84 idCol_.get(rno-1, resultid);
85 resultid++;
86 }
87 rotationCol_.put(rno, rotation);
88 angleCol_.put(rno, angle);
89 tanCol_.put(rno, ftan);
90 idCol_.put(rno, resultid);
91 }
92 return resultid;
93}
94
[839]95void asap::STFocus::getEntry( Float& rotation, Float& angle, Float& ftan,
[896]96 uInt id) const
[839]97{
98 Table t = table_(table_.col("ID") == Int(id) );
99 if (t.nrow() == 0 ) {
100 throw(AipsError("STFocus::getEntry - id out of range"));
101 }
102 ROTableRow row(t);
103 // get first row - there should only be one matching id
104 const TableRecord& rec = row.get(0);
105 rotation = rec.asFloat("ROTATION");
106 angle = rec.asFloat("ANGLE");
107 ftan = rec.asFloat("TAN");
[807]108}
[839]109
[849]110
[839]111}
Note: See TracBrowser for help on using the repository browser.