28 #ifndef _CASA_SINGLEDISH_MS_H_
29 #define _CASA_SINGLEDISH_MS_H_
36 #include <libsakura/sakura.h>
42 #define SinusoidWaveNumber_kUpperLimit -999
85 string const& out_ms_name,
86 string const& out_bloutput_name,
87 bool const& do_subtract,
91 float const clip_threshold_sigma,
92 int const num_fitting_max,
93 bool const linefinding,
94 float const threshold,
97 std::vector<int>
const& edge);
101 string const& out_ms_name,
102 string const& out_bloutput_name,
103 bool const& do_subtract,
104 string const& in_spw,
106 float const clip_threshold_sigma,
107 int const num_fitting_max,
108 bool const linefinding,
109 float const threshold,
112 std::vector<int>
const& edge);
116 string const& out_ms_name,
117 string const& out_bloutput_name,
118 bool const& do_subtract,
119 string const& in_spw,
120 string const& addwn0,
121 string const& rejwn0,
123 string const fftmethod,
124 string const fftthresh,
125 float const clip_threshold_sigma,
126 int const num_fitting_max,
127 bool const linefinding,
128 float const threshold,
131 std::vector<int>
const& edge);
135 string const& out_ms_name,
136 string const& out_bloutput_name,
137 bool const& do_subtract,
138 string const& in_spw,
139 string const& param_file,
140 bool const& verbose =
true);
144 string const& in_bltable_name,
string const& in_spw,
145 string const& out_ms_name);
148 void fitLine(
string const& in_column_name,
string const& in_spw,
149 string const& in_pol,
string const& fitfunc,
string const& in_nfit,
150 bool const linefinding,
float const threshold,
int const avg_limit,
151 int const minwidth, std::vector<int>
const& edge,
152 string const& tempfile_name,
string const& temp_out_ms_name);
156 void smooth(
string const &kernelType,
float const kernelWidth,
157 string const &columnName,
string const&outMsName);
175 string const &field_name);
178 string const&out_ms_name);
182 bool const addDefaultSortCols =
false);
192 std::vector<string>
split_string(
string const &s,
char delim);
248 std::vector<LIBSAKURA_SYMBOL(LSQFitContextFloat) *> &bl_contexts);
254 std::vector<size_t> &ctx_nchans,
255 std::vector<LIBSAKURA_SYMBOL(LSQFitContextFloat) *> &bl_contexts);
260 template<
typename T,
typename U>
263 for (
size_t ipol = 0; ipol < num_pol; ++ipol) {
264 for (
size_t i = 0; i < num_data_max; ++i) {
265 out_data[i][ipol] =
static_cast<U
>(0);
267 size_t num_data = in_data[ipol].
size();
268 for (
size_t i = 0; i < num_data; ++i) {
269 out_data[i][ipol] =
static_cast<U
>(in_data[ipol][i]);
273 template<
typename T,
typename U>
276 for (
size_t i = 0; i < num_data; ++i) {
277 out_data[i][ipol] =
static_cast<U
>(in_data[i]);
282 size_t &num_coeff_max);
283 std::vector<int>
string_to_list(
string const &wn_str,
char const delim);
285 std::vector<int>
const &rejwn,
287 std::vector<int> &effwn);
289 std::vector<int>
const &blparam_exclude,
290 int const &blparam_upperlimit,
291 size_t const &num_chan,
292 float const *spec,
bool const *
mask,
293 bool const &applyfft,
294 string const &fftmethod,
string const &fftthresh,
295 std::vector<size_t> &blparam_eff);
297 string& fftthresh_attr,
298 float& fftthresh_sigma,
303 string const &fftmethod,
304 string const &fftthresh_attr,
305 float const fftthresh_sigma,
306 int const fftthresh_top,
307 int const blparam_upperlimit,
308 std::vector<int> &blparam_fft);
309 void exec_fft(
size_t const num_chan,
310 float const *in_spec,
312 bool const get_real_imag,
313 bool const get_ampl_only,
314 std::vector<float> &fourier_spec);
316 float const *in_spec,
320 std::vector<int>
const &blparam_fft,
321 std::vector<int>
const &blparam_exclude,
322 std::vector<size_t> &blparam_eff);
326 bool mask[],
float const threshold,
327 int const avg_limit,
int const minwidth, std::vector<int>
const& edge,
331 bool const in_mask[],
float const threshold,
332 int const avg_limit,
int const minwidth, std::vector<int>
const& edge,
333 bool const invert,
bool out_mask[]);
335 template<
typename Func0,
typename Func1,
typename Func2,
typename Func3>
337 string const& out_ms_name,
338 string const& out_bloutput_name,
339 bool const& do_subtract,
340 string const& in_spw,
341 LIBSAKURA_SYMBOL(Status)& status,
342 std::vector<LIBSAKURA_SYMBOL(LSQFitContextFloat) *> &bl_contexts,
344 std::vector<int>
const& blparam,
345 std::vector<int>
const& blparam_exclude,
346 bool const& applyfft,
347 string const& fftmethod,
348 string const& fftthresh,
349 float const clip_threshold_sigma,
350 int const num_fitting_max,
351 bool const linefinding,
352 float const threshold,
355 std::vector<int>
const& edge,
367 size_t const plane,
size_t const num_data,
371 size_t const plane,
size_t const num_data,
float in_data[]);
379 size_t const plane,
size_t const num_flag,
383 size_t const plane,
size_t const num_flag,
bool in_flag[]);
429 static bool importAsap(
string const &infile,
string const &outfile,
bool const parallel=
false);
430 static bool importNRO(
string const &infile,
string const &outfile,
bool const parallel=
false);
casacore::MSMainEnums::PredefinedColumns in_column_
columns to read and save data
casacore::Record pol_average_
Record of polarization average.
void initialize()
Utility functions ///.
static constexpr casacore::Int kNRowBlocking
max number of rows to get in each iteration
void subtractBaselineVariable(string const &in_column_name, string const &out_ms_name, string const &out_bloutput_name, bool const &do_subtract, string const &in_spw, string const ¶m_file, bool const &verbose=true)
variable fitting parameters stored in a text file
void get_baseline_context(size_t const bltype, uint16_t order, size_t num_chan, casacore::Vector< size_t > const &nchan, casacore::Vector< bool > const &nchan_set, casacore::Vector< size_t > &ctx_indices, std::vector< LIBSAKURA_SYMBOL(LSQFitContextFloat)* > &bl_contexts)
Create a set of baseline contexts (if necessary)
std::vector< int > string_to_list(string const &wn_str, char const delim)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
void get_mask_from_rec(casacore::Int spwid, casacore::Matrix< casacore::Int > const &rec_chan, casacore::Vector< casacore::Bool > &mask, bool initialize=true)
static bool importAsap(string const &infile, string const &outfile, bool const parallel=false)
void get_flag_from_cube(casacore::Cube< casacore::Bool > &flag_cube, size_t const row, size_t const plane, size_t const num_flag, bool out_flag[])
retrieve a flag at the row and plane (polarization) from flag cube
void get_effective_nwave(std::vector< int > const &addwn, std::vector< int > const &rejwn, int const wn_ulimit, std::vector< int > &effwn)
void get_nchan_and_mask(casacore::Vector< casacore::Int > const &rec_spw, casacore::Vector< casacore::Int > const &data_spw, casacore::Matrix< casacore::Int > const &rec_chan, size_t const num_chan, casacore::Vector< size_t > &nchan, casacore::Vector< casacore::Vector< casacore::Bool > > &mask, casacore::Vector< bool > &nchan_set, bool &new_nchan)
void smooth(string const &kernelType, float const kernelWidth, string const &columnName, string const &outMsName)
smooth data with arbitrary smoothing kernel smoothing kernels currently supported include gaussian an...
void convertArrayC2F(casacore::Array< casacore::Float > &from, casacore::Array< casacore::Complex > const &to)
Convert a casacore::Complex casacore::Array to casacore::Float Array.
void subtractBaseline(string const &in_column_name, string const &out_ms_name, string const &out_bloutput_name, bool const &do_subtract, string const &in_spw, string const &blfunc, int const order, float const clip_threshold_sigma, int const num_fitting_max, bool const linefinding, float const threshold, int const avg_limit, int const minwidth, std::vector< int > const &edge)
Invoke baseline subtraction (polynomial, write results in new casacore::MS)
ostream-like interface to creating log messages.
void get_data_cube_float(vi::VisBuffer2 const &vb, casacore::Cube< casacore::Float > &data_cube)
get data cube (npol*nchan*nvirow) in in_column_ from visbuffer and convert it to float cube ...
PredefinedColumns
The Main table colums with predefined meaning.
void applyBaselineTable(string const &in_column_name, string const &in_bltable_name, string const &in_spw, string const &out_ms_name)
apply baseline table
void subtractBaselineSinusoid(string const &in_column_name, string const &out_ms_name, string const &out_bloutput_name, bool const &do_subtract, string const &in_spw, string const &addwn0, string const &rejwn0, bool const applyfft, string const fftmethod, string const fftthresh, float const clip_threshold_sigma, int const num_fitting_max, bool const linefinding, float const threshold, int const avg_limit, int const minwidth, std::vector< int > const &edge)
Sinusoid.
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
bool allchannels_flagged(size_t const num_flag, bool const *flag)
return true if all channels are flagged
void parse_fftthresh(string const &fftthresh_str, string &fftthresh_attr, float &fftthresh_sigma, int &fftthresh_top)
~SingleDishMS()
Destructor.
size_t get_num_coeff_bloutput(size_t const bltype, size_t order, size_t &num_coeff_max)
casacore::Record selection_
casacore::Record of selection
static bool importNRO(string const &infile, string const &outfile, bool const parallel=false)
void interpolate_constant(int const num_chan, float const *in_spec, bool const *in_mask, casacore::Vector< casacore::Float > &spec)
void fitLine(string const &in_column_name, string const &in_spw, string const &in_pol, string const &fitfunc, string const &in_nfit, bool const linefinding, float const threshold, int const avg_limit, int const minwidth, std::vector< int > const &edge, string const &tempfile_name, string const &temp_out_ms_name)
fit line profile
void destroy_baseline_contexts(std::vector< LIBSAKURA_SYMBOL(LSQFitContextFloat)* > &bl_contexts)
Destroy a set of baseline contexts.
casacore::Bool doSmoothing_
smoothing flag
string bloutputname_table
void exec_fft(size_t const num_chan, float const *in_spec, bool const *in_mask, bool const get_real_imag, bool const get_ampl_only, std::vector< float > &fourier_spec)
void set_flag_to_cube(casacore::Cube< casacore::Bool > &flag_cube, size_t const row, size_t const plane, size_t const num_flag, bool in_flag[])
set a flag at the row and plane (polarization) to flag cube
casacore::Record average_
casacore::Record of average
A hierarchical collection of named fields of various types.
bool Bool
Define the standard types used by Casacore.
TableExprNode cube(const TableExprNode &node)
SingleDishMS()
Default constructor.
void set_matrix_for_bltable(size_t const num_pol, size_t const num_data_max, std::vector< std::vector< T > > const &in_data, casacore::Array< U > &out_data)
std::vector< string > split_string(string const &s, char delim)
Split a string with given delimiter.
void setPolAverage(casacore::Record const &average, bool const verbose=true)
list< pair< size_t, size_t > > findLineAndGetRanges(size_t const num_data, float const data[], bool mask[], float const threshold, int const avg_limit, int const minwidth, std::vector< int > const &edge, bool const invert)
void split_bloutputname(string str)
split the name
void finalise_effective_nwave(std::vector< int > const &blparam_eff_base, std::vector< int > const &blparam_exclude, int const &blparam_upperlimit, size_t const &num_chan, float const *spec, bool const *mask, bool const &applyfft, string const &fftmethod, string const &fftthresh, std::vector< size_t > &blparam_eff)
casacore::String get_field_as_casa_string(casacore::Record const &in_data, string const &field_name)
retrieve a field by name from casacore::Record as casa::String.
void format_selection(casacore::Record &selection)
void findLineAndGetMask(size_t const num_data, float const data[], bool const in_mask[], float const threshold, int const avg_limit, int const minwidth, std::vector< int > const &edge, bool const invert, bool out_mask[])
void parse_spw(string const &in_spw, casacore::Vector< casacore::Int > &spw, casacore::Matrix< casacore::Int > &chan, casacore::Vector< size_t > &nchan, casacore::Vector< casacore::Vector< casacore::Bool > > &mask, casacore::Vector< bool > &nchan_set)
void set_array_for_bltable(size_t const ipol, size_t const num_data, T const *in_data, casacore::Array< U > &out_data)
void doSubtractBaseline(string const &in_column_name, string const &out_ms_name, string const &out_bloutput_name, bool const &do_subtract, string const &in_spw, LIBSAKURA_SYMBOL(Status)&status, std::vector< LIBSAKURA_SYMBOL(LSQFitContextFloat)* > &bl_contexts, size_t const bltype, std::vector< int > const &blparam, std::vector< int > const &blparam_exclude, bool const &applyfft, string const &fftmethod, string const &fftthresh, float const clip_threshold_sigma, int const num_fitting_max, bool const linefinding, float const threshold, int const avg_limit, int const minwidth, std::vector< int > const &edge, Func0 func0, Func1 func1, Func2 func2, Func3 func3, casacore::LogIO os)
VisBuffer2s encapsulate one chunk of visibility data for processing.
void select_wavenumbers_via_fft(size_t const num_chan, float const *spec, bool const *mask, string const &fftmethod, string const &fftthresh_attr, float const fftthresh_sigma, int const fftthresh_top, int const blparam_upperlimit, std::vector< int > &blparam_fft)
void(* visCubeAccessor_)(vi::VisBuffer2 const &vb, casacore::Cube< casacore::Float > &cube)
pointer to accessor function
the name of input MS *string msname_
casacore::Array execution functions ///
void merge_wavenumbers(std::vector< int > const &blparam_eff_base, std::vector< int > const &blparam_fft, std::vector< int > const &blparam_exclude, std::vector< size_t > &blparam_eff)
void get_flag_cube(vi::VisBuffer2 const &vb, casacore::Cube< casacore::Bool > &flag_cube)
get flag cube (npol*nchan*nvirow) from visbuffer
bool set_column(casacore::MSMainEnums::PredefinedColumns const &in, casacore::MSMainEnums::PredefinedColumns &out)
check column 'in' is in input casacore::MS and set to 'out' if it exists.
void get_masklist_from_mask(size_t const num_chan, bool const *mask, casacore::Vector< casacore::uInt > &masklist)
void check_baseline_status(LIBSAKURA_SYMBOL(LSQFitStatus) const bl_status)
size_t NValidMask(size_t const num_mask, bool const *mask)
returns the number of channels with true in input mask
String: the storage and methods of handling collections of characters.
void setAverage(casacore::Record const &average, bool const verbose=true)
void subtractBaselineCspline(string const &in_column_name, string const &out_ms_name, string const &out_bloutput_name, bool const &do_subtract, string const &in_spw, int const npiece, float const clip_threshold_sigma, int const num_fitting_max, bool const linefinding, float const threshold, int const avg_limit, int const minwidth, std::vector< int > const &edge)
Cubicspline.
void setSelection(casacore::Record const &selection, bool const verbose=true)
void check_sakura_status(string const &name, LIBSAKURA_SYMBOL(Status) const status)
void flag_spectrum_in_cube(casacore::Cube< casacore::Bool > &flag_cube, size_t const row, size_t const plane)
flag all channels in a supectrum in cube at the row and plane (polarization)
SDMSManager * sdh_
SDMSManager.
bool prepare_for_process(string const &in_column_name, string const &out_ms_name)
bool file_exists(string const &filename)
examine if a file with specified name exists