Ignore:
Timestamp:
07/18/09 06:35:47 (15 years ago)
Author:
TakTsutsumi
Message:

New Development: No, merge with asap2.3.1

JIRA Issue: Yes CAS-1450

Ready to Release: Yes/No?

Interface Changes: Yes/No?

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes

Module(s): single dish

Description: Upgrade of alma branch based on ASAP2.2.0

(rev.1562) to ASAP2.3.1 (rev.1561)


File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/alma/src/STFiller.cpp

    r1533 r1603  
    55//
    66//
    7 // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006
     7// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006-2007
    88//
    99// Copyright: See COPYING file that comes with this distribution
     
    2828#include <measures/Measures/MeasConvert.h>
    2929
     30#include <atnf/PKSIO/PKSrecord.h>
    3031#include <atnf/PKSIO/PKSreader.h>
     32#ifdef HAS_ALMA
     33 #include <casa/System/ProgressMeter.h>
     34#endif
    3135#include <casa/System/ProgressMeter.h>
    3236#include <atnf/PKSIO/NROReader.h>
    3337
    3438#include <time.h>
     39
    3540
    3641#include "STDefs.h"
     
    4853  header_(0),
    4954  table_(0),
     55  refRx_(".*(e|w|_R)$"),
    5056  nreader_(0)
    5157{
     
    5662  header_(0),
    5763  table_(stbl),
     64  refRx_(".*(e|w|_R)$"),
    5865  nreader_(0)
    5966{
     
    6471  header_(0),
    6572  table_(0),
     73  refRx_(".*(e|w|_R)$"),
    6674  nreader_(0)
    6775{
     
    141149  Int status = reader_->getHeader(header_->observer, header_->project,
    142150                                  header_->antennaname, header_->antennaposition,
    143                                   header_->obstype,header_->equinox,
     151                                  header_->obstype,
     152                                  header_->fluxunit,
     153                                  header_->equinox,
    144154                                  header_->freqref,
    145155                                  header_->utc, header_->reffreq,
    146                                   header_->bandwidth,
    147                                   header_->fluxunit);
     156                                  header_->bandwidth);
    148157
    149158  if (status) {
     
    166175  Bool throwIt = False;
    167176  Instrument inst = STAttr::convertInstrument(header_->antennaname, throwIt);
    168   //header_->fluxunit = "Jy";
     177
    169178  if (inst==ATMOPRA || inst==TIDBINBILLA) {
    170      header_->fluxunit = "K";
     179    header_->fluxunit = "K";
     180  } else {
     181    // downcase for use with Quanta
     182    if (header_->fluxunit == "JY") {
     183      header_->fluxunit = "Jy";
     184    }
    171185  }
    172186  STAttr stattr;
     
    275289  //
    276290
     291/**
    277292  Int    beamNo, IFno, refBeam, scanNo, cycleNo;
    278293  Float  azimuth, elevation, focusAxi, focusRot, focusTan,
     
    287302  Complex         xCalFctr;
    288303  Vector<Complex> xPol;
     304**/
     305
    289306  Double min = 0.0;
    290307  Double max = nInDataRow;
     308#ifdef HAS_ALMA
    291309  ProgressMeter fillpm(min, max, "Data importing progress");
     310#endif
     311  PKSrecord pksrec;
    292312  int n = 0;
    293313  while ( status == 0 ) {
    294     status = reader_->read(scanNo, cycleNo, mjd, interval, fieldName,
    295                           srcName, srcDir, srcPM, srcVel, obsType, IFno,
    296                           refFreq, bandwidth, freqInc, restFreq, tcal, tcalTime,
    297                           azimuth, elevation, parAngle, focusAxi,
    298                           focusTan, focusRot, temperature, pressure,
    299                           humidity, windSpeed, windAz, refBeam,
    300                           beamNo, direction, scanRate,
    301                           tsys, sigma, calFctr, baseLin, baseSub,
    302                           spectra, flagtra, xCalFctr, xPol);
     314    status = reader_->read(pksrec);
    303315    if ( status != 0 ) break;
    304316    n += 1;
    305    
     317
    306318    Regex filterrx(".*[SL|PA]$");
    307319    Regex obsrx("^AT.+");
    308     if ( header_->antennaname.matches(obsrx) && obsType.matches(filterrx)) {
     320    if ( header_->antennaname.matches(obsrx) &&
     321         pksrec.obsType.matches(filterrx)) {
    309322        //cerr << "ignoring paddle scan" << endl;
    310323        continue;
     
    314327    // fields that don't get used and are just passed through asap
    315328    RecordFieldPtr<Array<Double> > srateCol(rec, "SCANRATE");
    316     *srateCol = scanRate;
     329    // MRC changed type from double to float
     330    Vector<Double> sratedbl(pksrec.scanRate.nelements());
     331    convertArray(sratedbl, pksrec.scanRate);
     332    *srateCol = sratedbl;
    317333    RecordFieldPtr<Array<Double> > spmCol(rec, "SRCPROPERMOTION");
    318     *spmCol = srcPM;
     334    *spmCol = pksrec.srcPM;
    319335    RecordFieldPtr<Array<Double> > sdirCol(rec, "SRCDIRECTION");
    320     *sdirCol = srcDir;
     336    *sdirCol = pksrec.srcDir;
    321337    RecordFieldPtr<Double> svelCol(rec, "SRCVELOCITY");
    322     *svelCol = srcVel;
     338    *svelCol = pksrec.srcVel;
    323339    // the real stuff
    324340    RecordFieldPtr<Int> fitCol(rec, "FIT_ID");
    325341    *fitCol = -1;
    326342    RecordFieldPtr<uInt> scanoCol(rec, "SCANNO");
    327     *scanoCol = scanNo-1;
     343    *scanoCol = pksrec.scanNo-1;
    328344    RecordFieldPtr<uInt> cyclenoCol(rec, "CYCLENO");
    329     *cyclenoCol = cycleNo-1;
     345    *cyclenoCol = pksrec.cycleNo-1;
    330346    RecordFieldPtr<Double> mjdCol(rec, "TIME");
    331     *mjdCol = mjd;
     347    *mjdCol = pksrec.mjd;
    332348    RecordFieldPtr<Double> intCol(rec, "INTERVAL");
    333     *intCol = interval;
     349    *intCol = pksrec.interval;
    334350    RecordFieldPtr<String> srcnCol(rec, "SRCNAME");
    335351    RecordFieldPtr<Int> srctCol(rec, "SRCTYPE");
    336352    RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME");
    337     *fieldnCol = fieldName;
     353    *fieldnCol = pksrec.fieldName;
    338354    // try to auto-identify if it is on or off.
    339     Regex rx(".*[e|w|_R]$");
     355    Regex rx(refRx_);
    340356    Regex rx2("_S$");
    341     Int match = srcName.matches(rx);
     357    Int match = pksrec.srcName.matches(rx);
    342358    if (match) {
    343       *srcnCol = srcName;
     359      *srcnCol = pksrec.srcName;
    344360    } else {
    345       *srcnCol = srcName.before(rx2);
    346     }
    347     //*srcnCol = srcName;//.before(rx2);
     361      *srcnCol = pksrec.srcName.before(rx2);
     362    }
     363    //*srcnCol = pksrec.srcName;//.before(rx2);
    348364    *srctCol = match;
    349365    RecordFieldPtr<uInt> beamCol(rec, "BEAMNO");
    350     *beamCol = beamNo-beamOffset_-1;
     366    *beamCol = pksrec.beamNo-beamOffset_-1;
    351367    RecordFieldPtr<Int> rbCol(rec, "REFBEAMNO");
    352368    Int rb = -1;
    353     if (nBeam_ > 1 ) rb = refBeam-1;
     369    if (nBeam_ > 1 ) rb = pksrec.refBeam-1;
    354370    *rbCol = rb;
    355371    RecordFieldPtr<uInt> ifCol(rec, "IFNO");
    356     *ifCol = IFno-ifOffset_- 1;
     372    *ifCol = pksrec.IFno-ifOffset_- 1;
    357373    uInt id;
    358374    /// @todo this has to change when nchan isn't global anymore
    359375    id = table_->frequencies().addEntry(Double(header_->nchan/2),
    360                                             refFreq, freqInc);
     376                                            pksrec.refFreq, pksrec.freqInc);
    361377    RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID");
    362378    *mfreqidCol = id;
    363379
    364     id = table_->molecules().addEntry(restFreq);
     380    id = table_->molecules().addEntry(pksrec.restFreq);
    365381    RecordFieldPtr<uInt> molidCol(rec, "MOLECULE_ID");
    366382    *molidCol = id;
    367383
    368     id = table_->tcal().addEntry(tcalTime, tcal);
     384    id = table_->tcal().addEntry(pksrec.tcalTime, pksrec.tcal);
    369385    RecordFieldPtr<uInt> mcalidCol(rec, "TCAL_ID");
    370386    *mcalidCol = id;
    371     id = table_->weather().addEntry(temperature, pressure, humidity,
    372                                     windSpeed, windAz);
     387    id = table_->weather().addEntry(pksrec.temperature, pksrec.pressure,
     388                                    pksrec.humidity, pksrec.windSpeed,
     389                                    pksrec.windAz);
    373390    RecordFieldPtr<uInt> mweatheridCol(rec, "WEATHER_ID");
    374391    *mweatheridCol = id;
    375392    RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID");
    376     id = table_->focus().addEntry(focusAxi, focusTan, focusRot);
     393    id = table_->focus().addEntry(pksrec.focusAxi, pksrec.focusTan,
     394                                  pksrec.focusRot);
    377395    *mfocusidCol = id;
    378396    RecordFieldPtr<Array<Double> > dirCol(rec, "DIRECTION");
    379     *dirCol = direction;
     397    *dirCol = pksrec.direction;
    380398    RecordFieldPtr<Float> azCol(rec, "AZIMUTH");
    381     *azCol = azimuth;
     399    *azCol = pksrec.azimuth;
    382400    RecordFieldPtr<Float> elCol(rec, "ELEVATION");
    383     *elCol = elevation;
     401    *elCol = pksrec.elevation;
    384402
    385403    RecordFieldPtr<Float> parCol(rec, "PARANGLE");
    386     *parCol = parAngle;
     404    *parCol = pksrec.parAngle;
    387405
    388406    RecordFieldPtr< Array<Float> > specCol(rec, "SPECTRA");
     
    395413    Vector<Float> tsysvec(1);
    396414    // Why is spectra.ncolumn() == 3 for haveXPol_ == True
    397     uInt npol = (spectra.ncolumn()==1 ? 1: 2);
     415    uInt npol = (pksrec.spectra.ncolumn()==1 ? 1: 2);
    398416    for ( uInt i=0; i< npol; ++i ) {
    399       tsysvec = tsys(i);
     417      tsysvec = pksrec.tsys(i);
    400418      *tsysCol = tsysvec;
    401419      *polnoCol = i;
    402420
    403       *specCol = spectra.column(i);
    404       *flagCol = flagtra.column(i);
     421      *specCol = pksrec.spectra.column(i);
     422      *flagCol = pksrec.flagged.column(i);
    405423      table_->table().addRow();
    406424      row.put(table_->table().nrow()-1, rec);
     
    408426    if ( haveXPol_[0] ) {
    409427      // no tsys given for xpol, so emulate it
    410       tsysvec = sqrt(tsys[0]*tsys[1]);
     428      tsysvec = sqrt(pksrec.tsys[0]*pksrec.tsys[1]);
    411429      *tsysCol = tsysvec;
    412430      // add real part of cross pol
    413431      *polnoCol = 2;
    414       Vector<Float> r(real(xPol));
     432      Vector<Float> r(real(pksrec.xPol));
    415433      *specCol = r;
    416434      // make up flags from linears
    417435      /// @fixme this has to be a bitwise or of both pols
    418       *flagCol = flagtra.column(0);// | flagtra.column(1);
     436      *flagCol = pksrec.flagged.column(0);// | pksrec.flagged.column(1);
    419437      table_->table().addRow();
    420438      row.put(table_->table().nrow()-1, rec);
    421439      // ad imaginary part of cross pol
    422440      *polnoCol = 3;
    423       Vector<Float> im(imag(xPol));
     441      Vector<Float> im(imag(pksrec.xPol));
    424442      *specCol = im;
    425443      table_->table().addRow();
    426444      row.put(table_->table().nrow()-1, rec);
    427445    }
     446#ifdef HAS_ALMA
    428447    fillpm._update(n);
     448#endif
    429449  }
    430450  if (status > 0) {
     
    432452    throw(AipsError("Reading error occured, data possibly corrupted."));
    433453  }
     454#ifdef HAS_ALMA
    434455  fillpm.done();
     456#endif
    435457  return status;
    436458}
Note: See TracChangeset for help on using the changeset viewer.