Changeset 1815 for branches/newfiller


Ignore:
Timestamp:
08/02/10 14:18:33 (14 years ago)
Author:
Malte Marquarding
Message:

Eradicte raw pointer use.

Location:
branches/newfiller/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/newfiller/src/PKSFiller.cpp

    r1805 r1815  
    4848PKSFiller::PKSFiller( CountedPtr< Scantable > stbl ) :
    4949  FillerBase(stbl),
    50   reader_(0),
    51   header_(0)
     50  reader_(0)
    5251{
    5352  setReferenceRegex(".*(e|w|_R)$");
     
    6665  }
    6766  */
    68   if (reader_)  { delete reader_; reader_ = 0; }
     67
    6968  Bool haveBase, haveSpectra;
    7069
     
    8281
    8382  String antenna("");
    84   if ( (reader_ = getPKSreader(inName, antenna, 0, 0, format, beams, ifs,
    85                               nchans, npols, haveXPol_,haveBase, haveSpectra
    86                               )) == 0 )  {
     83
     84  reader_ = getPKSreader(inName, antenna, 0, 0, format, beams, ifs,
     85                         nchans, npols, haveXPol_, haveBase, haveSpectra);
     86  if (reader_.null() == True) {
    8787    return False;
    8888  }
    8989
    9090  if (!haveSpectra) {
    91     delete reader_;
    9291    reader_ = 0;
    9392    throw(AipsError("No spectral data in file."));
     
    103102    }
    104103  }
    105   if (header_) delete header_;
    106   header_ = new STHeader();
    107   header_->nchan = max(nchans);
    108   header_->npol = max(npols);
    109   header_->nbeam = nBeam_;
    110 
    111   Int status = reader_->getHeader(header_->observer, header_->project,
    112                                   header_->antennaname, header_->antennaposition,
    113                                   header_->obstype,
    114                                   header_->fluxunit,
    115                                   header_->equinox,
    116                                   header_->freqref,
    117                                   header_->utc, header_->reffreq,
    118                                   header_->bandwidth);
     104  STHeader header;
     105  header.nchan = max(nchans);
     106  header.npol = max(npols);
     107  header.nbeam = nBeam_;
     108
     109  Int status = reader_->getHeader(header.observer, header.project,
     110                                  header.antennaname, header.antennaposition,
     111                                  header.obstype,
     112                                  header.fluxunit,
     113                                  header.equinox,
     114                                  header.freqref,
     115                                  header.utc, header.reffreq,
     116                                  header.bandwidth);
    119117
    120118  if (status) {
    121     delete reader_;
    122119    reader_ = 0;
    123     delete header_;
    124     header_ = 0;
    125120    throw(AipsError("Failed to get header."));
    126121  }
    127   if ((header_->obstype).matches("*SW*")) {
     122  if ((header.obstype).matches("*SW*")) {
    128123    // need robust way here - probably read ahead of next timestamp
    129124    os << "Header indicates frequency switched observation.\n"
     
    131126
    132127    nIF_ = 1;
    133     header_->obstype = String("fswitch");
     128    header.obstype = String("fswitch");
    134129  }
    135130  // Determine Telescope and set brightness unit
    136131
    137132  Bool throwIt = False;
    138   Instrument inst = STAttr::convertInstrument(header_->antennaname, throwIt);
     133  Instrument inst = STAttr::convertInstrument(header.antennaname, throwIt);
    139134
    140135  if (inst==ATMOPRA || inst==TIDBINBILLA) {
    141     header_->fluxunit = "K";
     136    header.fluxunit = "K";
    142137  } else {
    143138    // downcase for use with Quanta
    144     if (header_->fluxunit == "JY") {
    145       header_->fluxunit = "Jy";
     139    if (header.fluxunit == "JY") {
     140      header.fluxunit = "Jy";
    146141    }
    147142  }
    148143  STAttr stattr;
    149   header_->poltype = stattr.feedPolType(inst);
    150   header_->nif = nIF_;
    151   header_->epoch = "UTC";
    152   // *** header_->frequnit = "Hz"
     144  header.poltype = stattr.feedPolType(inst);
     145  header.nif = nIF_;
     146  header.epoch = "UTC";
     147  // *** header.frequnit = "Hz"
    153148  // Apply selection criteria.
    154149  Vector<Int> ref;
     
    158153  Bool getPt = False;
    159154  reader_->select(beams, ifs, start, end, ref, True, haveXPol_[0], False, getPt);
    160   setHeader(*header_);
     155  setHeader(header);
    161156  //For MS, add the location of POINTING of the input MS so one get
    162157  //pointing data from there, if necessary.
     
    170165    ptTabPath.append("/POINTING");
    171166    table_->table().rwKeywordSet().define("POINTING", ptTabPath);
    172     if ((header_->antennaname).matches("GBT")) {
     167    if (header.antennaname.matches("GBT")) {
    173168      String GOTabPath = datapath.absoluteName();
    174169      GOTabPath.append("/GBT_GO");
     
    176171    }
    177172  }
    178   String freqFrame = header_->freqref;
     173  String freqFrame = header.freqref;
    179174  //translate frequency reference frame back to
    180175  //MS style (as PKSMS2reader converts the original frame
     
    197192  // set both "FRAME" and "BASEFRAME"
    198193  table_->frequencies().setFrame(freqFrame, false);
    199   table_->frequencies().setFrame(freqFrame,true);
    200   //table_->focus().setParallactify(true);
     194  table_->frequencies().setFrame(freqFrame, true);
     195  table_->focus().setParallactify(true);
    201196
    202197  return true;
     
    205200void PKSFiller::close( )
    206201{
    207   if (reader_ != 0) {
    208     delete reader_;
    209     reader_=0;
    210   }
    211 
    212   if (header_ != 0) {
    213     delete header_;
    214     header_=0;
     202  if (reader_.null() != False) {
     203    reader_ = 0;
    215204  }
    216205  table_ = 0;
     
    245234  int n = 0;
    246235  bool isGBTFITS = false ;
    247   if ((header_->antennaname.find( "GBT" ) != String::npos)
     236  if ((table_->getAntennaName().find( "GBT" ) != String::npos)
    248237       && File(filename_).isRegular()) {
    249238    FILE *fp = fopen( filename_.c_str(), "r" ) ;
     
    265254    Regex filterrx(".*[SL|PA]$");
    266255    Regex obsrx("^AT.+");
    267     if ( header_->antennaname.matches(obsrx) &&
     256    if ( table_->getAntennaName().matches(obsrx) &&
    268257         pksrec.obsType.matches(filterrx)) {
    269258        //cerr << "ignoring paddle scan" << endl;
  • branches/newfiller/src/PKSFiller.h

    r1811 r1815  
    4646    PKSFiller& operator=(const PKSFiller&);
    4747
    48     PKSreader* reader_;
    49     STHeader* header_;
     48    casa::CountedPtr<PKSreader> reader_;
    5049    casa::String filename_;
    5150    casa::Int nIF_, nBeam_, nPol_, nChan_, nInDataRow;
Note: See TracChangeset for help on using the changeset viewer.