source: branches/alma/src/STFocus.cpp@ 2691

Last change on this file since 2691 was 1757, checked in by Kana Sugimoto, 14 years ago

New Development: Yes

JIRA Issue: Yes (CAS-2211)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: ASAP 3.0.0 interface changes

Test Programs:

Put in Release Notes: Yes

Module(s): all the CASA sd tools and tasks are affected.

Description: Merged ATNF-ASAP 3.0.0 developments to CASA (alma) branch.

Note you also need to update casa/code/atnf.


File size: 5.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
[1757]36STFocus::STFocus( casa::Table tab ) :
37 STSubTable(tab, name_)
[849]38{
[1757]39 parangleCol_.attach(table_,"PARANGLE");
[849]40 rotationCol_.attach(table_,"ROTATION");
[957]41 axisCol_.attach(table_,"AXIS");
[849]42 tanCol_.attach(table_,"TAN");
[957]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");
[849]48}
[807]49
50STFocus::~STFocus()
51{
52}
53
[1757]54STFocus& STFocus::operator =( const STFocus & other )
[849]55{
56 if (this != &other) {
57 static_cast<STSubTable&>(*this) = other;
[1757]58 parangleCol_.attach(table_,"PARANGLE");
[849]59 rotationCol_.attach(table_,"ROTATION");
[957]60 axisCol_.attach(table_,"AXIS");
[849]61 tanCol_.attach(table_,"TAN");
[957]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");
[849]67 }
68 return *this;
69}
[1757]70void STFocus::setup( )
[807]71{
72 // add to base class table
[1757]73 table_.addColumn(ScalarColumnDesc<Float>("PARANGLE"));
[807]74 table_.addColumn(ScalarColumnDesc<Float>("ROTATION"));
[957]75 table_.addColumn(ScalarColumnDesc<Float>("AXIS"));
[807]76 table_.addColumn(ScalarColumnDesc<Float>("TAN"));
[957]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"));
[1757]82 table_.rwKeywordSet().define("PARALLACTIFY", False);
[807]83
84 // new cached columns
[1757]85 parangleCol_.attach(table_,"PARANGLE");
[807]86 rotationCol_.attach(table_,"ROTATION");
[957]87 axisCol_.attach(table_,"AXIS");
[807]88 tanCol_.attach(table_,"TAN");
[957]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");
[807]94}
95
[1757]96 uInt STFocus::addEntry( Float pa, Float fax, Float ftan, Float frot, Float hand,
97 Float user, Float mount,
98 Float xyphase, Float xyphaseoffset)
[807]99{
[1757]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 );
[807]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 }
[1757]122 parangleCol_.put(rno, pa);
[957]123 rotationCol_.put(rno, frot);
124 axisCol_.put(rno, fax);
[807]125 tanCol_.put(rno, ftan);
[957]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);
[807]131 idCol_.put(rno, resultid);
132 }
133 return resultid;
134}
135
[1757]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
[839]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);
[1757]148 pa = rec.asFloat("PARANGLE");
[839]149 rotation = rec.asFloat("ROTATION");
[957]150 angle = rec.asFloat("AXIS");
[839]151 ftan = rec.asFloat("TAN");
[957]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");
[807]157}
[839]158
[849]159
[1757]160casa::Float STFocus::getTotalAngle( casa::uInt id ) const
[957]161{
162 Float total = 0.0f;
163 Table t = table_(table_.col("ID") == Int(id) );
164 if (t.nrow() == 0 ) {
[1757]165 throw(AipsError("STFocus::getTotalAngle - id out of range"));
[957]166 }
[1757]167 if (table_.keywordSet().asBool("PARALLACTIFY")) {
168 return 0.0f;
169 }
[957]170 ROTableRow row(t);
171 // get first row - there should only be one matching id
172 const TableRecord& rec = row.get(0);
[1757]173 total += rec.asFloat("PARANGLE");
[957]174 total += rec.asFloat("ROTATION");
175 total += rec.asFloat("USERPHASE");
176 total += rec.asFloat("MOUNT");
177 return total;
[839]178}
[957]179
[1757]180
181casa::Float STFocus::getFeedHand( casa::uInt id ) const
[957]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
[1757]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.