source: trunk/src/Scantable.cpp@ 845

Last change on this file since 845 was 845, checked in by mar637, 19 years ago

changed getSDHeader -> getHeader
changed nrow interface
added ncycle()

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.4 KB
Line 
1//
2// C++ Implementation: Scantable
3//
4// Description:
5//
6//
7// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2005
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#include <map>
13
14#include <casa/aips.h>
15#include <casa/iostream.h>
16#include <casa/iomanip.h>
17#include <casa/OS/Path.h>
18#include <casa/OS/File.h>
19#include <casa/Arrays/Array.h>
20#include <casa/Arrays/ArrayMath.h>
21#include <casa/Arrays/MaskArrMath.h>
22#include <casa/Arrays/ArrayLogical.h>
23#include <casa/Arrays/ArrayAccessor.h>
24#include <casa/Arrays/VectorSTLIterator.h>
25#include <casa/Arrays/Vector.h>
26#include <casa/BasicMath/Math.h>
27#include <casa/BasicSL/Constants.h>
28#include <casa/Quanta/MVAngle.h>
29#include <casa/Containers/RecordField.h>
30
31#include <tables/Tables/TableParse.h>
32#include <tables/Tables/TableDesc.h>
33#include <tables/Tables/TableCopy.h>
34#include <tables/Tables/SetupNewTab.h>
35#include <tables/Tables/ScaColDesc.h>
36#include <tables/Tables/ArrColDesc.h>
37#include <tables/Tables/TableRow.h>
38#include <tables/Tables/TableVector.h>
39#include <tables/Tables/TableIter.h>
40
41#include <tables/Tables/ExprNode.h>
42#include <tables/Tables/TableRecord.h>
43#include <measures/Measures/MFrequency.h>
44#include <measures/Measures/MEpoch.h>
45#include <measures/Measures/MeasTable.h>
46#include <measures/Measures/MeasRef.h>
47#include <measures/TableMeasures/TableMeasRefDesc.h>
48#include <measures/TableMeasures/TableMeasValueDesc.h>
49#include <measures/TableMeasures/TableMeasDesc.h>
50#include <measures/TableMeasures/ScalarMeasColumn.h>
51#include <coordinates/Coordinates/CoordinateUtil.h>
52#include <casa/Quanta/MVTime.h>
53#include <casa/Quanta/MVAngle.h>
54
55#include "Scantable.h"
56#include "SDAttr.h"
57
58using namespace casa;
59
60namespace asap {
61
62Scantable::Scantable(Table::TableType ttype) :
63 type_(ttype),
64 freqTable_(ttype),
65 focusTable_(ttype),
66 weatherTable_(ttype),
67 tcalTable_(ttype),
68 moleculeTable_(ttype)
69{
70 setupMainTable();
71 table_.rwKeywordSet().defineTable("FREQUENCIES", freqTable_.table());
72 table_.rwKeywordSet().defineTable("WEATHER", weatherTable_.table());
73 table_.rwKeywordSet().defineTable("FOCUS", focusTable_.table());
74 table_.rwKeywordSet().defineTable("TCAL", tcalTable_.table());
75 table_.rwKeywordSet().defineTable("MOLECULES", moleculeTable_.table());
76 setupHistoryTable();
77 setupFitTable();
78
79 originalTable_ = table_;
80 attach();
81}
82
83Scantable::Scantable(const std::string& name, Table::TableType ttype) :
84 type_(ttype),
85 freqTable_(ttype)
86{
87 Table tab(name);
88 Int version;
89 tab.keywordSet().get("VERSION", version);
90 if (version != version_) {
91 throw(AipsError("Unsupported version of ASAP file."));
92 }
93 if ( type_ == Table::Memory )
94 table_ = tab.copyToMemoryTable("dummy");
95 else
96 table_ = tab;
97
98 originalTable_ = table_;
99 attach();
100}
101
102
103Scantable::Scantable( const Scantable& other, bool clear )
104{
105 // with or without data
106 if (clear) {
107 table_ = TableCopy::makeEmptyMemoryTable(String("dummy"), other.table_,
108 True);
109 } else {
110 table_ = other.table_.copyToMemoryTable(String("dummy"));
111 }
112
113 originalTable_ = table_;
114 attach();
115}
116
117Scantable::~Scantable()
118{
119 cout << "~Scantable() " << this << endl;
120}
121
122void Scantable::setupMainTable()
123{
124 TableDesc td("", "1", TableDesc::Scratch);
125 td.comment() = "An ASAP Scantable";
126 td.rwKeywordSet().define("VERSION", Int(version_));
127
128 // n Cycles
129 td.addColumn(ScalarColumnDesc<uInt>("SCANNO"));
130 // new index every nBeam x nIF x nPol
131 td.addColumn(ScalarColumnDesc<uInt>("CYCLENO"));
132
133 td.addColumn(ScalarColumnDesc<uInt>("BEAMNO"));
134 td.addColumn(ScalarColumnDesc<uInt>("IFNO"));
135 td.rwKeywordSet().define("POLTYPE", String("linear"));
136 td.addColumn(ScalarColumnDesc<uInt>("POLNO"));
137
138 td.addColumn(ScalarColumnDesc<uInt>("FREQ_ID"));
139 td.addColumn(ScalarColumnDesc<uInt>("MOLECULE_ID"));
140 // linear, circular, stokes [I Q U V], stokes1 [I Plinear Pangle V]
141 td.addColumn(ScalarColumnDesc<Int>("REFBEAMNO"));
142
143 td.addColumn(ScalarColumnDesc<Double>("TIME"));
144 TableMeasRefDesc measRef(MEpoch::UTC); // UTC as default
145 TableMeasValueDesc measVal(td, "TIME");
146 TableMeasDesc<MEpoch> mepochCol(measVal, measRef);
147 mepochCol.write(td);
148
149 td.addColumn(ScalarColumnDesc<Double>("INTERVAL"));
150
151 td.addColumn(ScalarColumnDesc<String>("SRCNAME"));
152 // Type of source (on=0, off=1, other=-1)
153 td.addColumn(ScalarColumnDesc<Int>("SRCTYPE", Int(-1)));
154 td.addColumn(ScalarColumnDesc<String>("FIELDNAME"));
155
156 //The actual Data Vectors
157 td.addColumn(ArrayColumnDesc<Float>("SPECTRA"));
158 td.addColumn(ArrayColumnDesc<uChar>("FLAGTRA"));
159 td.addColumn(ArrayColumnDesc<Float>("TSYS"));
160
161 td.addColumn(ArrayColumnDesc<Double>("DIRECTION",
162 IPosition(1,2),
163 ColumnDesc::Direct));
164 TableMeasRefDesc mdirRef(MDirection::J2000); // default
165 TableMeasValueDesc tmvdMDir(td, "DIRECTION");
166 // the TableMeasDesc gives the column a type
167 TableMeasDesc<MDirection> mdirCol(tmvdMDir, mdirRef);
168 // writing create the measure column
169 mdirCol.write(td);
170 td.addColumn(ScalarColumnDesc<Double>("AZIMUTH"));
171 td.addColumn(ScalarColumnDesc<Double>("ELEVATION"));
172 td.addColumn(ScalarColumnDesc<Float>("PARANGLE"));
173
174 td.addColumn(ScalarColumnDesc<uInt>("TCAL_ID"));
175 td.addColumn(ScalarColumnDesc<uInt>("FIT_ID"));
176
177 td.addColumn(ScalarColumnDesc<uInt>("FOCUS_ID"));
178 td.addColumn(ScalarColumnDesc<uInt>("WEATHER_ID"));
179
180 td.rwKeywordSet().define("OBSMODE", String(""));
181
182 // Now create Table SetUp from the description.
183 SetupNewTable aNewTab("dummy", td, Table::New);
184 table_ = Table(aNewTab, Table::Memory, 0);
185
186 originalTable_ = table_;
187
188}
189
190void Scantable::setupHistoryTable( )
191{
192 TableDesc tdh("", "1", TableDesc::Scratch);
193 tdh.addColumn(ScalarColumnDesc<String>("ITEM"));
194 SetupNewTable histtab("history", tdh, Table::New);
195 Table histTable(histtab, Table::Memory);
196 table_.rwKeywordSet().defineTable("HISTORY", histTable);
197}
198
199void Scantable::setupFitTable()
200{
201 TableDesc td("", "1", TableDesc::Scratch);
202 td.addColumn(ScalarColumnDesc<uInt>("FIT_ID"));
203 td.addColumn(ArrayColumnDesc<String>("FUNCTIONS"));
204 td.addColumn(ArrayColumnDesc<Int>("COMPONENTS"));
205 td.addColumn(ArrayColumnDesc<Double>("PARAMETERS"));
206 td.addColumn(ArrayColumnDesc<Bool>("PARMASK"));
207 td.addColumn(ArrayColumnDesc<String>("FRAMEINFO"));
208 SetupNewTable aNewTab("fits", td, Table::New);
209 Table aTable(aNewTab, Table::Memory);
210 table_.rwKeywordSet().defineTable("FITS", aTable);
211}
212
213void Scantable::attach()
214{
215 historyTable_ = table_.keywordSet().asTable("HISTORY");
216 fitTable_ = table_.keywordSet().asTable("FITS");
217
218 timeCol_.attach(table_, "TIME");
219 srcnCol_.attach(table_, "SRCNAME");
220 specCol_.attach(table_, "SPECTRA");
221 flagsCol_.attach(table_, "FLAGTRA");
222 tsCol_.attach(table_, "TSYS");
223 cycleCol_.attach(table_,"CYCLENO");
224 scanCol_.attach(table_, "SCANNO");
225 beamCol_.attach(table_, "BEAMNO");
226 integrCol_.attach(table_, "INTERVAL");
227 azCol_.attach(table_, "AZIMUTH");
228 elCol_.attach(table_, "ELEVATION");
229 dirCol_.attach(table_, "DIRECTION");
230 paraCol_.attach(table_, "PARANGLE");
231 fldnCol_.attach(table_, "FIELDNAME");
232 rbeamCol_.attach(table_, "REFBEAMNO");
233
234 mfitidCol_.attach(table_,"FIT_ID");
235 fitidCol_.attach(fitTable_,"FIT_ID");
236
237 mfreqidCol_.attach(table_, "FREQ_ID");
238
239 mtcalidCol_.attach(table_, "TCAL_ID");
240
241 mfocusidCol_.attach(table_, "FOCUS_ID");
242
243 mmolidCol_.attach(table_, "MOLECULE_ID");
244}
245
246void Scantable::setHeader(const SDHeader& sdh)
247{
248 table_.rwKeywordSet().define("nIF", sdh.nif);
249 table_.rwKeywordSet().define("nBeam", sdh.nbeam);
250 table_.rwKeywordSet().define("nPol", sdh.npol);
251 table_.rwKeywordSet().define("nChan", sdh.nchan);
252 table_.rwKeywordSet().define("Observer", sdh.observer);
253 table_.rwKeywordSet().define("Project", sdh.project);
254 table_.rwKeywordSet().define("Obstype", sdh.obstype);
255 table_.rwKeywordSet().define("AntennaName", sdh.antennaname);
256 table_.rwKeywordSet().define("AntennaPosition", sdh.antennaposition);
257 table_.rwKeywordSet().define("Equinox", sdh.equinox);
258 table_.rwKeywordSet().define("FreqRefFrame", sdh.freqref);
259 table_.rwKeywordSet().define("FreqRefVal", sdh.reffreq);
260 table_.rwKeywordSet().define("Bandwidth", sdh.bandwidth);
261 table_.rwKeywordSet().define("UTC", sdh.utc);
262 table_.rwKeywordSet().define("FluxUnit", sdh.fluxunit);
263 table_.rwKeywordSet().define("Epoch", sdh.epoch);
264}
265
266SDHeader Scantable::getHeader() const
267{
268 SDHeader sdh;
269 table_.keywordSet().get("nBeam",sdh.nbeam);
270 table_.keywordSet().get("nIF",sdh.nif);
271 table_.keywordSet().get("nPol",sdh.npol);
272 table_.keywordSet().get("nChan",sdh.nchan);
273 table_.keywordSet().get("Observer", sdh.observer);
274 table_.keywordSet().get("Project", sdh.project);
275 table_.keywordSet().get("Obstype", sdh.obstype);
276 table_.keywordSet().get("AntennaName", sdh.antennaname);
277 table_.keywordSet().get("AntennaPosition", sdh.antennaposition);
278 table_.keywordSet().get("Equinox", sdh.equinox);
279 table_.keywordSet().get("FreqRefFrame", sdh.freqref);
280 table_.keywordSet().get("FreqRefVal", sdh.reffreq);
281 table_.keywordSet().get("Bandwidth", sdh.bandwidth);
282 table_.keywordSet().get("UTC", sdh.utc);
283 table_.keywordSet().get("FluxUnit", sdh.fluxunit);
284 table_.keywordSet().get("Epoch", sdh.epoch);
285 return sdh;
286}
287
288bool Scantable::conformant( const Scantable& other )
289{
290 return this->getHeader().conformant(other.getHeader());
291}
292
293
294int Scantable::rowToScanIndex( int therow )
295{
296 int therealrow = -1;
297
298 return therealrow;
299}
300
301int Scantable::nscan() const {
302 int n = 0;
303 int previous = -1; int current = 0;
304 for (uInt i=0; i< scanCol_.nrow();i++) {
305 scanCol_.getScalar(i,current);
306 if (previous != current) {
307 previous = current;
308 n++;
309 }
310 }
311 return n;
312}
313
314std::string Scantable::formatSec(Double x) const
315{
316 Double xcop = x;
317 MVTime mvt(xcop/24./3600.); // make days
318
319 if (x < 59.95)
320 return String(" ") + mvt.string(MVTime::TIME_CLEAN_NO_HM, 7)+"s";
321 else if (x < 3599.95)
322 return String(" ") + mvt.string(MVTime::TIME_CLEAN_NO_H,7)+" ";
323 else {
324 ostringstream oss;
325 oss << setw(2) << std::right << setprecision(1) << mvt.hour();
326 oss << ":" << mvt.string(MVTime::TIME_CLEAN_NO_H,7) << " ";
327 return String(oss);
328 }
329};
330
331std::string Scantable::formatDirection(const MDirection& md) const
332{
333 Vector<Double> t = md.getAngle(Unit(String("rad"))).getValue();
334 Int prec = 7;
335
336 MVAngle mvLon(t[0]);
337 String sLon = mvLon.string(MVAngle::TIME,prec);
338 MVAngle mvLat(t[1]);
339 String sLat = mvLat.string(MVAngle::ANGLE+MVAngle::DIG2,prec);
340 return sLon + String(" ") + sLat;
341}
342
343
344std::string Scantable::getFluxUnit() const
345{
346 String tmp;
347 table_.keywordSet().get("FluxUnit", tmp);
348 return tmp;
349}
350
351void Scantable::setFluxUnit(const std::string& unit)
352{
353 String tmp(unit);
354 Unit tU(tmp);
355 if (tU==Unit("K") || tU==Unit("Jy")) {
356 table_.rwKeywordSet().define(String("FluxUnit"), tmp);
357 } else {
358 throw AipsError("Illegal unit - must be compatible with Jy or K");
359 }
360}
361
362void Scantable::setInstrument(const std::string& name)
363{
364 bool throwIt = true;
365 Instrument ins = SDAttr::convertInstrument(name, throwIt);
366 String nameU(name);
367 nameU.upcase();
368 table_.rwKeywordSet().define(String("AntennaName"), nameU);
369}
370
371MPosition Scantable::getAntennaPosition () const
372{
373 Vector<Double> antpos;
374 table_.keywordSet().get("AntennaPosition", antpos);
375 MVPosition mvpos(antpos(0),antpos(1),antpos(2));
376 return MPosition(mvpos);
377}
378
379void Scantable::makePersistent(const std::string& filename)
380{
381 String inname(filename);
382 Path path(inname);
383 inname = path.expandedName();
384 table_.deepCopy(inname, Table::New);
385}
386
387int Scantable::nbeam( int scanno ) const
388{
389 if ( scanno < 0 ) {
390 Int n;
391 table_.keywordSet().get("nBeam",n);
392 return int(n);
393 } else {
394 // take the first POLNO,IFNO,CYCLENO as nbeam shouldn't vary with these
395 Table tab = table_(table_.col("SCANNO") == scanno
396 && table_.col("POLNO") == 0
397 && table_.col("IFNO") == 0
398 && table_.col("CYCLENO") == 0 );
399 ROTableVector<uInt> v(tab, "BEAMNO");
400 return int(v.nelements());
401 }
402 return 0;
403}
404
405int Scantable::nif( int scanno ) const
406{
407 if ( scanno < 0 ) {
408 Int n;
409 table_.keywordSet().get("nIF",n);
410 return int(n);
411 } else {
412 // take the first POLNO,BEAMNO,CYCLENO as nbeam shouldn't vary with these
413 Table tab = table_(table_.col("SCANNO") == scanno
414 && table_.col("POLNO") == 0
415 && table_.col("BEAMNO") == 0
416 && table_.col("CYCLENO") == 0 );
417 ROTableVector<uInt> v(tab, "IFNO");
418 return int(v.nelements());
419 }
420 return 0;
421}
422
423int Scantable::npol( int scanno ) const
424{
425 if ( scanno < 0 ) {
426 Int n;
427 table_.keywordSet().get("nPol",n);
428 return n;
429 } else {
430 // take the first POLNO,IFNO,CYCLENO as nbeam shouldn't vary with these
431 Table tab = table_(table_.col("SCANNO") == scanno
432 && table_.col("IFNO") == 0
433 && table_.col("BEAMNO") == 0
434 && table_.col("CYCLENO") == 0 );
435 ROTableVector<uInt> v(tab, "POLNO");
436 return int(v.nelements());
437 }
438 return 0;
439}
440
441int Scantable::ncycle( int scanno ) const
442{
443 if ( scanno < 0 ) {
444 Block<String> cols(2);
445 cols[0] = "SCANNO";
446 cols[1] = "CYCLENO";
447 TableIterator it(table_, cols);
448 int n = 0;
449 while ( !it.pastEnd() ) {
450 ++n;
451 }
452 return n;
453 } else {
454 // take the first POLNO,IFNO,CYCLENO as nbeam shouldn't vary with these
455 Table tab = table_(table_.col("SCANNO") == scanno
456 && table_.col("BEAMNO") == 0
457 && table_.col("IFNO") == 0
458 && table_.col("POLNO") == 0 );
459 return int(tab.nrow());
460 }
461 return 0;
462}
463
464
465int Scantable::nrow( int scanno ) const
466{
467 return int(table_.nrow());
468}
469
470int Scantable::nchan( int ifno ) const
471{
472 if ( ifno < 0 ) {
473 Int n;
474 table_.keywordSet().get("nChan",n);
475 return int(n);
476 } else {
477 // take the first SCANNO,POLNO,BEAMNO,CYCLENO as nbeam shouldn't vary with these
478 Table tab = table_(table_.col("SCANNO") == 0
479 && table_.col("IFNO") == ifno
480 && table_.col("BEAMNO") == 0
481 && table_.col("POLNO") == 0
482 && table_.col("CYCLENO") == 0 );
483 ROArrayColumn<Float> v(tab, "SPECTRA");
484 return v(0).nelements();
485 }
486 return 0;
487}
488
489Table Scantable::getHistoryTable() const
490{
491 return table_.keywordSet().asTable("HISTORY");
492}
493
494void Scantable::appendToHistoryTable(const Table& otherHist)
495{
496 Table t = table_.rwKeywordSet().asTable("HISTORY");
497
498 addHistory(asap::SEPERATOR);
499 TableCopy::copyRows(t, otherHist, t.nrow(), 0, otherHist.nrow());
500 addHistory(asap::SEPERATOR);
501}
502
503void Scantable::addHistory(const std::string& hist)
504{
505 Table t = table_.rwKeywordSet().asTable("HISTORY");
506 uInt nrow = t.nrow();
507 t.addRow();
508 ScalarColumn<String> itemCol(t, "ITEM");
509 itemCol.put(nrow, hist);
510}
511
512std::vector<std::string> Scantable::getHistory() const
513{
514 Vector<String> history;
515 const Table& t = table_.keywordSet().asTable("HISTORY");
516 uInt nrow = t.nrow();
517 ROScalarColumn<String> itemCol(t, "ITEM");
518 std::vector<std::string> stlout;
519 String hist;
520 for (uInt i=0; i<nrow; ++i) {
521 itemCol.get(i, hist);
522 stlout.push_back(hist);
523 }
524 return stlout;
525}
526
527std::string Scantable::formatTime(const MEpoch& me, bool showdate) const
528{
529 MVTime mvt(me.getValue());
530 if (showdate)
531 mvt.setFormat(MVTime::YMD);
532 else
533 mvt.setFormat(MVTime::TIME);
534 ostringstream oss;
535 oss << mvt;
536 return String(oss);
537}
538
539void Scantable::calculateAZEL()
540{
541 MPosition mp = getAntennaPosition();
542 MEpoch::ROScalarColumn timeCol(table_, "TIME");
543 ostringstream oss;
544 oss << "Computed azimuth/elevation using " << endl
545 << mp << endl;
546 for (uInt i=0; i<nrow(); ++i) {
547 MEpoch me = timeCol(i);
548 MDirection md = dirCol_(i);
549 dirCol_.get(i,md);
550 oss << " Time: " << formatTime(me,False) << " Direction: " << formatDirection(md)
551 << endl << " => ";
552 MeasFrame frame(mp, me);
553 Vector<Double> azel =
554 MDirection::Convert(md, MDirection::Ref(MDirection::AZEL,
555 frame)
556 )().getAngle("rad").getValue();
557 azCol_.put(i,azel[0]);
558 elCol_.put(i,azel[1]);
559 oss << "azel: " << azel[0]/C::pi*180.0 << " "
560 << azel[1]/C::pi*180.0 << " (deg)" << endl;
561 }
562 pushLog(String(oss));
563}
564
565double Scantable::getInterval(int whichrow) const
566{
567 if (whichrow < 0) return 0.0;
568 Double intval;
569 integrCol_.get(Int(whichrow), intval);
570 return intval;
571}
572
573std::vector<bool> Scantable::getMask(int whichrow) const
574{
575 Vector<uChar> flags;
576 flagsCol_.get(uInt(whichrow), flags);
577 Vector<Bool> bflag(flags.shape());
578 convertArray(bflag, flags);
579 bflag = !bflag;
580 std::vector<bool> mask;
581 bflag.tovector(mask);
582 return mask;
583}
584
585std::vector<float> Scantable::getSpectrum(int whichrow) const
586{
587 Vector<Float> arr;
588 specCol_.get(whichrow, arr);
589 std::vector<float> out;
590 arr.tovector(out);
591 return out;
592}
593
594String Scantable::generateName()
595{
596 return (File::newUniqueName("./","temp")).baseName();
597}
598
599const casa::Table& Scantable::table( ) const
600{
601 return table_;
602}
603
604casa::Table& Scantable::table( )
605{
606 return table_;
607}
608
609std::string Scantable::getPolarizationLabel(bool linear, bool stokes,
610 bool linpol, int polidx) const
611{
612 uInt idx = 0;
613 if (polidx >=0) idx = polidx;
614 return "";
615 //return SDPolUtil::polarizationLabel(idx, linear, stokes, linpol);
616}
617
618void Scantable::unsetSelection()
619{
620 table_ = originalTable_;
621 selector_.reset();
622}
623
624void Scantable::setSelection( const STSelector& selection )
625{
626 Table tab = const_cast<STSelector&>(selection).apply(originalTable_);
627 if ( tab.nrow() == 0 ) {
628 throw(AipsError("Selection contains no data. Not applying it."));
629 }
630 table_ = tab;
631 selector_ = selection;
632}
633
634std::string Scantable::summary( bool verbose )
635{
636 // Format header info
637 ostringstream oss;
638 oss << endl;
639 oss << asap::SEPERATOR << endl;
640 oss << " Scan Table Summary" << endl;
641 oss << asap::SEPERATOR << endl;
642 oss.flags(std::ios_base::left);
643 oss << setw(15) << "Beams:" << setw(4) << nbeam() << endl
644 << setw(15) << "IFs:" << setw(4) << nif() << endl
645 << setw(15) << "Polarisations:" << setw(4) << npol() << endl
646 << setw(15) << "Channels:" << setw(4) << nchan() << endl;
647 oss << endl;
648 String tmp;
649 //table_.keywordSet().get("Observer", tmp);
650 oss << setw(15) << "Observer:" << table_.keywordSet().asString("Observer") << endl;
651 oss << setw(15) << "Obs Date:" << getTime(-1,true) << endl;
652 table_.keywordSet().get("Project", tmp);
653 oss << setw(15) << "Project:" << tmp << endl;
654 table_.keywordSet().get("Obstype", tmp);
655 oss << setw(15) << "Obs. Type:" << tmp << endl;
656 table_.keywordSet().get("AntennaName", tmp);
657 oss << setw(15) << "Antenna Name:" << tmp << endl;
658 table_.keywordSet().get("FluxUnit", tmp);
659 oss << setw(15) << "Flux Unit:" << tmp << endl;
660 Vector<Float> vec;
661 oss << setw(15) << "Rest Freqs:";
662 if (vec.nelements() > 0) {
663 oss << setprecision(10) << vec << " [Hz]" << endl;
664 } else {
665 oss << "none" << endl;
666 }
667 oss << setw(15) << "Abcissa:" << "channel" << endl;
668 oss << selector_.print() << endl;
669 oss << endl;
670 // main table
671 String dirtype = "Position ("
672 + MDirection::showType(dirCol_.getMeasRef().getType())
673 + ")";
674 oss << setw(5) << "Scan"
675 << setw(15) << "Source"
676// << setw(24) << dirtype
677 << setw(10) << "Time"
678 << setw(18) << "Integration" << endl
679 << setw(5) << "" << setw(10) << "Beam" << dirtype << endl
680 << setw(15) << "" << setw(5) << "IF"
681 << setw(8) << "Frame" << setw(16)
682 << "RefVal" << setw(10) << "RefPix" << setw(12) << "Increment" <<endl;
683 oss << asap::SEPERATOR << endl;
684 TableIterator iter(table_, "SCANNO");
685 while (!iter.pastEnd()) {
686 Table subt = iter.table();
687 ROTableRow row(subt);
688 MEpoch::ROScalarColumn timeCol(subt,"TIME");
689 const TableRecord& rec = row.get(0);
690 oss << setw(4) << std::right << rec.asuInt("SCANNO")
691 << std::left << setw(1) << ""
692 << setw(15) << rec.asString("SRCNAME")
693 << setw(10) << formatTime(timeCol(0), false);
694 // count the cycles in the scan
695 TableIterator cyciter(subt, "CYCLENO");
696 int nint = 0;
697 while (!cyciter.pastEnd()) {
698 ++nint;
699 ++cyciter;
700 }
701 oss << setw(3) << std::right << nint << setw(3) << " x " << std::left
702 << setw(6) << formatSec(rec.asFloat("INTERVAL")) << endl;
703
704 TableIterator biter(subt, "BEAMNO");
705 while (!biter.pastEnd()) {
706 Table bsubt = biter.table();
707 ROTableRow brow(bsubt);
708 MDirection::ROScalarColumn bdirCol(bsubt,"DIRECTION");
709 const TableRecord& brec = brow.get(0);
710 oss << setw(6) << "" << setw(10) << brec.asuInt("BEAMNO");
711 oss << setw(24) << formatDirection(bdirCol(0)) << endl;
712 TableIterator iiter(bsubt, "IFNO");
713 while (!iiter.pastEnd()) {
714 Table isubt = iiter.table();
715 ROTableRow irow(isubt);
716 const TableRecord& irec = irow.get(0);
717 oss << std::right <<setw(8) << "" << std::left << irec.asuInt("IFNO");
718 oss << frequencies().print(irec.asuInt("FREQ_ID"));
719
720 ++iiter;
721 }
722 ++biter;
723 }
724 ++iter;
725 }
726 /// @todo implement verbose mode
727 return String(oss);
728}
729
730std::string Scantable::getTime(int whichrow, bool showdate) const
731{
732 MEpoch::ROScalarColumn timeCol(table_, "TIME");
733 MEpoch me;
734 if (whichrow > -1) {
735 me = timeCol(uInt(whichrow));
736 } else {
737 Double tm;
738 table_.keywordSet().get("UTC",tm);
739 me = MEpoch(MVEpoch(tm));
740 }
741 return formatTime(me, showdate);
742}
743
744}//namespace asap
Note: See TracBrowser for help on using the repository browser.