Changeset 2431


Ignore:
Timestamp:
03/14/12 15:15:57 (12 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (CAS-2818)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: unit test: sdaverage[test900]

Put in Release Notes: No

Module(s):

Description:

Bug fixes and improvements of Scantable::regridChannel.

  • fixed bugs in regridding abcissa of spectra.
  • take channel flag into account when regridding spectra.
  • flag a regridded channel only when all channels mapped to it is flagged or no channel is mapped to it.


Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r2429 r2431  
    275275        Parameters:
    276276
    277             name:        the name of the outputfile. For format "ASCII"
     277            name:        the name of the outputfile. For format 'ASCII'
    278278                         this is the root file name (data in 'name'.txt
    279279                         and header in 'name'_header.txt)
     
    533533
    534534            selection:    a selector object (default unset the selection), or
    535                           any combination of "pols", "ifs", "beams", "scans",
    536                           "cycles", "name", "query"
     535                          any combination of 'pols', 'ifs', 'beams', 'scans',
     536                          'cycles', 'name', 'query'
    537537
    538538        Examples::
     
    12021202            end:      the end frequency or period to remove
    12031203
    1204             unit:     the frequency unit (default "MHz") or "" for
     1204            unit:     the frequency unit (default 'MHz') or '' for
    12051205                      explicit lag channels
    12061206
     
    17541754                # provided your scantable is called scan
    17551755                selection = selector()
    1756                 selection.set_name("ORION*")
     1756                selection.set_name('ORION*')
    17571757                selection.set_ifs([1])
    17581758                scan.set_selection(selection)
     
    19951995                         The first row of the ascii file must give the column
    19961996                         names and these MUST include columns
    1997                          "ELEVATION" (degrees) and "FACTOR" (multiply data
     1997                         'ELEVATION' (degrees) and 'FACTOR' (multiply data
    19981998                         by this) somewhere.
    19991999                         The second row must give the data type of the
     
    20122012
    20132013            method:      Interpolation method when correcting from a table.
    2014                          Values are  "nearest", "linear" (default), "cubic"
    2015                          and "spline"
     2014                         Values are  'nearest', 'linear' (default), 'cubic'
     2015                         and 'spline'
    20162016
    20172017            insitu:      if False a new scantable is returned.
     
    20472047
    20482048            method:      Interpolation method for regridding the spectra.
    2049                          Choose from "nearest", "linear", "cubic" (default)
    2050                          and "spline"
     2049                         Choose from 'nearest', 'linear', 'cubic' (default)
     2050                         and 'spline'
    20512051
    20522052            insitu:      if False a new scantable is returned.
     
    21382138
    21392139            method:      Interpolation method when correcting from a table.
    2140                          Values are  "nearest", "linear", "cubic" (default)
    2141                          and "spline"
     2140                         Values are  'nearest', 'linear', 'cubic' (default)
     2141                         and 'spline'
    21422142
    21432143            insitu:      if False a new scantable is returned.
     
    22222222
    22232223            poltype:    The new polarisation type. Valid types are:
    2224                         "linear", "circular", "stokes" and "linpol"
     2224                        'linear', 'circular', 'stokes' and 'linpol'
    22252225
    22262226        """
  • trunk/src/Scantable.cpp

    r2427 r2431  
    19061906
    19071907  // change channel number for specCol_ and flagCol_
    1908   Vector<Float> newspec( nChan, 0 ) ;
    1909   Vector<uChar> newflag( nChan, false ) ;
     1908  //Vector<Float> newspec( nChan, 0 ) ;
     1909  //Vector<uChar> newflag( nChan, false ) ;
    19101910  vector<string> coordinfo = getCoordInfo() ;
    19111911  string oldinfo = coordinfo[0] ;
     
    19331933  Vector<Float> oldspec = specCol_( irow ) ;
    19341934  Vector<uChar> oldflag = flagsCol_( irow ) ;
     1935  Vector<Float> oldtsys = tsysCol_( irow ) ;
    19351936  Vector<Float> newspec( nChan, 0 ) ;
    1936   Vector<uChar> newflag( nChan, false ) ;
     1937  //Vector<uChar> newflag( nChan, false ) ;
     1938  Vector<uChar> newflag( nChan, true ) ;
     1939  Vector<Float> newtsys ;
     1940  bool regridTsys = false ;
     1941  if (oldtsys.size() == oldspec.size()) {
     1942    regridTsys = true ;
     1943    newtsys.resize(nChan,false) ;
     1944    newtsys = 0 ;
     1945  }
    19371946
    19381947  // regrid
     
    19491958  Vector<Float> yi( oldsize + 1 ) ;
    19501959  zi[0] = abcissa[0] - 0.5 * olddnu ;
    1951   zi[1] = zi[1] + dnu ;
    1952   for ( int ii = 2 ; ii < nChan ; ii++ )
     1960  //zi[1] = zi[1] + dnu ;
     1961  for ( int ii = 1 ; ii < nChan ; ii++ )
    19531962    zi[ii] = zi[0] + dnu * ii ;
    19541963  zi[nChan] = zi[nChan-1] + dnu ;
    19551964  yi[0] = abcissa[0] - 0.5 * olddnu ;
    1956   yi[1] = abcissa[1] + 0.5 * olddnu ;
    1957   for ( int ii = 2 ; ii < oldsize ; ii++ )
    1958     yi[ii] = abcissa[ii-1] + olddnu ;
     1965  //yi[1] = abcissa[1] + 0.5 * olddnu ;
     1966  for ( int ii = 1 ; ii < oldsize ; ii++ )
     1967    //yi[ii] = abcissa[ii-1] + olddnu ;
     1968    yi[ii] = yi[0] + olddnu * ii ;
    19591969  yi[oldsize] = abcissa[oldsize-1] + 0.5 * olddnu ;
    19601970  if ( dnu > 0.0 ) {
     
    19701980          }
    19711981          else if ( yr <= zr ) {
    1972             newspec[ii] += oldspec[j] * ( yr - zl ) ;
    1973             newflag[ii] = newflag[ii] || oldflag[j] ;
    1974             wsum += ( yr - zl ) ;
     1982            if (!oldflag[j]) {
     1983              newspec[ii] += oldspec[j] * ( yr - zl ) ;
     1984              if (regridTsys) newtsys[ii] += oldtsys[j] * ( yr - zl ) ;
     1985              wsum += ( yr - zl ) ;
     1986            }
     1987            //newflag[ii] = newflag[ii] || oldflag[j] ;
     1988            newflag[ii] = newflag[ii] && oldflag[j] ;
    19751989          }
    19761990          else {
    1977             newspec[ii] += oldspec[j] * dnu ;
    1978             newflag[ii] = newflag[ii] || oldflag[j] ;
    1979             wsum += dnu ;
     1991            if (!oldflag[j]) {
     1992              newspec[ii] += oldspec[j] * dnu ;
     1993              if (regridTsys) newtsys[ii] += oldtsys[j] * dnu ;
     1994              wsum += dnu ;
     1995            }
     1996            //newflag[ii] = newflag[ii] || oldflag[j] ;
     1997            newflag[ii] = newflag[ii] && oldflag[j] ;
    19801998            ichan = j ;
    19811999            break ;
     
    19842002        else if ( yl < zr ) {
    19852003          if ( yr <= zr ) {
    1986               newspec[ii] += oldspec[j] * ( yr - yl ) ;
    1987               newflag[ii] = newflag[ii] || oldflag[j] ;
     2004            if (!oldflag[j]) {
     2005              newspec[ii] += oldspec[j] * ( yr - yl ) ;
     2006              if (regridTsys) newtsys[ii] += oldtsys[j] * ( yr - yl ) ;
    19882007              wsum += ( yr - yl ) ;
     2008            }
     2009            //newflag[ii] = newflag[ii] || oldflag[j] ;
     2010            newflag[ii] = newflag[ii] && oldflag[j] ;
    19892011          }
    19902012          else {
    1991             newspec[ii] += oldspec[j] * ( zr - yl ) ;
    1992             newflag[ii] = newflag[ii] || oldflag[j] ;
    1993             wsum += ( zr - yl ) ;
     2013            if (!oldflag[j]) {
     2014              newspec[ii] += oldspec[j] * ( zr - yl ) ;
     2015              if (regridTsys) newtsys[ii] += oldtsys[j] * ( zr - yl ) ;
     2016              wsum += ( zr - yl ) ;
     2017            }
     2018            //newflag[ii] = newflag[ii] || oldflag[j] ;
     2019            newflag[ii] = newflag[ii] && oldflag[j] ;
    19942020            ichan = j ;
    19952021            break ;
     
    20012027        }
    20022028      }
    2003       if ( wsum != 0.0 )
     2029      if ( wsum != 0.0 ) {
    20042030        newspec[ii] /= wsum ;
     2031        if (regridTsys) newtsys[ii] /= wsum ;
     2032      }
    20052033      wsum = 0.0 ;
    20062034    }
     
    20182046          }
    20192047          else if ( yr >= zr ) {
    2020             newspec[ii] += oldspec[j] * abs( yr - zl ) ;
    2021             newflag[ii] = newflag[ii] || oldflag[j] ;
    2022             wsum += abs( yr - zl ) ;
     2048            if (!oldflag[j]) {
     2049              newspec[ii] += oldspec[j] * abs( yr - zl ) ;
     2050              if (regridTsys) newtsys[ii] += oldtsys[j] * abs( yr - zl ) ;
     2051              wsum += abs( yr - zl ) ;
     2052            }
     2053            //newflag[ii] = newflag[ii] || oldflag[j] ;
     2054            newflag[ii] = newflag[ii] && oldflag[j] ;
    20232055          }
    20242056          else {
    2025             newspec[ii] += oldspec[j] * abs( dnu ) ;
    2026             newflag[ii] = newflag[ii] || oldflag[j] ;
    2027             wsum += abs( dnu ) ;
     2057            if (!oldflag[j]) {
     2058              newspec[ii] += oldspec[j] * abs( dnu ) ;
     2059              if (regridTsys) newtsys[ii] += oldtsys[j] * abs( dnu ) ;
     2060              wsum += abs( dnu ) ;
     2061            }
     2062            //newflag[ii] = newflag[ii] || oldflag[j] ;
     2063            newflag[ii] = newflag[ii] && oldflag[j] ;
    20282064            ichan = j ;
    20292065            break ;
     
    20322068        else if ( yl > zr ) {
    20332069          if ( yr >= zr ) {
    2034             newspec[ii] += oldspec[j] * abs( yr - yl ) ;
    2035             newflag[ii] = newflag[ii] || oldflag[j] ;
    2036             wsum += abs( yr - yl ) ;
     2070            if (!oldflag[j]) {
     2071              newspec[ii] += oldspec[j] * abs( yr - yl ) ;
     2072              if (regridTsys) newtsys[ii] += oldtsys[j] * abs( yr - yl ) ;
     2073              wsum += abs( yr - yl ) ;
     2074            }
     2075            //newflag[ii] = newflag[ii] || oldflag[j] ;
     2076            newflag[ii] = newflag[ii] && oldflag[j] ;
    20372077          }
    20382078          else {
    2039             newspec[ii] += oldspec[j] * abs( zr - yl ) ;
    2040             newflag[ii] = newflag[ii] || oldflag[j] ;
    2041             wsum += abs( zr - yl ) ;
     2079            if (!oldflag[j]) {
     2080              newspec[ii] += oldspec[j] * abs( zr - yl ) ;
     2081              if (regridTsys) newtsys[ii] += oldtsys[j] * abs( zr - yl ) ;
     2082              wsum += abs( zr - yl ) ;
     2083            }
     2084            //newflag[ii] = newflag[ii] || oldflag[j] ;
     2085            newflag[ii] = newflag[ii] && oldflag[j] ;
    20422086            ichan = j ;
    20432087            break ;
     
    20492093        }
    20502094      }
    2051       if ( wsum != 0.0 )
     2095      if ( wsum != 0.0 ) {
    20522096        newspec[ii] /= wsum ;
     2097        if (regridTsys) newtsys[ii] /= wsum ;
     2098      }
    20532099      wsum = 0.0 ;
    20542100    }
     
    21382184  specCol_.put( irow, newspec ) ;
    21392185  flagsCol_.put( irow, newflag ) ;
     2186  if (regridTsys) tsysCol_.put( irow, newtsys );
    21402187
    21412188  return ;
Note: See TracChangeset for help on using the changeset viewer.