Changeset 2519


Ignore:
Timestamp:
05/15/12 15:23:48 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: Defined STIdxIter and its python interface

Test Programs: List test programs

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Defined STIdxIter module that contains STIdxIterAcc class.
Python interface for STIdxIterAcc class also defined.
STMath::almacal is rewritten using STIdxIterAcc.


Location:
branches/hpc33/src
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/hpc33/src

  • branches/hpc33/src/CMakeLists.txt

    r2399 r2519  
    6060     ${SRCDIR}/STUpgrade.cpp
    6161     ${SRCDIR}/STGrid.cpp
     62     ${SRCDIR}/STIdxIter.cpp
    6263     ${SRCDIR}/Templates.cpp )
    6364
     
    8182     ${SRCDIR}/python_LogSink.cpp
    8283     ${SRCDIR}/python_STGrid.cpp
     84     ${SRCDIR}/python_Iterator.cpp
    8385     ${SRCDIR}/python_asap.cpp )
    8486
  • branches/hpc33/src/FillerWrapper.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/hpc33/src/SConscript

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/hpc33/src/STMath.cpp

    r2502 r2519  
    5454#include "STSelector.h"
    5555#include "Accelerator.h"
     56#include "STIdxIter.h"
    5657
    5758using namespace casa;
     
    38603861  }
    38613862  else {
     3863//     double t0 = mathutil::gettimeofday_sec() ;
    38623864    vector<bool> masks = s->getMask( 0 ) ;
    38633865   
    38643866    // off scan
    38653867    STSelector sel = STSelector() ;
    3866     vector<int> types ;
    3867     types.push_back( SrcType::PSOFF ) ;
     3868    vector<int> types( 1, SrcType::PSOFF ) ;
     3869    //types.push_back( SrcType::PSOFF ) ;
    38683870    sel.setTypes( types ) ;
    38693871    s->setSelection( sel ) ;
     
    38743876    CountedPtr<Scantable> soff = getScantable( s, false ) ;
    38753877    Table ttab = soff->table() ;
    3876     ROScalarColumn<Double> timeCol( ttab, "TIME" ) ;
    3877     uInt nrow = timeCol.nrow() ;
    3878     Vector<Double> timeSep( nrow - 1 ) ;
     3878//     String tmpname = File::newUniqueName( "./", "temp" ).baseName() ;
     3879//     Table ttab = s->table().copyToMemoryTable( tmpname, False ) ;
     3880    ROScalarColumn<Double> *timeCol = new ROScalarColumn<Double>( ttab, "TIME" ) ;
     3881    uInt nrow = timeCol->nrow() ;
     3882    Vector<Double> timeSep = timeCol->getColumn() ;
     3883    delete timeCol ;
     3884    for ( uInt i = nrow-2 ; i > 0 ; i-- ) {
     3885      timeSep[i] -= timeSep[i-1] ;
     3886    }
     3887    Vector<Double> interval = soff->integrCol_.getColumn() ;
     3888    interval /= 86400.0 ;
     3889    Block<uInt> gaplist( 100 ) ;
     3890    uInt glidx = 0 ;
     3891    uInt glsize = gaplist.size() ;
    38793892    for ( uInt i = 0 ; i < nrow - 1 ; i++ ) {
    3880       timeSep[i] = timeCol(i+1) - timeCol(i) ;
    3881     }
    3882     ScalarColumn<Double> intervalCol( ttab, "INTERVAL" ) ;
    3883     Vector<Double> interval = intervalCol.getColumn() ;
    3884     interval /= 86400.0 ;
    3885     ScalarColumn<uInt> scanCol( ttab, "SCANNO" ) ;
    3886     vector<uInt> glist ;
    3887     for ( uInt i = 0 ; i < nrow - 1 ; i++ ) {
    3888       double gap = 2.0 * timeSep[i] / ( interval[i] + interval[i+1] ) ;
     3893      double gap = 2.0 * timeSep[i+1] / ( interval[i] + interval[i+1] ) ;
    38893894      //cout << "gap[" << i << "]=" << setw(5) << gap << endl ;
    38903895      if ( gap > 1.1 ) {
    3891         glist.push_back( i ) ;
    3892       }
    3893     }
    3894     Vector<uInt> gaplist( glist ) ;
     3896//         cout << "detected gap between " << i << " and " << i+1 << endl ;
     3897        gaplist[glidx] = i ;
     3898        glidx++ ;
     3899      }
     3900      if ( glidx >= glsize ) {
     3901//         cout << "resize gaplist" << endl ;
     3902        glsize += 100 ;
     3903        gaplist.resize( glsize ) ;
     3904      }
     3905    }
    38953906    //cout << "gaplist = " << gaplist << endl ;
    38963907    uInt newid = 0 ;
    38973908    for ( uInt i = 0 ; i < nrow ; i++ ) {
    3898       scanCol.put( i, newid ) ;
     3909      soff->scanCol_.put( i, newid ) ;
    38993910      if ( i == gaplist[newid] ) {
    39003911        newid++ ;
     
    39073918    s->unsetSelection() ;
    39083919    sel.reset() ;
    3909     types.clear() ;
     3920    //types.clear() ;
     3921//     double t1 = mathutil::gettimeofday_sec() ;
     3922//     cout << "elapsed time for off averaging: " << t1-t0 << " sec" << endl ;
    39103923   
    39113924    // on scan
     3925//     t0 = mathutil::gettimeofday_sec() ;
    39123926    bool insitu = insitu_ ;
    39133927    insitu_ = false ;
    39143928    CountedPtr<Scantable> out = getScantable( s, true ) ;
    39153929    insitu_ = insitu ;
    3916     types.push_back( SrcType::PSON ) ;
     3930    //types.push_back( SrcType::PSON ) ;
     3931    types[0] = SrcType::PSON ;
    39173932    sel.setTypes( types ) ;
    39183933    s->setSelection( sel ) ;
     
    39203935    s->unsetSelection() ;
    39213936    sel.reset() ;
    3922     types.clear() ;
    3923    
     3937    //types.clear() ;
     3938//     t1 = mathutil::gettimeofday_sec() ;
     3939//     cout << "elapsed time for preparing output table: " << t1-t0 << " sec" << endl ;
     3940
    39243941    // process each on scan
     3942//     t0 = mathutil::gettimeofday_sec() ;
    39253943//     for ( int i = 0 ; i < out->nrow() ; i++ ) {
    39263944//       vector<float> sp = getCalibratedSpectra( out, aoff, i ) ;
     
    39283946//     }
    39293947
    3930     // selection first, then process
    3931     vector<unsigned int> ifs = out->getIFNos() ;
    3932     vector<unsigned int> beams = out->getBeamNos() ;
    3933     vector<unsigned int> pols = out->getPolNos() ;
    3934     vector<int> v( 1 ) ;
    3935     for ( vector<unsigned int>::iterator i = ifs.begin() ; \
    3936           i != ifs.end() ; i++ ) {
    3937       v[0] = *i ;
    3938       sel.setIFs( v ) ;
    3939       for ( vector<unsigned int>::iterator j = pols.begin() ; \
    3940             j != pols.end() ; j++ ) {
    3941         v[0] = *j ;
    3942         sel.setPolarizations( v ) ;
    3943         for ( vector<unsigned int>::iterator k = beams.begin() ; \
    3944               k != beams.end() ; k++ ) {
    3945           v[0] = *k ;
    3946           sel.setBeams( v ) ;
    3947           out->setSelection( sel ) ;
    3948           aoff->setSelection( sel ) ;
    3949 
    3950           // calibrate data
    3951           calibrateALMA( out, aoff ) ;
    3952 
    3953           out->unsetSelection() ;
    3954           aoff->unsetSelection() ;
    3955           sel.reset() ;
    3956         }
    3957       }
    3958     }
     3948    // using STIdxIterAcc
     3949    vector<string> cols( 3 ) ;
     3950    cols[0] = "BEAMNO" ;
     3951    cols[1] = "POLNO" ;
     3952    cols[2] = "IFNO" ;
     3953    STIdxIter *iter = new STIdxIterAcc( out, cols ) ;
     3954    while ( !iter->pastEnd() ) {
     3955      Vector<uInt> ids = iter->current() ;
     3956      stringstream ss ;
     3957      ss << "SELECT FROM $1 WHERE "
     3958         << "BEAMNO==" << ids[0] << "&&"
     3959         << "POLNO==" << ids[1] << "&&"
     3960         << "IFNO==" << ids[2] ;
     3961      sel.setTaQL( ss.str() ) ;
     3962      aoff->setSelection( sel ) ;
     3963      Vector<uInt> rows = iter->getRows() ;
     3964      calibrateALMA( out, aoff, rows ) ;
     3965      aoff->unsetSelection() ;
     3966      sel.reset() ;
     3967      iter->next() ;
     3968    }
     3969    delete iter ;
     3970
     3971//     t1 = mathutil::gettimeofday_sec() ;
     3972//     cout << "elapsed time for calibration: " << t1-t0 << " sec" << endl ;
    39593973
    39603974    // flux unit
     
    50875101
    50885102void STMath::calibrateALMA( CountedPtr<Scantable>& on,
    5089                                         CountedPtr<Scantable>& off )
    5090 {
    5091 //   string reftime = on->getTime( index ) ;
     5103                            CountedPtr<Scantable>& off )
     5104{
     5105  //   string reftime = on->getTime( index ) ;
    50925106  ROTableColumn timeCol( on->table(), "TIME" ) ;
    50935107  ArrayColumn<Float> tsysCol( on->table(), "TSYS" ) ;
     
    51155129    }
    51165130    on->setSpectrum( sp, index ) ;
     5131  }
     5132}
     5133
     5134void STMath::calibrateALMA( CountedPtr<Scantable>& on,
     5135                            CountedPtr<Scantable>& off,
     5136                            Vector<uInt>& rows )
     5137{
     5138//   string reftime = on->getTime( index ) ;
     5139  ROTableColumn timeCol( on->table(), "TIME" ) ;
     5140  ArrayColumn<Float> tsysCol( on->table(), "TSYS" ) ;
     5141  vector<float> sp( on->nchan( on->getIF(rows[0]) ) ) ;
     5142  unsigned int spsize = sp.size() ;
     5143  // I know that the data is contiguous
     5144  const uInt *p = rows.data() ;
     5145  for ( int irow = 0 ; irow < rows.nelements() ; irow++ ) {
     5146    //int index = rows[irow] ;
     5147    //double reftime = timeCol.asdouble(index) ;
     5148    double reftime = timeCol.asdouble(*p) ;
     5149    vector<float> spoff = getSpectrumFromTime( reftime, off, "linear" ) ;
     5150    //vector<float> spec = on->getSpectrum( index ) ;
     5151    //Vector<Float> tsys = tsysCol( index ) ;
     5152    vector<float> spec = on->getSpectrum( *p ) ;
     5153    Vector<Float> tsys = tsysCol( *p ) ;
     5154    // ALMA Calibration
     5155    //
     5156    // Ta* = Tsys * ( ON - OFF ) / OFF
     5157    //
     5158    // 2010/01/07 Takeshi Nakazato
     5159    unsigned int tsyssize = tsys.nelements() ;
     5160    for ( unsigned int j = 0 ; j < sp.size() ; j++ ) {
     5161      float tscale = 0.0 ;
     5162      if ( tsyssize == spsize )
     5163        tscale = tsys[j] ;
     5164      else
     5165        tscale = tsys[0] ;
     5166      float v = tscale * ( spec[j] - spoff[j] ) / spoff[j] ;
     5167      sp[j] = v ;
     5168    }
     5169    //on->setSpectrum( sp, index ) ;
     5170    on->setSpectrum( sp, *p ) ;
     5171    p++ ;
    51175172  }
    51185173}
  • branches/hpc33/src/STMath.h

    r2502 r2519  
    423423  void calibrateALMA( casa::CountedPtr<Scantable>& on,
    424424                      casa::CountedPtr<Scantable>& off ) ;
     425  void calibrateALMA( casa::CountedPtr<Scantable>& on,
     426                      casa::CountedPtr<Scantable>& off,
     427                      casa::Vector<casa::uInt>& rows ) ;
    425428  vector<float> getFSCalibratedSpectra( casa::CountedPtr<Scantable>& sig,
    426429                                        casa::CountedPtr<Scantable>& ref,
  • branches/hpc33/src/python_asap.cpp

    r2356 r2519  
    8585  asap::python::python_SrcType();
    8686  asap::python::python_STGrid();
     87  asap::python::python_Iterator();
    8788
    8889#ifndef HAVE_LIBPYRAP
  • branches/hpc33/src/python_asap.h

    r2356 r2519  
    5353    void python_SrcType();
    5454    void python_STGrid();
     55    void python_Iterator();
    5556
    5657  } // python
Note: See TracChangeset for help on using the changeset viewer.