From ca521bec6fc37e1be3a99bba830999909a1c8a2b Mon Sep 17 00:00:00 2001 From: Adriaan Renting <renting@astron.nl> Date: Tue, 10 Apr 2007 11:49:16 +0000 Subject: [PATCH] BugID: 1049 Initial version of DataSquasher --- Appl/CEP/CS1/CS1_DFTImager/package.dox | 2 +- Appl/CEP/CS1/CS1_DataSquasher/Makefile.am | 15 ++ Appl/CEP/CS1/CS1_DataSquasher/configure.in | 61 ++++++ .../include/CS1_DataSquasher/Makefile.am | 3 + .../CS1_DataSquasher/SquasherProcessControl.h | 89 +++++++++ .../CS1/CS1_DataSquasher/include/Makefile.am | 3 + Appl/CEP/CS1/CS1_DataSquasher/package.dox | 2 + .../CEP/CS1/CS1_DataSquasher/src/MS_Reader.cc | 176 ++++++++++++++++++ Appl/CEP/CS1/CS1_DataSquasher/src/MS_Reader.h | 65 +++++++ Appl/CEP/CS1/CS1_DataSquasher/src/Makefile.am | 12 ++ Appl/CEP/CS1/CS1_DataSquasher/src/Squasher.cc | 48 +++++ .../src/SquasherProcessControl.cc | 167 +++++++++++++++++ 12 files changed, 642 insertions(+), 1 deletion(-) create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/Makefile.am create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/configure.in create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/include/CS1_DataSquasher/Makefile.am create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/include/CS1_DataSquasher/SquasherProcessControl.h create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/include/Makefile.am create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/package.dox create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/src/MS_Reader.cc create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/src/MS_Reader.h create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/src/Makefile.am create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/src/Squasher.cc create mode 100644 Appl/CEP/CS1/CS1_DataSquasher/src/SquasherProcessControl.cc diff --git a/Appl/CEP/CS1/CS1_DFTImager/package.dox b/Appl/CEP/CS1/CS1_DFTImager/package.dox index 4f120303676..73e91b140ec 100644 --- a/Appl/CEP/CS1/CS1_DFTImager/package.dox +++ b/Appl/CEP/CS1/CS1_DFTImager/package.dox @@ -1,2 +1,2 @@ // \ingroup CS1 -// \defgroup CS1_Flagger CS1_Flagger Description +// \defgroup CS1_DFTImager CS1_Imager Description diff --git a/Appl/CEP/CS1/CS1_DataSquasher/Makefile.am b/Appl/CEP/CS1/CS1_DataSquasher/Makefile.am new file mode 100644 index 00000000000..d4add4d15a8 --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/Makefile.am @@ -0,0 +1,15 @@ +SUBDIRS=src test include + +pkgextdir = $(prefix)/config/$(PACKAGE) +pkgext_DATA = pkgext pkgextcppflags pkgextcxxflags pkgextldflags + +DISTCHECK_CONFIGURE_FLAGS= \ + --with-common=$(prefix) \ + --with-aips++ + +EXTRA_DIST = \ + Makefile.common \ + CS1_dataSquasher.spec \ + autoconf_share/compiletool + +include $(top_srcdir)/Makefile.common diff --git a/Appl/CEP/CS1/CS1_DataSquasher/configure.in b/Appl/CEP/CS1/CS1_DataSquasher/configure.in new file mode 100644 index 00000000000..51b0aec370e --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/configure.in @@ -0,0 +1,61 @@ +dnl +dnl Process this file with autoconf to produce a configure script. +dnl +AC_INIT +AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE(CS1_DataSquasher, 1.0, no-define) + +dnl Initialize for LOFAR (may set compilers) +lofar_INIT + +dnl Checks for programs. +AC_LANG_CPLUSPLUS +AC_PROG_CXX +AC_PROG_LIBTOOL + +dnl Checks for libraries. + +dnl dnl Replace `main' with a function in -lfl: +dnl AC_CHECK_LIB(fl, main) +dnl dnl Replace `main' with a function in -lcosev_r: +dnl AC_CHECK_LIB(cosev_r, main) +dnl dnl Replace `main' with a function in -lcosnm_r: +dnl AC_CHECK_LIB(cosnm_r, main) +dnl dnl Replace `main' with a function in -lorb_r: +dnl AC_CHECK_LIB(orb_r, main) +dnl dnl Replace `main' with a function in -lpthread: +dnl AC_CHECK_LIB(pthread, main) +dnl dnl Replace `main' with a function in -lvport_r: +dnl AC_CHECK_LIB(vport_r, main) + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(unistd.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T + +dnl Checks for library functions. +AC_FUNC_VPRINTF + +dnl +dnl Check for LOFAR specific things +dnl +lofar_GENERAL(1) +lofar_AIPSPP(1) +lofar_INTERNAL(LCS/ACC/PLC,PLC,,1,PLC/ProcessControl.h) +lofar_INTERNAL(LCS/ACC/APS,APS,,1,APS/ParameterSet.h) +lofar_EXTERNAL(boost,1,boost/logic/tribool.hpp,"") + +dnl +dnl Output Makefiles +dnl +AC_OUTPUT( +include/Makefile +include/CS1_DataSquasher/Makefile +src/Makefile +test/Makefile +Makefile +CS1_dataSquasher.spec +) diff --git a/Appl/CEP/CS1/CS1_DataSquasher/include/CS1_DataSquasher/Makefile.am b/Appl/CEP/CS1/CS1_DataSquasher/include/CS1_DataSquasher/Makefile.am new file mode 100644 index 00000000000..dce7ab0bb4d --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/include/CS1_DataSquasher/Makefile.am @@ -0,0 +1,3 @@ +pkginclude_HEADERS = SquasherProcessControl.h + +include $(top_srcdir)/Makefile.common diff --git a/Appl/CEP/CS1/CS1_DataSquasher/include/CS1_DataSquasher/SquasherProcessControl.h b/Appl/CEP/CS1/CS1_DataSquasher/include/CS1_DataSquasher/SquasherProcessControl.h new file mode 100644 index 00000000000..458814dcb6b --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/include/CS1_DataSquasher/SquasherProcessControl.h @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2007 by Adriaan Renting, ASTRON * + * renting@astron.nl * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef LOFARSQUASHERPROCESSCONTROL_H +#define LOFARSQUASHERPROCESSCONTROL_H + +#include <PLC/ProcessControl.h> +#include <APS/ParameterSet.h> + +/** +@author Adriaan Renting +*/ +namespace LOFAR +{ + namespace CS1 + { + class MS_Reader; //foreward declaration + class MS_Writer; + class DataSquasher; + + class FlaggerProcessControl : public LOFAR::ACC::PLC::ProcessControl + { + private: + std::string itsMS; + bool itsFlagData; + bool itsFlagRMS; + bool itsExisting; + int itsWindow; + bool itsCrosspol; + double itsMin; + double itsMax; + WSRT::MS_File* myMS; + WSRT::DataSquasher* itsFlagger; + public: + FlaggerProcessControl(void); + + ~FlaggerProcessControl(void); + // \name Command to control the processes. + // There are a dozen commands that can be sent to a application process + // to control its flow. The return values for these command are:<br> + // - True - Command executed succesfully. + // - False - Command could not be executed. + // + // @{ + + // During the \c define state the process check the contents of the + // ParameterSet it received during start-up. When everthing seems ok the + // process constructs the communication channels for exchanging data + // with the other processes. The connection are NOT made in the stage. + tribool define (void); + + // When a process receives an \c init command it allocates the buffers it + // needs an makes the connections with the other processes. When the + // process succeeds in this it is ready for dataprocessing (or whatever + // task the process has). + tribool init (void); + + // During the \c run phase the process does the work it is designed for. + // The run phase stays active until another command is send. + tribool run (void); + + tribool pause(const std::string&); + tribool quit(void); + tribool recover(const std::string&); + tribool reinit(const std::string&); + tribool snapshot(const std::string&); + std::string askInfo(const std::string&); + + }; //class FlaggerProcessControl + } //namespace CS1_Flagger +}; //namespace LOFAR + +#endif diff --git a/Appl/CEP/CS1/CS1_DataSquasher/include/Makefile.am b/Appl/CEP/CS1/CS1_DataSquasher/include/Makefile.am new file mode 100644 index 00000000000..1eed6edb99d --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/include/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = CS1_DataSquasherr + +include $(top_srcdir)/Makefile.common diff --git a/Appl/CEP/CS1/CS1_DataSquasher/package.dox b/Appl/CEP/CS1/CS1_DataSquasher/package.dox new file mode 100644 index 00000000000..1f7d55f495b --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/package.dox @@ -0,0 +1,2 @@ +// \ingroup CS1 +// \defgroup CS1_DataSquasher CS1_DataSquasher Description diff --git a/Appl/CEP/CS1/CS1_DataSquasher/src/MS_Reader.cc b/Appl/CEP/CS1/CS1_DataSquasher/src/MS_Reader.cc new file mode 100644 index 00000000000..a70c2b57281 --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/src/MS_Reader.cc @@ -0,0 +1,176 @@ +/*************************************************************************** + * Copyright (C) 2007 by Adriaan Renting, ASTRON * + * renting@astron.nl * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include <casa/BasicMath/Math.h> +#include <casa/Arrays.h> +//#include <casa/Quanta/MVTime.h> + +#include <iostream> + +#include "MS_Reader.h" + +using namespace casa; + +//===============>>> MS_Reader::MS_Reader <<<=============== + +MS_Reader::MS_Reader(const std::string& msname) +{ + MSName = msname; + MS = new MeasurementSet(MSName, Table::Update); + init(); +} + +//===============>>> MS_Reader::~MS_Reader <<<=============== + +MS_Reader::~MS_Reader() +{ + delete MS; +} + +//===============>>> MS_Reader::init <<<=============== + +void MS_Reader::init() +{ + //Number of samples + itsNumSamples = (*MS).nrow(); + std::cout << "NumSamples" << itsNumSamples << std::endl; + //Number of Fields + MSField fields = (*MS).field(); + itsNumFields = fields.nrow(); + std::cout << "NumFields" << itsNumFields << std::endl; + + //Number of Antennae + MSAntenna antennae = (*MS).antenna(); + itsNumAntennae = antennae.nrow(); + std::cout << "NumAntennae" << itsNumAntennae << std::endl; + + //Antenna Names + ROScalarColumn<String> ANT_NAME_col(antennae, "NAME"); + Vector<String> ant_names = ANT_NAME_col.getColumn(); + ant_names.tovector(itsAntennaNames); + + //Number of channels in the Band + MSSpectralWindow spectral_window = (*MS).spectralWindow(); + ROScalarColumn<Int> NUM_CHAN_col(spectral_window, "NUM_CHAN"); + itsNumChannels = NUM_CHAN_col(0); + std::cout << "NumChannels" << itsNumChannels << std::endl; + + //Number of polarizations + MSPolarization polarization = (*MS).polarization(); + ROScalarColumn<Int> NUM_CORR_col(polarization, "NUM_CORR"); + itsNumPolarizations = NUM_CORR_col(0); + ROArrayColumn<Int> CORR_TYPE_col(polarization, "CORR_TYPE"); + itsPolarizations.resize(itsNumPolarizations); + CORR_TYPE_col.get(0, itsPolarizations); + std::cout << "NumPolarizations" << itsNumPolarizations << std::endl; + + //calculate theoretical noise level + ROScalarColumn<Double> EXPOSURE_col((*MS), "EXPOSURE"); + Double exposure = EXPOSURE_col(0); + + ROScalarColumn<Double> TOTAL_BANDWIDTH_col(spectral_window, "TOTAL_BANDWIDTH"); + Double bandwidth = TOTAL_BANDWIDTH_col(0) / itsNumChannels; + + itsNoiseLevel = 1.0 / sqrt(bandwidth * exposure); + std::cout << "Noiselevel" << itsNoiseLevel << std::endl; + + //calculate number of timeslots + ROScalarColumn<Double> INTERVAL_col((*MS), "INTERVAL"); + Double interval = INTERVAL_col(0); + + //Number of timeslots + ROScalarColumn<Double> TIME_CENTROID_col((*MS), "TIME_CENTROID"); + Double firstdate = TIME_CENTROID_col(0); + Double lastdate = TIME_CENTROID_col(itsNumSamples-1); + std::cout << "interval" << interval << std::endl; + + itsNumTimeslots = (int)((lastdate-firstdate)/interval) + 1; + std::cout << "Numtimeslots" << itsNumTimeslots << std::endl; + + //calculate number of baselines. + itsNumPairs = (itsNumAntennae) * (itsNumAntennae + 1) / 2; //Triangular numbers formula + std::cout << "NumPairs" << itsNumPairs << std::endl; + + //calculate number of Bands + itsNumBands = itsNumSamples / (itsNumPairs * itsNumTimeslots); + std::cout << "NumBands" << itsNumBands << std::endl; + +} + +//===============>>> MS_Reader::BaselineIterator <<<=============== + +MSAntenna MS_Reader::antenna() +{ + return (*MS).antenna(); +} + +//===============>>> MS_Reader::BaselineIterator <<<=============== + +TableIterator MS_Reader::TimeslotIterator() +{ + Block<String> ms_iteration_variables(1); + ms_iteration_variables[0] = "TIME_CENTROID"; + + return TableIterator((*MS), ms_iteration_variables); +} + +//===============>>> MS_Reader::BaselineIterator <<<=============== + +TableIterator MS_Reader::TimeAntennaIterator() +{ + Block<String> ms_iteration_variables(4); + ms_iteration_variables[0] = "TIME_CENTROID"; + ms_iteration_variables[1] = "DATA_DESC_ID"; + ms_iteration_variables[2] = "ANTENNA1"; + ms_iteration_variables[3] = "ANTENNA2"; + + return TableIterator((*MS), ms_iteration_variables); +} + +//===============>>> MS_Reader::WriteDataPointFlags <<<=============== + +void MS_Reader::WriteDataPointFlags(TableIterator* flag_iter, + Matrix<Bool>* Flags, + Bool FlagCompleteRow, + bool ExistingFlags) +{ + Table FlagTable = (*flag_iter).table(); +// ROTableVector<Int> antenna1(FlagTable, "ANTENNA1"); +// ROTableVector<Int> antenna2(FlagTable, "ANTENNA2"); +// ROTableVector<Int> bandnr (FlagTable, "DATA_DESC_ID"); +// ROTableVector<Double> time (FlagTable, "TIME_CENTROID"); + ArrayColumn <Bool> flags (FlagTable, "FLAG"); + ScalarColumn <Bool> flag_row(FlagTable, "FLAG_ROW"); +// ArrayColumn<String> flag_desc((*TimeslotTable), "FLAG_CATEGORY"); + if (ExistingFlags) + { + Matrix<Bool> OldFlags; + Bool OldFlagCompleteRow; + flags.get(0, OldFlags); + flag_row.get(0, OldFlagCompleteRow); + flags.put(0, OldFlags || (*Flags)); + } + else + { + flags.put(0, (*Flags)); + } + flag_row.put(0, FlagCompleteRow); +} +//===============>>> MS_Reader <<<=============== + diff --git a/Appl/CEP/CS1/CS1_DataSquasher/src/MS_Reader.h b/Appl/CEP/CS1/CS1_DataSquasher/src/MS_Reader.h new file mode 100644 index 00000000000..0af1ddd3e69 --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/src/MS_Reader.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (C) 2007 by Adriaan Renting, ASTRON * + * renting@astron.nl * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __SQUASHER_MS_READER_H__ +#define __SQUASHER_MS_READER_H__ + +#include <ms/MeasurementSets.h> +#include <vector> +#include <string> +#include <tables/Tables.h> +#include <tables/Tables/TableIter.h> + +namespace WSRT +{ + class MS_Reader + { + public: + MS_Reader(const std::string& msname); + ~MS_Reader(); + + int itsNumSamples; + int itsNumAntennae; + int itsNumFields; + int itsNumBands; + int itsNumChannels; + int itsNumPolarizations; + int itsNumPairs; + int itsNumTimeslots; + double itsNoiseLevel; + std::vector<casa::String> itsAntennaNames; + casa::Vector<casa::Int> itsPolarizations; + + casa::TableIterator TimeslotIterator(); + casa::TableIterator TimeAntennaIterator(); + casa::MSAntenna antenna(); + void WriteDataPointFlags(casa::TableIterator* flag_iter, + casa::Matrix<casa::Bool>* Flags, + bool FlagcompleteRow, + bool ExistingFlags); + + protected: + string MSName; + casa::MeasurementSet* MS; + void init(); + private: + }; // MS_Reader +}; // namespace WSRT + +#endif // __SQUASHER_MS_READER_H__ diff --git a/Appl/CEP/CS1/CS1_DataSquasher/src/Makefile.am b/Appl/CEP/CS1/CS1_DataSquasher/src/Makefile.am new file mode 100644 index 00000000000..c97da486929 --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/src/Makefile.am @@ -0,0 +1,12 @@ +bin_PROGRAMS = CS1_DataSquasher + +CS1_DataSquasher_SOURCES = Squasher.cc \ + MS_Reader.cc \ + MS_Reader.h \ + MS_Writer.cc \ + MS_Writer.h \ + SquasherProcessControl.cc +CS1_DataSquasher_LDADD = +CS1_DataSquasher_DEPENDENCIES = $(LOFAR_DEPEND) + +include $(top_srcdir)/Makefile.common diff --git a/Appl/CEP/CS1/CS1_DataSquasher/src/Squasher.cc b/Appl/CEP/CS1/CS1_DataSquasher/src/Squasher.cc new file mode 100644 index 00000000000..7154b57e64e --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/src/Squasher.cc @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2007 by Adriaan Renting, ASTRON * + * renting@astron.nl * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <libgen.h> +#include <PLC/ACCmain.h> +#include <casa/Exceptions.h> +#include <CS1_Flagger/FlaggerProcessControl.h> + +int main(int argc, char *argv[]) +{ + try + { + INIT_LOGGER(basename(argv[0])); + LOFAR::CS1::FlaggerProcessControl myProcess; + return LOFAR::ACC::PLC::ACCmain(argc, argv, &myProcess); + } //try + catch(casa::AipsError& err) + { + std::cerr << "Aips++ error detected: " << err.getMesg() << std::endl; + return -2; + } + catch(...) + { + std::cerr << "** PROBLEM **: Unhandled exception caught." << std::endl; + return -3; + } +} diff --git a/Appl/CEP/CS1/CS1_DataSquasher/src/SquasherProcessControl.cc b/Appl/CEP/CS1/CS1_DataSquasher/src/SquasherProcessControl.cc new file mode 100644 index 00000000000..00107acbca9 --- /dev/null +++ b/Appl/CEP/CS1/CS1_DataSquasher/src/SquasherProcessControl.cc @@ -0,0 +1,167 @@ +/*************************************************************************** + * Copyright (C) 2007 by Adriaan Renting, ASTRON * + * renting@astron.nl * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include <iostream> +#include <cstdlib> +#include <iostream> +#include <ms/MeasurementSets.h> + +#include <CS1_DataSquasher/SquasherProcessControl.h> +#include "DataSquasher.h" + +#define SQUASHER_VERSION "0.10" + +namespace LOFAR +{ + namespace CS1 + { + //===============>>> SquasherProcessControl::SquasherProcessControl <<<=============== + SquasherProcessControl::SquasherProcessControl() + : ProcessControl() + { + inMS = NULL; + outMS = NULL; + itsSquasher = NULL; + } + + //===============>>> SquasherProcessControl::~SquasherProcessControl <<<============== + SquasherProcessControl::~SquasherProcessControl() + { + if (inMS) + { delete inMS; + } + if (outMS) + { delete outMS; + } + if (itsSquasher) + { delete itsSquasher; + } + } + + //===============>>> SquasherProcessControl::define <<<============================== + tribool SquasherProcessControl::define() + { + LOFAR::ACC::APS::ParameterSet* ParamSet = LOFAR::ACC::APS::globalParameterSet(); + itsInMS = ParamSet->getString("inms"); + itsOutMS = ParamSet->getString("outms"); + itsStart = ParamSet->getBool("start"); + itsStep = ParamSet->getBool("step"); + itsNChan = ParamSet->getBool("nchan"); + return true; + } + + //===============>>> SquasherProcessControl::run <<<================================= + tribool SquasherProcessControl::run() + { + try{ + std::cout << "Runnning Data Squasher please wait..." << std::endl; + MS_Reader.MS.deepCopy(itsOutMS); + renameColumn("DATA", "OLDDATA"); + addColumn("DATA"); + + itsSquasher->Squash("OLDDATA", + "DATA", + itsStart, + itsStep, + itsNchan); + removeColumn("OLDDATA"); + } + catch(casa::AipsError& err) + { + std::cerr << "Aips++ error detected: " << err.getMesg() << std::endl; + return false; + } + return true; + } + + //===============>>> SquasherProcessControl::init <<<================================ + tribool SquasherProcessControl::init() + { + try { + using std::cout; + using std::cerr; + using std::endl; + + cout << string(SQUASHER_VERSION) + string(" data squasher by Adriaan Renting for LOFAR CS1\n") + + string("This is experimental software, please report errors or requests to renting@astron.nl\n") + + string("Documentation can be found at: www.astron.nl/~renting\n"); + cout << itsMS << endl; + if (itsInMS == "") + { + cerr << " Error missing input" << endl; + return false; + } + myMS = new MS_File(itsMS); + itsSquasher = new DataSquasher (myMS, + itsWindow, + itsCrosspol, + itsMin, + itsMax); + } + catch(casa::AipsError& err) + { + std::cerr << "Aips++ error detected: " << err.getMesg() << std::endl; + return false; + } + return true; + } + + //===============>>> SquasherProcessControl::pause <<<=============================== + tribool SquasherProcessControl::pause(const std::string&) + { return false; + } + + //===============>>> SquasherProcessControl::quit <<<================================ + tribool SquasherProcessControl::quit() + { + if (myMS) + { + delete myMS; + myMS = NULL; + } + if (itsSquasher) + { + delete itsSquasher; + itsSquasher = NULL; + } + return true; + } + + //===============>>> SquasherProcessControl::recover <<<============================= + tribool SquasherProcessControl::recover(const std::string&) + { return false; + } + + //===============>>> SquasherProcessControl::reinit <<<============================== + tribool SquasherProcessControl::reinit(const std::string&) + { return false; + } + + //===============>>> SquasherProcessControl::askInfo <<<============================= + std::string SquasherProcessControl::askInfo(const std::string&) + { return std::string(""); + } + + //===============>>> SquasherProcessControl::snapshot <<<============================ + tribool SquasherProcessControl::snapshot(const std::string&) + { return false; + } + } //namespace CS1 +}; //namespace LOFAR -- GitLab