Changeset 2720


Ignore:
Timestamp:
01/09/13 19:27:23 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: Yes

JIRA Issue: Yes CAS-4770 and its sub-tickets

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

First version of applycal for single dish calibration.
Added new classes for the operation (STApplyCal, Calibrator, PSAlmaCalibrator,
Locator, BisectionLocator, Interpolator1D, NearestInterpolator1D).
Also, modified existing classes to fit with implementation of applycal.


Location:
trunk/src
Files:
14 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/CMakeLists.txt

    r2707 r2720  
    7676     ${SRCDIR}/STCalibration.cpp
    7777     ${SRCDIR}/STCalSkyPSAlma.cpp
    78      ${SRCDIR}/STCalTsys.cpp )
     78     ${SRCDIR}/STCalTsys.cpp
     79     ${SRCDIR}/STApplyCal.cpp
     80     ${SRCDIR}/Calibrator.cpp
     81     ${SRCDIR}/PSAlmaCalibrator.cpp
     82     ${SRCDIR}/Locator.cpp
     83     ${SRCDIR}/BisectionLocator.cpp
     84     ${SRCDIR}/Interpolator1D.cpp
     85     ${SRCDIR}/NearestInterpolator1D.cpp )
    7986
    8087set( ASAP_PYSRCS
  • trunk/src/STApplyTable.cpp

    r2703 r2720  
    1515#include <tables/Tables/ScaColDesc.h>
    1616#include <tables/Tables/TableRecord.h>
     17#include <tables/Tables/Table.h>
     18#include <tables/Tables/ExprNode.h>
    1719#include <measures/TableMeasures/TableMeasDesc.h>
    1820#include <measures/TableMeasures/TableMeasRefDesc.h>
     
    3537  td.addColumn(ScalarColumnDesc<uInt>("IFNO"));
    3638  td.addColumn(ScalarColumnDesc<uInt>("POLNO"));
     39  td.addColumn(ScalarColumnDesc<uInt>("FREQ_ID"));
    3740  td.addColumn(ScalarColumnDesc<Double>("TIME"));
    3841  TableMeasRefDesc measRef(MEpoch::UTC); // UTC as default
     
    5356  table_.tableInfo().setType("ApplyTable");
    5457
     58  originaltable_ = table_;
     59}
     60
     61STApplyTable::STApplyTable(const String &name)
     62{
     63  table_ = Table(name, Table::Update);
     64  attachBaseColumns();
    5565  originaltable_ = table_;
    5666}
     
    7686  timeCol_.attach(table_, "TIME");
    7787  timeMeasCol_.attach(table_, "TIME");
     88  freqidCol_.attach(table_, "FREQ_ID");
    7889}
    7990
    80 void STApplyTable::setSelection(STSelector &sel)
     91void STApplyTable::setSelection(STSelector &sel, bool sortByTime)
    8192{
    8293  table_ = sel.apply(originaltable_);
     94  if (sortByTime)
     95    table_.sort("TIME", Sort::Descending);
    8396  attach();
    8497  sel_ = sel;
     
    94107void STApplyTable::setbasedata(uInt irow, uInt scanno, uInt cycleno,
    95108                               uInt beamno, uInt ifno, uInt polno,
    96                                Double time)
     109                               uInt freqid, Double time)
    97110{
    98111  scanCol_.put(irow, scanno);
     
    102115  polCol_.put(irow, polno);
    103116  timeCol_.put(irow, time);
     117  freqidCol_.put(irow, freqid);
    104118}
    105119
     
    109123}
    110124
     125String STApplyTable::caltype()
     126{
     127  if (table_.keywordSet().isDefined("ApplyType")) {
     128    return table_.keywordSet().asString("ApplyType");
     129  }
     130  else
     131    return "NONE";
    111132}
     133
     134STCalEnum::CalType  STApplyTable::getCalType(const String &name)
     135{
     136  Table t(name, Table::Old);
     137  return stringToType(t.keywordSet().asString("ApplyType"));
     138}
     139
     140STCalEnum::CalType STApplyTable::getCalType(CountedPtr<STApplyTable> tab)
     141{
     142  return stringToType(tab->caltype());
     143}
     144
     145STCalEnum::CalType STApplyTable::getCalType(STApplyTable *tab)
     146{
     147  return stringToType(tab->caltype());
     148}
     149
     150STCalEnum::CalType STApplyTable::stringToType(const String &caltype)
     151{
     152  if (caltype == "CALSKY_PSALMA")
     153    return STCalEnum::CalPSAlma;
     154  else if (caltype == "CALTSYS")
     155    return STCalEnum::CalTsys;
     156  else
     157    return STCalEnum::NoType;
     158}
     159
     160Block<Double> STApplyTable::getFrequenciesRow(uInt id)
     161{
     162  const TableRecord &rec = table_.keywordSet();
     163  rec.print(os_.output());
     164  os_ << LogIO::POST;
     165  Table ftab = rec.asTable("FREQUENCIES");
     166  Table t = ftab(ftab.col("ID") == id);
     167  ROTableColumn col(t, "REFPIX");
     168  Block<Double> r(3);
     169  r[0] = col.asdouble(0);
     170  col.attach(t, "REFVAL");
     171  r[1] = col.asdouble(0);
     172  col.attach(t, "INCREMENT");
     173  r[2] = col.asdouble(0);
     174  return r;
     175}
     176}
  • trunk/src/STApplyTable.h

    r2703 r2720  
    2222#include "Scantable.h"
    2323#include "STSelector.h"
     24#include "STCalEnum.h"
    2425
    2526namespace asap {
     
    3637  STApplyTable() {;}
    3738  STApplyTable(const Scantable& parent, const casa::String& name);
     39  STApplyTable(const casa::String &name);
    3840
    3941  virtual ~STApplyTable();
     
    5557  virtual void attachOptionalColumns() = 0;
    5658
    57   casa::Int nrow() {return table_.nrow();}
     59  casa::uInt nrow() {return table_.nrow();}
    5860
    5961  casa::Vector<casa::uInt> getScan() {return scanCol_.getColumn();}
     
    6466  casa::Vector<casa::Double> getTime() {return timeCol_.getColumn();}
    6567
    66   void setSelection(STSelector &sel);
     68  void setSelection(STSelector &sel, bool sortByTime=false);
    6769  void unsetSelection();
     70  casa::String caltype();
    6871
    6972  void save(const casa::String &name);
     73
     74  virtual casa::uInt nchan(casa::uInt ifno) = 0;
     75
     76  // static methods
     77  static STCalEnum::CalType getCalType(const casa::String &name);
     78  static STCalEnum::CalType getCalType(casa::CountedPtr<STApplyTable> tab);
     79  static STCalEnum::CalType getCalType(STApplyTable *tab);
    7080
    7181protected:
    7282  void setbasedata(casa::uInt irow, casa::uInt scanno, casa::uInt cycleno,
    7383                   casa::uInt beamno, casa::uInt ifno, casa::uInt polno,
    74                    casa::Double time);
     84                   casa::uInt freqid, casa::Double time);
     85  casa::Block<casa::Double> getFrequenciesRow(casa::uInt id);
    7586
    7687  casa::Table table_, originaltable_;
    77   casa::ScalarColumn<casa::uInt> scanCol_, cycleCol_, beamCol_, ifCol_, polCol_;
     88  casa::ScalarColumn<casa::uInt> scanCol_, cycleCol_, beamCol_, ifCol_, polCol_, freqidCol_;
    7889  casa::ScalarColumn<casa::Double> timeCol_;
    7990  casa::MEpoch::ScalarColumn timeMeasCol_;
     
    8293
    8394private:
     95  static STCalEnum::CalType stringToType(const casa::String &caltype);
    8496};
    8597
  • trunk/src/STCalSkyPSAlma.cpp

    r2703 r2720  
    2626  : STCalibration(s)
    2727{
    28   applytable_ = new STCalSkyTable(*s, "PS");
     28  applytable_ = new STCalSkyTable(*s, "PSALMA");
    2929}
    3030
     
    6363  ROArrayColumn<Float> specCol(scantable_->table(), "SPECTRA");
    6464  ROArrayColumn<uChar> flagCol(scantable_->table(), "FLAGTRA");
     65  ROScalarColumn<uInt> freqidCol(scantable_->table(), "FREQ_ID");
    6566
    6667  // dummy Tsys: the following process doesn't need Tsys but RowAccumulator
     
    124125          STCalSkyTable *p = dynamic_cast<STCalSkyTable *>(&(*applytable_));
    125126          p->appenddata(0, 0, current[2], current[0], current[1],
    126                         timeCen, elCen, acc.getSpectrum());
     127                        freqidCol(irow), timeCen, elCen, acc.getSpectrum());
    127128        }
    128129        acc.reset() ;
  • trunk/src/STCalSkyTable.cpp

    r2703 r2720  
    3838}
    3939
     40STCalSkyTable::STCalSkyTable(const String &name)
     41  : STApplyTable(name)
     42{
     43  attachOptionalColumns();
     44}
     45
    4046STCalSkyTable::~STCalSkyTable()
    4147{
     
    6369
    6470void STCalSkyTable::setdata(uInt irow, uInt scanno, uInt cycleno,
    65                        uInt beamno, uInt ifno, uInt polno,
    66                        Double time, Float elevation, Vector<Float> spectra)
     71                            uInt beamno, uInt ifno, uInt polno, uInt freqid,
     72                            Double time, Float elevation, Vector<Float> spectra)
    6773{
    6874  if (irow >= (uInt)nrow()) {
     
    7581  } 
    7682
    77   setbasedata(irow, scanno, cycleno, beamno, ifno, polno, time);
     83  setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time);
    7884  elCol_.put(irow, elevation);
    7985  spectraCol_.put(irow, spectra);
     
    8187
    8288void STCalSkyTable::appenddata(uInt scanno, uInt cycleno,
    83                           uInt beamno, uInt ifno, uInt polno,
    84                           Double time, Float elevation, Vector<Float> spectra)
     89                               uInt beamno, uInt ifno, uInt polno, uInt freqid,
     90                               Double time, Float elevation, Vector<Float> spectra)
    8591{
    8692  uInt irow = nrow();
    8793  table_.addRow(1, True);
    88   setdata(irow, scanno, cycleno, beamno, ifno, polno, time, elevation, spectra);
     94  setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation, spectra);
    8995}
     96
     97uInt STCalSkyTable::nchan(uInt ifno)
     98{
     99  STSelector org = sel_;
     100  STSelector sel;
     101  sel.setIFs(vector<int>(1,(int)ifno));
     102  setSelection(sel);
     103  uInt n = spectraCol_(0).nelements();
     104  unsetSelection();
     105  if (!org.empty())
     106    setSelection(org);
     107  return n;
    90108}
     109
     110// Vector<Double> STCalSkyTable::getBaseFrequency(uInt whichrow)
     111// {
     112//   assert(whichrow < nrow());
     113//   uInt freqid = freqidCol_(whichrow);
     114//   uInt nc = spectraCol_(whichrow).nelements();
     115//   Block<Double> f = getFrequenciesRow(freqid);
     116//   Vector<Double> freqs(nc);
     117//   indgen(freqs, f[1]-f[0]*f[2], f[2]);
     118//   return freqs;
     119// }
     120}
  • trunk/src/STCalSkyTable.h

    r2703 r2720  
    3535  STCalSkyTable() {;}
    3636  STCalSkyTable(const Scantable& parent, const casa::String &caltype);
     37  STCalSkyTable(const casa::String &name);
    3738
    3839  virtual ~STCalSkyTable();
     
    4445
    4546  void setdata(casa::uInt irow, casa::uInt scannos, casa::uInt cycleno,
    46                casa::uInt beamno, casa::uInt ifno,
    47                casa::uInt polno, casa::Double time, casa::Float elevation,
     47               casa::uInt beamno, casa::uInt ifno, casa::uInt polno,
     48               casa::uInt freqid, casa::Double time, casa::Float elevation,
    4849               casa::Vector<casa::Float> spectra);
    4950  void appenddata(casa::uInt scanno, casa::uInt cycleno, casa::uInt beamno,
    50                   casa::uInt ifno, casa::uInt polno,
     51                  casa::uInt ifno, casa::uInt polno, casa::uInt freqid, 
    5152                  casa::Double time, casa::Float elevation,
    5253                  casa::Vector<casa::Float> spectra);
     
    5455  casa::Vector<casa::Float> getElevation() {return elCol_.getColumn();}
    5556  casa::Matrix<casa::Float> getSpectra() {return spectraCol_.getColumn();}
     57  casa::uInt nchan(casa::uInt ifno);
    5658
     59  //casa::Vector<casa::Double> getBaseFrequency(casa::uInt whichrow);
    5760private:
    5861  static const casa::String name_;
  • trunk/src/STCalTsys.cpp

    r2703 r2720  
    6565  ROArrayColumn<Float> specCol(scantable_->table(), "TSYS");
    6666  ROArrayColumn<uChar> flagCol(scantable_->table(), "FLAGTRA");
     67  ROScalarColumn<uInt> freqidCol(scantable_->table(), "FREQ_ID");
    6768
    6869  // dummy Tsys: the following process doesn't need Tsys but RowAccumulator
     
    126127          STCalTsysTable *p = dynamic_cast<STCalTsysTable *>(&(*applytable_));
    127128          p->appenddata(0, 0, current[2], current[0], current[1],
    128                         timeCen, elCen, acc.getSpectrum());
     129                        freqidCol(irow), timeCen, elCen, acc.getSpectrum());
    129130        }
    130131        acc.reset() ;
  • trunk/src/STCalTsysTable.cpp

    r2703 r2720  
    3636}
    3737
     38STCalTsysTable::STCalTsysTable(const String &name)
     39  : STApplyTable(name)
     40{
     41  attachOptionalColumns();
     42}
     43
    3844STCalTsysTable::~STCalTsysTable()
    3945{
     
    4551  table_.addColumn(ScalarColumnDesc<Float>("ELEVATION"));
    4652
    47   table_.rwKeywordSet().define("ApplyType", "TSYS");
     53  table_.rwKeywordSet().define("ApplyType", "CALTSYS");
    4854
    4955  attachOptionalColumns();
     
    5864
    5965void STCalTsysTable::setdata(uInt irow, uInt scanno, uInt cycleno,
    60                         uInt beamno, uInt ifno, uInt polno,
    61                         Double time, Float elevation, Vector<Float> tsys)
     66                             uInt beamno, uInt ifno, uInt polno, uInt freqid,
     67                             Double time, Float elevation, Vector<Float> tsys)
    6268{
    6369  if (irow >= (uInt)nrow()) {
     
    7076  } 
    7177
    72   setbasedata(irow, scanno, cycleno, beamno, ifno, polno, time);
     78  setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time);
    7379  elCol_.put(irow, elevation);
    7480  tsysCol_.put(irow, tsys);
     
    7682
    7783void STCalTsysTable::appenddata(uInt scanno, uInt cycleno,
    78                            uInt beamno, uInt ifno, uInt polno,
    79                            Double time, Float elevation, Vector<Float> tsys)
     84                                uInt beamno, uInt ifno, uInt polno, uInt freqid,
     85                                Double time, Float elevation, Vector<Float> tsys)
    8086{
    8187  uInt irow = nrow();
    8288  table_.addRow(1, True);
    83   setdata(irow, scanno, cycleno, beamno, ifno, polno, time, elevation, tsys);
     89  setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation, tsys);
     90}
     91
     92uInt STCalTsysTable::nchan(uInt ifno)
     93{
     94  STSelector org = sel_;
     95  STSelector sel;
     96  sel.setIFs(vector<int>(1,(int)ifno));
     97  setSelection(sel);
     98  uInt n = tsysCol_(0).nelements();
     99  unsetSelection();
     100  if (!org.empty())
     101    setSelection(org);
     102  return n;
     103}
     104
     105Vector<Double> STCalTsysTable::getBaseFrequency(uInt whichrow)
     106{
     107  assert(whichrow < nrow());
     108  uInt freqid = freqidCol_(whichrow);
     109  uInt nc = tsysCol_(whichrow).nelements();
     110  Block<Double> f = getFrequenciesRow(freqid);
     111  Vector<Double> freqs(nc);
     112  indgen(freqs, f[1]-f[0]*f[2], f[2]);
     113  return freqs;
    84114}
    85115}
  • trunk/src/STCalTsysTable.h

    r2703 r2720  
    3333  STCalTsysTable() {;}
    3434  STCalTsysTable(const Scantable& parent);
     35  STCalTsysTable(const casa::String &name);
    3536
    3637  virtual ~STCalTsysTable();
     
    4243
    4344  void setdata(casa::uInt irow, casa::uInt scanno, casa::uInt cycleno,
    44                casa::uInt beamno, casa::uInt ifno,
    45                casa::uInt polno, casa::Double time, casa::Float elevation,
     45               casa::uInt beamno, casa::uInt ifno, casa::uInt polno,
     46               casa::uInt freqid, casa::Double time, casa::Float elevation,
    4647               casa::Vector<casa::Float> tsys);
    4748  void appenddata(casa::uInt scanno, casa::uInt cycleno,
    4849                  casa::uInt beamno, casa::uInt ifno, casa::uInt polno,
    49                   casa::Double time, casa::Float elevation,
     50                  casa::uInt freqid, casa::Double time, casa::Float elevation,
    5051                  casa::Vector<casa::Float> tsys);
    5152 
    5253  casa::Vector<casa::Float> getElevation() {return elCol_.getColumn();}
    5354  casa::Matrix<casa::Float> getTsys() {return tsysCol_.getColumn();}
     55  casa::uInt nchan(casa::uInt ifno);
     56
     57  casa::Vector<casa::Double> getBaseFrequency(casa::uInt whichrow);
    5458
    5559private:
Note: See TracChangeset for help on using the changeset viewer.