source: branches/Release2.1.2/src/STFocus.cpp

Last change on this file was 957, checked in by mar637, 18 years ago

Polarisation changes according to Ticket #8; Fix Ticket #10

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