Changeset 2374 for trunk


Ignore:
Timestamp:
12/16/11 19:55:23 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-2816

Ready for Test: No

Interface Changes: Yes/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...

Load spectra (Float) as Complex at the beggining to save memory usage.


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STGrid.cpp

    r2371 r2374  
    155155
    156156  // retrieve data
    157   Cube<Float> spectra ;
     157  Cube<Complex> spectra ;
    158158  Matrix<Double> direction ;
    159159  Cube<uChar> flagtra ;
     
    209209  Bool deletePos, deleteData, deleteWgt, deleteFlag, deleteFlagR, deleteConv, deleteDataG, deleteWgtG ;
    210210  Double *xypos_p = xypos.getStorage( deletePos ) ;
    211   Cube<Complex> dataC( spectra.shape(), 0.0 ) ;
    212   setReal( dataC, spectra ) ;
    213   const Complex *data_p = dataC.getStorage( deleteData ) ;
     211  const Complex *data_p = spectra.getStorage( deleteData ) ;
    214212  const Float *wgt_p = weight.getStorage( deleteWgt ) ;
    215213  const Int *flag_p = flagI.getStorage( deleteFlag ) ;
     
    278276  os << "ggridsd: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    279277  xypos.putStorage( xypos_p, deletePos ) ;
    280   dataC.freeStorage( data_p, deleteData ) ;
     278  spectra.freeStorage( data_p, deleteData ) ;
    281279  weight.freeStorage( wgt_p, deleteWgt ) ;
    282280  flagI.freeStorage( flag_p, deleteFlag ) ;
     
    287285  gdataArrC.putStorage( gdata_p, deleteDataG ) ;
    288286  gwgtArr.putStorage( wdata_p, deleteWgtG ) ;
    289   Array<Float> gdataArr = real( gdataArrC ) ;
    290   setData( data_, gdataArr, gwgtArr ) ;
     287  setData( data_, gdataArrC, gwgtArr ) ;
    291288  //Matrix<Double> sumWeight( IPosition( 2, npol_, nchan_ ), sumw_p, TAKE_OVER ) ;
    292289  delete sumw_p ;
     
    298295
    299296void STGrid::setData( Array<Float> &data,
    300                       Array<Float> &gdata,
     297                      Array<Complex> &gdata,
    301298                      Array<Float> &gwgt )
    302299{
     
    307304  uInt len = data.nelements() ;
    308305  Float *w0_p ;
    309   const Float *w1_p, *w2_p ;
     306  const Complex *w1_p ;
     307  const Float *w2_p ;
    310308  Bool b0, b1, b2 ;
    311309  Float *data_p = data.getStorage( b0 ) ;
    312   const Float *gdata_p = gdata.getStorage( b1 ) ;
     310  const Complex *gdata_p = gdata.getStorage( b1 ) ;
    313311  const Float *gwgt_p = gwgt.getStorage( b2 ) ;
    314312  w0_p = data_p ;
     
    316314  w2_p = gwgt_p ;
    317315  for ( uInt i = 0 ; i < len ; i++ ) {
    318     *w0_p = (*w2_p > 0.0) ? (*w1_p / *w2_p) : 0.0 ;
     316    *w0_p = (*w2_p > 0.0) ? ((*w1_p).real() / *w2_p) : 0.0 ;
    319317    w0_p++ ;
    320318    w1_p++ ;
     
    457455}
    458456
    459 void STGrid::getData( Cube<Float> &spectra,
     457void STGrid::getData( Cube<Complex> &spectra,
    460458                      Matrix<Double> &direction,
    461459                      Cube<uChar> &flagtra,
     
    463461                      Matrix<Float> &weight )
    464462{
     463//   LogIO os( LogOrigin("STGrid","getData",WHERE) ) ;
     464//   os << "start" << LogIO::POST ;
    465465  Table tab ;
    466466  selectData( tab ) ;
    467467  updatePolList( tab ) ;
    468 //   cout << "npol_ = " << npol_ << endl ;
    469 //   cout << "nchan_ = " << nchan_ << endl ;
    470 //   cout << "nrow_ = " << nrow_ << endl ;
     468//   os << "npol_ = " << npol_ << LogIO::POST ;
     469//   os << "nchan_ = " << nchan_ << LogIO::POST ;
     470//   os << "nrow_ = " << nrow_ << LogIO::POST ;
    471471  spectra.resize( npol_, nchan_, nrow_ ) ;
    472472  flagtra.resize( npol_, nchan_, nrow_ ) ;
     
    475475  Matrix<Double> tint( npol_, nrow_ ) ;
    476476  // boolean for pointer access
    477   Bool bsp, bfl, bfr, bts, bti ;
     477  Bool bsp, bfl, bfr, bts, bti, bsps ;
    478478  // pointer to the data
    479   Float *sp_p = spectra.getStorage( bsp ) ;
     479  Complex *sp_p = spectra.getStorage( bsp ) ;
    480480  uChar *fl_p = flagtra.getStorage( bfl ) ;
    481481  uInt *fr_p = rflag.getStorage( bfr ) ;
     
    483483  Double *ti_p = tint.getStorage( bti ) ;
    484484  // working pointer
    485   Float *wsp_p = sp_p ;
     485  Complex *wsp_p = sp_p ;
    486486  uChar *wfl_p = fl_p ;
    487487  uInt *wfr_p = fr_p ;
     
    491491  IPosition mshape( 2, nchan_, nrow_ ) ;
    492492  IPosition vshape( 1, nrow_ ) ;
     493  Vector<Float> spSlice( nchan_ ) ;
     494  const Float *sps_p = spSlice.getStorage( bsps ) ;
     495  long cincr = npol_ ;
     496  long rincr = npol_ * nchan_ ;
    493497  for ( Int ipol = 0 ; ipol < npol_ ; ipol++ ) {
    494498    Table subt = tab( tab.col("POLNO") == pollist_[ipol] ) ;
     
    499503    ROArrayColumn<Float> tsysCol( subt, "TSYS" ) ;
    500504    ROScalarColumn<Double> tintCol( subt, "INTERVAL" ) ;
    501     Matrix<Float> spSlice( mshape, wsp_p, SHARE ) ;
     505    for ( Int irow = 0 ; irow < nrow_ ; irow++ ) {
     506      spectraCol.get( irow, spSlice ) ;
     507      const Float *wsps_p = sps_p ;
     508      wsp_p = sp_p + (long)ipol + rincr * (long)irow ;
     509      for ( Int ichan = 0 ; ichan < nchan_ ; ichan++ ) {
     510        *wsp_p = *wsps_p ;
     511        wsps_p++ ;
     512        wsp_p += cincr ;
     513      }
     514    }
    502515    Matrix<uChar> flSlice( mshape, wfl_p, SHARE ) ;
    503516    Vector<uInt> frSlice( vshape, wfr_p, SHARE ) ;
    504     spectraCol.getColumn( spSlice ) ;
    505517    flagtraCol.getColumn( flSlice ) ;
    506518    rflagCol.getColumn( frSlice ) ;
     
    524536    wti_p += nrow_ ;
    525537  }
     538  spSlice.freeStorage( sps_p, bsps ) ;
    526539  spectra.putStorage( sp_p, bsp ) ;
    527540  flagtra.putStorage( fl_p, bfl ) ;
     
    898911  t1 = mathutil::gettimeofday_sec() ;
    899912  os << "saveData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    900  
     913
    901914  return outfile_ ;
    902915}
  • trunk/src/STGrid.h

    r2371 r2374  
    8383
    8484  void setData( Array<Float> &data,
    85                 Array<Float> &gdata,
     85                Array<Complex> &gdata,
    8686                Array<Float> &gwgt ) ;
    8787 
    88   void getData( Cube<Float> &spectra,
     88  void getData( Cube<Complex> &spectra,
    8989                Matrix<Double> &direction,
    9090                Cube<uChar> &flagtra,
Note: See TracChangeset for help on using the changeset viewer.