source: trunk/src/SDMemTable.cc@ 324

Last change on this file since 324 was 323, checked in by kil064, 20 years ago

remove debug state,ment

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