casa
$Rev:20696$
|
Fits and optionally subtracts the continuum in visibility spectra. More...
#include <VBContinuumSubtractor.h>
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 | |
VBContinuumSubtractor & | operator= (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 |
Fits and optionally subtracts the continuum in visibility spectra.
Public interface
This class's main aim is to subtract the continuum from VisBuffers.
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.
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..\. } }
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.
casa::VBContinuumSubtractor::VBContinuumSubtractor | ( | const Double | lofreq, |
const Double | hifreq | ||
) |
Construct it with the low and high frequencies used for scaling the frequencies in the polynomial.
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.
Bool casa::VBContinuumSubtractor::areFreqsInBounds | ( | VisBuffer & | vb, |
const 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.)
Double casa::VBContinuumSubtractor::calcFreqScale | ( | ) | const [inline] |
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.
Double casa::VBContinuumSubtractor::getHighFreq | ( | ) | const [inline] |
Definition at line 170 of file VBContinuumSubtractor.h.
References hifreq_p.
Double casa::VBContinuumSubtractor::getLowFreq | ( | ) | const [inline] |
Definition at line 169 of file VBContinuumSubtractor.h.
References lofreq_p.
Int casa::VBContinuumSubtractor::getMaxAntNum | ( | ) | const [inline] |
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.
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 167 of file VBContinuumSubtractor.h.
References fitorder_p.
uInt casa::VBContinuumSubtractor::getTotNumChan | ( | ) | const [inline] |
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.
void casa::VBContinuumSubtractor::setScalingFreqs | ( | Double | lof, |
Double | hif | ||
) | [inline] |
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.
PtrBlock<Vector<Bool> * > casa::VBContinuumSubtractor::chanmask_p [private] |
Definition at line 244 of file VBContinuumSubtractor.h.
Int casa::VBContinuumSubtractor::fitorder_p [private] |
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().
Double casa::VBContinuumSubtractor::hifreq_p [private] |
Definition at line 235 of file VBContinuumSubtractor.h.
Referenced by calcFreqScale(), getHighFreq(), and setScalingFreqs().
Double casa::VBContinuumSubtractor::lofreq_p [private] |
Definition at line 234 of file VBContinuumSubtractor.h.
Referenced by getLowFreq(), and setScalingFreqs().
Int casa::VBContinuumSubtractor::maxAnt_p [private] |
Definition at line 238 of file VBContinuumSubtractor.h.
Referenced by getMaxAntNum(), hashFunction(), and setNAnt().
Double casa::VBContinuumSubtractor::midfreq_p [private] |
Definition at line 236 of file VBContinuumSubtractor.h.
Referenced by calcFreqScale(), and setScalingFreqs().
uInt casa::VBContinuumSubtractor::ncorr_p [private] |
Definition at line 241 of file VBContinuumSubtractor.h.
Referenced by checkSize().
uInt casa::VBContinuumSubtractor::nHashes_p [private] |
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().