Changeset 1450 for trunk/src


Ignore:
Timestamp:
11/19/08 14:15:36 (16 years ago)
Author:
MarkCalabretta
Message:

Adapted to new API, PKSreader::read(const PKSrecord &).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STFiller.cpp

    r1438 r1450  
    2525#include <tables/Tables/TableRow.h>
    2626
     27#include <atnf/PKSIO/PKSrecord.h>
    2728#include <atnf/PKSIO/PKSreader.h>
    2829#ifdef HAS_ALMA
     
    193194  Vector<Int> start(nIF_, 1);
    194195  Vector<Int> end(nIF_, 0);
    195   reader_->select(beams, ifs, start, end, ref, True, haveXPol_[0], False);
     196  reader_->select(beams, ifs, start, end, ref, True, haveXPol_[0]);
    196197  table_->setHeader(*header_);
    197198  //For MS, add the location of POINTING of the input MS so one get
     
    226227  int status = 0;
    227228
    228   Int    beamNo, IFno, refBeam, scanNo, cycleNo;
    229   Float  azimuth, elevation, focusAxi, focusRot, focusTan,
    230     humidity, parAngle, pressure, temperature, windAz, windSpeed;
    231   Double bandwidth, freqInc, interval, mjd, refFreq, restFreq, srcVel;
    232   String          fieldName, srcName, tcalTime, obsType;
    233   Vector<Float>   calFctr, sigma, tcal, tsys;
    234   Matrix<Float>   baseLin, baseSub;
    235   Vector<Double>  direction(2), scanRate(2), srcDir(2), srcPM(2);
    236   Matrix<Float>   spectra;
    237   Matrix<uChar>   flagtra;
    238   Complex         xCalFctr;
    239   Vector<Complex> xPol;
    240229  Double min = 0.0;
    241230  Double max = nInDataRow;
     
    243232  ProgressMeter fillpm(min, max, "Data importing progress");
    244233#endif
     234  PKSrecord pksrec;
    245235  int n = 0;
    246236  while ( status == 0 ) {
    247     status = reader_->read(scanNo, cycleNo, mjd, interval, fieldName,
    248                           srcName, srcDir, srcPM, srcVel, obsType, IFno,
    249                           refFreq, bandwidth, freqInc, restFreq, tcal, tcalTime,
    250                           azimuth, elevation, parAngle, focusAxi,
    251                           focusTan, focusRot, temperature, pressure,
    252                           humidity, windSpeed, windAz, refBeam,
    253                           beamNo, direction, scanRate,
    254                           tsys, sigma, calFctr, baseLin, baseSub,
    255                           spectra, flagtra, xCalFctr, xPol);
     237    status = reader_->read(pksrec);
    256238    if ( status != 0 ) break;
    257239    n += 1;
     
    259241    Regex filterrx(".*[SL|PA]$");
    260242    Regex obsrx("^AT.+");
    261     if ( header_->antennaname.matches(obsrx) && obsType.matches(filterrx)) {
     243    if ( header_->antennaname.matches(obsrx) &&
     244         pksrec.obsType.matches(filterrx)) {
    262245        //cerr << "ignoring paddle scan" << endl;
    263246        continue;
     
    267250    // fields that don't get used and are just passed through asap
    268251    RecordFieldPtr<Array<Double> > srateCol(rec, "SCANRATE");
    269     *srateCol = scanRate;
     252    *srateCol = pksrec.scanRate;
    270253    RecordFieldPtr<Array<Double> > spmCol(rec, "SRCPROPERMOTION");
    271     *spmCol = srcPM;
     254    *spmCol = pksrec.srcPM;
    272255    RecordFieldPtr<Array<Double> > sdirCol(rec, "SRCDIRECTION");
    273     *sdirCol = srcDir;
     256    *sdirCol = pksrec.srcDir;
    274257    RecordFieldPtr<Double> svelCol(rec, "SRCVELOCITY");
    275     *svelCol = srcVel;
     258    *svelCol = pksrec.srcVel;
    276259    // the real stuff
    277260    RecordFieldPtr<Int> fitCol(rec, "FIT_ID");
    278261    *fitCol = -1;
    279262    RecordFieldPtr<uInt> scanoCol(rec, "SCANNO");
    280     *scanoCol = scanNo-1;
     263    *scanoCol = pksrec.scanNo-1;
    281264    RecordFieldPtr<uInt> cyclenoCol(rec, "CYCLENO");
    282     *cyclenoCol = cycleNo-1;
     265    *cyclenoCol = pksrec.cycleNo-1;
    283266    RecordFieldPtr<Double> mjdCol(rec, "TIME");
    284     *mjdCol = mjd;
     267    *mjdCol = pksrec.mjd;
    285268    RecordFieldPtr<Double> intCol(rec, "INTERVAL");
    286     *intCol = interval;
     269    *intCol = pksrec.interval;
    287270    RecordFieldPtr<String> srcnCol(rec, "SRCNAME");
    288271    RecordFieldPtr<Int> srctCol(rec, "SRCTYPE");
    289272    RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME");
    290     *fieldnCol = fieldName;
     273    *fieldnCol = pksrec.fieldName;
    291274    // try to auto-identify if it is on or off.
    292275    Regex rx(".*(e|w|_R)$");
    293276    Regex rx2("_S$");
    294     Int match = srcName.matches(rx);
     277    Int match = pksrec.srcName.matches(rx);
    295278    if (match) {
    296       *srcnCol = srcName;
     279      *srcnCol = pksrec.srcName;
    297280    } else {
    298       *srcnCol = srcName.before(rx2);
    299     }
    300     //*srcnCol = srcName;//.before(rx2);
     281      *srcnCol = pksrec.srcName.before(rx2);
     282    }
     283    //*srcnCol = pksrec.srcName;//.before(rx2);
    301284    *srctCol = match;
    302285    RecordFieldPtr<uInt> beamCol(rec, "BEAMNO");
    303     *beamCol = beamNo-beamOffset_-1;
     286    *beamCol = pksrec.beamNo-beamOffset_-1;
    304287    RecordFieldPtr<Int> rbCol(rec, "REFBEAMNO");
    305288    Int rb = -1;
    306     if (nBeam_ > 1 ) rb = refBeam-1;
     289    if (nBeam_ > 1 ) rb = pksrec.refBeam-1;
    307290    *rbCol = rb;
    308291    RecordFieldPtr<uInt> ifCol(rec, "IFNO");
    309     *ifCol = IFno-ifOffset_- 1;
     292    *ifCol = pksrec.IFno-ifOffset_- 1;
    310293    uInt id;
    311294    /// @todo this has to change when nchan isn't global anymore
    312295    id = table_->frequencies().addEntry(Double(header_->nchan/2),
    313                                             refFreq, freqInc);
     296                                            pksrec.refFreq, pksrec.freqInc);
    314297    RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID");
    315298    *mfreqidCol = id;
    316299
    317     id = table_->molecules().addEntry(restFreq);
     300    id = table_->molecules().addEntry(pksrec.restFreq);
    318301    RecordFieldPtr<uInt> molidCol(rec, "MOLECULE_ID");
    319302    *molidCol = id;
    320303
    321     id = table_->tcal().addEntry(tcalTime, tcal);
     304    id = table_->tcal().addEntry(pksrec.tcalTime, pksrec.tcal);
    322305    RecordFieldPtr<uInt> mcalidCol(rec, "TCAL_ID");
    323306    *mcalidCol = id;
    324     id = table_->weather().addEntry(temperature, pressure, humidity,
    325                                     windSpeed, windAz);
     307    id = table_->weather().addEntry(pksrec.temperature, pksrec.pressure,
     308                                    pksrec.humidity, pksrec.windSpeed,
     309                                    pksrec.windAz);
    326310    RecordFieldPtr<uInt> mweatheridCol(rec, "WEATHER_ID");
    327311    *mweatheridCol = id;
    328312    RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID");
    329     id = table_->focus().addEntry(focusAxi, focusTan, focusRot);
     313    id = table_->focus().addEntry(pksrec.focusAxi, pksrec.focusTan,
     314                                  pksrec.focusRot);
    330315    *mfocusidCol = id;
    331316    RecordFieldPtr<Array<Double> > dirCol(rec, "DIRECTION");
    332     *dirCol = direction;
     317    *dirCol = pksrec.direction;
    333318    RecordFieldPtr<Float> azCol(rec, "AZIMUTH");
    334     *azCol = azimuth;
     319    *azCol = pksrec.azimuth;
    335320    RecordFieldPtr<Float> elCol(rec, "ELEVATION");
    336     *elCol = elevation;
     321    *elCol = pksrec.elevation;
    337322
    338323    RecordFieldPtr<Float> parCol(rec, "PARANGLE");
    339     *parCol = parAngle;
     324    *parCol = pksrec.parAngle;
    340325
    341326    RecordFieldPtr< Array<Float> > specCol(rec, "SPECTRA");
     
    347332    // into 2-4 rows in the scantable
    348333    Vector<Float> tsysvec(1);
    349     // Why is spectra.ncolumn() == 3 for haveXPol_ == True
    350     uInt npol = (spectra.ncolumn()==1 ? 1: 2);
     334    // Why is pksrec.spectra.ncolumn() == 3 for haveXPol_ == True
     335    uInt npol = (pksrec.spectra.ncolumn()==1 ? 1: 2);
    351336    for ( uInt i=0; i< npol; ++i ) {
    352       tsysvec = tsys(i);
     337      tsysvec = pksrec.tsys(i);
    353338      *tsysCol = tsysvec;
    354339      *polnoCol = i;
    355340
    356       *specCol = spectra.column(i);
    357       *flagCol = flagtra.column(i);
     341      *specCol = pksrec.spectra.column(i);
     342      *flagCol = pksrec.flagtra.column(i);
    358343      table_->table().addRow();
    359344      row.put(table_->table().nrow()-1, rec);
     
    361346    if ( haveXPol_[0] ) {
    362347      // no tsys given for xpol, so emulate it
    363       tsysvec = sqrt(tsys[0]*tsys[1]);
     348      tsysvec = sqrt(pksrec.tsys[0]*pksrec.tsys[1]);
    364349      *tsysCol = tsysvec;
    365350      // add real part of cross pol
    366351      *polnoCol = 2;
    367       Vector<Float> r(real(xPol));
     352      Vector<Float> r(real(pksrec.xPol));
    368353      *specCol = r;
    369354      // make up flags from linears
    370355      /// @fixme this has to be a bitwise or of both pols
    371       *flagCol = flagtra.column(0);// | flagtra.column(1);
     356      *flagCol = pksrec.flagtra.column(0);// | pksrec.flagtra.column(1);
    372357      table_->table().addRow();
    373358      row.put(table_->table().nrow()-1, rec);
    374359      // ad imaginary part of cross pol
    375360      *polnoCol = 3;
    376       Vector<Float> im(imag(xPol));
     361      Vector<Float> im(imag(pksrec.xPol));
    377362      *specCol = im;
    378363      table_->table().addRow();
Note: See TracChangeset for help on using the changeset viewer.