Changeset 1818 for branches/alma/src


Ignore:
Timestamp:
08/02/10 16:10:43 (14 years ago)
Author:
Kana Sugimoto
Message:

New Development: Yes

JIRA Issue: No (merge)

Ready for Test: Yes

Interface Changes: No

Description:

Merged changes -r1774:1817 in newfiller branch to alma branch


Location:
branches/alma
Files:
8 edited
11 copied

Legend:

Unmodified
Added
Removed
  • branches/alma

  • branches/alma/src/Makefile

    r1762 r1818  
    130130             STAtmosphere.o \
    131131             Scantable.o \
     132             FillerBase.o \
     133             NROFiller.o \
     134             PKSFiller.o \
     135             AsapLogSink.o \
    132136             Templates.o
     137
    133138PYOBJECTS := python_Scantable.o \
    134139             python_STFiller.o \
     
    144149             python_STAtmosphere.o \
    145150             python_STCoordinate.o \
     151             python_Filler.o \
     152             python_LogSink.o \
    146153             python_asap.o
    147154
     
    149156
    150157HEADERS   := MathUtils.h \
     158             LineCatalog.h \
    151159             Lorentzian1D.h \
    152160             Lorentzian1DParam.h \
     
    183191             IndexedCompare.h \
    184192             STAtmosphere.h \
    185              STCoordinate.h
     193             STCoordinate.h \
     194             FillerBase.h \
     195             NROFiller.h \
     196             PKSFiller.h \
     197             AsapLogSink.h
    186198
    187199STATICCCLIB := libasap.a
  • branches/alma/src/SConscript

  • branches/alma/src/STFiller.cpp

    r1757 r1818  
    8282  close();
    8383}
    84  
     84
    8585void STFiller::open( const std::string& filename, const std::string& antenna, int whichIF, int whichBeam, casa::Bool getPt )
    8686{
     
    230230  //For MS, add the location of POINTING of the input MS so one get
    231231  //pointing data from there, if necessary.
    232   //Also find nrow in MS 
     232  //Also find nrow in MS
    233233  nInDataRow = 0;
    234234  if (format == "MS2") {
    235     Path datapath(inName); 
     235    Path datapath(inName);
    236236    String ptTabPath = datapath.absoluteName();
    237237    Table inMS(ptTabPath);
     
    246246  }
    247247  String freqFrame = header_->freqref;
    248   //translate frequency reference frame back to 
    249   //MS style (as PKSMS2reader converts the original frame 
     248  //translate frequency reference frame back to
     249  //MS style (as PKSMS2reader converts the original frame
    250250  //in FITS standard style)
    251251  if (freqFrame == "TOPOCENT") {
     
    282282  int status = 0;
    283283
    284   // 
     284  //
    285285  // for NRO data
    286286  //
     
    326326    }
    327327    fclose( fp ) ;
    328   } 
     328  }
    329329  while ( status == 0 ) {
    330330    status = reader_->read(pksrec);
     
    389389    RecordFieldPtr<uInt> ifCol(rec, "IFNO");
    390390    *ifCol = pksrec.IFno-ifOffset_- 1;
    391     uInt id;
    392     /// @todo this has to change when nchan isn't global anymore
    393     //id = table_->frequencies().addEntry(Double(header_->nchan/2),
    394     //                                    pksrec.refFreq, pksrec.freqInc);
    395     if ( pksrec.nchan == 1 ) {
    396       id = table_->frequencies().addEntry(Double(0),
    397                                           pksrec.refFreq, pksrec.freqInc);
    398     }
    399     else {
    400       id = table_->frequencies().addEntry(Double(pksrec.nchan/2),
    401                                           pksrec.refFreq, pksrec.freqInc);
    402     }
     391    uInt id = table_->frequencies().addEntry(Double(pksrec.spectra.nrow()/2),
     392                                             pksrec.refFreq, pksrec.freqInc);
    403393    RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID");
    404394    *mfreqidCol = id;
     
    419409
    420410    RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID");
    421     id = table_->focus().addEntry(pksrec.parAngle, pksrec.focusAxi, 
     411    id = table_->focus().addEntry(pksrec.parAngle, pksrec.focusAxi,
    422412                                  pksrec.focusTan, pksrec.focusRot);
    423413    *mfocusidCol = id;
     
    503493  tm *ttm = localtime( &t0 ) ;
    504494  LogIO os( LogOrigin( "STFiller", "openNRO()", WHERE ) ) ;
    505 //   cout << "STFiller::openNRO()  Start time = " << t0 
    506 //        << " (" 
    507 //        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    508 //        << " " 
    509 //        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     495//   cout << "STFiller::openNRO()  Start time = " << t0
     496//        << " ("
     497//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     498//        << " "
     499//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    510500//        << ")" << endl ;
    511   os << "Start time = " << t0 
    512      << " (" 
    513      << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    514      << " " 
    515      << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     501  os << "Start time = " << t0
     502     << " ("
     503     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     504     << " "
     505     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    516506     << ")" << LogIO::POST ;
    517507
     
    551541  if ( whichIF >= 0 ) {
    552542    if ( whichIF >= 0 && whichIF < nIF_ ) {
    553       for ( int i = 0 ; i < nIF_ ; i++ ) 
     543      for ( int i = 0 ; i < nIF_ ; i++ )
    554544        ifs[i] = False ;
    555545      ifs[whichIF] = True ;
     
    570560  if (whichBeam>=0) {
    571561    if (whichBeam>=0 && whichBeam<nBeam_) {
    572       for ( int i = 0 ; i < nBeam_ ; i++ ) 
     562      for ( int i = 0 ; i < nBeam_ ; i++ )
    573563        beams[i] = False ;
    574564      beams[whichBeam] = True;
     
    595585  time( &t1 ) ;
    596586  ttm = localtime( &t1 ) ;
    597 //   cout << "STFiller::openNRO()  End time = " << t1 
    598 //        << " (" 
    599 //        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    600 //        << " " 
    601 //        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     587//   cout << "STFiller::openNRO()  End time = " << t1
     588//        << " ("
     589//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     590//        << " "
     591//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    602592//        << ")" << endl ;
    603593//   cout << "STFiller::openNRO()  Elapsed time = " << t1 - t0 << " sec" << endl ;
    604   os << "End time = " << t1 
    605      << " (" 
    606      << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    607      << " " 
    608      << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     594  os << "End time = " << t1
     595     << " ("
     596     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     597     << " "
     598     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    609599     << ")" << endl ;
    610600  os << "Elapsed time = " << t1 - t0 << " sec" << endl ;
     
    622612  tm *ttm = localtime( &t0 ) ;
    623613  LogIO os( LogOrigin( "STFiller", "readNRO()", WHERE ) ) ;
    624 //   cout << "STFiller::readNRO()  Start time = " << t0 
    625 //        << " (" 
    626 //        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    627 //        << " " 
    628 //        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     614//   cout << "STFiller::readNRO()  Start time = " << t0
     615//        << " ("
     616//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     617//        << " "
     618//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    629619//        << ")" << endl ;
    630   os << "Start time = " << t0 
    631      << " (" 
    632      << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    633      << " " 
    634      << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     620  os << "Start time = " << t0
     621     << " ("
     622     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     623     << " "
     624     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    635625     << ")" << LogIO::POST ;
    636626  //
     
    692682      srcType = 3 ;
    693683    }
    694  
     684
    695685    // if srcType is 2 (ZERO scan), ignore scan
    696     if ( srcType != 2 && srcType != -1 && srcType != 3 ) { 
     686    if ( srcType != 2 && srcType != -1 && srcType != 3 ) {
    697687      TableRow row( table_->table() ) ;
    698688      TableRecord& rec = row.record();
     
    789779      *srcnCol = srcname ;
    790780      RecordFieldPtr<Int> srctCol(rec, "SRCTYPE") ;
    791       *srctCol = srcType ;     
    792       RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME"); 
     781      *srctCol = srcType ;
     782      RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME");
    793783      *fieldnCol = fieldname ;
    794784      RecordFieldPtr< Array<Float> > specCol(rec, "SPECTRA") ;
     
    820810                                       windvel,
    821811                                       winddir ) ;
    822       *mweatheridCol = id ;         
     812      *mweatheridCol = id ;
    823813      RecordFieldPtr<Double> svelCol(rec, "SRCVELOCITY") ;
    824814      *svelCol = srcvel ;
     
    847837  ttm = localtime( &t1 ) ;
    848838//   cout << "STFiller::readNRO()  Processed " << i << " rows" << endl ;
    849 //   cout << "STFiller::readNRO()  Added " << i - count << " rows (ignored " 
     839//   cout << "STFiller::readNRO()  Added " << i - count << " rows (ignored "
    850840//        << count << " \"ZERO\" scans)" << endl ;
    851 //   cout << "STFiller::readNRO()  End time = " << t1 
    852 //        << " (" 
    853 //        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    854 //        << " " 
    855 //        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     841//   cout << "STFiller::readNRO()  End time = " << t1
     842//        << " ("
     843//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     844//        << " "
     845//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    856846//        << ")" << endl ;
    857847//   cout << "STFiller::readNRO()  Elapsed time = " << t1 - t0 << " sec" << endl ;
    858848  os << "Processed " << i << " rows" << endl ;
    859   os << "Added " << i - count << " rows (ignored " 
     849  os << "Added " << i - count << " rows (ignored "
    860850     << count << " \"ZERO\" scans)" << endl ;
    861851  os.post() ;
    862   os << "End time = " << t1 
    863      << " (" 
    864      << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    865      << " " 
    866      << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     852  os << "End time = " << t1
     853     << " ("
     854     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     855     << " "
     856     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    867857     << ")" << endl ;
    868858  os << "Elapsed time = " << t1 - t0 << " sec" << endl ;
     
    871861
    872862  return 0 ;
    873 } 
     863}
    874864
    875865Bool STFiller::fileCheck()
     
    881871  if ( inFile.isDirectory() )
    882872    return bval ;
    883  
     873
    884874  // if beginning of header data is "RW", return true
    885   // otherwise, return false ; 
     875  // otherwise, return false ;
    886876  FILE *fp = fopen( filename_.c_str(), "r" ) ;
    887877  char buf[9] ;
  • branches/alma/src/Scantable.cpp

    r1757 r1818  
    224224  td.addColumn(ScalarColumnDesc<uInt>("FREQ_ID"));
    225225  td.addColumn(ScalarColumnDesc<uInt>("MOLECULE_ID"));
    226   td.addColumn(ScalarColumnDesc<Int>("REFBEAMNO"));
    227 
    228   td.addColumn(ScalarColumnDesc<uInt>("FLAGROW"));
     226
     227  ScalarColumnDesc<Int> refbeamnoColumn("REFBEAMNO");
     228  refbeamnoColumn.setDefault(Int(-1));
     229  td.addColumn(refbeamnoColumn);
     230
     231  ScalarColumnDesc<uInt> flagrowColumn("FLAGROW");
     232  flagrowColumn.setDefault(uInt(0));
     233  td.addColumn(flagrowColumn);
    229234
    230235  td.addColumn(ScalarColumnDesc<Double>("TIME"));
     
    361366      for (int i = 0; i < size; ++i)
    362367        arr[i] = static_cast<T>(defValue[i]);
    363      
     368
    364369      col.fillColumn(arr);
    365370    } else {
     
    949954          Vector<Double> vec(moleculeTable_.getRestFrequency(i));
    950955          if (vec.nelements() > 0) {
    951                if (firstline) { 
     956               if (firstline) {
    952957                   oss << setprecision(10) << vec << " [Hz]" << endl;
    953958                   firstline=False;
    954959               }
    955                else{ 
     960               else{
    956961                   oss << setw(15)<<" " << setprecision(10) << vec << " [Hz]" << endl;
    957                } 
     962               }
    958963          } else {
    959964              oss << "none" << endl;
     
    11671172  //Quantum<Double> urf(rf, u);
    11681173  Quantum<Vector<Double> >urf(rf, u);
    1169   Vector<String> formattedname(0); 
     1174  Vector<String> formattedname(0);
    11701175  //cerr<<"Scantable::setRestFrequnecies="<<urf<<endl;
    1171  
     1176
    11721177  //uInt id = moleculeTable_.addEntry(urf.getValue("Hz"), name, "");
    11731178  uInt id = moleculeTable_.addEntry(urf.getValue("Hz"), mathutil::toVectorString(name), formattedname);
     
    12411246}
    12421247
    1243 std::string Scantable::getAntennaName() const
     1248String Scantable::getAntennaName() const
    12441249{
    12451250  String out;
     
    13471352  Vector<Float> arr = specCol_( 0 ) ;
    13481353  int nChan = arr.nelements() ;
    1349  
     1354
    13501355  // if nmin < 0 or nmax < 0, nothing to do
    13511356  if (  nmin < 0 ) {
     
    13551360    throw( casa::indexError<int>( nmax, "asap::Scantable::reshapeSpectrum: Invalid range. Negative index is specified." ) ) ;
    13561361  }
    1357  
     1362
    13581363  // if nmin > nmax, exchange values
    13591364  if ( nmin > nmax ) {
     
    13621367    nmin = tmp ;
    13631368    LogIO os( LogOrigin( "Scantable", "reshapeSpectrum()", WHERE ) ) ;
    1364     os << "Swap values. Applied range is [" 
     1369    os << "Swap values. Applied range is ["
    13651370       << nmin << ", " << nmax << "]" << LogIO::POST ;
    13661371  }
    1367  
     1372
    13681373  // if nmin exceeds nChan, nothing to do
    13691374  if ( nmin >= nChan ) {
    13701375    throw( casa::indexError<int>( nmin, "asap::Scantable::reshapeSpectrum: Invalid range. Specified minimum exceeds nChan." ) ) ;
    13711376  }
    1372  
     1377
    13731378  // if nmax exceeds nChan, reset nmax to nChan
    13741379  if ( nmax >= nChan ) {
     
    13861391    }
    13871392  }
    1388  
     1393
    13891394  // reshape specCol_ and flagCol_
    13901395  for ( int irow = 0 ; irow < nrow() ; irow++ ) {
     
    14061411     ***/
    14071412    refval = refval - ( refpix - nmin ) * increment ;
    1408     refpix = 0 ; 
     1413    refpix = 0 ;
    14091414    freqTable_.setEntry( refpix, refval, increment, irow ) ;
    14101415  }
    1411  
     1416
    14121417  // update nchan
    14131418  int newsize = nmax - nmin + 1 ;
    14141419  table_.rwKeywordSet().define( "nChan", newsize ) ;
    1415  
     1420
    14161421  // update bandwidth
    14171422  // assumed all spectra in the scantable have same bandwidth
    14181423  table_.rwKeywordSet().define( "Bandwidth", increment * newsize ) ;
    1419  
     1424
    14201425  return ;
    14211426}
    14221427
    1423 void asap::Scantable::reshapeSpectrum( int nmin, int nmax, int irow ) 
     1428void asap::Scantable::reshapeSpectrum( int nmin, int nmax, int irow )
    14241429{
    14251430  // reshape specCol_ and flagCol_
     
    14621467  for ( int irow = 0 ; irow < nrow() ; irow++ ) {
    14631468    regridChannel( nChan, dnu, irow ) ;
    1464   } 
     1469  }
    14651470  coordinfo[0] = oldinfo ;
    14661471  setCoordInfo( coordinfo ) ;
    14671472
    14681473
    1469   // NOTE: this method does not update metadata such as 
     1474  // NOTE: this method does not update metadata such as
    14701475  //       FREQUENCIES subtable, nChan, Bandwidth, etc.
    14711476
    1472   return ; 
    1473 }
    1474 
    1475 void asap::Scantable::regridChannel( int nChan, double dnu, int irow ) 
     1477  return ;
     1478}
     1479
     1480void asap::Scantable::regridChannel( int nChan, double dnu, int irow )
    14761481{
    14771482  // logging
     
    14831488  Vector<Float> newspec( nChan, 0 ) ;
    14841489  Vector<uChar> newflag( nChan, false ) ;
    1485  
     1490
    14861491  // regrid
    14871492  vector<double> abcissa = getAbcissa( irow ) ;
     
    15021507  zi[0] = z[0] - 0.5 * dnu ;
    15031508  zi[1] = z[0] + 0.5 * dnu ;
    1504   for ( int ii = 2 ; ii < nChan ; ii++ ) 
     1509  for ( int ii = 2 ; ii < nChan ; ii++ )
    15051510    zi[ii] = zi[ii-1] + dnu ;
    15061511  zi[nChan] = z[nChan-1] + 0.5 * dnu ;
     
    15091514  for ( int ii = 2 ; ii < oldsize ; ii++ )
    15101515    yi[ii] = abcissa[ii-1] + olddnu ;
    1511   yi[oldsize] = abcissa[oldsize-1] + 0.5 * olddnu ; 
     1516  yi[oldsize] = abcissa[oldsize-1] + 0.5 * olddnu ;
    15121517  if ( dnu > 0.0 ) {
    15131518    for ( int ii = 0 ; ii < nChan ; ii++ ) {
     
    16641669//    ***/
    16651670//   // NOTE: Assumed that all spectra have the same bandwidth
    1666 //   pile += dnu ; 
     1671//   pile += dnu ;
    16671672//   newspec[nChan-1] += frac * olddnu * oldspec[refChan] ;
    16681673//   newflag[nChan-1] = newflag[nChan-1] || oldflag[refChan] ;
     
    16831688//   newspec[nChan-1] /= wsum ;
    16841689//   //ofs << "newspec[" << nChan - 1 << "] = " << newspec[nChan-1] << endl ;
    1685  
     1690
    16861691//   specCol_.put( irow, newspec ) ;
    16871692//   flagsCol_.put( irow, newflag ) ;
  • branches/alma/src/Scantable.h

    r1757 r1818  
    237237
    238238  /**
    239    * Get flagRow info at the specified row. If true, the whole data 
     239   * Get flagRow info at the specified row. If true, the whole data
    240240   * at the row should be flagged.
    241241   */
     
    250250
    251251  /**
    252    * Return a list of booleans with the size of nchan for a specified row, to get info 
     252   * Return a list of booleans with the size of nchan for a specified row, to get info
    253253   * about which channel is clipped.
    254254   */
    255255  std::vector<bool> getClipMask(int whichrow, const casa::Float uthres, const casa::Float dthres, bool clipoutside, bool unflag);
    256   void srchChannelsToClip(casa::uInt whichrow, const casa::Float uthres, const casa::Float dthres, bool clipoutside, bool unflag, 
     256  void srchChannelsToClip(casa::uInt whichrow, const casa::Float uthres, const casa::Float dthres, bool clipoutside, bool unflag,
    257257                          casa::Vector<casa::uChar> flgs);
    258258
     
    441441   * @return antenna name string
    442442   */
    443   std::string getAntennaName() const;
     443  casa::String getAntennaName() const;
    444444
    445445  /**
     
    470470   * @param[in] nmin, nmax minimum and maximum channel
    471471   * @param[in] irow       row number
    472    * 
    473    * 30/07/2008 Takeshi Nakazato 
     472   *
     473   * 30/07/2008 Takeshi Nakazato
    474474   **/
    475475  void reshapeSpectrum( int nmin, int nmax ) throw( casa::AipsError );
     
    486486  void regridChannel( int nchan, double dnu, int irow ) ;
    487487
    488  
     488
    489489private:
    490490
     
    583583
    584584  /**
    585    * Add an auxiliary column to the main table and attach it to a 
     585   * Add an auxiliary column to the main table and attach it to a
    586586   * cached column. Use for adding new columns that the original asap2
    587    * tables do not have. 
     587   * tables do not have.
    588588   * @param[in] col      reference to the cached column to be attached
    589589   * @param[in] colName  column name in asap table
  • branches/alma/src/python_asap.cpp

    r1757 r1818  
    6767  asap::python::python_Scantable();
    6868  asap::python::python_STFiller();
     69  asap::python::python_Filler();
    6970  asap::python::python_STSelector();
    7071  asap::python::python_STMath();
     
    7576  asap::python::python_LineCatalog();
    7677  asap::python::python_Logger();
     78  asap::python::python_LogSink();
    7779  asap::python::python_STCoordinate();
    7880  asap::python::python_STAtmosphere();
  • branches/alma/src/python_asap.h

    r1757 r1818  
    3939    void python_Scantable();
    4040    void python_STFiller();
     41    void python_Filler();
    4142    void python_STSelector();
    4243    void python_STMath();
     
    4748    void python_LineCatalog();
    4849    void python_Logger();
     50    void python_LogSink();
    4951    void python_STCoordinate();
    5052    void python_STAtmosphere();
Note: See TracChangeset for help on using the changeset viewer.