casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
casa::VBContinuumSubtractor Class Reference

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

#include <VBContinuumSubtractor.h>

Public Member Functions

 VBContinuumSubtractor ()
 
 VBContinuumSubtractor (const casacore::Double lofreq, const casacore::Double hifreq)
 Construct it with the low and high frequencies used for scaling the frequencies in the polynomial. More...
 
 ~VBContinuumSubtractor ()
 
void init (const casacore::IPosition &shp, const casacore::uInt maxAnt, const casacore::uInt totnumchan, const casacore::Double lof, const casacore::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. More...
 
casacore::Bool initFromVBGA (VisBuffGroupAcc &vbga)
 Set the low and high frequencies, and #s of correlations, antennas, and channels from vbga. More...
 
void fit (VisBuffGroupAcc &vbga, const casacore::Int fitorder, casacore::MS::PredefinedColumns whichcol, casacore::Cube< casacore::Complex > &coeffs, casacore::Cube< casacore::Bool > &coeffsOK, const casacore::Bool doInit=false, const casacore::Bool doResize=false, const casacore::Bool squawk=true)
 Makes the continuum estimate by fitting a frequency polynomial of order fitorder to the data in vbga. More...
 
casacore::Bool apply (VisBuffer &vb, const casacore::MS::PredefinedColumns whichcol, const casacore::Cube< casacore::Complex > &coeffs, const casacore::Cube< casacore::Bool > &coeffsOK, const casacore::Bool doSubtraction=true, const casacore::Bool squawk=true)
 Apply the continuum estimate in coeffs (from fit) to vb. More...
 
casacore::Bool areFreqsInBounds (VisBuffer &vb, const casacore::Bool squawk) const
 Returns whether or not vb's frequencies are within the bounds used for the continuum fit. More...
 
casacore::Bool areFreqsInBounds (vi::VisBuffer2 &vb, const casacore::Bool squawk) const
 
casacore::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. More...
 
casacore::Double getLowFreq () const
 
casacore::Double getHighFreq () const
 
casacore::Int getMaxAntNum () const
 the casacore::MS def'n v.2. More...
 
casacore::uInt getTotNumChan () const
 The total number of input channels that will be looked at (including masked ones!) More...
 
void setScalingFreqs (casacore::Double lof, casacore::Double hif)
 Low (lof) and high (hif) frequencies, in Hz, used for renormalizing frequencies in the polynomials. More...
 
void setNAnt (const casacore::uInt nAnt)
 Set the maximum number of antennas (actually, 1 + the maximum antenna number). More...
 
void setTotNumChan (const casacore::uInt tnc)
 Set the total number of input channels that will be looked at (including masked ones!) More...
 
void resize (casacore::Cube< casacore::Complex > &coeffs, casacore::Cube< casacore::Bool > &coeffsOK) const
 A convenience function for prepping coeffs and coeffsOK to hold the polynomial coefficients and their validities. More...
 
casacore::Bool checkSize (casacore::Cube< casacore::Complex > &coeffs, casacore::Cube< casacore::Bool > &coeffsOK) const
 
casacore::Double calcFreqScale () const
 
void setTVIDebug (bool debug)
 
casacore::Bool apply2 (vi::VisBuffer2 &vb, casacore::Cube< casacore::Complex > &Vout, const casacore::Cube< casacore::Complex > &coeffs, const casacore::Cube< casacore::Bool > &coeffsOK, const casacore::Bool doSubtraction=true, const casacore::Bool squawk=true)
 

Static Public Member Functions

static void getMinMaxFreq (VisBuffer &vb, casacore::Double &minfreq, casacore::Double &maxfreq, const casacore::Bool initialize=true)
 Fills minfreq and maxfreq with the minimum and maximum frequencies (in Hz, acc. More...
 
static void getMinMaxFreq (vi::VisBuffer2 &vb, casacore::Double &minfreq, casacore::Double &maxfreq, const casacore::Bool initialize=true)
 

Private Member Functions

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

Private Attributes

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

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 casacore::Int fitorder = 4; // Careful! High orders might
// absorb power from the lines.
casacore::MS inMS(fileName);
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 101 of file VBContinuumSubtractor.h.

Constructor & Destructor Documentation

casa::VBContinuumSubtractor::VBContinuumSubtractor ( )
casa::VBContinuumSubtractor::VBContinuumSubtractor ( const casacore::Double  lofreq,
const casacore::Double  hifreq 
)

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

casa::VBContinuumSubtractor::~VBContinuumSubtractor ( )

Member Function Documentation

casacore::Bool casa::VBContinuumSubtractor::apply ( VisBuffer vb,
const casacore::MS::PredefinedColumns  whichcol,
const casacore::Cube< casacore::Complex > &  coeffs,
const casacore::Cube< casacore::Bool > &  coeffsOK,
const casacore::Bool  doSubtraction = true,
const casacore::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 casacore::MS::DATA, casacore::MS::MODEL_DATA, or casacore::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.

casacore::Bool casa::VBContinuumSubtractor::apply2 ( vi::VisBuffer2 vb,
casacore::Cube< casacore::Complex > &  Vout,
const casacore::Cube< casacore::Complex > &  coeffs,
const casacore::Cube< casacore::Bool > &  coeffsOK,
const casacore::Bool  doSubtraction = true,
const casacore::Bool  squawk = true 
)
Parameters
coeffsconst casacore::MS::PredefinedColumns whichcol,
casacore::Bool casa::VBContinuumSubtractor::areFreqsInBounds ( VisBuffer vb,
const casacore::Bool  squawk 
) const

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.)

casacore::Bool casa::VBContinuumSubtractor::areFreqsInBounds ( vi::VisBuffer2 vb,
const casacore::Bool  squawk 
) const
casacore::Double casa::VBContinuumSubtractor::calcFreqScale ( ) const
inline

Definition at line 221 of file VBContinuumSubtractor.h.

References hifreq_p, and midfreq_p.

Referenced by setScalingFreqs().

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

Definition at line 211 of file VBContinuumSubtractor.h.

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

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

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

casacore::Bool casa::VBContinuumSubtractor::doShapesMatch ( vi::VisBuffer2 vb,
casacore::LogIO os,
const casacore::Bool  squawk = true 
) const
private
void casa::VBContinuumSubtractor::fit ( VisBuffGroupAcc vbga,
const casacore::Int  fitorder,
casacore::MS::PredefinedColumns  whichcol,
casacore::Cube< casacore::Complex > &  coeffs,
casacore::Cube< casacore::Bool > &  coeffsOK,
const casacore::Bool  doInit = false,
const casacore::Bool  doResize = false,
const casacore::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. casacore::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: casacore::Polynomial coefficients for the continuum, indexed by (corr, order, hash(ant1, ant2). coeffsOK: and whether or not they're usable.

casacore::Double casa::VBContinuumSubtractor::getHighFreq ( ) const
inline

Definition at line 179 of file VBContinuumSubtractor.h.

References hifreq_p.

casacore::Double casa::VBContinuumSubtractor::getLowFreq ( ) const
inline

Definition at line 178 of file VBContinuumSubtractor.h.

References lofreq_p.

casacore::Int casa::VBContinuumSubtractor::getMaxAntNum ( ) const
inline

the casacore::MS def'n v.2.

Definition at line 181 of file VBContinuumSubtractor.h.

References maxAnt_p.

static void casa::VBContinuumSubtractor::getMinMaxFreq ( VisBuffer vb,
casacore::Double minfreq,
casacore::Double maxfreq,
const casacore::Bool  initialize = true 
)
static

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

to the casacore::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.

static void casa::VBContinuumSubtractor::getMinMaxFreq ( vi::VisBuffer2 vb,
casacore::Double minfreq,
casacore::Double maxfreq,
const casacore::Bool  initialize = true 
)
static
casacore::Int casa::VBContinuumSubtractor::getOrder ( ) const
inline

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 176 of file VBContinuumSubtractor.h.

References fitorder_p.

casacore::uInt casa::VBContinuumSubtractor::getTotNumChan ( ) const
inline

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

Definition at line 185 of file VBContinuumSubtractor.h.

References totnumchan_p.

casacore::uInt casa::VBContinuumSubtractor::hashFunction ( const casacore::Int  ant1,
const casacore::Int  ant2 
)
inlineprivate

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

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

Definition at line 248 of file VBContinuumSubtractor.h.

References maxAnt_p.

void casa::VBContinuumSubtractor::init ( const casacore::IPosition shp,
const casacore::uInt  maxAnt,
const casacore::uInt  totnumchan,
const casacore::Double  lof,
const casacore::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.

casacore::Bool casa::VBContinuumSubtractor::initFromVBGA ( VisBuffGroupAcc vbga)

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 ( casacore::Cube< casacore::Complex > &  coeffs,
casacore::Cube< casacore::Bool > &  coeffsOK 
) const

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

void casa::VBContinuumSubtractor::setNAnt ( const casacore::uInt  nAnt)
inline

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

Definition at line 198 of file VBContinuumSubtractor.h.

References maxAnt_p, and nHashes_p.

void casa::VBContinuumSubtractor::setScalingFreqs ( casacore::Double  lof,
casacore::Double  hif 
)
inline

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

Definition at line 189 of file VBContinuumSubtractor.h.

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

void casa::VBContinuumSubtractor::setTotNumChan ( const casacore::uInt  tnc)
inline

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

Definition at line 205 of file VBContinuumSubtractor.h.

References totnumchan_p.

void casa::VBContinuumSubtractor::setTVIDebug ( bool  debug)
inline

Definition at line 225 of file VBContinuumSubtractor.h.

References debug, and tvi_debug.

Member Data Documentation

casacore::PtrBlock<casacore::Vector<casacore::Bool> * > casa::VBContinuumSubtractor::chanmask_p
private

Definition at line 266 of file VBContinuumSubtractor.h.

casacore::Int casa::VBContinuumSubtractor::fitorder_p
private

VisBuffGroupAcc& vbga_p; // Holds the VisBuffers.

Definition at line 254 of file VBContinuumSubtractor.h.

Referenced by checkSize(), and getOrder().

casacore::Double casa::VBContinuumSubtractor::freqscale_p
private

Definition at line 259 of file VBContinuumSubtractor.h.

Referenced by setScalingFreqs().

casacore::Double casa::VBContinuumSubtractor::hifreq_p
private

Definition at line 257 of file VBContinuumSubtractor.h.

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

casacore::Double casa::VBContinuumSubtractor::lofreq_p
private

Definition at line 256 of file VBContinuumSubtractor.h.

Referenced by getLowFreq(), and setScalingFreqs().

casacore::Int casa::VBContinuumSubtractor::maxAnt_p
private

Definition at line 260 of file VBContinuumSubtractor.h.

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

casacore::Double casa::VBContinuumSubtractor::midfreq_p
private

Definition at line 258 of file VBContinuumSubtractor.h.

Referenced by calcFreqScale(), and setScalingFreqs().

casacore::uInt casa::VBContinuumSubtractor::ncorr_p
private

Definition at line 263 of file VBContinuumSubtractor.h.

Referenced by checkSize().

casacore::uInt casa::VBContinuumSubtractor::nHashes_p
private

used with the fits.

-1 if not ready.

Definition at line 262 of file VBContinuumSubtractor.h.

Referenced by checkSize(), and setNAnt().

casacore::uInt casa::VBContinuumSubtractor::totnumchan_p
private

Definition at line 264 of file VBContinuumSubtractor.h.

Referenced by getTotNumChan(), and setTotNumChan().

bool casa::VBContinuumSubtractor::tvi_debug
private

Definition at line 268 of file VBContinuumSubtractor.h.

Referenced by setTVIDebug().


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