source: branches/asap-3.x/src/STFocus.cpp@ 3122

Last change on this file since 3122 was 1587, checked in by Malte Marquarding, 15 years ago

Removed debug cout

File size: 5.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(const Scantable& parent ) :
31 STSubTable( parent, name_ )
32{
33 setup();
34}
35
36STFocus::STFocus( casa::Table tab ) :
37 STSubTable(tab, name_)
38{
39 parangleCol_.attach(table_,"PARANGLE");
40 rotationCol_.attach(table_,"ROTATION");
41 axisCol_.attach(table_,"AXIS");
42 tanCol_.attach(table_,"TAN");
43 handCol_.attach(table_,"HAND");
44 userCol_.attach(table_,"USERPHASE");
45 mountCol_.attach(table_,"MOUNT");
46 xyphCol_.attach(table_,"XYPHASE");
47 xyphoffCol_.attach(table_,"XYPHASEOFFSET");
48}
49
50STFocus::~STFocus()
51{
52}
53
54STFocus& STFocus::operator =( const STFocus & other )
55{
56 if (this != &other) {
57 static_cast<STSubTable&>(*this) = other;
58 parangleCol_.attach(table_,"PARANGLE");
59 rotationCol_.attach(table_,"ROTATION");
60 axisCol_.attach(table_,"AXIS");
61 tanCol_.attach(table_,"TAN");
62 handCol_.attach(table_,"HAND");
63 userCol_.attach(table_,"USERPHASE");
64 mountCol_.attach(table_,"MOUNT");
65 xyphCol_.attach(table_,"XYPHASE");
66 xyphoffCol_.attach(table_,"XYPHASEOFFSET");
67 }
68 return *this;
69}
70void STFocus::setup( )
71{
72 // add to base class table
73 table_.addColumn(ScalarColumnDesc<Float>("PARANGLE"));
74 table_.addColumn(ScalarColumnDesc<Float>("ROTATION"));
75 table_.addColumn(ScalarColumnDesc<Float>("AXIS"));
76 table_.addColumn(ScalarColumnDesc<Float>("TAN"));
77 table_.addColumn(ScalarColumnDesc<Float>("HAND"));
78 table_.addColumn(ScalarColumnDesc<Float>("USERPHASE"));
79 table_.addColumn(ScalarColumnDesc<Float>("MOUNT"));
80 table_.addColumn(ScalarColumnDesc<Float>("XYPHASE"));
81 table_.addColumn(ScalarColumnDesc<Float>("XYPHASEOFFSET"));
82 table_.rwKeywordSet().define("PARALLACTIFY", False);
83
84 // new cached columns
85 parangleCol_.attach(table_,"PARANGLE");
86 rotationCol_.attach(table_,"ROTATION");
87 axisCol_.attach(table_,"AXIS");
88 tanCol_.attach(table_,"TAN");
89 handCol_.attach(table_,"HAND");
90 userCol_.attach(table_,"USERPHASE");
91 mountCol_.attach(table_,"MOUNT");
92 xyphCol_.attach(table_,"XYPHASE");
93 xyphoffCol_.attach(table_,"XYPHASEOFFSET");
94}
95
96 uInt STFocus::addEntry( Float pa, Float fax, Float ftan, Float frot, Float hand,
97 Float user, Float mount,
98 Float xyphase, Float xyphaseoffset)
99{
100 Table result = table_( near(table_.col("PARANGLE"), pa)
101 && near(table_.col("ROTATION"), frot)
102 && near(table_.col("AXIS"), fax)
103 && near(table_.col("TAN"), ftan)
104 && near(table_.col("HAND"), hand)
105 && near(table_.col("USERPHASE"), user)
106 && near(table_.col("MOUNT"), mount)
107 && near(table_.col("XYPHASE"), xyphase)
108 && near(table_.col("XYPHASEOFFSET"), xyphaseoffset)
109 );
110 uInt resultid = 0;
111 if ( result.nrow() > 0) {
112 ROScalarColumn<uInt> c(result, "ID");
113 c.get(0, resultid);
114 } else {
115 uInt rno = table_.nrow();
116 table_.addRow();
117 // get last assigned _id and increment
118 if ( rno > 0 ) {
119 idCol_.get(rno-1, resultid);
120 resultid++;
121 }
122 parangleCol_.put(rno, pa);
123 rotationCol_.put(rno, frot);
124 axisCol_.put(rno, fax);
125 tanCol_.put(rno, ftan);
126 handCol_.put(rno, hand);
127 userCol_.put(rno, user);
128 mountCol_.put(rno, mount);
129 xyphCol_.put(rno, xyphase);
130 xyphoffCol_.put(rno, xyphaseoffset);
131 idCol_.put(rno, resultid);
132 }
133 return resultid;
134}
135
136 void STFocus::getEntry( Float& pa, Float& rotation, Float& angle, Float& ftan,
137 Float& hand, Float& user, Float& mount,
138 Float& xyphase, Float& xyphaseoffset,
139 uInt id) const
140{
141 Table t = table_(table_.col("ID") == Int(id) );
142 if (t.nrow() == 0 ) {
143 throw(AipsError("STFocus::getEntry - id out of range"));
144 }
145 ROTableRow row(t);
146 // get first row - there should only be one matching id
147 const TableRecord& rec = row.get(0);
148 pa = rec.asFloat("PARANGLE");
149 rotation = rec.asFloat("ROTATION");
150 angle = rec.asFloat("AXIS");
151 ftan = rec.asFloat("TAN");
152 hand = rec.asFloat("HAND");
153 user = rec.asFloat("USERPHASE");
154 mount = rec.asFloat("MOUNT");
155 xyphase = rec.asFloat("XYPHASE");
156 xyphaseoffset = rec.asFloat("XYPHASEOFFSET");
157}
158
159
160casa::Float STFocus::getTotalAngle( casa::uInt id ) const
161{
162 Float total = 0.0f;
163 Table t = table_(table_.col("ID") == Int(id) );
164 if (t.nrow() == 0 ) {
165 throw(AipsError("STFocus::getTotalAngle - id out of range"));
166 }
167 if (table_.keywordSet().asBool("PARALLACTIFY")) {
168 return 0.0f;
169 }
170 ROTableRow row(t);
171 // get first row - there should only be one matching id
172 const TableRecord& rec = row.get(0);
173 total += rec.asFloat("PARANGLE");
174 total += rec.asFloat("ROTATION");
175 total += rec.asFloat("USERPHASE");
176 total += rec.asFloat("MOUNT");
177 return total;
178}
179
180
181casa::Float STFocus::getFeedHand( casa::uInt id ) const
182{
183 Table t = table_(table_.col("ID") == Int(id) );
184 if (t.nrow() == 0 ) {
185 throw(AipsError("STFocus::getEntry - id out of range"));
186 }
187 ROTableRow row(t);
188 const TableRecord& rec = row.get(0);
189 return rec.asFloat("HAND");
190}
191
192void STFocus::setParallactify(bool istrue) {
193 table_.rwKeywordSet().define("PARALLACTIFY", Bool(istrue));
194}
195
196}
Note: See TracBrowser for help on using the repository browser.