#include <casa/Arrays/ArrayMath.h>
#include <casa/Arrays/Vector.h>
#include <casa/Containers/Allocator.h>
#include <casa/Containers/Block.h>
#include <casa/Logging/LogIO.h>
#include <casa/Logging/LogOrigin.h>
#include <casa/Quanta/MVTime.h>
#include <casa/Utilities/Assert.h>
#include <casa/Utilities/GenSort.h>
#include <ms/MeasurementSets/MSSpectralWindow.h>
#include <ms/MSSel/MSSelection.h>
#include <ms/MSSel/MSSelectionTools.h>
#include <msvis/MSVis/VisibilityIterator2.h>
#include <msvis/MSVis/VisSetUtil.h>
#include <scimath/Fitting/GenericL2Fit.h>
#include <scimath/Fitting/NonLinearFitLM.h>
#include <scimath/Functionals/CompiledFunction.h>
#include <scimath/Functionals/CompoundFunction.h>
#include <scimath/Functionals/Function.h>
#include <scimath/Functionals/Gaussian1D.h>
#include <scimath/Functionals/Lorentzian1D.h>
#include <scimath/Mathematics/Convolver.h>
#include <scimath/Mathematics/VectorKernel.h>
#include <singledish/SingleDish/BaselineTable.h>
#include <singledish/SingleDish/BLParameterParser.h>
#include <singledish/SingleDish/LineFinder.h>
#include <singledish/SingleDish/SingleDishMS.h>
#include <stdcasa/StdCasa/CasacSupport.h>
#include <tables/Tables/ScalarColumn.h>
#include <singledishfiller/Filler/NRO2MSReader.h>
#include <singledishfiller/Filler/Scantable2MSReader.h>
#include <singledishfiller/Filler/SingleDishMSFiller.h>
#define _ORIGIN LogOrigin("SingleDishMS", __func__, WHERE)
constexpr casacore::Int kNRowBlocking = 1000;
constexpr int SinusoidWaveNumber_kUpperLimit = -999;
constexpr size_t WeightIndex_kStddev = 0;
constexpr size_t WeightIndex_kRms = 1;
constexpr size_t WeightIndex_kNum = 2;
double gettimeofday_sec() {
return tv.tv_sec + (double) tv.tv_usec * 1.0e-6;
using casa::vi::VisBuffer2;
using casacore::AipsError;
template<class CUBE_ACCESSOR>
struct DataAccessorInterface {
static void GetCube(VisBuffer2 const &vb, Cube<Float> &cube) {
real(cube, CUBE_ACCESSOR::GetVisCube(vb));
static void GetSlice(VisBuffer2 const &vb, size_t const iPol,
Matrix<Float> &cubeSlice) {
real(cubeSlice, CUBE_ACCESSOR::GetVisCube(vb).yzPlane(iPol));
struct DataAccessor: public DataAccessorInterface<DataAccessor> {
static Cube<Complex> GetVisCube(VisBuffer2 const &vb) {
struct CorrectedDataAccessor: public DataAccessorInterface<CorrectedDataAccessor> {
static Cube<Complex> GetVisCube(VisBuffer2 const &vb) {
return vb.visCubeCorrected();