casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
casa::VBContinuumSubtractor Class Reference

Fits and optionally subtracts the continuum in visibility spectra. More...

#include <VBContinuumSubtractor.h>

List of all members.

Public Member Functions

 VBContinuumSubtractor ()
 VBContinuumSubtractor (const Double lofreq, const Double hifreq)
 Construct it with the low and high frequencies used for scaling the frequencies in the polynomial.
 ~VBContinuumSubtractor ()
void init (const IPosition &shp, const uInt maxAnt, const uInt totnumchan, const Double lof, const Double hif)
 Set the # of correlations and fitorder from shp, the total number of input channels to look at (including masked ones!), and the low and high scaling frequencies.
Bool initFromVBGA (VisBuffGroupAcc &vbga)
 Set the low and high frequencies, and #s of correlations, antennas, and channels from vbga.
void fit (VisBuffGroupAcc &vbga, const Int fitorder, MS::PredefinedColumns whichcol, Cube< Complex > &coeffs, Cube< Bool > &coeffsOK, const Bool doInit=False, const Bool doResize=False, const Bool squawk=True)
 Makes the continuum estimate by fitting a frequency polynomial of order fitorder to the data in vbga.
Bool apply (VisBuffer &vb, const MS::PredefinedColumns whichcol, const Cube< Complex > &coeffs, const Cube< Bool > &coeffsOK, const Bool doSubtraction=True, const Bool squawk=True)
 Apply the continuum estimate in coeffs (from fit) to vb.
Bool areFreqsInBounds (VisBuffer &vb, const Bool squawk) const
 Returns whether or not vb's frequencies are within the bounds used for the continuum fit.
Int getOrder () const
 These are provided for the calibration framework so that a VBContinuumSubtractor can be c'ted from a VisBuffGroupAcc, make a continuum fit, write its results to a caltable, destroyed, and then later another one can be c'ted from the caltable and apply the fit to a VisBuffer.
Double getLowFreq () const
Double getHighFreq () const
Int getMaxAntNum () const
 the MS def'n v.2.
uInt getTotNumChan () const
 The total number of input channels that will be looked at (including masked ones!)
void setScalingFreqs (Double lof, Double hif)
 Low (lof) and high (hif) frequencies, in Hz, used for renormalizing frequencies in the polynomials.
void setNAnt (const uInt nAnt)
 Set the maximum number of antennas (actually, 1 + the maximum antenna number).
void setTotNumChan (const uInt tnc)
 Set the total number of input channels that will be looked at (including masked ones!)
void resize (Cube< Complex > &coeffs, Cube< Bool > &coeffsOK) const
 A convenience function for prepping coeffs and coeffsOK to hold the polynomial coefficients and their validities.
Bool checkSize (Cube< Complex > &coeffs, Cube< Bool > &coeffsOK) const
Double calcFreqScale () const

Static Public Member Functions

static void getMinMaxFreq (VisBuffer &vb, Double &minfreq, Double &maxfreq, const Bool initialize=True)
 Fills minfreq and maxfreq with the minimum and maximum frequencies (in Hz, acc.

Private Member Functions

VBContinuumSubtractoroperator= (VBContinuumSubtractor &other)
 Disable default copying, and assignment.
Bool doShapesMatch (VisBuffer &vb, LogIO &os, const Bool squawk=true) const
 Can the fit be applied to vb? If not and squawk is true, send a severe message to os.
uInt hashFunction (const Int ant1, const Int ant2)
 Compute baseline (row) index in coeffs_p for (ant1, ant2).

Private Attributes

Int fitorder_p
 VisBuffGroupAcc& vbga_p; // Holds the VisBuffers.
Double lofreq_p
Double hifreq_p
Double midfreq_p
Double freqscale_p
Int maxAnt_p
uInt nHashes_p
 used with the fits.
uInt ncorr_p
uInt totnumchan_p
PtrBlock< Vector< Bool > * > chanmask_p

Detailed Description

Fits and optionally subtracts the continuum in visibility spectra.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Etymology

This class's main aim is to subtract the continuum from VisBuffers.

Synopsis

Spectral line observations often contain continuum emission which is present in all channels (often with a small slope and curvature across the band). This class fits a polynomial to this continuum, and can return the continuum and/or line (continuum-subtracted) estimates as VisBuffers.

Example

      const Int fitorder = 4;                 // Careful!  High orders might
                                              // absorb power from the lines.
      MS inMS(fileName);
      Block<Int> sortcolumns;
      ROVisIter vi(inMS, sortcolumns, 0.0);
      VisBuffer cvb(vi);                         // Continuum estimate
      VisBuffer lvb(vi);                         // Line estimate
      VisBuffer vb(vi);
      for(vi.originChunks(); vi.moreChunks(); vi.nextChunk()){
        for(vi.origin(); vi.more(); ++vi){
          VBContinuumSubtractor contestor(vb, fitorder); // Continuum Estimator
   
          contestor.cont_est(cvb);             // Put continuum estimate into cvb.
          contestor.cont_subtracted(lvb);      // Put line estimate into lvb.
   
          // Do something with cvb and lvb..\.
        }
      }

Motivation

This class provides continuum fitting by polynomials with order >= 0, with a convenient interface for use by other classes in synthesis and msvis (i.e. calibration, imaging, and split).

Definition at line 95 of file VBContinuumSubtractor.h.


Constructor & Destructor Documentation

Construct it with the low and high frequencies used for scaling the frequencies in the polynomial.


Member Function Documentation

Bool casa::VBContinuumSubtractor::apply ( VisBuffer vb,
const MS::PredefinedColumns  whichcol,
const Cube< Complex > &  coeffs,
const Cube< Bool > &  coeffsOK,
const Bool  doSubtraction = True,
const Bool  squawk = True 
)

Apply the continuum estimate in coeffs (from fit) to vb.

The affected column of vb is chosen by whichcol, which must be exactly one of MS::DATA, MS::MODEL_DATA, or MS::CORRECTED_DATA lest an exception will be thrown. If doSubtraction is True, vb becomes the line estimate. Otherwise it is replaced with the continuum estimate. Returns False if it detects an error, True otherwise. squawk=True increases the potential number of warnings sent to the logger.

Returns whether or not vb's frequencies are within the bounds used for the continuum fit.

If not, and squawk is True, a warning will be sent to the logger. (Extrapolation is allowed, just not recommended.)

Definition at line 212 of file VBContinuumSubtractor.h.

References hifreq_p, and midfreq_p.

Referenced by setScalingFreqs().

Bool casa::VBContinuumSubtractor::checkSize ( Cube< Complex > &  coeffs,
Cube< Bool > &  coeffsOK 
) const [inline]

Definition at line 202 of file VBContinuumSubtractor.h.

References fitorder_p, ncorr_p, nHashes_p, and casa::Cube< T >::shape().

Bool casa::VBContinuumSubtractor::doShapesMatch ( VisBuffer vb,
LogIO os,
const Bool  squawk = true 
) const [private]

Can the fit be applied to vb? If not and squawk is true, send a severe message to os.

void casa::VBContinuumSubtractor::fit ( VisBuffGroupAcc vbga,
const Int  fitorder,
MS::PredefinedColumns  whichcol,
Cube< Complex > &  coeffs,
Cube< Bool > &  coeffsOK,
const Bool  doInit = False,
const Bool  doResize = False,
const Bool  squawk = True 
)

Makes the continuum estimate by fitting a frequency polynomial of order fitorder to the data in vbga.

It sets the low and high frequencies used for scaling the frequencies in the polynomial to the min and max frequencies in vbga. Input: vbga, The data fitorder, e.g. 2 for a + bf + cf**2 doInit, if true call initFromVBGA(vbga) doResize if true set coeffs and coeffsOK to the right shape. Output (these will be resized): coeffs: Polynomial coefficients for the continuum, indexed by (corr, order, hash(ant1, ant2). coeffsOK: and whether or not they're usable.

Definition at line 170 of file VBContinuumSubtractor.h.

References hifreq_p.

Definition at line 169 of file VBContinuumSubtractor.h.

References lofreq_p.

the MS def'n v.2.

Definition at line 172 of file VBContinuumSubtractor.h.

References maxAnt_p.

static void casa::VBContinuumSubtractor::getMinMaxFreq ( VisBuffer vb,
Double minfreq,
Double maxfreq,
const Bool  initialize = True 
) [static]

Fills minfreq and maxfreq with the minimum and maximum frequencies (in Hz, acc.

to the MS def'n v.2) of vb (not the continuum fit!). If you want to get the extreme frequencies over a set of VisBuffers, set initialize to False and initialize minfreq and maxfreq yourself to DBL_MAX and -1.0, respectively.

These are provided for the calibration framework so that a VBContinuumSubtractor can be c'ted from a VisBuffGroupAcc, make a continuum fit, write its results to a caltable, destroyed, and then later another one can be c'ted from the caltable and apply the fit to a VisBuffer.

Obviously it'd be safer and faster to use the same VBContinuumSubtractor for fitting and application, but the rest of CASA isn't ready for that yet (3/7/2011).

Definition at line 167 of file VBContinuumSubtractor.h.

References fitorder_p.

The total number of input channels that will be looked at (including masked ones!)

Definition at line 176 of file VBContinuumSubtractor.h.

References totnumchan_p.

uInt casa::VBContinuumSubtractor::hashFunction ( const Int  ant1,
const Int  ant2 
) [inline, private]

Compute baseline (row) index in coeffs_p for (ant1, ant2).

It ASSUMES that ant1 and ant2 are both <= maxAnt_p.

Definition at line 226 of file VBContinuumSubtractor.h.

References maxAnt_p.

void casa::VBContinuumSubtractor::init ( const IPosition shp,
const uInt  maxAnt,
const uInt  totnumchan,
const Double  lof,
const Double  hif 
)

Set the # of correlations and fitorder from shp, the total number of input channels to look at (including masked ones!), and the low and high scaling frequencies.

Set the low and high frequencies, and #s of correlations, antennas, and channels from vbga.

Returns False if vbga is empty.

VBContinuumSubtractor& casa::VBContinuumSubtractor::operator= ( VBContinuumSubtractor other) [private]

Disable default copying, and assignment.

void casa::VBContinuumSubtractor::resize ( Cube< Complex > &  coeffs,
Cube< Bool > &  coeffsOK 
) const

A convenience function for prepping coeffs and coeffsOK to hold the polynomial coefficients and their validities.

void casa::VBContinuumSubtractor::setNAnt ( const uInt  nAnt) [inline]

Set the maximum number of antennas (actually, 1 + the maximum antenna number).

Definition at line 189 of file VBContinuumSubtractor.h.

References maxAnt_p, and nHashes_p.

Low (lof) and high (hif) frequencies, in Hz, used for renormalizing frequencies in the polynomials.

Definition at line 180 of file VBContinuumSubtractor.h.

References calcFreqScale(), freqscale_p, hifreq_p, lofreq_p, and midfreq_p.

void casa::VBContinuumSubtractor::setTotNumChan ( const uInt  tnc) [inline]

Set the total number of input channels that will be looked at (including masked ones!)

Definition at line 196 of file VBContinuumSubtractor.h.

References totnumchan_p.


Member Data Documentation

Definition at line 244 of file VBContinuumSubtractor.h.

VisBuffGroupAcc& vbga_p; // Holds the VisBuffers.

Definition at line 232 of file VBContinuumSubtractor.h.

Referenced by checkSize(), and getOrder().

Definition at line 237 of file VBContinuumSubtractor.h.

Referenced by setScalingFreqs().

Definition at line 235 of file VBContinuumSubtractor.h.

Referenced by calcFreqScale(), getHighFreq(), and setScalingFreqs().

Definition at line 234 of file VBContinuumSubtractor.h.

Referenced by getLowFreq(), and setScalingFreqs().

Definition at line 238 of file VBContinuumSubtractor.h.

Referenced by getMaxAntNum(), hashFunction(), and setNAnt().

Definition at line 236 of file VBContinuumSubtractor.h.

Referenced by calcFreqScale(), and setScalingFreqs().

Definition at line 241 of file VBContinuumSubtractor.h.

Referenced by checkSize().

used with the fits.

-1 if not ready.

Definition at line 240 of file VBContinuumSubtractor.h.

Referenced by checkSize(), and setNAnt().

Definition at line 242 of file VBContinuumSubtractor.h.

Referenced by getTotNumChan(), and setTotNumChan().


The documentation for this class was generated from the following file: