[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 | |
---|
| 24 | using namespace casa; |
---|
| 25 | |
---|
| 26 | namespace asap { |
---|
| 27 | |
---|
| 28 | const casa::String STFocus::name_ = "FOCUS"; |
---|
| 29 | |
---|
[849] | 30 | STFocus::STFocus(const Scantable& parent ) : |
---|
| 31 | STSubTable( parent, name_ ) |
---|
[807] | 32 | { |
---|
| 33 | setup(); |
---|
| 34 | } |
---|
| 35 | |
---|
[1586] | 36 | STFocus::STFocus( casa::Table tab ) : |
---|
| 37 | STSubTable(tab, name_) |
---|
[849] | 38 | { |
---|
[1586] | 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 | |
---|
| 50 | STFocus::~STFocus() |
---|
| 51 | { |
---|
| 52 | } |
---|
| 53 | |
---|
[1586] | 54 | STFocus& STFocus::operator =( const STFocus & other ) |
---|
[849] | 55 | { |
---|
| 56 | if (this != &other) { |
---|
| 57 | static_cast<STSubTable&>(*this) = other; |
---|
[1586] | 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 | } |
---|
[1586] | 70 | void STFocus::setup( ) |
---|
[807] | 71 | { |
---|
| 72 | // add to base class table |
---|
[1586] | 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")); |
---|
[1586] | 82 | table_.rwKeywordSet().define("PARALLACTIFY", False); |
---|
[807] | 83 | |
---|
| 84 | // new cached columns |
---|
[1586] | 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 | |
---|
[1586] | 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 | { |
---|
[1586] | 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) |
---|
[2242] | 108 | && near(table_.col("XYPHASEOFFSET"), xyphaseoffset), 1 |
---|
[1586] | 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 | } |
---|
[1586] | 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 | |
---|
[1586] | 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 | { |
---|
[2243] | 141 | Table t = table_(table_.col("ID") == Int(id), 1 ); |
---|
[839] | 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); |
---|
[1586] | 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 | |
---|
[1586] | 160 | casa::Float STFocus::getTotalAngle( casa::uInt id ) const |
---|
[957] | 161 | { |
---|
| 162 | Float total = 0.0f; |
---|
[2243] | 163 | Table t = table_(table_.col("ID") == Int(id), 1 ); |
---|
[957] | 164 | if (t.nrow() == 0 ) { |
---|
[1586] | 165 | throw(AipsError("STFocus::getTotalAngle - id out of range")); |
---|
[957] | 166 | } |
---|
[1586] | 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); |
---|
[1586] | 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 | |
---|
[1586] | 180 | |
---|
| 181 | casa::Float STFocus::getFeedHand( casa::uInt id ) const |
---|
[957] | 182 | { |
---|
[2243] | 183 | Table t = table_(table_.col("ID") == Int(id), 1 ); |
---|
[957] | 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 | |
---|
[1586] | 192 | void STFocus::setParallactify(bool istrue) { |
---|
| 193 | table_.rwKeywordSet().define("PARALLACTIFY", Bool(istrue)); |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | } |
---|