[2] | 1 | //#---------------------------------------------------------------------------
|
---|
| 2 | //# SDMemTable.cc: A MemoryTable container for single dish integrations
|
---|
| 3 | //#---------------------------------------------------------------------------
|
---|
| 4 | //# Copyright (C) 2004
|
---|
[125] | 5 | //# ATNF
|
---|
[2] | 6 | //#
|
---|
| 7 | //# This program is free software; you can redistribute it and/or modify it
|
---|
| 8 | //# under the terms of the GNU General Public License as published by the Free
|
---|
| 9 | //# Software Foundation; either version 2 of the License, or (at your option)
|
---|
| 10 | //# any later version.
|
---|
| 11 | //#
|
---|
| 12 | //# This program is distributed in the hope that it will be useful, but
|
---|
| 13 | //# WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
---|
| 15 | //# Public License for more details.
|
---|
| 16 | //#
|
---|
| 17 | //# You should have received a copy of the GNU General Public License along
|
---|
| 18 | //# with this program; if not, write to the Free Software Foundation, Inc.,
|
---|
| 19 | //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
|
---|
| 20 | //#
|
---|
| 21 | //# Correspondence concerning this software should be addressed as follows:
|
---|
| 22 | //# Internet email: Malte.Marquarding@csiro.au
|
---|
| 23 | //# Postal address: Malte Marquarding,
|
---|
| 24 | //# Australia Telescope National Facility,
|
---|
| 25 | //# P.O. Box 76,
|
---|
| 26 | //# Epping, NSW, 2121,
|
---|
| 27 | //# AUSTRALIA
|
---|
| 28 | //#
|
---|
| 29 | //# $Id:
|
---|
| 30 | //#---------------------------------------------------------------------------
|
---|
| 31 |
|
---|
[206] | 32 | #include <map>
|
---|
| 33 |
|
---|
[125] | 34 | #include <casa/aips.h>
|
---|
[80] | 35 | #include <casa/iostream.h>
|
---|
| 36 | #include <casa/iomanip.h>
|
---|
| 37 | #include <casa/Arrays/Array.h>
|
---|
| 38 | #include <casa/Arrays/ArrayMath.h>
|
---|
| 39 | #include <casa/Arrays/MaskArrMath.h>
|
---|
| 40 | #include <casa/Arrays/ArrayLogical.h>
|
---|
| 41 | #include <casa/Arrays/ArrayAccessor.h>
|
---|
[206] | 42 | #include <casa/Arrays/Vector.h>
|
---|
[2] | 43 |
|
---|
[80] | 44 | #include <tables/Tables/TableParse.h>
|
---|
| 45 | #include <tables/Tables/TableDesc.h>
|
---|
| 46 | #include <tables/Tables/SetupNewTab.h>
|
---|
| 47 | #include <tables/Tables/ScaColDesc.h>
|
---|
| 48 | #include <tables/Tables/ArrColDesc.h>
|
---|
[2] | 49 |
|
---|
[80] | 50 | #include <tables/Tables/ExprNode.h>
|
---|
| 51 | #include <tables/Tables/ScalarColumn.h>
|
---|
| 52 | #include <tables/Tables/ArrayColumn.h>
|
---|
| 53 | #include <tables/Tables/TableRecord.h>
|
---|
| 54 | #include <measures/Measures/MFrequency.h>
|
---|
| 55 | #include <measures/Measures/MeasTable.h>
|
---|
[105] | 56 | #include <coordinates/Coordinates/CoordinateUtil.h>
|
---|
[80] | 57 | #include <casa/Quanta/MVTime.h>
|
---|
[281] | 58 | #include <casa/Quanta/MVAngle.h>
|
---|
[2] | 59 |
|
---|
[215] | 60 | #include "SDDefs.h"
|
---|
[2] | 61 | #include "SDMemTable.h"
|
---|
| 62 | #include "SDContainer.h"
|
---|
| 63 |
|
---|
[206] | 64 |
|
---|
[125] | 65 | using namespace casa;
|
---|
[83] | 66 | using namespace asap;
|
---|
[2] | 67 |
|
---|
[18] | 68 | SDMemTable::SDMemTable() :
|
---|
| 69 | IFSel_(0),
|
---|
| 70 | beamSel_(0),
|
---|
[206] | 71 | polSel_(0)
|
---|
| 72 | {
|
---|
[18] | 73 | setup();
|
---|
| 74 | }
|
---|
[206] | 75 |
|
---|
[2] | 76 | SDMemTable::SDMemTable(const std::string& name) :
|
---|
| 77 | IFSel_(0),
|
---|
| 78 | beamSel_(0),
|
---|
[206] | 79 | polSel_(0)
|
---|
| 80 | {
|
---|
[50] | 81 | Table tab(name);
|
---|
[22] | 82 | table_ = tab.copyToMemoryTable("dummy");
|
---|
[206] | 83 | //cerr << "hello from C SDMemTable @ " << this << endl;
|
---|
[2] | 84 | }
|
---|
| 85 |
|
---|
[206] | 86 | SDMemTable::SDMemTable(const SDMemTable& other, Bool clear)
|
---|
| 87 | {
|
---|
[148] | 88 | IFSel_= other.IFSel_;
|
---|
| 89 | beamSel_= other.beamSel_;
|
---|
| 90 | polSel_= other.polSel_;
|
---|
| 91 | chanMask_ = other.chanMask_;
|
---|
| 92 | table_ = other.table_.copyToMemoryTable(String("dummy"));
|
---|
[2] | 93 | // clear all rows()
|
---|
[16] | 94 | if (clear) {
|
---|
[148] | 95 | table_.removeRow(this->table_.rowNumbers());
|
---|
[16] | 96 | } else {
|
---|
[148] | 97 | IFSel_ = other.IFSel_;
|
---|
| 98 | beamSel_ = other.beamSel_;
|
---|
| 99 | polSel_ = other.polSel_;
|
---|
[16] | 100 | }
|
---|
[206] | 101 | //cerr << "hello from CC SDMemTable @ " << this << endl;
|
---|
[2] | 102 | }
|
---|
| 103 |
|
---|
[80] | 104 | SDMemTable::SDMemTable(const Table& tab, const std::string& exprs) :
|
---|
[2] | 105 | IFSel_(0),
|
---|
| 106 | beamSel_(0),
|
---|
[206] | 107 | polSel_(0)
|
---|
| 108 | {
|
---|
[2] | 109 | Table t = tableCommand(exprs,tab);
|
---|
[89] | 110 | if (t.nrow() == 0)
|
---|
| 111 | throw(AipsError("Query unsuccessful."));
|
---|
[22] | 112 | table_ = t.copyToMemoryTable("dummy");
|
---|
[2] | 113 | }
|
---|
| 114 |
|
---|
[206] | 115 | SDMemTable::~SDMemTable()
|
---|
| 116 | {
|
---|
[105] | 117 | //cerr << "goodbye from SDMemTable @ " << this << endl;
|
---|
[2] | 118 | }
|
---|
| 119 |
|
---|
[206] | 120 | SDMemTable SDMemTable::getScan(Int scanID) const
|
---|
| 121 | {
|
---|
[80] | 122 | String cond("SELECT * from $1 WHERE SCANID == ");
|
---|
| 123 | cond += String::toString(scanID);
|
---|
| 124 | return SDMemTable(table_, cond);
|
---|
[2] | 125 | }
|
---|
| 126 |
|
---|
[206] | 127 | SDMemTable &SDMemTable::operator=(const SDMemTable& other)
|
---|
| 128 | {
|
---|
[148] | 129 | if (this != &other) {
|
---|
| 130 | IFSel_= other.IFSel_;
|
---|
| 131 | beamSel_= other.beamSel_;
|
---|
| 132 | polSel_= other.polSel_;
|
---|
| 133 | chanMask_.resize(0);
|
---|
| 134 | chanMask_ = other.chanMask_;
|
---|
| 135 | table_ = other.table_.copyToMemoryTable(String("dummy"));
|
---|
[206] | 136 | }
|
---|
| 137 | //cerr << "hello from ASS SDMemTable @ " << this << endl;
|
---|
[138] | 138 | return *this;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
[206] | 141 | SDMemTable SDMemTable::getSource(const std::string& source) const
|
---|
| 142 | {
|
---|
[80] | 143 | String cond("SELECT * from $1 WHERE SRCNAME == ");
|
---|
| 144 | cond += source;
|
---|
| 145 | return SDMemTable(table_, cond);
|
---|
| 146 | }
|
---|
| 147 |
|
---|
[206] | 148 | void SDMemTable::setup()
|
---|
| 149 | {
|
---|
[2] | 150 | TableDesc td("", "1", TableDesc::Scratch);
|
---|
| 151 | td.comment() = "A SDMemTable";
|
---|
| 152 | td.addColumn(ScalarColumnDesc<Double>("TIME"));
|
---|
| 153 | td.addColumn(ScalarColumnDesc<String>("SRCNAME"));
|
---|
| 154 | td.addColumn(ArrayColumnDesc<Float>("SPECTRA"));
|
---|
| 155 | td.addColumn(ArrayColumnDesc<uChar>("FLAGTRA"));
|
---|
[89] | 156 | td.addColumn(ArrayColumnDesc<Float>("TSYS"));
|
---|
| 157 | td.addColumn(ScalarColumnDesc<Int>("SCANID"));
|
---|
| 158 | td.addColumn(ScalarColumnDesc<Double>("INTERVAL"));
|
---|
[39] | 159 | td.addColumn(ArrayColumnDesc<uInt>("FREQID"));
|
---|
[78] | 160 | td.addColumn(ArrayColumnDesc<Double>("DIRECTION"));
|
---|
[105] | 161 | td.addColumn(ScalarColumnDesc<String>("FIELDNAME"));
|
---|
| 162 | td.addColumn(ScalarColumnDesc<String>("TCALTIME"));
|
---|
| 163 | td.addColumn(ArrayColumnDesc<Float>("TCAL"));
|
---|
| 164 | td.addColumn(ScalarColumnDesc<Float>("AZIMUTH"));
|
---|
| 165 | td.addColumn(ScalarColumnDesc<Float>("ELEVATION"));
|
---|
| 166 | td.addColumn(ScalarColumnDesc<Float>("PARANGLE"));
|
---|
| 167 | td.addColumn(ScalarColumnDesc<Int>("REFBEAM"));
|
---|
[206] | 168 | td.addColumn(ArrayColumnDesc<String>("HISTORY"));
|
---|
[105] | 169 |
|
---|
[2] | 170 | // Now create a new table from the description.
|
---|
[18] | 171 |
|
---|
[22] | 172 | SetupNewTable aNewTab("dummy", td, Table::New);
|
---|
[89] | 173 | table_ = Table(aNewTab, Table::Memory, 0);
|
---|
[2] | 174 | }
|
---|
| 175 |
|
---|
[206] | 176 | std::string SDMemTable::getSourceName(Int whichRow) const
|
---|
| 177 | {
|
---|
[2] | 178 | ROScalarColumn<String> src(table_, "SRCNAME");
|
---|
| 179 | String name;
|
---|
| 180 | src.get(whichRow, name);
|
---|
| 181 | return name;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
[281] | 184 | std::string SDMemTable::getTime(Int whichRow, Bool showDate) const
|
---|
[206] | 185 | {
|
---|
[2] | 186 | Double tm;
|
---|
[281] | 187 | if (whichRow > -1) {
|
---|
| 188 | ROScalarColumn<Double> src(table_, "TIME");
|
---|
| 189 | src.get(whichRow, tm);
|
---|
| 190 | } else {
|
---|
| 191 | table_.keywordSet().get("UTC",tm);
|
---|
| 192 | }
|
---|
[50] | 193 | MVTime mvt(tm);
|
---|
[281] | 194 | if (showDate)
|
---|
| 195 | mvt.setFormat(MVTime::YMD);
|
---|
| 196 | else
|
---|
| 197 | mvt.setFormat(MVTime::TIME);
|
---|
[50] | 198 | ostringstream oss;
|
---|
| 199 | oss << mvt;
|
---|
[281] | 200 | return String(oss);
|
---|
[2] | 201 | }
|
---|
[281] | 202 |
|
---|
[206] | 203 | double SDMemTable::getInterval(Int whichRow) const
|
---|
| 204 | {
|
---|
[50] | 205 | ROScalarColumn<Double> src(table_, "INTERVAL");
|
---|
| 206 | Double intval;
|
---|
| 207 | src.get(whichRow, intval);
|
---|
| 208 | return intval;
|
---|
| 209 | }
|
---|
[2] | 210 |
|
---|
[206] | 211 | bool SDMemTable::setIF(Int whichIF)
|
---|
| 212 | {
|
---|
[50] | 213 | if ( whichIF >= 0 && whichIF < nIF()) {
|
---|
[2] | 214 | IFSel_ = whichIF;
|
---|
| 215 | return true;
|
---|
[50] | 216 | }
|
---|
| 217 | return false;
|
---|
[2] | 218 | }
|
---|
[50] | 219 |
|
---|
[206] | 220 | bool SDMemTable::setBeam(Int whichBeam)
|
---|
| 221 | {
|
---|
[50] | 222 | if ( whichBeam >= 0 && whichBeam < nBeam()) {
|
---|
[2] | 223 | beamSel_ = whichBeam;
|
---|
| 224 | return true;
|
---|
[50] | 225 | }
|
---|
| 226 | return false;
|
---|
| 227 | }
|
---|
[2] | 228 |
|
---|
[206] | 229 | bool SDMemTable::setPol(Int whichPol)
|
---|
| 230 | {
|
---|
[50] | 231 | if ( whichPol >= 0 && whichPol < nPol()) {
|
---|
[2] | 232 | polSel_ = whichPol;
|
---|
| 233 | return true;
|
---|
[50] | 234 | }
|
---|
| 235 | return false;
|
---|
[2] | 236 | }
|
---|
| 237 |
|
---|
[206] | 238 | bool SDMemTable::setMask(std::vector<int> whichChans)
|
---|
| 239 | {
|
---|
[16] | 240 | ROArrayColumn<uChar> spec(table_, "FLAGTRA");
|
---|
| 241 | std::vector<int>::iterator it;
|
---|
| 242 | uInt n = spec.shape(0)(3);
|
---|
[105] | 243 | if (whichChans.empty()) {
|
---|
| 244 | chanMask_ = std::vector<bool>(n,true);
|
---|
| 245 | return true;
|
---|
| 246 | }
|
---|
[16] | 247 | chanMask_.resize(n,true);
|
---|
[39] | 248 | for (it = whichChans.begin(); it != whichChans.end(); ++it) {
|
---|
[105] | 249 | if (*it < n) {
|
---|
[16] | 250 | chanMask_[*it] = false;
|
---|
[105] | 251 | }
|
---|
[16] | 252 | }
|
---|
[2] | 253 | return true;
|
---|
| 254 | }
|
---|
| 255 |
|
---|
[16] | 256 | std::vector<bool> SDMemTable::getMask(Int whichRow) const {
|
---|
| 257 | std::vector<bool> mask;
|
---|
| 258 | ROArrayColumn<uChar> spec(table_, "FLAGTRA");
|
---|
| 259 | Array<uChar> arr;
|
---|
| 260 | spec.get(whichRow, arr);
|
---|
[206] | 261 | ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr);
|
---|
[16] | 262 | aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
|
---|
[206] | 263 | ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0);
|
---|
[16] | 264 | aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
|
---|
[206] | 265 | ArrayAccessor<uChar, Axis<asap::PolAxis> > aa2(aa1);
|
---|
[16] | 266 | aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
|
---|
| 267 |
|
---|
| 268 | Bool useUserMask = ( chanMask_.size() == arr.shape()(3) );
|
---|
| 269 |
|
---|
| 270 | std::vector<bool> tmp;
|
---|
| 271 | tmp = chanMask_; // WHY the fxxx do I have to make a copy here
|
---|
| 272 | std::vector<bool>::iterator miter;
|
---|
| 273 | miter = tmp.begin();
|
---|
| 274 |
|
---|
[206] | 275 | for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
|
---|
[16] | 276 | bool out =!static_cast<bool>(*i);
|
---|
| 277 | if (useUserMask) {
|
---|
| 278 | out = out && (*miter);
|
---|
| 279 | miter++;
|
---|
| 280 | }
|
---|
| 281 | mask.push_back(out);
|
---|
[89] | 282 | }
|
---|
[16] | 283 | return mask;
|
---|
[2] | 284 | }
|
---|
[206] | 285 | std::vector<float> SDMemTable::getSpectrum(Int whichRow) const
|
---|
| 286 | {
|
---|
[2] | 287 | std::vector<float> spectrum;
|
---|
| 288 | ROArrayColumn<Float> spec(table_, "SPECTRA");
|
---|
| 289 | Array<Float> arr;
|
---|
| 290 | spec.get(whichRow, arr);
|
---|
[206] | 291 | ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr);
|
---|
[2] | 292 | aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
|
---|
[206] | 293 | ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0);
|
---|
[2] | 294 | aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
|
---|
[206] | 295 | ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1);
|
---|
[16] | 296 | aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
|
---|
[206] | 297 | for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
|
---|
[16] | 298 | spectrum.push_back(*i);
|
---|
[2] | 299 | }
|
---|
| 300 | return spectrum;
|
---|
| 301 | }
|
---|
[206] | 302 | std::vector<string> SDMemTable::getCoordInfo() const
|
---|
| 303 | {
|
---|
[105] | 304 | String un;
|
---|
| 305 | Table t = table_.keywordSet().asTable("FREQUENCIES");
|
---|
| 306 | String sunit;
|
---|
| 307 | t.keywordSet().get("UNIT",sunit);
|
---|
| 308 | String dpl;
|
---|
| 309 | t.keywordSet().get("DOPPLER",dpl);
|
---|
| 310 | if (dpl == "") dpl = "RADIO";
|
---|
| 311 | String rfrm;
|
---|
| 312 | t.keywordSet().get("REFFRAME",rfrm);
|
---|
| 313 | std::vector<string> inf;
|
---|
| 314 | inf.push_back(sunit);
|
---|
| 315 | inf.push_back(rfrm);
|
---|
| 316 | inf.push_back(dpl);
|
---|
[263] | 317 | t.keywordSet().get("BASEREFFRAME",rfrm);
|
---|
| 318 | inf.push_back(rfrm);
|
---|
[105] | 319 | return inf;
|
---|
| 320 | }
|
---|
[39] | 321 |
|
---|
[206] | 322 | void SDMemTable::setCoordInfo(std::vector<string> theinfo)
|
---|
| 323 | {
|
---|
[105] | 324 | std::vector<string>::iterator it;
|
---|
| 325 | String un,rfrm,dpl;
|
---|
| 326 | un = theinfo[0];
|
---|
| 327 | rfrm = theinfo[1];
|
---|
| 328 | dpl = theinfo[2];
|
---|
| 329 |
|
---|
| 330 | Table t = table_.rwKeywordSet().asTable("FREQUENCIES");
|
---|
| 331 | Vector<Double> rstf;
|
---|
| 332 | t.keywordSet().get("RESTFREQS",rstf);
|
---|
| 333 | Bool canDo = True;
|
---|
| 334 | Unit u1("km/s");Unit u2("Hz");
|
---|
| 335 | if (Unit(un) == u1) {
|
---|
| 336 | Vector<Double> rstf;
|
---|
| 337 | t.keywordSet().get("RESTFREQS",rstf);
|
---|
| 338 | if (rstf.nelements() == 0) {
|
---|
| 339 | throw(AipsError("Can't set unit to km/s if no restfrequencies are specified"));
|
---|
| 340 | }
|
---|
| 341 | } else if (Unit(un) != u2 && un != "") {
|
---|
| 342 | throw(AipsError("Unit not conformant with Spectral Coordinates"));
|
---|
| 343 | }
|
---|
| 344 | t.rwKeywordSet().define("UNIT", un);
|
---|
[275] | 345 | //
|
---|
[105] | 346 | MFrequency::Types mdr;
|
---|
| 347 | if (!MFrequency::getType(mdr, rfrm)) {
|
---|
| 348 |
|
---|
| 349 | Int a,b;const uInt* c;
|
---|
| 350 | const String* valid = MFrequency::allMyTypes(a, b, c);
|
---|
| 351 | String pfix = "Please specify a legal frame type. Types are\n";
|
---|
| 352 | throw(AipsError(pfix+(*valid)));
|
---|
| 353 | } else {
|
---|
| 354 | t.rwKeywordSet().define("REFFRAME",rfrm);
|
---|
| 355 | }
|
---|
[275] | 356 | //
|
---|
| 357 | MDoppler::Types dtype;
|
---|
| 358 | dpl.upcase();
|
---|
| 359 | if (!MDoppler::getType(dtype, dpl)) {
|
---|
| 360 | throw(AipsError("Doppler type unknown"));
|
---|
| 361 | } else {
|
---|
| 362 | t.rwKeywordSet().define("DOPPLER",dpl);
|
---|
| 363 | }
|
---|
[105] | 364 | }
|
---|
| 365 |
|
---|
[206] | 366 | std::vector<double> SDMemTable::getAbcissa(Int whichRow) const
|
---|
| 367 | {
|
---|
[39] | 368 | std::vector<double> absc(nChan());
|
---|
[89] | 369 | Vector<Double> absc1(nChan());
|
---|
[39] | 370 | indgen(absc1);
|
---|
| 371 | ROArrayColumn<uInt> fid(table_, "FREQID");
|
---|
| 372 | Vector<uInt> v;
|
---|
| 373 | fid.get(whichRow, v);
|
---|
| 374 | uInt specidx = v(IFSel_);
|
---|
| 375 | SpectralCoordinate spc = getCoordinate(specidx);
|
---|
[78] | 376 | Table t = table_.keywordSet().asTable("FREQUENCIES");
|
---|
[206] | 377 |
|
---|
| 378 | MDirection direct = getDirection(whichRow);
|
---|
| 379 |
|
---|
[78] | 380 | ROScalarColumn<Double> tme(table_, "TIME");
|
---|
| 381 | Double obstime;
|
---|
| 382 | tme.get(whichRow,obstime);
|
---|
[89] | 383 | MVEpoch tm2(Quantum<Double>(obstime, Unit(String("d"))));
|
---|
[212] | 384 | MEpoch::Types met = getTimeReference();
|
---|
[206] | 385 | MEpoch epoch(tm2, met);
|
---|
| 386 |
|
---|
[78] | 387 | Vector<Double> antpos;
|
---|
| 388 | table_.keywordSet().get("AntennaPosition", antpos);
|
---|
| 389 | MVPosition mvpos(antpos(0),antpos(1),antpos(2));
|
---|
| 390 | MPosition pos(mvpos);
|
---|
[105] | 391 | String sunit;
|
---|
| 392 | t.keywordSet().get("UNIT",sunit);
|
---|
| 393 | if (sunit == "") sunit = "pixel";
|
---|
| 394 | Unit u(sunit);
|
---|
| 395 | String frm;
|
---|
| 396 | t.keywordSet().get("REFFRAME",frm);
|
---|
| 397 | if (frm == "") frm = "TOPO";
|
---|
| 398 | String dpl;
|
---|
| 399 | t.keywordSet().get("DOPPLER",dpl);
|
---|
| 400 | if (dpl == "") dpl = "RADIO";
|
---|
[78] | 401 | MFrequency::Types mtype;
|
---|
[105] | 402 | if (!MFrequency::getType(mtype, frm)) {
|
---|
[275] | 403 | cout << "Frequency type unknown assuming TOPO" << endl; // SHould never happen
|
---|
[78] | 404 | mtype = MFrequency::TOPO;
|
---|
| 405 | }
|
---|
[275] | 406 | MDoppler::Types dtype;
|
---|
| 407 | if (!MDoppler::getType(dtype, dpl)) {
|
---|
| 408 | cout << "Doppler type unknown assuming RADIO" << endl; // SHould never happen
|
---|
| 409 | dtype = MDoppler::RADIO;
|
---|
| 410 | }
|
---|
[105] | 411 |
|
---|
| 412 | if (!spc.setReferenceConversion(mtype,epoch,pos,direct)) {
|
---|
| 413 | throw(AipsError("Couldn't convert frequency frame."));
|
---|
| 414 | }
|
---|
[78] | 415 |
|
---|
[39] | 416 | if ( u == Unit("km/s") ) {
|
---|
[89] | 417 | Vector<Double> rstf;
|
---|
| 418 | t.keywordSet().get("RESTFREQS",rstf);
|
---|
| 419 | if (rstf.nelements() > 0) {
|
---|
[121] | 420 | if (rstf.nelements() >= nIF())
|
---|
[125] | 421 | spc.selectRestFrequency(uInt(IFSel_));
|
---|
[275] | 422 | spc.setVelocity(u.getName(),dtype);
|
---|
[39] | 423 | Vector<Double> wrld;
|
---|
| 424 | spc.pixelToVelocity(wrld,absc1);
|
---|
| 425 | std::vector<double>::iterator it;
|
---|
| 426 | uInt i = 0;
|
---|
| 427 | for (it = absc.begin(); it != absc.end(); ++it) {
|
---|
[89] | 428 | (*it) = wrld[i];
|
---|
| 429 | i++;
|
---|
[39] | 430 | }
|
---|
| 431 | }
|
---|
| 432 | } else if (u == Unit("Hz")) {
|
---|
| 433 | Vector<String> wau(1); wau = u.getName();
|
---|
| 434 | spc.setWorldAxisUnits(wau);
|
---|
| 435 | std::vector<double>::iterator it;
|
---|
| 436 | Double tmp;
|
---|
| 437 | uInt i = 0;
|
---|
[89] | 438 | for (it = absc.begin(); it != absc.end(); ++it) {
|
---|
[39] | 439 | spc.toWorld(tmp,absc1[i]);
|
---|
| 440 | (*it) = tmp;
|
---|
| 441 | i++;
|
---|
| 442 | }
|
---|
[105] | 443 |
|
---|
| 444 | } else {
|
---|
| 445 | // assume channels/pixels
|
---|
| 446 | std::vector<double>::iterator it;
|
---|
| 447 | uInt i=0;
|
---|
| 448 | for (it = absc.begin(); it != absc.end(); ++it) {
|
---|
| 449 | (*it) = Double(i++);
|
---|
| 450 | }
|
---|
[39] | 451 | }
|
---|
| 452 | return absc;
|
---|
| 453 | }
|
---|
| 454 |
|
---|
[164] | 455 | std::string SDMemTable::getAbcissaString(Int whichRow) const
|
---|
[105] | 456 | {
|
---|
| 457 | ROArrayColumn<uInt> fid(table_, "FREQID");
|
---|
| 458 | Table t = table_.keywordSet().asTable("FREQUENCIES");
|
---|
| 459 | String sunit;
|
---|
| 460 | t.keywordSet().get("UNIT",sunit);
|
---|
| 461 | if (sunit == "") sunit = "pixel";
|
---|
| 462 | Unit u(sunit);
|
---|
| 463 | Vector<uInt> v;
|
---|
| 464 | fid.get(whichRow, v);
|
---|
| 465 | uInt specidx = v(IFSel_);
|
---|
| 466 | SpectralCoordinate spc = getCoordinate(specidx);
|
---|
| 467 | String frm;
|
---|
| 468 | t.keywordSet().get("REFFRAME",frm);
|
---|
[275] | 469 | //
|
---|
[105] | 470 | MFrequency::Types mtype;
|
---|
| 471 | if (!MFrequency::getType(mtype, frm)) {
|
---|
| 472 | cout << "Frequency type unknown assuming TOPO" << endl;
|
---|
| 473 | mtype = MFrequency::TOPO;
|
---|
| 474 | }
|
---|
| 475 | spc.setFrequencySystem(mtype);
|
---|
[275] | 476 | //
|
---|
| 477 | String dpl;
|
---|
| 478 | t.keywordSet().get("DOPPLER",dpl);
|
---|
| 479 | MDoppler::Types dtype;
|
---|
| 480 | MDoppler::getType(dtype, dpl); // Can't fail
|
---|
| 481 | //
|
---|
[105] | 482 | String s = "Channel";
|
---|
| 483 | if (u == Unit("km/s")) {
|
---|
[275] | 484 | spc.setVelocity(u.getName(), dtype);
|
---|
[105] | 485 | s = CoordinateUtil::axisLabel(spc,0,True,True,True);
|
---|
| 486 | } else if (u == Unit("Hz")) {
|
---|
| 487 | Vector<String> wau(1);wau = u.getName();
|
---|
| 488 | spc.setWorldAxisUnits(wau);
|
---|
| 489 | s = CoordinateUtil::axisLabel(spc);
|
---|
| 490 | }
|
---|
| 491 | return s;
|
---|
| 492 | }
|
---|
| 493 |
|
---|
[206] | 494 | void SDMemTable::setSpectrum(std::vector<float> spectrum, int whichRow)
|
---|
| 495 | {
|
---|
[89] | 496 | ArrayColumn<Float> spec(table_, "SPECTRA");
|
---|
| 497 | Array<Float> arr;
|
---|
| 498 | spec.get(whichRow, arr);
|
---|
| 499 | if (spectrum.size() != arr.shape()(3)) {
|
---|
| 500 | throw(AipsError("Attempting to set spectrum with incorrect length."));
|
---|
| 501 | }
|
---|
| 502 |
|
---|
[206] | 503 | ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr);
|
---|
[89] | 504 | aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
|
---|
[206] | 505 | ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0);
|
---|
[89] | 506 | aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
|
---|
[206] | 507 | ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1);
|
---|
[89] | 508 | aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
|
---|
| 509 |
|
---|
| 510 | std::vector<float>::iterator it = spectrum.begin();
|
---|
[206] | 511 | for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
|
---|
[89] | 512 | (*i) = Float(*it);
|
---|
| 513 | it++;
|
---|
| 514 | }
|
---|
| 515 | spec.put(whichRow, arr);
|
---|
| 516 | }
|
---|
| 517 |
|
---|
[206] | 518 | void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow) const
|
---|
| 519 | {
|
---|
[21] | 520 | ROArrayColumn<Float> spec(table_, "SPECTRA");
|
---|
| 521 | Array<Float> arr;
|
---|
| 522 | spec.get(whichRow, arr);
|
---|
| 523 | spectrum.resize(arr.shape()(3));
|
---|
[206] | 524 | ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr);
|
---|
[21] | 525 | aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
|
---|
[206] | 526 | ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0);
|
---|
[21] | 527 | aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
|
---|
[206] | 528 | ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1);
|
---|
[21] | 529 | aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
|
---|
[2] | 530 |
|
---|
[206] | 531 | ArrayAccessor<Float, Axis<asap::BeamAxis> > va(spectrum);
|
---|
| 532 | for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
|
---|
[21] | 533 | (*va) = (*i);
|
---|
| 534 | va++;
|
---|
| 535 | }
|
---|
| 536 | }
|
---|
[89] | 537 | /*
|
---|
[68] | 538 | void SDMemTable::getMask(Vector<Bool>& mask, Int whichRow) const {
|
---|
[21] | 539 | ROArrayColumn<uChar> spec(table_, "FLAGTRA");
|
---|
| 540 | Array<uChar> arr;
|
---|
| 541 | spec.get(whichRow, arr);
|
---|
| 542 | mask.resize(arr.shape()(3));
|
---|
| 543 |
|
---|
[206] | 544 | ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr);
|
---|
[21] | 545 | aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
|
---|
[206] | 546 | ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0);
|
---|
[21] | 547 | aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
|
---|
[206] | 548 | ArrayAccessor<uChar, Axis<asap::PolAxis> > aa2(aa1);
|
---|
[21] | 549 | aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
|
---|
| 550 |
|
---|
| 551 | Bool useUserMask = ( chanMask_.size() == arr.shape()(3) );
|
---|
[89] | 552 |
|
---|
[206] | 553 | ArrayAccessor<Bool, Axis<asap::BeamAxis> > va(mask);
|
---|
[21] | 554 | std::vector<bool> tmp;
|
---|
| 555 | tmp = chanMask_; // WHY the fxxx do I have to make a copy here. The
|
---|
[89] | 556 | // iterator should work on chanMask_??
|
---|
[21] | 557 | std::vector<bool>::iterator miter;
|
---|
| 558 | miter = tmp.begin();
|
---|
| 559 |
|
---|
[206] | 560 | for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
|
---|
[21] | 561 | bool out =!static_cast<bool>(*i);
|
---|
| 562 | if (useUserMask) {
|
---|
| 563 | out = out && (*miter);
|
---|
| 564 | miter++;
|
---|
| 565 | }
|
---|
| 566 | (*va) = out;
|
---|
| 567 | va++;
|
---|
[89] | 568 | }
|
---|
[21] | 569 | }
|
---|
[89] | 570 | */
|
---|
[16] | 571 | MaskedArray<Float> SDMemTable::rowAsMaskedArray(uInt whichRow,
|
---|
[164] | 572 | Bool useSelection) const
|
---|
| 573 | {
|
---|
[2] | 574 | ROArrayColumn<Float> spec(table_, "SPECTRA");
|
---|
| 575 | Array<Float> arr;
|
---|
| 576 | ROArrayColumn<uChar> flag(table_, "FLAGTRA");
|
---|
| 577 | Array<uChar> farr;
|
---|
| 578 | spec.get(whichRow, arr);
|
---|
| 579 | flag.get(whichRow, farr);
|
---|
| 580 | Array<Bool> barr(farr.shape());convertArray(barr, farr);
|
---|
| 581 | MaskedArray<Float> marr;
|
---|
[16] | 582 | if (useSelection) {
|
---|
[206] | 583 | ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr);
|
---|
[16] | 584 | aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
|
---|
[206] | 585 | ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0);
|
---|
[16] | 586 | aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
|
---|
[206] | 587 | ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1);
|
---|
[16] | 588 | aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
|
---|
[89] | 589 |
|
---|
[206] | 590 | ArrayAccessor<Bool, Axis<asap::BeamAxis> > baa0(barr);
|
---|
[16] | 591 | baa0.reset(baa0.begin(uInt(beamSel_)));//go to beam
|
---|
[206] | 592 | ArrayAccessor<Bool, Axis<asap::IFAxis> > baa1(baa0);
|
---|
[16] | 593 | baa1.reset(baa1.begin(uInt(IFSel_)));// go to IF
|
---|
[206] | 594 | ArrayAccessor<Bool, Axis<asap::PolAxis> > baa2(baa1);
|
---|
[16] | 595 | baa2.reset(baa2.begin(uInt(polSel_)));// go to pol
|
---|
| 596 |
|
---|
| 597 | Vector<Float> a(arr.shape()(3));
|
---|
| 598 | Vector<Bool> b(barr.shape()(3));
|
---|
[206] | 599 | ArrayAccessor<Float, Axis<asap::BeamAxis> > a0(a);
|
---|
| 600 | ArrayAccessor<Bool, Axis<asap::BeamAxis> > b0(b);
|
---|
[16] | 601 |
|
---|
[206] | 602 | ArrayAccessor<Bool, Axis<asap::ChanAxis> > j(baa2);
|
---|
| 603 | for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2);
|
---|
| 604 | i != i.end(); ++i) {
|
---|
[16] | 605 | (*a0) = (*i);
|
---|
| 606 | (*b0) = !(*j);
|
---|
| 607 | j++;
|
---|
| 608 | a0++;
|
---|
| 609 | b0++;
|
---|
| 610 | }
|
---|
| 611 | marr.setData(a,b);
|
---|
| 612 | } else {
|
---|
| 613 | marr.setData(arr,!barr);
|
---|
| 614 | }
|
---|
[2] | 615 | return marr;
|
---|
| 616 | }
|
---|
| 617 |
|
---|
[206] | 618 | Float SDMemTable::getTsys(Int whichRow) const
|
---|
| 619 | {
|
---|
[2] | 620 | ROArrayColumn<Float> ts(table_, "TSYS");
|
---|
| 621 | Array<Float> arr;
|
---|
| 622 | ts.get(whichRow, arr);
|
---|
| 623 | Float out;
|
---|
| 624 | IPosition ip(arr.shape());
|
---|
[16] | 625 | ip(0) = beamSel_;ip(1) = IFSel_;ip(2) = polSel_;ip(3)=0;
|
---|
[2] | 626 | out = arr(ip);
|
---|
| 627 | return out;
|
---|
| 628 | }
|
---|
| 629 |
|
---|
[281] | 630 | MDirection SDMemTable::getDirection(Int whichRow, Bool refBeam) const
|
---|
[206] | 631 | {
|
---|
[212] | 632 | MDirection::Types mdr = getDirectionReference();
|
---|
[206] | 633 | ROArrayColumn<Double> dir(table_, "DIRECTION");
|
---|
| 634 | Array<Double> posit;
|
---|
| 635 | dir.get(whichRow,posit);
|
---|
| 636 | Vector<Double> wpos(2);
|
---|
| 637 | wpos[0] = posit(IPosition(2,beamSel_,0));
|
---|
| 638 | wpos[1] = posit(IPosition(2,beamSel_,1));
|
---|
| 639 | Quantum<Double> lon(wpos[0],Unit(String("rad")));
|
---|
| 640 | Quantum<Double> lat(wpos[1],Unit(String("rad")));
|
---|
| 641 | MDirection direct(lon, lat, mdr);
|
---|
| 642 | return direct;
|
---|
| 643 | }
|
---|
[39] | 644 |
|
---|
[206] | 645 | SpectralCoordinate SDMemTable::getCoordinate(uInt whichIdx) const
|
---|
| 646 | {
|
---|
| 647 |
|
---|
[39] | 648 | Table t = table_.keywordSet().asTable("FREQUENCIES");
|
---|
| 649 | if (whichIdx > t.nrow() ) {
|
---|
[206] | 650 | throw(AipsError("SDMemTable::getCoordinate - whichIdx out of range"));
|
---|
[39] | 651 | }
|
---|
[89] | 652 |
|
---|
[39] | 653 | Double rp,rv,inc;
|
---|
| 654 | String rf;
|
---|
[89] | 655 | Vector<Double> vec;
|
---|
[39] | 656 | ROScalarColumn<Double> rpc(t, "REFPIX");
|
---|
| 657 | ROScalarColumn<Double> rvc(t, "REFVAL");
|
---|
| 658 | ROScalarColumn<Double> incc(t, "INCREMENT");
|
---|
[89] | 659 | t.keywordSet().get("RESTFREQS",vec);
|
---|
[105] | 660 | t.keywordSet().get("BASEREFFRAME",rf);
|
---|
[89] | 661 |
|
---|
[39] | 662 | MFrequency::Types mft;
|
---|
| 663 | if (!MFrequency::getType(mft, rf)) {
|
---|
| 664 | cerr << "Frequency type unknown assuming TOPO" << endl;
|
---|
[89] | 665 | mft = MFrequency::TOPO;
|
---|
| 666 | }
|
---|
[39] | 667 | rpc.get(whichIdx, rp);
|
---|
| 668 | rvc.get(whichIdx, rv);
|
---|
| 669 | incc.get(whichIdx, inc);
|
---|
| 670 | SpectralCoordinate spec(mft,rv,inc,rp);
|
---|
[89] | 671 | if (vec.nelements() > 0)
|
---|
| 672 | spec.setRestFrequencies(vec);
|
---|
[39] | 673 | return spec;
|
---|
| 674 | }
|
---|
| 675 |
|
---|
[89] | 676 | Bool SDMemTable::setCoordinate(const SpectralCoordinate& speccord,
|
---|
| 677 | uInt whichIdx) {
|
---|
[50] | 678 | Table t = table_.rwKeywordSet().asTable("FREQUENCIES");
|
---|
| 679 | if (whichIdx > t.nrow() ) {
|
---|
[89] | 680 | throw(AipsError("SDMemTable::setCoordinate - coord no out of range"));
|
---|
[50] | 681 | }
|
---|
| 682 | ScalarColumn<Double> rpc(t, "REFPIX");
|
---|
| 683 | ScalarColumn<Double> rvc(t, "REFVAL");
|
---|
| 684 | ScalarColumn<Double> incc(t, "INCREMENT");
|
---|
[89] | 685 |
|
---|
[50] | 686 | rpc.put(whichIdx, speccord.referencePixel()[0]);
|
---|
| 687 | rvc.put(whichIdx, speccord.referenceValue()[0]);
|
---|
| 688 | incc.put(whichIdx, speccord.increment()[0]);
|
---|
| 689 |
|
---|
| 690 | return True;
|
---|
| 691 | }
|
---|
| 692 |
|
---|
[89] | 693 | Int SDMemTable::nCoordinates() const
|
---|
| 694 | {
|
---|
| 695 | return table_.keywordSet().asTable("FREQUENCIES").nrow();
|
---|
| 696 | }
|
---|
[50] | 697 |
|
---|
[206] | 698 | void SDMemTable::setRestFreqs(std::vector<double> freqs,
|
---|
| 699 | const std::string& theunit)
|
---|
[89] | 700 | {
|
---|
| 701 | Vector<Double> tvec(freqs);
|
---|
| 702 | Quantum<Vector<Double> > q(tvec, String(theunit));
|
---|
| 703 | tvec.resize();
|
---|
| 704 | tvec = q.getValue("Hz");
|
---|
| 705 | Table t = table_.keywordSet().asTable("FREQUENCIES");
|
---|
| 706 | t.rwKeywordSet().define("RESTFREQS",tvec);
|
---|
| 707 | }
|
---|
| 708 |
|
---|
[251] | 709 | std::vector<double> SDMemTable::getRestFreqs() const
|
---|
| 710 | {
|
---|
| 711 | Table t = table_.keywordSet().asTable("FREQUENCIES");
|
---|
| 712 | Vector<Double> tvec;
|
---|
| 713 | t.keywordSet().get("RESTFREQS",tvec);
|
---|
| 714 | std::vector<double> stlout;
|
---|
| 715 | tvec.tovector(stlout);
|
---|
| 716 | return stlout;
|
---|
| 717 | }
|
---|
| 718 |
|
---|
[206] | 719 | bool SDMemTable::putSDFreqTable(const SDFrequencyTable& sdft)
|
---|
| 720 | {
|
---|
[39] | 721 | TableDesc td("", "1", TableDesc::Scratch);
|
---|
| 722 | td.addColumn(ScalarColumnDesc<Double>("REFPIX"));
|
---|
| 723 | td.addColumn(ScalarColumnDesc<Double>("REFVAL"));
|
---|
| 724 | td.addColumn(ScalarColumnDesc<Double>("INCREMENT"));
|
---|
| 725 | SetupNewTable aNewTab("freqs", td, Table::New);
|
---|
| 726 | Table aTable (aNewTab, Table::Memory, sdft.length());
|
---|
| 727 | ScalarColumn<Double> sc0(aTable, "REFPIX");
|
---|
| 728 | ScalarColumn<Double> sc1(aTable, "REFVAL");
|
---|
| 729 | ScalarColumn<Double> sc2(aTable, "INCREMENT");
|
---|
| 730 | for (uInt i=0; i < sdft.length(); ++i) {
|
---|
| 731 | sc0.put(i,sdft.referencePixel(i));
|
---|
| 732 | sc1.put(i,sdft.referenceValue(i));
|
---|
| 733 | sc2.put(i,sdft.increment(i));
|
---|
| 734 | }
|
---|
[105] | 735 | String rf = sdft.refFrame();
|
---|
| 736 | if (rf.contains("TOPO")) rf = "TOPO";
|
---|
| 737 |
|
---|
| 738 | aTable.rwKeywordSet().define("BASEREFFRAME", rf);
|
---|
| 739 | aTable.rwKeywordSet().define("REFFRAME", rf);
|
---|
[39] | 740 | aTable.rwKeywordSet().define("EQUINOX", sdft.equinox());
|
---|
[105] | 741 | aTable.rwKeywordSet().define("UNIT", String(""));
|
---|
| 742 | aTable.rwKeywordSet().define("DOPPLER", String("RADIO"));
|
---|
[89] | 743 | Vector<Double> rfvec;
|
---|
[206] | 744 | String rfunit;
|
---|
| 745 | sdft.restFrequencies(rfvec,rfunit);
|
---|
| 746 | Quantum<Vector<Double> > q(rfvec, rfunit);
|
---|
| 747 | rfvec.resize();
|
---|
| 748 | rfvec = q.getValue("Hz");
|
---|
[89] | 749 | aTable.rwKeywordSet().define("RESTFREQS", rfvec);
|
---|
[39] | 750 | table_.rwKeywordSet().defineTable ("FREQUENCIES", aTable);
|
---|
| 751 | return True;
|
---|
| 752 | }
|
---|
| 753 |
|
---|
[206] | 754 | SDFrequencyTable SDMemTable::getSDFreqTable() const
|
---|
| 755 | {
|
---|
[251] | 756 | // TODO !!!!! implement this properly USE with care
|
---|
| 757 | const Table& t = table_.keywordSet().asTable("FREQUENCIES");
|
---|
[39] | 758 | SDFrequencyTable sdft;
|
---|
[251] | 759 | sdft.setLength(t.nrow());
|
---|
[39] | 760 | return sdft;
|
---|
| 761 | }
|
---|
| 762 |
|
---|
[206] | 763 | bool SDMemTable::putSDContainer(const SDContainer& sdc)
|
---|
| 764 | {
|
---|
[2] | 765 | ScalarColumn<Double> mjd(table_, "TIME");
|
---|
| 766 | ScalarColumn<String> srcn(table_, "SRCNAME");
|
---|
[105] | 767 | ScalarColumn<String> fldn(table_, "FIELDNAME");
|
---|
[2] | 768 | ArrayColumn<Float> spec(table_, "SPECTRA");
|
---|
| 769 | ArrayColumn<uChar> flags(table_, "FLAGTRA");
|
---|
| 770 | ArrayColumn<Float> ts(table_, "TSYS");
|
---|
| 771 | ScalarColumn<Int> scan(table_, "SCANID");
|
---|
[16] | 772 | ScalarColumn<Double> integr(table_, "INTERVAL");
|
---|
[39] | 773 | ArrayColumn<uInt> freqid(table_, "FREQID");
|
---|
[78] | 774 | ArrayColumn<Double> dir(table_, "DIRECTION");
|
---|
[105] | 775 | ScalarColumn<Int> rbeam(table_, "REFBEAM");
|
---|
| 776 | ArrayColumn<Float> tcal(table_, "TCAL");
|
---|
| 777 | ScalarColumn<String> tcalt(table_, "TCALTIME");
|
---|
| 778 | ScalarColumn<Float> az(table_, "AZIMUTH");
|
---|
| 779 | ScalarColumn<Float> el(table_, "ELEVATION");
|
---|
| 780 | ScalarColumn<Float> para(table_, "PARANGLE");
|
---|
[206] | 781 | ArrayColumn<String> hist(table_, "HISTORY");
|
---|
[2] | 782 |
|
---|
| 783 | uInt rno = table_.nrow();
|
---|
| 784 | table_.addRow();
|
---|
[89] | 785 |
|
---|
[2] | 786 | mjd.put(rno, sdc.timestamp);
|
---|
| 787 | srcn.put(rno, sdc.sourcename);
|
---|
[105] | 788 | fldn.put(rno, sdc.fieldname);
|
---|
[2] | 789 | spec.put(rno, sdc.getSpectrum());
|
---|
| 790 | flags.put(rno, sdc.getFlags());
|
---|
| 791 | ts.put(rno, sdc.getTsys());
|
---|
| 792 | scan.put(rno, sdc.scanid);
|
---|
[16] | 793 | integr.put(rno, sdc.interval);
|
---|
[39] | 794 | freqid.put(rno, sdc.getFreqMap());
|
---|
[78] | 795 | dir.put(rno, sdc.getDirection());
|
---|
[105] | 796 | rbeam.put(rno, sdc.refbeam);
|
---|
| 797 | tcal.put(rno, sdc.tcal);
|
---|
| 798 | tcalt.put(rno, sdc.tcaltime);
|
---|
| 799 | az.put(rno, sdc.azimuth);
|
---|
| 800 | el.put(rno, sdc.elevation);
|
---|
| 801 | para.put(rno, sdc.parangle);
|
---|
[206] | 802 | hist.put(rno, sdc.getHistory());
|
---|
[89] | 803 |
|
---|
[2] | 804 | return true;
|
---|
| 805 | }
|
---|
[18] | 806 |
|
---|
[206] | 807 | SDContainer SDMemTable::getSDContainer(uInt whichRow) const
|
---|
| 808 | {
|
---|
[21] | 809 | ROScalarColumn<Double> mjd(table_, "TIME");
|
---|
| 810 | ROScalarColumn<String> srcn(table_, "SRCNAME");
|
---|
[105] | 811 | ROScalarColumn<String> fldn(table_, "FIELDNAME");
|
---|
[21] | 812 | ROArrayColumn<Float> spec(table_, "SPECTRA");
|
---|
| 813 | ROArrayColumn<uChar> flags(table_, "FLAGTRA");
|
---|
| 814 | ROArrayColumn<Float> ts(table_, "TSYS");
|
---|
| 815 | ROScalarColumn<Int> scan(table_, "SCANID");
|
---|
| 816 | ROScalarColumn<Double> integr(table_, "INTERVAL");
|
---|
[39] | 817 | ROArrayColumn<uInt> freqid(table_, "FREQID");
|
---|
[78] | 818 | ROArrayColumn<Double> dir(table_, "DIRECTION");
|
---|
[105] | 819 | ROScalarColumn<Int> rbeam(table_, "REFBEAM");
|
---|
| 820 | ROArrayColumn<Float> tcal(table_, "TCAL");
|
---|
| 821 | ROScalarColumn<String> tcalt(table_, "TCALTIME");
|
---|
| 822 | ROScalarColumn<Float> az(table_, "AZIMUTH");
|
---|
| 823 | ROScalarColumn<Float> el(table_, "ELEVATION");
|
---|
| 824 | ROScalarColumn<Float> para(table_, "PARANGLE");
|
---|
[206] | 825 | ROArrayColumn<String> hist(table_, "HISTORY");
|
---|
[21] | 826 |
|
---|
| 827 | SDContainer sdc(nBeam(),nIF(),nPol(),nChan());
|
---|
| 828 | mjd.get(whichRow, sdc.timestamp);
|
---|
| 829 | srcn.get(whichRow, sdc.sourcename);
|
---|
| 830 | integr.get(whichRow, sdc.interval);
|
---|
| 831 | scan.get(whichRow, sdc.scanid);
|
---|
[105] | 832 | fldn.get(whichRow, sdc.fieldname);
|
---|
| 833 | rbeam.get(whichRow, sdc.refbeam);
|
---|
| 834 | az.get(whichRow, sdc.azimuth);
|
---|
| 835 | el.get(whichRow, sdc.elevation);
|
---|
| 836 | para.get(whichRow, sdc.parangle);
|
---|
| 837 | Vector<Float> tc;
|
---|
| 838 | tcal.get(whichRow, tc);
|
---|
| 839 | sdc.tcal[0] = tc[0];sdc.tcal[1] = tc[1];
|
---|
| 840 | tcalt.get(whichRow, sdc.tcaltime);
|
---|
[21] | 841 | Array<Float> spectrum;
|
---|
| 842 | Array<Float> tsys;
|
---|
| 843 | Array<uChar> flagtrum;
|
---|
[39] | 844 | Vector<uInt> fmap;
|
---|
[78] | 845 | Array<Double> direction;
|
---|
[206] | 846 | Vector<String> histo;
|
---|
[21] | 847 | spec.get(whichRow, spectrum);
|
---|
| 848 | sdc.putSpectrum(spectrum);
|
---|
| 849 | flags.get(whichRow, flagtrum);
|
---|
| 850 | sdc.putFlags(flagtrum);
|
---|
| 851 | ts.get(whichRow, tsys);
|
---|
| 852 | sdc.putTsys(tsys);
|
---|
[39] | 853 | freqid.get(whichRow, fmap);
|
---|
| 854 | sdc.putFreqMap(fmap);
|
---|
[78] | 855 | dir.get(whichRow, direction);
|
---|
| 856 | sdc.putDirection(direction);
|
---|
[206] | 857 | hist.get(whichRow, histo);
|
---|
| 858 | sdc.putHistory(histo);
|
---|
[21] | 859 | return sdc;
|
---|
| 860 | }
|
---|
[78] | 861 |
|
---|
[206] | 862 | bool SDMemTable::putSDHeader(const SDHeader& sdh)
|
---|
| 863 | {
|
---|
[18] | 864 | table_.rwKeywordSet().define("nIF", sdh.nif);
|
---|
| 865 | table_.rwKeywordSet().define("nBeam", sdh.nbeam);
|
---|
| 866 | table_.rwKeywordSet().define("nPol", sdh.npol);
|
---|
| 867 | table_.rwKeywordSet().define("nChan", sdh.nchan);
|
---|
| 868 | table_.rwKeywordSet().define("Observer", sdh.observer);
|
---|
| 869 | table_.rwKeywordSet().define("Project", sdh.project);
|
---|
| 870 | table_.rwKeywordSet().define("Obstype", sdh.obstype);
|
---|
| 871 | table_.rwKeywordSet().define("AntennaName", sdh.antennaname);
|
---|
| 872 | table_.rwKeywordSet().define("AntennaPosition", sdh.antennaposition);
|
---|
| 873 | table_.rwKeywordSet().define("Equinox", sdh.equinox);
|
---|
| 874 | table_.rwKeywordSet().define("FreqRefFrame", sdh.freqref);
|
---|
| 875 | table_.rwKeywordSet().define("FreqRefVal", sdh.reffreq);
|
---|
| 876 | table_.rwKeywordSet().define("Bandwidth", sdh.bandwidth);
|
---|
| 877 | table_.rwKeywordSet().define("UTC", sdh.utc);
|
---|
[206] | 878 | table_.rwKeywordSet().define("FluxUnit", sdh.fluxunit);
|
---|
| 879 | table_.rwKeywordSet().define("Epoch", sdh.epoch);
|
---|
[18] | 880 | return true;
|
---|
[50] | 881 | }
|
---|
[21] | 882 |
|
---|
[206] | 883 | SDHeader SDMemTable::getSDHeader() const
|
---|
| 884 | {
|
---|
[21] | 885 | SDHeader sdh;
|
---|
| 886 | table_.keywordSet().get("nBeam",sdh.nbeam);
|
---|
| 887 | table_.keywordSet().get("nIF",sdh.nif);
|
---|
| 888 | table_.keywordSet().get("nPol",sdh.npol);
|
---|
| 889 | table_.keywordSet().get("nChan",sdh.nchan);
|
---|
| 890 | table_.keywordSet().get("Observer", sdh.observer);
|
---|
| 891 | table_.keywordSet().get("Project", sdh.project);
|
---|
| 892 | table_.keywordSet().get("Obstype", sdh.obstype);
|
---|
| 893 | table_.keywordSet().get("AntennaName", sdh.antennaname);
|
---|
| 894 | table_.keywordSet().get("AntennaPosition", sdh.antennaposition);
|
---|
| 895 | table_.keywordSet().get("Equinox", sdh.equinox);
|
---|
| 896 | table_.keywordSet().get("FreqRefFrame", sdh.freqref);
|
---|
| 897 | table_.keywordSet().get("FreqRefVal", sdh.reffreq);
|
---|
| 898 | table_.keywordSet().get("Bandwidth", sdh.bandwidth);
|
---|
| 899 | table_.keywordSet().get("UTC", sdh.utc);
|
---|
[206] | 900 | table_.keywordSet().get("FluxUnit", sdh.fluxunit);
|
---|
| 901 | table_.keywordSet().get("Epoch", sdh.epoch);
|
---|
[21] | 902 | return sdh;
|
---|
[18] | 903 | }
|
---|
[206] | 904 | void SDMemTable::makePersistent(const std::string& filename)
|
---|
| 905 | {
|
---|
[2] | 906 | table_.deepCopy(filename,Table::New);
|
---|
| 907 | }
|
---|
| 908 |
|
---|
[89] | 909 | Int SDMemTable::nScan() const {
|
---|
[50] | 910 | Int n = 0;
|
---|
| 911 | ROScalarColumn<Int> scans(table_, "SCANID");
|
---|
| 912 | Int previous = -1;Int current=0;
|
---|
| 913 | for (uInt i=0; i< scans.nrow();i++) {
|
---|
| 914 | scans.getScalar(i,current);
|
---|
| 915 | if (previous != current) {
|
---|
[89] | 916 | previous = current;
|
---|
[50] | 917 | n++;
|
---|
| 918 | }
|
---|
| 919 | }
|
---|
| 920 | return n;
|
---|
| 921 | }
|
---|
| 922 |
|
---|
[260] | 923 | String SDMemTable::formatSec(Double x) const
|
---|
[206] | 924 | {
|
---|
[105] | 925 | Double xcop = x;
|
---|
| 926 | MVTime mvt(xcop/24./3600.); // make days
|
---|
[281] | 927 |
|
---|
[105] | 928 | if (x < 59.95)
|
---|
[281] | 929 | return String(" ") + mvt.string(MVTime::TIME_CLEAN_NO_HM, 7)+"s";
|
---|
| 930 | else if (x < 3599.95)
|
---|
| 931 | return String(" ") + mvt.string(MVTime::TIME_CLEAN_NO_H,7)+" ";
|
---|
| 932 | else {
|
---|
| 933 | ostringstream oss;
|
---|
| 934 | oss << setw(2) << std::right << setprecision(1) << mvt.hour();
|
---|
| 935 | oss << ":" << mvt.string(MVTime::TIME_CLEAN_NO_H,7) << " ";
|
---|
| 936 | return String(oss);
|
---|
| 937 | }
|
---|
[105] | 938 | };
|
---|
| 939 |
|
---|
[281] | 940 | String SDMemTable::formatDirection(const MDirection& md) const
|
---|
| 941 | {
|
---|
| 942 | Vector<Double> t = md.getAngle(Unit(String("rad"))).getValue();
|
---|
| 943 | Int prec = 7;
|
---|
| 944 |
|
---|
| 945 | MVAngle mvLon(t[0]);
|
---|
| 946 | String sLon = mvLon.string(MVAngle::TIME,prec);
|
---|
| 947 | MVAngle mvLat(t[1]);
|
---|
| 948 | String sLat = mvLat.string(MVAngle::ANGLE+MVAngle::DIG2,prec);
|
---|
| 949 |
|
---|
| 950 | return sLon + String(" ") + sLat;
|
---|
| 951 | }
|
---|
| 952 |
|
---|
| 953 |
|
---|
[206] | 954 | std::string SDMemTable::getFluxUnit() const
|
---|
| 955 | {
|
---|
| 956 | String tmp;
|
---|
| 957 | table_.keywordSet().get("FluxUnit", tmp);
|
---|
| 958 | return tmp;
|
---|
| 959 | }
|
---|
| 960 |
|
---|
[218] | 961 | void SDMemTable::setFluxUnit(const std::string& unit)
|
---|
| 962 | {
|
---|
| 963 | String tmp(unit);
|
---|
| 964 | Unit tU(tmp);
|
---|
| 965 | if (tU==Unit("K") || tU==Unit("Jy")) {
|
---|
| 966 | table_.rwKeywordSet().define(String("FluxUnit"), tmp);
|
---|
| 967 | } else {
|
---|
| 968 | throw AipsError("Illegal unit - must be compatible with Jy or K");
|
---|
| 969 | }
|
---|
| 970 | }
|
---|
| 971 |
|
---|
[275] | 972 |
|
---|
[236] | 973 | void SDMemTable::setInstrument(const std::string& name)
|
---|
| 974 | {
|
---|
| 975 | Bool throwIt = True;
|
---|
| 976 | Instrument ins = convertInstrument (name, throwIt);
|
---|
| 977 | String nameU(name);
|
---|
| 978 | nameU.upcase();
|
---|
| 979 | table_.rwKeywordSet().define(String("AntennaName"), nameU);
|
---|
| 980 | }
|
---|
| 981 |
|
---|
[260] | 982 | std::string SDMemTable::summary() const {
|
---|
[2] | 983 | ROScalarColumn<Int> scans(table_, "SCANID");
|
---|
| 984 | ROScalarColumn<String> srcs(table_, "SRCNAME");
|
---|
[281] | 985 |
|
---|
| 986 | // get number of integrations per scan
|
---|
| 987 | int cIdx = 0;
|
---|
| 988 | int idx = 0;
|
---|
| 989 | int scount = 0;
|
---|
| 990 | std::vector<int> cycles;
|
---|
| 991 | for (uInt i=0; i<scans.nrow();++i) {
|
---|
| 992 | while (idx == cIdx && i<scans.nrow()) {
|
---|
| 993 | scans.getScalar(++i,cIdx);
|
---|
| 994 | ++scount;
|
---|
| 995 | }
|
---|
| 996 | idx = cIdx;
|
---|
| 997 | cycles.push_back(scount);
|
---|
| 998 | scount=0;
|
---|
| 999 | --i;
|
---|
| 1000 | }
|
---|
| 1001 |
|
---|
| 1002 |
|
---|
[89] | 1003 | ostringstream oss;
|
---|
| 1004 | oss << endl;
|
---|
| 1005 | oss << "--------------------------------------------------" << endl;
|
---|
| 1006 | oss << " Scan Table Summary" << endl;
|
---|
| 1007 | oss << "--------------------------------------------------" << endl;
|
---|
| 1008 | oss.flags(std::ios_base::left);
|
---|
| 1009 | oss << setw(15) << "Beams:" << setw(4) << nBeam() << endl
|
---|
| 1010 | << setw(15) << "IFs:" << setw(4) << nIF() << endl
|
---|
| 1011 | << setw(15) << "Polarisations:" << setw(4) << nPol() << endl
|
---|
| 1012 | << setw(15) << "Channels:" << setw(4) << nChan() << endl;
|
---|
| 1013 | oss << endl;
|
---|
| 1014 | String tmp;
|
---|
| 1015 | table_.keywordSet().get("Observer", tmp);
|
---|
| 1016 | oss << setw(15) << "Observer:" << tmp << endl;
|
---|
[281] | 1017 | oss << setw(15) << "Obs Date:" << getTime(-1,True) << endl;
|
---|
[89] | 1018 | table_.keywordSet().get("Project", tmp);
|
---|
| 1019 | oss << setw(15) << "Project:" << tmp << endl;
|
---|
| 1020 | table_.keywordSet().get("Obstype", tmp);
|
---|
| 1021 | oss << setw(15) << "Obs. Type:" << tmp << endl;
|
---|
| 1022 | table_.keywordSet().get("AntennaName", tmp);
|
---|
| 1023 | oss << setw(15) << "Antenna Name:" << tmp << endl;
|
---|
[206] | 1024 | table_.keywordSet().get("FluxUnit", tmp);
|
---|
| 1025 | oss << setw(15) << "Flux Unit:" << tmp << endl;
|
---|
[260] | 1026 | Table t = table_.keywordSet().asTable("FREQUENCIES");
|
---|
[105] | 1027 | Vector<Double> vec;
|
---|
| 1028 | t.keywordSet().get("RESTFREQS",vec);
|
---|
| 1029 | oss << setw(15) << "Rest Freqs:";
|
---|
| 1030 | if (vec.nelements() > 0) {
|
---|
| 1031 | oss << setprecision(0) << vec << " [Hz]" << endl;
|
---|
| 1032 | } else {
|
---|
| 1033 | oss << "None set" << endl;
|
---|
| 1034 | }
|
---|
[158] | 1035 | oss << setw(15) << "Abcissa:" << getAbcissaString() << endl;
|
---|
[105] | 1036 | oss << setw(15) << "Cursor:" << "Beam[" << getBeam() << "] "
|
---|
| 1037 | << "IF[" << getIF() << "] " << "Pol[" << getPol() << "]" << endl;
|
---|
[89] | 1038 | oss << endl;
|
---|
[2] | 1039 | uInt count = 0;
|
---|
| 1040 | String name;
|
---|
| 1041 | Int previous = -1;Int current=0;
|
---|
[89] | 1042 | Int integ = 0;
|
---|
[281] | 1043 | String dirtype ="Position ("+
|
---|
| 1044 | MDirection::showType(getDirectionReference())+
|
---|
| 1045 | ")";
|
---|
[89] | 1046 | oss << setw(6) << "Scan"
|
---|
[281] | 1047 | << setw(15) << "Source"
|
---|
| 1048 | << setw(26) << dirtype
|
---|
| 1049 | << setw(10) << "Time"
|
---|
| 1050 | << setw(13) << "Integration" << endl;
|
---|
| 1051 | oss << "-------------------------------------------------------------------------------" << endl;
|
---|
| 1052 |
|
---|
| 1053 | std::vector<int>::iterator it = cycles.begin();
|
---|
[2] | 1054 | for (uInt i=0; i< scans.nrow();i++) {
|
---|
| 1055 | scans.getScalar(i,current);
|
---|
| 1056 | if (previous != current) {
|
---|
| 1057 | srcs.getScalar(i,name);
|
---|
[50] | 1058 | previous = current;
|
---|
[105] | 1059 | String t = formatSec(Double(getInterval(i)));
|
---|
[281] | 1060 | String posit = formatDirection(getDirection(i,True));
|
---|
| 1061 | oss << setw(6) << count
|
---|
| 1062 | << setw(15) << name
|
---|
| 1063 | << setw(26) << posit
|
---|
| 1064 | << setw(10) << getTime(i,False)
|
---|
| 1065 | << setw(3) << std::right << *it << " x "
|
---|
| 1066 | << setw(10)
|
---|
| 1067 | << t << std::left << endl;
|
---|
[50] | 1068 | count++;
|
---|
[281] | 1069 | it++;
|
---|
[89] | 1070 | } else {
|
---|
| 1071 | integ++;
|
---|
[2] | 1072 | }
|
---|
| 1073 | }
|
---|
[89] | 1074 | oss << endl;
|
---|
| 1075 | oss << "Table contains " << table_.nrow() << " integration(s)." << endl;
|
---|
| 1076 | oss << "in " << count << " scan(s)." << endl;
|
---|
[281] | 1077 | oss << "-------------------------------------------------------------------------------";
|
---|
[89] | 1078 | return String(oss);
|
---|
[2] | 1079 | }
|
---|
[18] | 1080 |
|
---|
[206] | 1081 | Int SDMemTable::nBeam() const
|
---|
| 1082 | {
|
---|
[18] | 1083 | Int n;
|
---|
| 1084 | table_.keywordSet().get("nBeam",n);
|
---|
| 1085 | return n;
|
---|
| 1086 | }
|
---|
| 1087 | Int SDMemTable::nIF() const {
|
---|
| 1088 | Int n;
|
---|
| 1089 | table_.keywordSet().get("nIF",n);
|
---|
| 1090 | return n;
|
---|
| 1091 | }
|
---|
| 1092 | Int SDMemTable::nPol() const {
|
---|
| 1093 | Int n;
|
---|
| 1094 | table_.keywordSet().get("nPol",n);
|
---|
| 1095 | return n;
|
---|
| 1096 | }
|
---|
| 1097 | Int SDMemTable::nChan() const {
|
---|
| 1098 | Int n;
|
---|
| 1099 | table_.keywordSet().get("nChan",n);
|
---|
| 1100 | return n;
|
---|
| 1101 | }
|
---|
[206] | 1102 | bool SDMemTable::appendHistory(const std::string& hist, int whichRow)
|
---|
| 1103 | {
|
---|
| 1104 | ArrayColumn<String> histo(table_, "HISTORY");
|
---|
| 1105 | Vector<String> history;
|
---|
| 1106 | histo.get(whichRow, history);
|
---|
| 1107 | history.resize(history.nelements()+1,True);
|
---|
| 1108 | history[history.nelements()-1] = hist;
|
---|
| 1109 | histo.put(whichRow, history);
|
---|
| 1110 | }
|
---|
| 1111 |
|
---|
| 1112 | std::vector<std::string> SDMemTable::history(int whichRow) const
|
---|
| 1113 | {
|
---|
| 1114 | ROArrayColumn<String> hist(table_, "HISTORY");
|
---|
| 1115 | Vector<String> history;
|
---|
| 1116 | hist.get(whichRow, history);
|
---|
| 1117 | std::vector<std::string> stlout;
|
---|
| 1118 | // there is no Array<String>.tovector(std::vector<std::string>), so
|
---|
| 1119 | // do it by hand
|
---|
| 1120 | for (uInt i=0; i<history.nelements(); ++i) {
|
---|
| 1121 | stlout.push_back(history[i]);
|
---|
| 1122 | }
|
---|
| 1123 | return stlout;
|
---|
| 1124 | }
|
---|
[16] | 1125 | /*
|
---|
[18] | 1126 | void SDMemTable::maskChannels(const std::vector<Int>& whichChans ) {
|
---|
[89] | 1127 |
|
---|
[16] | 1128 | std::vector<int>::iterator it;
|
---|
[206] | 1129 | ArrayAccessor<uChar, Axis<asap::PolAxis> > j(flags_);
|
---|
[16] | 1130 | for (it = whichChans.begin(); it != whichChans.end(); it++) {
|
---|
| 1131 | j.reset(j.begin(uInt(*it)));
|
---|
[206] | 1132 | for (ArrayAccessor<uChar, Axis<asap::BeamAxis> > i(j); i != i.end(); ++i) {
|
---|
| 1133 | for (ArrayAccessor<uChar, Axis<asap::IFAxis> > ii(i); ii != ii.end(); ++ii) {
|
---|
| 1134 | for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > iii(ii);
|
---|
[89] | 1135 | iii != iii.end(); ++iii) {
|
---|
| 1136 | (*iii) =
|
---|
| 1137 | }
|
---|
[16] | 1138 | }
|
---|
| 1139 | }
|
---|
| 1140 | }
|
---|
[89] | 1141 |
|
---|
[16] | 1142 | }
|
---|
| 1143 | */
|
---|
[206] | 1144 | void SDMemTable::flag(int whichRow)
|
---|
| 1145 | {
|
---|
[89] | 1146 | ArrayColumn<uChar> spec(table_, "FLAGTRA");
|
---|
| 1147 | Array<uChar> arr;
|
---|
| 1148 | spec.get(whichRow, arr);
|
---|
| 1149 |
|
---|
[206] | 1150 | ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr);
|
---|
[89] | 1151 | aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
|
---|
[206] | 1152 | ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0);
|
---|
[89] | 1153 | aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
|
---|
[206] | 1154 | ArrayAccessor<uChar, Axis<asap::PolAxis> > aa2(aa1);
|
---|
[89] | 1155 | aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
|
---|
| 1156 |
|
---|
[206] | 1157 | for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
|
---|
[89] | 1158 | (*i) = uChar(True);
|
---|
| 1159 | }
|
---|
| 1160 |
|
---|
| 1161 | spec.put(whichRow, arr);
|
---|
| 1162 | }
|
---|
[212] | 1163 |
|
---|
[281] | 1164 | MDirection::Types SDMemTable::getDirectionReference() const
|
---|
[212] | 1165 | {
|
---|
| 1166 | Float eq;
|
---|
| 1167 | table_.keywordSet().get("Equinox",eq);
|
---|
| 1168 | std::map<float,string> mp;
|
---|
| 1169 | mp[2000.0] = "J2000";
|
---|
| 1170 | mp[1950.0] = "B1950";
|
---|
| 1171 | MDirection::Types mdr;
|
---|
| 1172 | if (!MDirection::getType(mdr, mp[eq])) {
|
---|
| 1173 | mdr = MDirection::J2000;
|
---|
| 1174 | cerr << "Unknown equinox using J2000" << endl;
|
---|
| 1175 | }
|
---|
| 1176 | //
|
---|
| 1177 | return mdr;
|
---|
| 1178 | }
|
---|
| 1179 |
|
---|
| 1180 | MEpoch::Types SDMemTable::getTimeReference () const
|
---|
| 1181 | {
|
---|
| 1182 | MEpoch::Types met;
|
---|
| 1183 | String ep;
|
---|
| 1184 | table_.keywordSet().get("Epoch",ep);
|
---|
| 1185 | if (!MEpoch::getType(met, ep)) {
|
---|
| 1186 | cerr << "Epoch type uknown - using UTC" << endl;
|
---|
| 1187 | met = MEpoch::UTC;
|
---|
| 1188 | }
|
---|
| 1189 | //
|
---|
| 1190 | return met;
|
---|
| 1191 | }
|
---|
| 1192 |
|
---|
[236] | 1193 |
|
---|
| 1194 | Instrument SDMemTable::convertInstrument (const String& instrument,
|
---|
| 1195 | Bool throwIt)
|
---|
| 1196 | {
|
---|
| 1197 | String t(instrument);
|
---|
| 1198 | t.upcase();
|
---|
| 1199 | //
|
---|
| 1200 | Instrument inst = asap::UNKNOWN;
|
---|
| 1201 | if (t==String("TID")) {
|
---|
| 1202 | inst = TIDBINBILLA;
|
---|
| 1203 | } else if (t==String("ATPKSMB")) {
|
---|
| 1204 | inst = PKSMULTIBEAM;
|
---|
| 1205 | } else if (t==String("ATPKSSB")) {
|
---|
| 1206 | inst = PKSSINGLEBEAM;
|
---|
| 1207 | } else if (t==String("MOPRA")) {
|
---|
| 1208 | inst = MOPRA;
|
---|
| 1209 | } else {
|
---|
| 1210 | if (throwIt) {
|
---|
| 1211 | throw AipsError("Unrecognized instrument - use function scan.set_instrument to set");
|
---|
| 1212 | }
|
---|
| 1213 | }
|
---|
| 1214 | return inst;
|
---|
| 1215 | }
|
---|
| 1216 |
|
---|