source: trunk/src/SDMemTable.cc @ 68

Last change on this file since 68 was 68, checked in by mmarquar, 20 years ago

Fixed vaious warnings arising when compiled without warning suprssion.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 19.4 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDMemTable.cc: A MemoryTable container for single dish integrations
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# Malte Marquarding, 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
33#include <aips/iostream.h>
34#include <aips/iomanip.h>
35#include <aips/Arrays/Array.h>
36#include <aips/Arrays/ArrayMath.h>
37#include <aips/Arrays/MaskArrMath.h>
38#include <aips/Arrays/ArrayLogical.h>
39#include <aips/Arrays/ArrayAccessor.h>
40
41#include <aips/Tables/TableParse.h>
42#include <aips/Tables/TableDesc.h>
43#include <aips/Tables/SetupNewTab.h>
44#include <aips/Tables/ScaColDesc.h>
45#include <aips/Tables/ArrColDesc.h>
46
47#include <aips/Tables/ExprNode.h>
48#include <aips/Tables/ScalarColumn.h>
49#include <aips/Tables/ArrayColumn.h>
50#include <aips/Tables/TableRecord.h>
51#include <aips/Measures/MFrequency.h>
52#include <aips/Quanta/MVTime.h>
53
54#include "SDMemTable.h"
55#include "SDContainer.h"
56
57using namespace atnf_sd;
58
59SDMemTable::SDMemTable() :
60  IFSel_(0),
61  beamSel_(0),
62  polSel_(0) {
63  setup();
64}
65SDMemTable::SDMemTable(const std::string& name) :
66  IFSel_(0),
67  beamSel_(0),
68  polSel_(0) {
69  Table tab(name);
70  table_ = tab.copyToMemoryTable("dummy");
71}
72
73SDMemTable::SDMemTable(const SDMemTable& other, Bool clear) {
74  this->IFSel_= other.IFSel_;
75  this->beamSel_= other.beamSel_;
76  this->polSel_= other.polSel_;
77  this->chanMask_ = other.chanMask_;
78  this->table_ = other.table_.copyToMemoryTable(String("dummy"));
79  // clear all rows()
80  if (clear) {
81    this->table_.removeRow(this->table_.rowNumbers());
82  } else {
83    this->IFSel_ = other.IFSel_;
84    this->beamSel_ = other.beamSel_;
85    this->polSel_ = other.polSel_;
86  }
87}
88
89SDMemTable::SDMemTable(const Table& tab, Int scanID) :
90  IFSel_(0),
91  beamSel_(0),
92  polSel_(0) {
93  String exprs = String("select * from $1 where SCANID == ")
94    +String::toString(scanID);
95  //cerr << exprs << endl;
96  Table t = tableCommand(exprs,tab);
97  table_ = t.copyToMemoryTable("dummy");
98}
99
100SDMemTable::~SDMemTable(){
101  //cerr << "goodbye from SDMemTable @ " << this << endl;
102}
103
104SDMemTable SDMemTable::getScan(Int scanID) {
105  return SDMemTable(table_, scanID);
106}
107
108void SDMemTable::setup() {
109  TableDesc td("", "1", TableDesc::Scratch);
110  td.comment() = "A SDMemTable";
111  td.addColumn(ScalarColumnDesc<Double>("TIME"));
112  td.addColumn(ScalarColumnDesc<String>("SRCNAME"));
113  td.addColumn(ArrayColumnDesc<Float>("SPECTRA"));
114  td.addColumn(ArrayColumnDesc<uChar>("FLAGTRA"));
115  td.addColumn(ArrayColumnDesc<Float>("TSYS")); 
116  td.addColumn(ScalarColumnDesc<Int>("SCANID")); 
117  td.addColumn(ScalarColumnDesc<Double>("INTERVAL")); 
118  td.addColumn(ArrayColumnDesc<uInt>("FREQID"));
119  // Now create a new table from the description.
120
121  SetupNewTable aNewTab("dummy", td, Table::New);
122  table_ = Table(aNewTab, Table::Memory, 0); 
123}
124
125std::string SDMemTable::getSourceName(Int whichRow) const {
126  ROScalarColumn<String> src(table_, "SRCNAME");
127  String name;
128  src.get(whichRow, name);
129  return name;
130}
131
132std::string SDMemTable::getTime(Int whichRow) const {
133  ROScalarColumn<Double> src(table_, "TIME");
134  Double tm;
135  src.get(whichRow, tm);
136  MVTime mvt(tm);
137  mvt.setFormat(MVTime::YMD);
138  ostringstream oss;
139  oss << mvt;
140  String str(oss);
141  return str;
142}
143double SDMemTable::getInterval(Int whichRow) const {
144  ROScalarColumn<Double> src(table_, "INTERVAL");
145  Double intval;
146  src.get(whichRow, intval);
147  return intval;
148}
149
150bool SDMemTable::setIF(Int whichIF) {
151  if ( whichIF >= 0 && whichIF < nIF()) {
152    IFSel_ = whichIF;
153    return true;
154  }
155  return false;
156}
157
158bool SDMemTable::setBeam(Int whichBeam) {
159  if ( whichBeam >= 0 && whichBeam < nBeam()) {
160    beamSel_ = whichBeam;
161    return true;
162  }
163  return false;
164}
165
166bool SDMemTable::setPol(Int whichPol) {
167  if ( whichPol >= 0 && whichPol < nPol()) {
168    polSel_ = whichPol;
169    return true;
170  }
171  return false;
172}
173
174bool SDMemTable::setMask(std::vector<int> whichChans) {
175  ROArrayColumn<uChar> spec(table_, "FLAGTRA");
176 
177  std::vector<int>::iterator it;
178  uInt n = spec.shape(0)(3);
179  chanMask_.resize(n,true);
180  for (it = whichChans.begin(); it != whichChans.end(); ++it) {
181    if (*it < n)
182      chanMask_[*it] = false;
183  }
184  return true;
185}
186
187std::vector<bool> SDMemTable::getMask(Int whichRow) const {
188  std::vector<bool> mask;
189  ROArrayColumn<uChar> spec(table_, "FLAGTRA");
190  Array<uChar> arr;
191  spec.get(whichRow, arr);
192  ArrayAccessor<uChar, Axis<0> > aa0(arr);
193  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
194  ArrayAccessor<uChar, Axis<1> > aa1(aa0);
195  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
196  ArrayAccessor<uChar, Axis<2> > aa2(aa1);
197  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
198
199  Bool useUserMask = ( chanMask_.size() == arr.shape()(3) );
200
201  std::vector<bool> tmp;
202  tmp = chanMask_; // WHY the fxxx do I have to make a copy here
203  std::vector<bool>::iterator miter;
204  miter = tmp.begin();
205
206  for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) {
207    bool out =!static_cast<bool>(*i);
208    if (useUserMask) {
209      out = out && (*miter);
210      miter++;
211    }
212    mask.push_back(out);
213  } 
214  return mask;
215}
216std::vector<float> SDMemTable::getSpectrum(Int whichRow) const {
217
218  std::vector<float> spectrum;
219  ROArrayColumn<Float> spec(table_, "SPECTRA");
220  Array<Float> arr;
221  spec.get(whichRow, arr);
222  ArrayAccessor<Float, Axis<0> > aa0(arr);
223  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
224  ArrayAccessor<Float, Axis<1> > aa1(aa0);
225  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
226  ArrayAccessor<Float, Axis<2> > aa2(aa1);
227  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
228  for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
229    spectrum.push_back(*i);
230  }
231  return spectrum;
232}
233
234std::vector<double> SDMemTable::getAbscissa(Int whichRow,
235                                            const std::string& whichUnit,
236                                            double restfreq) {
237  std::vector<double> absc(nChan());
238  Vector<Double> absc1(nChan());
239  indgen(absc1);
240  ROArrayColumn<uInt> fid(table_, "FREQID");
241  Vector<uInt> v;
242  fid.get(whichRow, v);
243  uInt specidx = v(IFSel_);
244  Unit u;
245  if (whichUnit == "") {
246    // get unit from table
247  } else {
248    u = String(whichUnit);
249  }
250  SpectralCoordinate spc = getCoordinate(specidx);
251  if ( u == Unit("km/s") ) {
252    if (Double(restfreq) >  Double(0.000001)) {
253      cerr << "converting to velocities"<< endl;
254      spc.setRestFrequency(Double(restfreq));
255      spc.setVelocity(u.getName());
256      Vector<Double> wrld;
257      spc.pixelToVelocity(wrld,absc1);
258      std::vector<double>::iterator it;
259      uInt i = 0;
260      for (it = absc.begin(); it != absc.end(); ++it) {
261        (*it) = wrld[i];
262        i++;
263      }
264    }
265  } else if (u == Unit("Hz")) {
266    Vector<String> wau(1); wau = u.getName();
267    spc.setWorldAxisUnits(wau);
268    cerr << " converting in frequency" << endl;
269    std::vector<double>::iterator it;
270    Double tmp;
271    uInt i = 0;
272    for (it = absc.begin(); it != absc.end(); ++it) {     
273      spc.toWorld(tmp,absc1[i]);
274      (*it) = tmp;
275      i++;
276    }
277  }
278  return absc;
279}
280
281void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow) {
282  ROArrayColumn<Float> spec(table_, "SPECTRA");
283  Array<Float> arr;
284  spec.get(whichRow, arr);
285  spectrum.resize(arr.shape()(3));
286  ArrayAccessor<Float, Axis<0> > aa0(arr);
287  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
288  ArrayAccessor<Float, Axis<1> > aa1(aa0);
289  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
290  ArrayAccessor<Float, Axis<2> > aa2(aa1);
291  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
292
293  ArrayAccessor<Float, Axis<0> > va(spectrum);
294  for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
295    (*va) = (*i);
296    va++;
297  }
298}
299
300void SDMemTable::getMask(Vector<Bool>& mask, Int whichRow) const {
301  ROArrayColumn<uChar> spec(table_, "FLAGTRA");
302  Array<uChar> arr;
303  spec.get(whichRow, arr);
304  mask.resize(arr.shape()(3));
305
306  ArrayAccessor<uChar, Axis<0> > aa0(arr);
307  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
308  ArrayAccessor<uChar, Axis<1> > aa1(aa0);
309  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
310  ArrayAccessor<uChar, Axis<2> > aa2(aa1);
311  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
312
313  Bool useUserMask = ( chanMask_.size() == arr.shape()(3) );
314 
315  ArrayAccessor<Bool, Axis<0> > va(mask);
316  std::vector<bool> tmp;
317  tmp = chanMask_; // WHY the fxxx do I have to make a copy here. The
318                   // iterator should work on chanMask_??
319  std::vector<bool>::iterator miter;
320  miter = tmp.begin();
321
322  for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) {
323    bool out =!static_cast<bool>(*i);
324    if (useUserMask) {
325      out = out && (*miter);
326      miter++;
327    }
328    (*va) = out;
329    va++;
330  } 
331}
332
333MaskedArray<Float> SDMemTable::rowAsMaskedArray(uInt whichRow,
334                                                Bool useSelection) {
335  ROArrayColumn<Float> spec(table_, "SPECTRA");
336  Array<Float> arr;
337  ROArrayColumn<uChar> flag(table_, "FLAGTRA");
338  Array<uChar> farr;
339  spec.get(whichRow, arr);
340  flag.get(whichRow, farr);
341  Array<Bool> barr(farr.shape());convertArray(barr, farr);
342  MaskedArray<Float> marr;
343  if (useSelection) {
344    ArrayAccessor<Float, Axis<0> > aa0(arr);
345    aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
346    ArrayAccessor<Float, Axis<1> > aa1(aa0);
347    aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
348    ArrayAccessor<Float, Axis<2> > aa2(aa1);
349    aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
350   
351    ArrayAccessor<Bool, Axis<0> > baa0(barr);
352    baa0.reset(baa0.begin(uInt(beamSel_)));//go to beam
353    ArrayAccessor<Bool, Axis<1> > baa1(baa0);
354    baa1.reset(baa1.begin(uInt(IFSel_)));// go to IF
355    ArrayAccessor<Bool, Axis<2> > baa2(baa1);
356    baa2.reset(baa2.begin(uInt(polSel_)));// go to pol
357
358    Vector<Float> a(arr.shape()(3));
359    Vector<Bool> b(barr.shape()(3));
360    ArrayAccessor<Float, Axis<0> > a0(a);
361    ArrayAccessor<Bool, Axis<0> > b0(b);
362
363    ArrayAccessor<Bool, Axis<3> > j(baa2);
364    for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
365      (*a0) = (*i);
366      (*b0) = !(*j);
367      j++;
368      a0++;
369      b0++;
370    }
371    marr.setData(a,b);
372  } else {
373    marr.setData(arr,!barr);
374  }
375  return marr;
376}
377
378Float SDMemTable::getTsys(Int whichRow) const {
379  ROArrayColumn<Float> ts(table_, "TSYS");
380  Array<Float> arr;
381  ts.get(whichRow, arr);
382  Float out;
383  IPosition ip(arr.shape());
384  ip(0) = beamSel_;ip(1) = IFSel_;ip(2) = polSel_;ip(3)=0;
385  out = arr(ip);
386  return out;
387}
388
389SpectralCoordinate SDMemTable::getCoordinate(uInt whichIdx)  const {
390
391  Table t = table_.keywordSet().asTable("FREQUENCIES");
392  if (whichIdx > t.nrow() ) {
393    cerr << "SDMemTable::getCoordinate - whichIdx out of range" << endl;
394    return SpectralCoordinate();
395  }
396  Double rp,rv,inc;
397  String rf;
398  ROScalarColumn<Double> rpc(t, "REFPIX");
399  ROScalarColumn<Double> rvc(t, "REFVAL");
400  ROScalarColumn<Double> incc(t, "INCREMENT");
401  t.keywordSet().get("REFFRAME",rf);
402 
403  MFrequency::Types mft;
404  if (!MFrequency::getType(mft, rf)) {
405    cerr << "Frequency type unknown assuming TOPO" << endl;
406    mft = MFrequency::TOPO;   
407  }   
408  rpc.get(whichIdx, rp);
409  rvc.get(whichIdx, rv);
410  incc.get(whichIdx, inc);
411  //cerr << "creating speccord from " << whichIdx << ": "
412  //     << rp <<", " << rv << ", " << inc << ", " << mft <<endl;
413  SpectralCoordinate spec(mft,rv,inc,rp);
414  return spec;
415}
416
417Bool SDMemTable::setCoordinate(const SpectralCoordinate& speccord,
418                               uInt whichIdx) {
419  Table t = table_.rwKeywordSet().asTable("FREQUENCIES");
420  if (whichIdx > t.nrow() ) {
421    cerr << "SDMemTable::setCoordinate - whichIdx out of range" << endl;
422    return False;
423  }
424  ScalarColumn<Double> rpc(t, "REFPIX");
425  ScalarColumn<Double> rvc(t, "REFVAL");
426  ScalarColumn<Double> incc(t, "INCREMENT");
427 
428  rpc.put(whichIdx, speccord.referencePixel()[0]);
429  rvc.put(whichIdx, speccord.referenceValue()[0]);
430  incc.put(whichIdx, speccord.increment()[0]);
431
432  return True;
433}
434
435
436bool SDMemTable::putSDFreqTable(const SDFrequencyTable& sdft) {
437  TableDesc td("", "1", TableDesc::Scratch);
438  td.addColumn(ScalarColumnDesc<Double>("REFPIX"));
439  td.addColumn(ScalarColumnDesc<Double>("REFVAL"));
440  td.addColumn(ScalarColumnDesc<Double>("INCREMENT"));
441  SetupNewTable aNewTab("freqs", td, Table::New);
442  Table aTable (aNewTab, Table::Memory, sdft.length());
443  ScalarColumn<Double> sc0(aTable, "REFPIX");
444  ScalarColumn<Double> sc1(aTable, "REFVAL");
445  ScalarColumn<Double> sc2(aTable, "INCREMENT");
446  for (uInt i=0; i < sdft.length(); ++i) {
447    sc0.put(i,sdft.referencePixel(i));
448    sc1.put(i,sdft.referenceValue(i));
449    sc2.put(i,sdft.increment(i));
450  }
451  aTable.rwKeywordSet().define("REFFRAME", sdft.refFrame());
452  aTable.rwKeywordSet().define("EQUINOX", sdft.equinox());
453  aTable.rwKeywordSet().define("Unit", String("kms-1"));
454  table_.rwKeywordSet().defineTable ("FREQUENCIES", aTable);
455  return True;
456}
457
458SDFrequencyTable SDMemTable::getSDFreqTable() const  {
459  SDFrequencyTable sdft;
460 
461  return sdft;
462}
463
464bool SDMemTable::putSDContainer(const SDContainer& sdc) {
465  ScalarColumn<Double> mjd(table_, "TIME");
466  ScalarColumn<String> srcn(table_, "SRCNAME");
467  ArrayColumn<Float> spec(table_, "SPECTRA");
468  ArrayColumn<uChar> flags(table_, "FLAGTRA");
469  ArrayColumn<Float> ts(table_, "TSYS");
470  ScalarColumn<Int> scan(table_, "SCANID");
471  ScalarColumn<Double> integr(table_, "INTERVAL");
472  ArrayColumn<uInt> freqid(table_, "FREQID");
473
474  uInt rno = table_.nrow();
475  table_.addRow();
476 
477  mjd.put(rno, sdc.timestamp);
478  srcn.put(rno, sdc.sourcename);
479  spec.put(rno, sdc.getSpectrum());
480  flags.put(rno, sdc.getFlags());
481  ts.put(rno, sdc.getTsys());
482  scan.put(rno, sdc.scanid);
483  integr.put(rno, sdc.interval);
484  freqid.put(rno, sdc.getFreqMap());
485 
486  return true;
487}
488
489SDContainer SDMemTable::getSDContainer(uInt whichRow) const {
490  ROScalarColumn<Double> mjd(table_, "TIME");
491  ROScalarColumn<String> srcn(table_, "SRCNAME");
492  ROArrayColumn<Float> spec(table_, "SPECTRA");
493  ROArrayColumn<uChar> flags(table_, "FLAGTRA");
494  ROArrayColumn<Float> ts(table_, "TSYS");
495  ROScalarColumn<Int> scan(table_, "SCANID");
496  ROScalarColumn<Double> integr(table_, "INTERVAL");
497  ROArrayColumn<uInt> freqid(table_, "FREQID");
498
499  SDContainer sdc(nBeam(),nIF(),nPol(),nChan());
500  mjd.get(whichRow, sdc.timestamp);
501  srcn.get(whichRow, sdc.sourcename);
502  integr.get(whichRow, sdc.interval);
503  scan.get(whichRow, sdc.scanid);
504  Array<Float> spectrum;
505  Array<Float> tsys;
506  Array<uChar> flagtrum;
507  Vector<uInt> fmap;
508  spec.get(whichRow, spectrum);
509  sdc.putSpectrum(spectrum);
510  flags.get(whichRow, flagtrum);
511  sdc.putFlags(flagtrum);
512  ts.get(whichRow, tsys);
513  sdc.putTsys(tsys);
514  freqid.get(whichRow, fmap);
515  sdc.putFreqMap(fmap);
516  return sdc;
517}
518bool SDMemTable::putSDHeader(const SDHeader& sdh) {
519  table_.lock();
520  table_.rwKeywordSet().define("nIF", sdh.nif);
521  table_.rwKeywordSet().define("nBeam", sdh.nbeam);
522  table_.rwKeywordSet().define("nPol", sdh.npol);
523  table_.rwKeywordSet().define("nChan", sdh.nchan);
524  table_.rwKeywordSet().define("Observer", sdh.observer);
525  table_.rwKeywordSet().define("Project", sdh.project);
526  table_.rwKeywordSet().define("Obstype", sdh.obstype);
527  table_.rwKeywordSet().define("AntennaName", sdh.antennaname);
528  table_.rwKeywordSet().define("AntennaPosition", sdh.antennaposition);
529  table_.rwKeywordSet().define("Equinox", sdh.equinox);
530  table_.rwKeywordSet().define("FreqRefFrame", sdh.freqref);
531  table_.rwKeywordSet().define("FreqRefVal", sdh.reffreq);
532  table_.rwKeywordSet().define("Bandwidth", sdh.bandwidth);
533  table_.rwKeywordSet().define("UTC", sdh.utc);
534  table_.unlock();
535  return true;
536}
537
538SDHeader SDMemTable::getSDHeader() const {
539  SDHeader sdh;
540  table_.keywordSet().get("nBeam",sdh.nbeam);
541  table_.keywordSet().get("nIF",sdh.nif);
542  table_.keywordSet().get("nPol",sdh.npol);
543  table_.keywordSet().get("nChan",sdh.nchan);
544  table_.keywordSet().get("Observer", sdh.observer);
545  table_.keywordSet().get("Project", sdh.project);
546  table_.keywordSet().get("Obstype", sdh.obstype);
547  table_.keywordSet().get("AntennaName", sdh.antennaname);
548  table_.keywordSet().get("AntennaPosition", sdh.antennaposition);
549  table_.keywordSet().get("Equinox", sdh.equinox);
550  table_.keywordSet().get("FreqRefFrame", sdh.freqref);
551  table_.keywordSet().get("FreqRefVal", sdh.reffreq);
552  table_.keywordSet().get("Bandwidth", sdh.bandwidth);
553  table_.keywordSet().get("UTC", sdh.utc);
554  return sdh;
555}
556void SDMemTable::makePersistent(const std::string& filename) {
557  table_.deepCopy(filename,Table::New);
558}
559
560Int SDMemTable::nScans() const {
561  Int n = 0;
562  ROScalarColumn<Int> scans(table_, "SCANID");
563  Int previous = -1;Int current=0;
564  for (uInt i=0; i< scans.nrow();i++) {
565    scans.getScalar(i,current);
566    if (previous != current) {
567      previous = current;     
568      n++;
569    }
570  }
571  return n;
572}
573
574void SDMemTable::summary() const {
575  ROScalarColumn<Int> scans(table_, "SCANID");
576  ROScalarColumn<String> srcs(table_, "SRCNAME");
577  cout << "*************** Header ***************" << endl;
578  cout << "nBeam = " << nBeam() << "\t"
579       << "nIF   = " << nIF() << endl
580       << "nPol  = " << nPol() << "\t"
581       << "nChan = " << nChan() << "\t" << endl;
582  cout << "*************** Header ***************" << endl;
583  uInt count = 0;
584  String name;
585  Int previous = -1;Int current=0;
586  cout << "Scan\tSource\t\tTime\t\tIntegration" << endl;
587  for (uInt i=0; i< scans.nrow();i++) {
588    scans.getScalar(i,current);
589    if (previous != current) {
590      srcs.getScalar(i,name);
591      previous = current;
592      Double t = getInterval();
593      String unit("sec");
594      if (t/60.0 > 1.0) {
595        t/=60.0;unit = "min";
596      }
597      cout << count << "\t"
598           << name << "\t"
599           << getTime() << "\t"
600           << setprecision(2) <<  setiosflags(std::ios_base::fixed)
601           << t << " " << unit << endl
602           << endl;
603      count++;
604    }
605  }
606  cout << "Table contains " << table_.nrow() << " integration(s)." << endl;
607  cout << "in " << count << " scan(s)." << endl;
608}
609
610Int SDMemTable::nBeam() const {
611  Int n;
612  table_.keywordSet().get("nBeam",n);
613  return n;
614}
615Int SDMemTable::nIF() const {
616  Int n;
617  table_.keywordSet().get("nIF",n);
618  return n;
619}
620Int SDMemTable::nPol() const {
621  Int n;
622  table_.keywordSet().get("nPol",n);
623  return n;
624}
625Int SDMemTable::nChan() const {
626  Int n;
627  table_.keywordSet().get("nChan",n);
628  return n;
629}
630/*
631void SDMemTable::maskChannels(const std::vector<Int>& whichChans ) {
632 
633  std::vector<int>::iterator it;
634  ArrayAccessor<uChar, Axis<2> > j(flags_);
635  for (it = whichChans.begin(); it != whichChans.end(); it++) {
636    j.reset(j.begin(uInt(*it)));
637    for (ArrayAccessor<uChar, Axis<0> > i(j); i != i.end(); ++i) {
638      for (ArrayAccessor<uChar, Axis<1> > ii(i); ii != ii.end(); ++ii) {
639        for (ArrayAccessor<uChar, Axis<3> > iii(ii);
640             iii != iii.end(); ++iii) {   
641          (*iii) =
642        }
643      }
644    }
645  }
646 
647}
648*/
Note: See TracBrowser for help on using the repository browser.