Changeset 2006


Ignore:
Timestamp:
02/23/11 20:08:16 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

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...

Added iteration for SRCTYPE.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STWriter.cpp

    r2005 r2006  
    204204      while (!cycit.pastEnd() ) {
    205205        Table ctable = cycit.table();
    206         TableIterator ifit(ctable, "IFNO", TableIterator::Ascending, TableIterator::HeapSort);
    207         MDirection::ScalarColumn dirCol(ctable, "DIRECTION");
    208         pksrec.direction = dirCol(0).getAngle("rad").getValue();
    209         pksrec.IFno = 1;
    210         while (!ifit.pastEnd() ) {
    211           Table itable = ifit.table();
    212           TableRow row(itable);
    213           // use the first row to fill in all the "metadata"
    214           const TableRecord& rec = row.get(0);
    215           ROArrayColumn<Float> specCol(itable, "SPECTRA");
    216           pksrec.IFno = rec.asuInt("IFNO")+1;
    217           uInt nchan = specCol(0).nelements();
    218           Double crval,crpix;
    219           //Vector<Double> restfreq;
    220           Float tmp0,tmp1,tmp2,tmp3,tmp4;
    221           String tcalt;
    222           Vector<String> stmp0, stmp1;
    223           inst->frequencies().getEntry(crpix,crval, pksrec.freqInc,
    224                                      rec.asuInt("FREQ_ID"));
    225           inst->focus().getEntry(pksrec.parAngle, pksrec.focusAxi, pksrec.focusTan,
    226                                  pksrec.focusRot, tmp0,tmp1,tmp2,tmp3,tmp4,
    227                                  rec.asuInt("FOCUS_ID"));
    228           inst->molecules().getEntry(pksrec.restFreq,stmp0,stmp1,
    229                                    rec.asuInt("MOLECULE_ID"));
    230 //           inst->tcal().getEntry(pksrec.tcalTime, pksrec.tcal,
    231 //                               rec.asuInt("TCAL_ID"));
    232           inst->weather().getEntry(pksrec.temperature, pksrec.pressure,
    233                                  pksrec.humidity, pksrec.windSpeed,
    234                                  pksrec.windAz, rec.asuInt("WEATHER_ID"));
    235           Double pixel = Double(nchan/2);
    236           pksrec.refFreq = (pixel-crpix)*pksrec.freqInc + crval;
    237           // ok, now we have nrows for the n polarizations in this table
    238           polConversion(pksrec.spectra, pksrec.flagged, pksrec.xPol, itable);
    239           pksrec.tsys = tsysFromTable(itable);
    240           // dummy data
    241           uInt npol = pksrec.spectra.ncolumn();
    242 
    243           // TCAL
    244           inst->tcal().getEntry( pksrec.tcalTime, pksrec.tcal,
    245                                  rec.asuInt("TCAL_ID") ) ;
    246           if ( pksrec.tcal.nelements() == 1 ) {
    247             ROScalarColumn<uInt> uintCol( itable, "TCAL_ID" ) ;
    248             Vector<uInt> tcalids = uintCol.getColumn() ;
    249             pksrec.tcal.resize( npol ) ;
    250             Vector<Float> dummyA ;
    251             String dummyS ;
    252             for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
    253               inst->tcal().getEntry( dummyS, dummyA, tcalids[ipol] ) ;
    254               pksrec.tcal[ipol] = dummyA[0] ;
     206        TableIterator typeit( ctable, "SRCTYPE" ) ;
     207        while(!typeit.pastEnd() ) {
     208          Table ttable = typeit.table() ;
     209          TableIterator ifit(ctable, "IFNO", TableIterator::Ascending, TableIterator::HeapSort);
     210          MDirection::ScalarColumn dirCol(ctable, "DIRECTION");
     211          pksrec.direction = dirCol(0).getAngle("rad").getValue();
     212          pksrec.IFno = 1;
     213          while (!ifit.pastEnd() ) {
     214            Table itable = ifit.table();
     215            TableRow row(itable);
     216            // use the first row to fill in all the "metadata"
     217            const TableRecord& rec = row.get(0);
     218            ROArrayColumn<Float> specCol(itable, "SPECTRA");
     219            pksrec.IFno = rec.asuInt("IFNO")+1;
     220            uInt nchan = specCol(0).nelements();
     221            Double crval,crpix;
     222            //Vector<Double> restfreq;
     223            Float tmp0,tmp1,tmp2,tmp3,tmp4;
     224            String tcalt;
     225            Vector<String> stmp0, stmp1;
     226            inst->frequencies().getEntry(crpix,crval, pksrec.freqInc,
     227                                         rec.asuInt("FREQ_ID"));
     228            inst->focus().getEntry(pksrec.parAngle, pksrec.focusAxi, pksrec.focusTan,
     229                                   pksrec.focusRot, tmp0,tmp1,tmp2,tmp3,tmp4,
     230                                   rec.asuInt("FOCUS_ID"));
     231            inst->molecules().getEntry(pksrec.restFreq,stmp0,stmp1,
     232                                       rec.asuInt("MOLECULE_ID"));
     233//             inst->tcal().getEntry(pksrec.tcalTime, pksrec.tcal,
     234//                                   rec.asuInt("TCAL_ID"));
     235            inst->weather().getEntry(pksrec.temperature, pksrec.pressure,
     236                                     pksrec.humidity, pksrec.windSpeed,
     237                                     pksrec.windAz, rec.asuInt("WEATHER_ID"));
     238            Double pixel = Double(nchan/2);
     239            pksrec.refFreq = (pixel-crpix)*pksrec.freqInc + crval;
     240            // ok, now we have nrows for the n polarizations in this table
     241            polConversion(pksrec.spectra, pksrec.flagged, pksrec.xPol, itable);
     242            pksrec.tsys = tsysFromTable(itable);
     243            // dummy data
     244            uInt npol = pksrec.spectra.ncolumn();
     245           
     246            // TCAL
     247            inst->tcal().getEntry( pksrec.tcalTime, pksrec.tcal,
     248                                   rec.asuInt("TCAL_ID") ) ;
     249            if ( pksrec.tcal.nelements() == 1 ) {
     250              ROScalarColumn<uInt> uintCol( itable, "TCAL_ID" ) ;
     251              Vector<uInt> tcalids = uintCol.getColumn() ;
     252              pksrec.tcal.resize( npol ) ;
     253              Vector<Float> dummyA ;
     254              String dummyS ;
     255              for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
     256                inst->tcal().getEntry( dummyS, dummyA, tcalids[ipol] ) ;
     257                pksrec.tcal[ipol] = dummyA[0] ;
     258              }
    255259            }
     260            else if ( pksrec.tcal.nelements() == nchan ) {
     261              ROScalarColumn<uInt> uintCol( itable, "TCAL_ID" ) ;
     262              Vector<uInt> tcalids = uintCol.getColumn() ;
     263              pksrec.tcal.resize( npol ) ;
     264              Vector<Float> dummyA ;
     265              String dummyS ;
     266              for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
     267                inst->tcal().getEntry( dummyS, dummyA, tcalids[ipol] ) ;
     268                pksrec.tcal[ipol] = mean( dummyA ) ;
     269              }
     270            }
     271            //LogIO os ;
     272            //os << "npol = " << npol << " pksrec.tcal = " << pksrec.tcal << LogIO::POST ;
     273           
     274            pksrec.mjd       = rec.asDouble("TIME");
     275            pksrec.interval  = rec.asDouble("INTERVAL");
     276            pksrec.fieldName = rec.asString("FIELDNAME");
     277            pksrec.srcName   = rec.asString("SRCNAME");
     278            //pksrec.obsType   = obstypes[rec.asInt("SRCTYPE")];
     279            pksrec.obsType = getObsTypes( rec.asInt("SRCTYPE") ) ;
     280            pksrec.bandwidth = nchan * abs(pksrec.freqInc);
     281            pksrec.azimuth   = rec.asFloat("AZIMUTH");
     282            pksrec.elevation = rec.asFloat("ELEVATION");
     283            pksrec.refBeam   = rec.asInt("REFBEAMNO") + 1;
     284            pksrec.sigma.resize(npol);
     285            pksrec.sigma     = 0.0f;
     286            pksrec.calFctr.resize(npol);
     287            pksrec.calFctr   = 0.0f;
     288            pksrec.baseLin.resize(npol,2);
     289            pksrec.baseLin   = 0.0f;
     290            pksrec.baseSub.resize(npol,9);
     291            pksrec.baseSub   = 0.0f;
     292            pksrec.xCalFctr  = 0.0;
     293            pksrec.flagrow = rec.asuInt("FLAGROW");
     294           
     295            status = writer_->write(pksrec);
     296            if ( status ) {
     297              writer_->close();
     298              throw(AipsError("STWriter: Failed to export Scantable."));
     299            }
     300            ++count;
     301            //++pksrec.IFno;
     302            ++ifit;
    256303          }
    257           else if ( pksrec.tcal.nelements() == nchan ) {
    258             ROScalarColumn<uInt> uintCol( itable, "TCAL_ID" ) ;
    259             Vector<uInt> tcalids = uintCol.getColumn() ;
    260             pksrec.tcal.resize( npol ) ;
    261             Vector<Float> dummyA ;
    262             String dummyS ;
    263             for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
    264               inst->tcal().getEntry( dummyS, dummyA, tcalids[ipol] ) ;
    265               pksrec.tcal[ipol] = mean( dummyA ) ;
    266             }
    267           }
    268           //LogIO os ;
    269           //os << "npol = " << npol << " pksrec.tcal = " << pksrec.tcal << LogIO::POST ;
    270 
    271           pksrec.mjd       = rec.asDouble("TIME");
    272           pksrec.interval  = rec.asDouble("INTERVAL");
    273           pksrec.fieldName = rec.asString("FIELDNAME");
    274           pksrec.srcName   = rec.asString("SRCNAME");
    275           //pksrec.obsType   = obstypes[rec.asInt("SRCTYPE")];
    276           pksrec.obsType = getObsTypes( rec.asInt("SRCTYPE") ) ;
    277           pksrec.bandwidth = nchan * abs(pksrec.freqInc);
    278           pksrec.azimuth   = rec.asFloat("AZIMUTH");
    279           pksrec.elevation = rec.asFloat("ELEVATION");
    280           pksrec.refBeam   = rec.asInt("REFBEAMNO") + 1;
    281           pksrec.sigma.resize(npol);
    282           pksrec.sigma     = 0.0f;
    283           pksrec.calFctr.resize(npol);
    284           pksrec.calFctr   = 0.0f;
    285           pksrec.baseLin.resize(npol,2);
    286           pksrec.baseLin   = 0.0f;
    287           pksrec.baseSub.resize(npol,9);
    288           pksrec.baseSub   = 0.0f;
    289           pksrec.xCalFctr  = 0.0;
    290           pksrec.flagrow = rec.asuInt("FLAGROW");
    291 
    292           status = writer_->write(pksrec);
    293           if ( status ) {
    294             writer_->close();
    295             throw(AipsError("STWriter: Failed to export Scantable."));
    296           }
    297           ++count;
    298           //++pksrec.IFno;
    299           ++ifit;
     304          ++typeit ;
    300305        }
    301306        ++pksrec.cycleNo;
     
    311316  oss << "STWriter: wrote " << count << " rows to " << filename;
    312317  pushLog(String(oss));
     318 
    313319  writer_->close();
    314320  //if MS2 delete POINTING table exists and copy the one in the keyword
Note: See TracChangeset for help on using the changeset viewer.