Changeset 2475


Ignore:
Timestamp:
04/23/12 16:43:34 (12 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...

Bug fix on averageall mode: fixed a bug that cannot handle spectral
Tsys when averaging.


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STMath.cpp

    r2474 r2475  
    269269        */
    270270        specCol.get(k, spec);
    271         tsysCol.get(k, tsys);
     271        //tsysCol.get(k, tsys);
     272        tsys.assign( tsysCol(k) );
    272273        intCol.get(k, inter);
    273274        mjdCol.get(k, time);
     
    36053606    }
    36063607    // combine spectra
    3607     ArrayColumn<Float> specColOut ;
    3608     specColOut.attach( out->table(), "SPECTRA" ) ;
    3609     ArrayColumn<uChar> flagColOut ;
    3610     flagColOut.attach( out->table(), "FLAGTRA" ) ;
    3611     ScalarColumn<uInt> ifnoColOut ;
    3612     ifnoColOut.attach( out->table(), "IFNO" ) ;
    3613     ScalarColumn<uInt> polnoColOut ;
    3614     polnoColOut.attach( out->table(), "POLNO" ) ;
    3615     ScalarColumn<uInt> freqidColOut ;
    3616     freqidColOut.attach( out->table(), "FREQ_ID" ) ;
     3608    ArrayColumn<Float> specColOut( out->table(), "SPECTRA" ) ;
     3609    ArrayColumn<uChar> flagColOut( out->table(), "FLAGTRA" ) ;
     3610    ArrayColumn<Float> tsysColOut( out->table(), "TSYS" ) ;
     3611    ScalarColumn<uInt> ifnoColOut( out->table(), "IFNO" ) ;
     3612    ScalarColumn<uInt> polnoColOut( out->table(), "POLNO" ) ;
     3613    ScalarColumn<uInt> freqidColOut( out->table(), "FREQ_ID" ) ;
    36173614//     MDirection::ScalarColumn dirColOut ;
    36183615//     dirColOut.attach( out->table(), "DIRECTION" ) ;
     
    36223619    TableIterator iter( tab, cols ) ;
    36233620    vector< vector<uInt> > sizes( freqgrp.size() ) ;
     3621    vector<uInt> totalsizes( freqgrp.size(), 0 ) ;
     3622    ArrayColumn<Float> specCols ;
     3623    ArrayColumn<uChar> flagCols ;
     3624    ArrayColumn<Float> tsysCols ;
     3625    ScalarColumn<uInt> polnos ;
     3626    vector< Vector<Float> > specout( freqgrp.size() ) ;
     3627    vector< Vector<uChar> > flagout( freqgrp.size() ) ;
     3628    vector< Vector<Float> > tsysout( freqgrp.size() ) ;
    36243629    while( !iter.pastEnd() ) {
    3625       vector< vector<Float> > specout( freqgrp.size() ) ;
    3626       vector< vector<uChar> > flagout( freqgrp.size() ) ;
    3627       ArrayColumn<Float> specCols ;
    36283630      specCols.attach( iter.table(), "SPECTRA" ) ;
    3629       ArrayColumn<uChar> flagCols ;
    36303631      flagCols.attach( iter.table(), "FLAGTRA" ) ;
     3632      tsysCols.attach( iter.table(), "TSYS" ) ;
    36313633      ifnoCol.attach( iter.table(), "IFNO" ) ;
    3632       ScalarColumn<uInt> polnos ;
    36333634      polnos.attach( iter.table(), "POLNO" ) ;
    36343635//       MDirection::ScalarColumn dircol ;
     
    36713672//       }
    36723673      // get a list of number of channels for each frequency group member
    3673       for ( uInt igrp = 0 ; igrp < freqgrp.size() ; igrp++ ) {
    3674         sizes[igrp].resize( freqgrp[igrp].size() ) ;
    3675         for ( uInt imem = 0 ; imem < freqgrp[igrp].size() ; imem++ ) {
    3676           for ( uInt irow = 0 ; irow < iter.table().nrow() ; irow++ ) {
    3677             uInt ifno = ifnoCol( irow ) ;
    3678             if ( ifno == freqgrp[igrp][imem] ) {
    3679               Vector<Float> spec = specCols( irow ) ;
    3680               sizes[igrp][imem] = spec.nelements() ;
    3681               break ;
    3682             }
    3683           }
    3684         }
    3685       }
     3674      if ( totalsizes[0] == 0 ) {
     3675        for ( uInt igrp = 0 ; igrp < freqgrp.size() ; igrp++ ) {
     3676          sizes[igrp].resize( freqgrp[igrp].size() ) ;
     3677          for ( uInt imem = 0 ; imem < freqgrp[igrp].size() ; imem++ ) {
     3678            for ( uInt irow = 0 ; irow < iter.table().nrow() ; irow++ ) {
     3679              uInt ifno = ifnoCol( irow ) ;
     3680              if ( ifno == freqgrp[igrp][imem] ) {
     3681                Vector<Float> spec = specCols( irow ) ;
     3682                sizes[igrp][imem] = spec.nelements() ;
     3683                totalsizes[igrp] += sizes[igrp][imem] ;
     3684                break ;
     3685              }
     3686            }
     3687          }
     3688          specout[igrp].resize( totalsizes[igrp] ) ;
     3689          flagout[igrp].resize( totalsizes[igrp] ) ;
     3690          tsysout[igrp].resize( totalsizes[igrp] ) ;
     3691        }
     3692      }
     3693
    36863694      // combine spectra
    36873695      for ( uInt irow = 0 ; irow < out->table().nrow() ; irow++ ) {
     
    36973705            }
    36983706          }
     3707          IPosition startpos( 1, 0 ) ;
     3708          IPosition endpos( 1, 0 ) ;
    36993709          for ( uInt imem = 0 ; imem < freqgrp[igrp].size() ; imem++ ) {
    37003710            for ( uInt jrow = 0 ; jrow < iter.table().nrow() ; jrow++ ) {
     
    37113721//               if ( ifno == freqgrp[igrp][imem] && dd <= tol ) {
    37123722              if ( ifno == freqgrp[igrp][imem] ) {
     3723                endpos[0] = startpos[0] + sizes[igrp][imem] - 1 ;
    37133724                Vector<Float> spec = specCols( jrow ) ;
    37143725                Vector<uChar> flag = flagCols( jrow ) ;
    3715                 vector<Float> svec ;
    3716                 spec.tovector( svec ) ;
    3717                 vector<uChar> fvec ;
    3718                 flag.tovector( fvec ) ;
     3726                Vector<Float> tsys = tsysCols( jrow ) ;
    37193727                //os << "spec.size() = " << svec.size() << " fvec.size() = " << fvec.size() << LogIO::POST ;
    3720                 specout[igrp].insert( specout[igrp].end(), svec.begin(), svec.end() ) ;
    3721                 flagout[igrp].insert( flagout[igrp].end(), fvec.begin(), fvec.end() ) ;
     3728                specout[igrp]( startpos, endpos ) = spec ;
     3729                flagout[igrp]( startpos, endpos ) = flag ;
     3730                if ( spec.size() == tsys.size() ) {
     3731                  tsysout[igrp]( startpos, endpos ) = tsys ;
     3732                }
     3733                else {
     3734                  tsysout[igrp]( startpos, endpos ) = tsys[0] ;
     3735                }
    37223736                //os << "specout[" << igrp << "].size() = " << specout[igrp].size() << LogIO::POST ;
     3737                startpos[0] += sizes[igrp][imem] ;
    37233738              }
    37243739            }
    37253740          }
    37263741          // set SPECTRA and FRAGTRA
    3727           Vector<Float> newspec( specout[igrp] ) ;
    3728           Vector<uChar> newflag( flagout[igrp] ) ;
    3729           specColOut.put( irow, newspec ) ;
    3730           flagColOut.put( irow, newflag ) ;
     3742          specColOut.put( irow, specout[igrp] ) ;
     3743          flagColOut.put( irow, flagout[igrp] ) ;
     3744          tsysColOut.put( irow, tsysout[igrp] ) ;
    37313745          // IFNO renumbering (renumbered as frequency group ID)
    37323746          ifnoColOut.put( irow, igrp ) ;
  • trunk/src/Scantable.cpp

    r2463 r2475  
    18801880  Vector<Float> oldspec = specCol_( irow ) ;
    18811881  Vector<uChar> oldflag = flagsCol_( irow ) ;
     1882  Vector<Float> oldtsys = tsysCol_( irow ) ;
    18821883  uInt newsize = nmax - nmin + 1 ;
    1883   specCol_.put( irow, oldspec( Slice( nmin, newsize, 1 ) ) ) ;
    1884   flagsCol_.put( irow, oldflag( Slice( nmin, newsize, 1 ) ) ) ;
     1884  Slice slice( nmin, newsize, 1 ) ;
     1885  specCol_.put( irow, oldspec( slice ) ) ;
     1886  flagsCol_.put( irow, oldflag( slice ) ) ;
     1887  if ( oldspec.size() == oldtsys.size() )
     1888    tsysCol_.put( irow, oldtsys( slice ) ) ;
    18851889
    18861890  return ;
Note: See TracChangeset for help on using the changeset viewer.