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