From 0e9f7814f587f41541bb73e9e52dc00be0e9b8e9 Mon Sep 17 00:00:00 2001 From: Ger van Diepen <diepen@astron.nl> Date: Thu, 6 Dec 2012 12:35:42 +0000 Subject: [PATCH] Task #2699 Turn checkparset into an int to able to ignore unused keys --- CEP/DP3/DPPP/include/DPPP/AORFlagger.h | 6 +- CEP/DP3/DPPP/include/DPPP/Averager.h | 6 +- CEP/DP3/DPPP/include/DPPP/BaselineSelection.h | 7 +- CEP/DP3/DPPP/include/DPPP/CMakeLists.txt | 2 +- CEP/DP3/DPPP/include/DPPP/Counter.h | 6 +- CEP/DP3/DPPP/include/DPPP/DPRun.h | 4 +- CEP/DP3/DPPP/include/DPPP/Demixer.h | 6 +- CEP/DP3/DPPP/include/DPPP/Filter.h | 6 +- CEP/DP3/DPPP/include/DPPP/FlagCounter.h | 7 +- CEP/DP3/DPPP/include/DPPP/MSReader.h | 10 +- CEP/DP3/DPPP/include/DPPP/MSUpdater.h | 6 +- CEP/DP3/DPPP/include/DPPP/MSWriter.h | 4 +- CEP/DP3/DPPP/include/DPPP/MedFlagger.h | 5 +- CEP/DP3/DPPP/include/DPPP/MultiMSReader.h | 10 +- CEP/DP3/DPPP/include/DPPP/ParSet.h | 112 --------- CEP/DP3/DPPP/include/DPPP/PhaseShift.h | 12 +- CEP/DP3/DPPP/include/DPPP/PreFlagger.h | 7 +- CEP/DP3/DPPP/include/DPPP/StationAdder.h | 5 +- CEP/DP3/DPPP/include/DPPP/UVWFlagger.h | 7 +- CEP/DP3/DPPP/src/AORFlagger.cc | 5 +- CEP/DP3/DPPP/src/Averager.cc | 5 +- CEP/DP3/DPPP/src/BaselineSelection.cc | 4 +- CEP/DP3/DPPP/src/CMakeLists.txt | 2 +- CEP/DP3/DPPP/src/Counter.cc | 5 +- CEP/DP3/DPPP/src/DPRun.cc | 34 +-- CEP/DP3/DPPP/src/Demixer.cc | 18 +- CEP/DP3/DPPP/src/Filter.cc | 5 +- CEP/DP3/DPPP/src/FlagCounter.cc | 5 +- CEP/DP3/DPPP/src/MSReader.cc | 24 +- CEP/DP3/DPPP/src/MSUpdater.cc | 6 +- CEP/DP3/DPPP/src/MSWriter.cc | 6 +- CEP/DP3/DPPP/src/MedFlagger.cc | 5 +- CEP/DP3/DPPP/src/MultiMSReader.cc | 15 +- CEP/DP3/DPPP/src/ParSet.cc | 217 ------------------ CEP/DP3/DPPP/src/PhaseShift.cc | 8 +- CEP/DP3/DPPP/src/PreFlagger.cc | 8 +- CEP/DP3/DPPP/src/StationAdder.cc | 5 +- CEP/DP3/DPPP/src/UVWFlagger.cc | 7 +- CEP/DP3/DPPP/test/CMakeLists.txt | 1 - CEP/DP3/DPPP/test/tAORFlagger.cc | 2 +- CEP/DP3/DPPP/test/tAverager.cc | 2 +- CEP/DP3/DPPP/test/tBaselineSelection.cc | 2 +- CEP/DP3/DPPP/test/tDemixer.cc | 2 +- CEP/DP3/DPPP/test/tFilter.cc | 2 +- CEP/DP3/DPPP/test/tMedFlagger.cc | 2 +- CEP/DP3/DPPP/test/tPSet.cc | 2 +- CEP/DP3/DPPP/test/tParSet.cc | 57 ----- CEP/DP3/DPPP/test/tPhaseShift.cc | 2 +- CEP/DP3/DPPP/test/tPreFlagger.cc | 2 +- CEP/DP3/DPPP/test/tStationAdder.cc | 2 +- CEP/DP3/DPPP/test/tUVWFlagger.cc | 2 +- LCS/Common/include/Common/ParameterSet.h | 18 ++ LCS/Common/include/Common/ParameterSetImpl.h | 10 + LCS/Common/src/ParameterSetImpl.cc | 30 ++- LCS/Common/test/tParameterSet.cc | 30 ++- MAC/Deployment/data/OTDB/DPPP.comp | 2 +- 56 files changed, 261 insertions(+), 521 deletions(-) delete mode 100644 CEP/DP3/DPPP/include/DPPP/ParSet.h delete mode 100644 CEP/DP3/DPPP/src/ParSet.cc delete mode 100644 CEP/DP3/DPPP/test/tParSet.cc diff --git a/CEP/DP3/DPPP/include/DPPP/AORFlagger.h b/CEP/DP3/DPPP/include/DPPP/AORFlagger.h index 1d9a71928fa..93a29d66ee8 100644 --- a/CEP/DP3/DPPP/include/DPPP/AORFlagger.h +++ b/CEP/DP3/DPPP/include/DPPP/AORFlagger.h @@ -38,9 +38,9 @@ namespace LOFAR { - namespace DPPP { - class ParSet; + class ParameterSet; + namespace DPPP { // @ingroup NDPPP // This class is a DPStep class flagging data points based on the @@ -70,7 +70,7 @@ namespace LOFAR { public: // Construct the object. // Parameters are obtained from the parset using the given prefix. - AORFlagger (DPInput*, const ParSet&, const string& prefix); + AORFlagger (DPInput*, const ParameterSet&, const string& prefix); virtual ~AORFlagger(); diff --git a/CEP/DP3/DPPP/include/DPPP/Averager.h b/CEP/DP3/DPPP/include/DPPP/Averager.h index 06b11b4c5b1..f137ef49bae 100644 --- a/CEP/DP3/DPPP/include/DPPP/Averager.h +++ b/CEP/DP3/DPPP/include/DPPP/Averager.h @@ -33,9 +33,9 @@ namespace LOFAR { - namespace DPPP { - class ParSet; + class ParameterSet; + namespace DPPP { // @ingroup NDPPP // This class is a DPStep class calculating the weighted average of @@ -55,7 +55,7 @@ namespace LOFAR { public: // Construct the object. // Parameters are obtained from the parset using the given prefix. - Averager (DPInput*, const ParSet&, const string& prefix); + Averager (DPInput*, const ParameterSet&, const string& prefix); // Construct the object using the given parameters. Averager (DPInput*, const string& stepname, diff --git a/CEP/DP3/DPPP/include/DPPP/BaselineSelection.h b/CEP/DP3/DPPP/include/DPPP/BaselineSelection.h index 7f83ace2753..7fa3c694f34 100644 --- a/CEP/DP3/DPPP/include/DPPP/BaselineSelection.h +++ b/CEP/DP3/DPPP/include/DPPP/BaselineSelection.h @@ -27,13 +27,14 @@ // @file // @brief Class to handle the baseline selection -#include <DPPP/ParSet.h> #include <DPPP/DPInfo.h> -#include <Common/ParameterValue.h> #include <casa/Arrays/Vector.h> #include <casa/Arrays/Matrix.h> namespace LOFAR { + class ParameterSet; + class ParameterValue; + namespace DPPP { // Class containing a few static functions to parse a baseline selection @@ -53,7 +54,7 @@ namespace LOFAR { // <li> minbl: minimum baseline length (in m); only if minmax=true // <li> maxbl: maximum baseline length (in m); only if minmax=true // </ul> - BaselineSelection (const ParSet&, const string& prefix, + BaselineSelection (const ParameterSet&, const string& prefix, bool minmax=false, const string& defaultCorrType=string()); diff --git a/CEP/DP3/DPPP/include/DPPP/CMakeLists.txt b/CEP/DP3/DPPP/include/DPPP/CMakeLists.txt index 5ecc418523b..82df68d72af 100644 --- a/CEP/DP3/DPPP/include/DPPP/CMakeLists.txt +++ b/CEP/DP3/DPPP/include/DPPP/CMakeLists.txt @@ -3,7 +3,7 @@ # List of header files that will be installed. set(inst_HEADERS DPRun.h DPStep.h DPInput.h DPBuffer.h DPInfo.h - ParSet.h DPLogger.h ProgressMeter.h FlagCounter.h + DPLogger.h ProgressMeter.h FlagCounter.h UVWCalculator.h BaselineSelection.h MSReader.h MSWriter.h MSUpdater.h Counter.h Averager.h MedFlagger.h PreFlagger.h UVWFlagger.h AORFlagger.h diff --git a/CEP/DP3/DPPP/include/DPPP/Counter.h b/CEP/DP3/DPPP/include/DPPP/Counter.h index 0d8cbbca992..8215f2383e1 100644 --- a/CEP/DP3/DPPP/include/DPPP/Counter.h +++ b/CEP/DP3/DPPP/include/DPPP/Counter.h @@ -33,9 +33,9 @@ namespace LOFAR { - namespace DPPP { - class ParSet; + class ParameterSet; + namespace DPPP { // @ingroup NDPPP // This class is a DPStep class counting the number of flags per @@ -48,7 +48,7 @@ namespace LOFAR { public: // Construct the object. // Parameters are obtained from the parset using the given prefix. - Counter (DPInput*, const ParSet&, const string& prefix); + Counter (DPInput*, const ParameterSet&, const string& prefix); virtual ~Counter(); diff --git a/CEP/DP3/DPPP/include/DPPP/DPRun.h b/CEP/DP3/DPPP/include/DPPP/DPRun.h index 3ba728f3d46..d00f0a8771f 100644 --- a/CEP/DP3/DPPP/include/DPPP/DPRun.h +++ b/CEP/DP3/DPPP/include/DPPP/DPRun.h @@ -29,7 +29,7 @@ #include <lofar_config.h> #include <DPPP/DPStep.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> namespace LOFAR { namespace DPPP { @@ -49,7 +49,7 @@ namespace LOFAR { private: // Create the step objects. // It fills DPInfo object and the name of the MS being written. - static DPStep::ShPtr makeSteps (const ParSet& parset, + static DPStep::ShPtr makeSteps (const ParameterSet& parset, std::string& msName); }; diff --git a/CEP/DP3/DPPP/include/DPPP/Demixer.h b/CEP/DP3/DPPP/include/DPPP/Demixer.h index 25b8258a8d6..ffe995a8717 100644 --- a/CEP/DP3/DPPP/include/DPPP/Demixer.h +++ b/CEP/DP3/DPPP/include/DPPP/Demixer.h @@ -46,9 +46,9 @@ namespace LOFAR { - namespace DPPP { - class ParSet; + class ParameterSet; + namespace DPPP { // @ingroup NDPPP typedef vector<Patch::ConstPtr> PatchList; @@ -68,7 +68,7 @@ namespace LOFAR { public: // Construct the object. // Parameters are obtained from the parset using the given prefix. - Demixer (DPInput*, const ParSet&, const string& prefix); + Demixer (DPInput*, const ParameterSet&, const string& prefix); // Process the data. // It keeps the data. diff --git a/CEP/DP3/DPPP/include/DPPP/Filter.h b/CEP/DP3/DPPP/include/DPPP/Filter.h index ee63f382749..2ebe3e23701 100644 --- a/CEP/DP3/DPPP/include/DPPP/Filter.h +++ b/CEP/DP3/DPPP/include/DPPP/Filter.h @@ -33,9 +33,9 @@ namespace LOFAR { - namespace DPPP { - class ParSet; + class ParameterSet; + namespace DPPP { // @ingroup NDPPP // This class is a DPInput step reading the data from a MeasurementSet. @@ -128,7 +128,7 @@ namespace LOFAR { // Construct the object for the given MS. // Parameters are obtained from the parset using the given prefix. - Filter (DPInput* input, const ParSet&, const string& prefix); + Filter (DPInput* input, const ParameterSet&, const string& prefix); // Construct the object for the given MS and baseline selection. Filter (DPInput* input, const BaselineSelection&); diff --git a/CEP/DP3/DPPP/include/DPPP/FlagCounter.h b/CEP/DP3/DPPP/include/DPPP/FlagCounter.h index 7a8fee17554..92d7a596d2a 100644 --- a/CEP/DP3/DPPP/include/DPPP/FlagCounter.h +++ b/CEP/DP3/DPPP/include/DPPP/FlagCounter.h @@ -33,11 +33,11 @@ #include <casa/Arrays/Vector.h> namespace LOFAR { - namespace DPPP { + class ParameterSet; + namespace DPPP { //# Forward Declarations. class DPInfo; - class ParSet; // @ingroup NDPPP @@ -57,7 +57,8 @@ namespace LOFAR { // This constructor creates an empty object. // It reads info from the parset to see if percentages have to be saved. - FlagCounter (const string& msName, const ParSet&, const string& prefix); + FlagCounter (const string& msName, const ParameterSet&, + const string& prefix); // Size all counters and initialize them to zero using the sizes // from the DPInfo object. diff --git a/CEP/DP3/DPPP/include/DPPP/MSReader.h b/CEP/DP3/DPPP/include/DPPP/MSReader.h index 62ba12d5494..5d86df4ca81 100644 --- a/CEP/DP3/DPPP/include/DPPP/MSReader.h +++ b/CEP/DP3/DPPP/include/DPPP/MSReader.h @@ -38,9 +38,9 @@ namespace LOFAR { - namespace DPPP { - class ParSet; + class ParameterSet; + namespace DPPP { // @ingroup NDPPP // This class is a DPInput step reading the data from a MeasurementSet. @@ -135,7 +135,7 @@ namespace LOFAR { // Parameters are obtained from the parset using the given prefix. // The missingData argument is for MultiMSReader. MSReader (const std::string& msName, - const ParSet&, const string& prefix, + const ParameterSet&, const string& prefix, bool missingData = false); virtual ~MSReader(); @@ -172,8 +172,8 @@ namespace LOFAR { virtual casa::Cube<bool> getFullResFlags (const casa::RefRows& rowNrs); // Read the given data column at the given row numbers. - virtual casa::Cube<casa::Complex> getData (const casa::String& columnName, - const casa::RefRows& rowNrs); + /// virtual casa::Cube<casa::Complex> getData (const casa::String& columnName, + /// const casa::RefRows& rowNrs); // Write the flags at the given row numbers. // It is used by MSUpdater. diff --git a/CEP/DP3/DPPP/include/DPPP/MSUpdater.h b/CEP/DP3/DPPP/include/DPPP/MSUpdater.h index 49f84e208ae..acb87da13ef 100644 --- a/CEP/DP3/DPPP/include/DPPP/MSUpdater.h +++ b/CEP/DP3/DPPP/include/DPPP/MSUpdater.h @@ -32,9 +32,9 @@ namespace LOFAR { - namespace DPPP { - class ParSet; + class ParameterSet; + namespace DPPP { //# Forward Declarations. class MSReader; @@ -50,7 +50,7 @@ namespace LOFAR { class MSUpdater: public DPStep { public: - MSUpdater (MSReader*, const ParSet& parset, + MSUpdater (MSReader*, const ParameterSet& parset, const std::string& prefix); virtual ~MSUpdater(); diff --git a/CEP/DP3/DPPP/include/DPPP/MSWriter.h b/CEP/DP3/DPPP/include/DPPP/MSWriter.h index 7d32aa282d0..fad5c9432cd 100644 --- a/CEP/DP3/DPPP/include/DPPP/MSWriter.h +++ b/CEP/DP3/DPPP/include/DPPP/MSWriter.h @@ -39,8 +39,6 @@ namespace LOFAR { class ParameterSet; namespace DPPP { - class ParSet; - // @ingroup NDPPP // This class is a DPStep creating a new MeasurementSet and writing @@ -64,7 +62,7 @@ namespace LOFAR { public: explicit MSWriter (MSReader* reader, const std::string& outName, const DPInfo&, - const ParSet&, const string& prefix); + const ParameterSet&, const string& prefix); virtual ~MSWriter(); diff --git a/CEP/DP3/DPPP/include/DPPP/MedFlagger.h b/CEP/DP3/DPPP/include/DPPP/MedFlagger.h index 4e3e17434c7..3410d28bab4 100644 --- a/CEP/DP3/DPPP/include/DPPP/MedFlagger.h +++ b/CEP/DP3/DPPP/include/DPPP/MedFlagger.h @@ -33,10 +33,9 @@ #include <Common/lofar_vector.h> namespace LOFAR { + class ParameterSet; namespace DPPP { - class ParSet; - // @ingroup NDPPP // This class is a DPStep class flagging data points based on the median @@ -78,7 +77,7 @@ namespace LOFAR { public: // Construct the object. // Parameters are obtained from the parset using the given prefix. - MedFlagger (DPInput*, const ParSet&, const string& prefix); + MedFlagger (DPInput*, const ParameterSet&, const string& prefix); virtual ~MedFlagger(); diff --git a/CEP/DP3/DPPP/include/DPPP/MultiMSReader.h b/CEP/DP3/DPPP/include/DPPP/MultiMSReader.h index 35623820d64..6a9c2255fee 100644 --- a/CEP/DP3/DPPP/include/DPPP/MultiMSReader.h +++ b/CEP/DP3/DPPP/include/DPPP/MultiMSReader.h @@ -38,9 +38,9 @@ namespace LOFAR { - namespace DPPP { - class ParSet; + class ParameterSet; + namespace DPPP { // @ingroup NDPPP // This class is a DPInput step reading the data from a MeasurementSet. @@ -131,7 +131,7 @@ namespace LOFAR { // Construct the object for the given MS. // Parameters are obtained from the parset using the given prefix. MultiMSReader (const vector<string>& msNames, - const ParSet&, const string& prefix); + const ParameterSet&, const string& prefix); virtual ~MultiMSReader(); @@ -167,8 +167,8 @@ namespace LOFAR { virtual casa::Cube<bool> getFullResFlags (const casa::RefRows& rowNrs); // Read the given data column at the given row numbers. - virtual casa::Cube<casa::Complex> getData (const casa::String& columnName, - const casa::RefRows& rowNrs); + /// virtual casa::Cube<casa::Complex> getData (const casa::String& columnName, + /// const casa::RefRows& rowNrs); // Tell if the visibility data are to be read. virtual void setReadVisData (bool readVisData); diff --git a/CEP/DP3/DPPP/include/DPPP/ParSet.h b/CEP/DP3/DPPP/include/DPPP/ParSet.h deleted file mode 100644 index 69f5baa1ecb..00000000000 --- a/CEP/DP3/DPPP/include/DPPP/ParSet.h +++ /dev/null @@ -1,112 +0,0 @@ -//# ParSet.h: Wrapper around ParaMeterSet to keep track of parameters asked for -//# Copyright (C) 2010 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite 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 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ -//# -//# @author Ger van Diepen - -#ifndef DPPP_PARSET_H -#define DPPP_PARSET_H - -// @file -// @brief Wrapper around ParaMeterSet to keep track of parameters asked for - -#include <Common/ParameterSet.h> -#include <Common/lofar_string.h> -#include <Common/lofar_vector.h> -#include <Common/lofar_set.h> - -namespace LOFAR { - - namespace DPPP { - - // @ingroup NDPPP - - // This class keeps track of the parameters asked for. - // In this way it is possible to give a warning or error that the - // ParameterSet has more parameters than asked for. It is an aid in - // detecting misspelled parameters names. - - class ParSet - { - public: - ParSet (const ParameterSet&); - - // Ask a parameter with a possible default value. - // @{ - bool getBool (const string& aKey) const; - bool getBool (const string& aKey, bool aValue) const; - int getInt (const string& aKey) const; - int getInt (const string& aKey, int aValue) const; - uint getUint (const string& aKey) const; - uint getUint (const string& aKey, uint aValue) const; - float getFloat (const string& aKey) const; - float getFloat (const string& aKey, float aValue) const; - double getDouble(const string& aKey) const; - double getDouble(const string& aKey, double aValue) const; - string getString(const string& aKey) const; - string getString(const string& aKey, const string& aValue) const; - vector<bool> getBoolVector (const string& aKey, - bool expandable = false) const; - vector<bool> getBoolVector (const string& aKey, - const vector<bool>& aValue, - bool expandable = false) const; - vector<int> getIntVector (const string& aKey, - bool expandable = false) const; - vector<int> getIntVector (const string& aKey, - const vector<int>& aValue, - bool expandable = false) const; - vector<uint> getUintVector (const string& aKey, - bool expandable = false) const; - vector<uint> getUintVector (const string& aKey, - const vector<uint>& aValue, - bool expandable = false) const; - vector<float> getFloatVector (const string& aKey, - bool expandable = false) const; - vector<float> getFloatVector (const string& aKey, - const vector<float>& aValue, - bool expandable = false) const; - vector<double> getDoubleVector(const string& aKey, - bool expandable = false) const; - vector<double> getDoubleVector(const string& aKey, - const vector<double>& aValue, - bool expandable = false) const; - vector<string> getStringVector(const string& aKey, - bool expandable = false) const; - vector<string> getStringVector(const string& aKey, - const vector<string>& aValue, - bool expandable = false) const; - ParameterRecord getRecord (const string& aKey) const; - - // Get all unused parameters. - vector<string> unusedKeys() const; - - // Get the underlying ParameterSet. - const ParameterSet& parameterSet() const - { return itsParSet; } - - private: - ParameterSet itsParSet; - mutable set<string> itsAskedParms; - }; - - } //# end namespace -} - -#endif diff --git a/CEP/DP3/DPPP/include/DPPP/PhaseShift.h b/CEP/DP3/DPPP/include/DPPP/PhaseShift.h index 13421919feb..4018a9b06b5 100644 --- a/CEP/DP3/DPPP/include/DPPP/PhaseShift.h +++ b/CEP/DP3/DPPP/include/DPPP/PhaseShift.h @@ -33,9 +33,9 @@ namespace LOFAR { - namespace DPPP { - class ParSet; + class ParameterSet; + namespace DPPP { // @ingroup NDPPP // This class is a DPStep class to shift the data and UVW coordinates @@ -50,13 +50,13 @@ namespace LOFAR { // Construct the object. // Parameters are obtained from the parset using the given prefix. // This is the standard constructor where the phasecenter must be given. - PhaseShift (DPInput*, const ParSet&, const string& prefix); + PhaseShift (DPInput*, const ParameterSet&, const string& prefix); // Construct the object. // Parameters are obtained from the parset using the given prefix. // This is a constructor for Demixer where the phasecenter has the // given default value. - PhaseShift (DPInput*, const ParSet&, const string& prefix, + PhaseShift (DPInput*, const ParameterSet&, const string& prefix, const vector<string>& defVal); virtual ~PhaseShift(); @@ -87,6 +87,10 @@ namespace LOFAR { const casa::Matrix<casa::DComplex>& getPhasors() const { return itsPhasors; } + // Get the phase center. + const vector<string>& getPhaseCenter() const + { return itsCenter; } + private: // Interpret the phase center specification. // Currently only J2000 RA and DEC can be given. diff --git a/CEP/DP3/DPPP/include/DPPP/PreFlagger.h b/CEP/DP3/DPPP/include/DPPP/PreFlagger.h index baa8c937b6a..b335bc8c071 100644 --- a/CEP/DP3/DPPP/include/DPPP/PreFlagger.h +++ b/CEP/DP3/DPPP/include/DPPP/PreFlagger.h @@ -34,11 +34,10 @@ #include <measures/Measures/MDirection.h> namespace LOFAR { + class ParameterSet; class ParameterValue; namespace DPPP { - class ParSet; - // @ingroup NDPPP // This class is a DPStep class flagging data points based on data @@ -75,7 +74,7 @@ namespace LOFAR { // Construct the object. // Parameters are obtained from the parset using the given prefix. - PreFlagger (DPInput*, const ParSet&, const string& prefix); + PreFlagger (DPInput*, const ParameterSet&, const string& prefix); virtual ~PreFlagger(); @@ -125,7 +124,7 @@ namespace LOFAR { {} // Construct from the parset parameters. - PSet (DPInput*, const ParSet& parset, const string& prefix); + PSet (DPInput*, const ParameterSet& parset, const string& prefix); // Set and return the flags. casa::Cube<bool>* process (DPBuffer&, uint timeSlot, diff --git a/CEP/DP3/DPPP/include/DPPP/StationAdder.h b/CEP/DP3/DPPP/include/DPPP/StationAdder.h index 75596261214..3cd95859eae 100644 --- a/CEP/DP3/DPPP/include/DPPP/StationAdder.h +++ b/CEP/DP3/DPPP/include/DPPP/StationAdder.h @@ -34,10 +34,9 @@ #include <measures/Measures/MPosition.h> namespace LOFAR { + class ParameterSet; namespace DPPP { - class ParSet; - // @ingroup NDPPP // This class is a DPStep class summing stations to a superstation. @@ -63,7 +62,7 @@ namespace LOFAR { public: // Construct the object. // Parameters are obtained from the parset using the given prefix. - StationAdder (DPInput*, const ParSet&, const string& prefix); + StationAdder (DPInput*, const ParameterSet&, const string& prefix); virtual ~StationAdder(); diff --git a/CEP/DP3/DPPP/include/DPPP/UVWFlagger.h b/CEP/DP3/DPPP/include/DPPP/UVWFlagger.h index f3a6b32adcf..3642f190ea3 100644 --- a/CEP/DP3/DPPP/include/DPPP/UVWFlagger.h +++ b/CEP/DP3/DPPP/include/DPPP/UVWFlagger.h @@ -33,11 +33,10 @@ #include <Common/lofar_vector.h> namespace LOFAR { + class ParameterSet; class ParameterValue; namespace DPPP { - class ParSet; - // @ingroup NDPPP // This class is a DPStep class flagging data points based on data @@ -59,7 +58,7 @@ namespace LOFAR { // The antenna names are used to find antenna numbers. // The channel frequencies as they are in the input step must be given // starting at the start-channel. - UVWFlagger (DPInput*, const ParSet&, const string& prefix); + UVWFlagger (DPInput*, const ParameterSet&, const string& prefix); virtual ~UVWFlagger(); @@ -97,7 +96,7 @@ namespace LOFAR { // (min and max are also turned into a range). // Optionally the values are squared to avoid having to take a sqrt // of the data's UVW coordinates. - vector<double> fillUVW (const ParSet& parset, + vector<double> fillUVW (const ParameterSet& parset, const string& prefix, const string& name, bool square); diff --git a/CEP/DP3/DPPP/src/AORFlagger.cc b/CEP/DP3/DPPP/src/AORFlagger.cc index 81eda1d4a83..d74578eb729 100644 --- a/CEP/DP3/DPPP/src/AORFlagger.cc +++ b/CEP/DP3/DPPP/src/AORFlagger.cc @@ -25,7 +25,7 @@ #include <DPPP/AORFlagger.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/LofarLogger.h> #include <casa/OS/HostInfo.h> @@ -68,7 +68,8 @@ namespace LOFAR { namespace DPPP { AORFlagger::AORFlagger (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsInput (input), itsName (prefix), itsBufIndex (0), diff --git a/CEP/DP3/DPPP/src/Averager.cc b/CEP/DP3/DPPP/src/Averager.cc index 24bf4720fdf..028148c1a8d 100644 --- a/CEP/DP3/DPPP/src/Averager.cc +++ b/CEP/DP3/DPPP/src/Averager.cc @@ -25,7 +25,7 @@ #include <DPPP/Averager.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/LofarLogger.h> #include <casa/Arrays/ArrayMath.h> #include <iostream> @@ -37,7 +37,8 @@ namespace LOFAR { namespace DPPP { Averager::Averager (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsInput (input), itsName (prefix), itsNChanAvg (parset.getUint (prefix+"freqstep", 1)), diff --git a/CEP/DP3/DPPP/src/BaselineSelection.cc b/CEP/DP3/DPPP/src/BaselineSelection.cc index d5d3f45f5c1..b01f4205097 100644 --- a/CEP/DP3/DPPP/src/BaselineSelection.cc +++ b/CEP/DP3/DPPP/src/BaselineSelection.cc @@ -25,6 +25,8 @@ #include <DPPP/BaselineSelection.h> #include <DPPP/DPLogger.h> #include <MS/BaselineSelect.h> +#include <Common/ParameterSet.h> +#include <Common/ParameterValue.h> #include <Common/LofarLogger.h> #include <Common/StreamUtil.h> @@ -37,7 +39,7 @@ namespace LOFAR { BaselineSelection::BaselineSelection() {} - BaselineSelection::BaselineSelection (const ParSet& parset, + BaselineSelection::BaselineSelection (const ParameterSet& parset, const string& prefix, bool minmax, const string& defaultCorrType) diff --git a/CEP/DP3/DPPP/src/CMakeLists.txt b/CEP/DP3/DPPP/src/CMakeLists.txt index 9c3b4f87d6d..708486fdc2d 100644 --- a/CEP/DP3/DPPP/src/CMakeLists.txt +++ b/CEP/DP3/DPPP/src/CMakeLists.txt @@ -6,7 +6,7 @@ include(PythonInstall) lofar_add_library(dppp Package__Version.cc DPRun.cc DPStep.cc DPInput.cc DPBuffer.cc DPInfo.cc - ParSet.cc DPLogger.cc ProgressMeter.cc FlagCounter.cc + DPLogger.cc ProgressMeter.cc FlagCounter.cc UVWCalculator.cc BaselineSelection.cc MSReader.cc MultiMSReader.cc MSWriter.cc MSUpdater.cc Counter.cc Averager.cc MedFlagger.cc AORFlagger.cc PreFlagger.cc UVWFlagger.cc diff --git a/CEP/DP3/DPPP/src/Counter.cc b/CEP/DP3/DPPP/src/Counter.cc index 832f074d502..771580217e1 100644 --- a/CEP/DP3/DPPP/src/Counter.cc +++ b/CEP/DP3/DPPP/src/Counter.cc @@ -24,7 +24,7 @@ #include <lofar_config.h> #include <DPPP/Counter.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <iostream> using namespace casa; @@ -33,7 +33,8 @@ namespace LOFAR { namespace DPPP { Counter::Counter (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsName (prefix), itsCount (0), itsFlagCounter (input->msName(), parset, prefix) diff --git a/CEP/DP3/DPPP/src/DPRun.cc b/CEP/DP3/DPPP/src/DPRun.cc index 3e3ec6b7925..9bab26e8910 100644 --- a/CEP/DP3/DPPP/src/DPRun.cc +++ b/CEP/DP3/DPPP/src/DPRun.cc @@ -39,7 +39,7 @@ #include <DPPP/StationAdder.h> #include <DPPP/Filter.h> #include <DPPP/Counter.h> -#include <DPPP/ParSet.h> +#include <DPPP/ApplyCal.h> #include <DPPP/ProgressMeter.h> #include <DPPP/DPLogger.h> #include <Common/Timer.h> @@ -57,9 +57,9 @@ namespace LOFAR { casa::Timer timer; NSTimer nstimer; nstimer.start(); - ParSet parset ((ParameterSet(parsetName))); + ParameterSet parset (parsetName); DPLogger::useLogger = parset.getBool ("uselogger", false); - bool checkparset = parset.getBool ("checkparset", false); + int checkparset = parset.getInt ("checkparset", 0); bool showProgress = parset.getBool ("showprogress", true); bool showTimings = parset.getBool ("showtimings", true); string msName; @@ -73,17 +73,19 @@ namespace LOFAR { DPLOG_INFO (os.str(), true); step = step->getNextStep(); } - // Show unused parameters (might be misspelled). - vector<string> unused = parset.unusedKeys(); - if (! unused.empty()) { - DPLOG_WARN_STR - (endl - << "*** WARNING: the following parset keywords were not used ***" - << endl - << " maybe they are misspelled" - << endl - << " " << unused << endl); - ASSERTSTR (!checkparset, "Unused parset keywords found"); + if (checkparset >= 0) { + // Show unused parameters (might be misspelled). + vector<string> unused = parset.unusedKeys(); + if (! unused.empty()) { + DPLOG_WARN_STR + (endl + << "*** WARNING: the following parset keywords were not used ***" + << endl + << " maybe they are misspelled" + << endl + << " " << unused << endl); + ASSERTSTR (checkparset==0, "Unused parset keywords found"); + } } // Process until the end. uint ntodo = firstStep->getInfo().ntime(); @@ -157,7 +159,7 @@ namespace LOFAR { // The destructors are called automatically at this point. } - DPStep::ShPtr DPRun::makeSteps (const ParSet& parset, string& msName) + DPStep::ShPtr DPRun::makeSteps (const ParameterSet& parset, string& msName) { DPStep::ShPtr firstStep; DPStep::ShPtr lastStep; @@ -252,6 +254,8 @@ namespace LOFAR { step = DPStep::ShPtr(new StationAdder (reader, parset, prefix)); } else if (type == "filter") { step = DPStep::ShPtr(new Filter (reader, parset, prefix)); + /// } else if (type == "applycal" || type == "correct") { + /// step = DPStep::ShPtr(new ApplyCal (reader, parset, prefix)); } else { THROW (LOFAR::Exception, "DPPP step type " << type << " is unknown"); } diff --git a/CEP/DP3/DPPP/src/Demixer.cc b/CEP/DP3/DPPP/src/Demixer.cc index 34a33b0e0c2..a74d159cf27 100644 --- a/CEP/DP3/DPPP/src/Demixer.cc +++ b/CEP/DP3/DPPP/src/Demixer.cc @@ -30,7 +30,6 @@ #include <DPPP/DPInfo.h> #include <DPPP/EstimateMixed.h> #include <DPPP/PhaseShift.h> -#include <DPPP/ParSet.h> #include <DPPP/Simulate.h> #include <DPPP/SourceDBUtil.h> #include <DPPP/SubtractMixed.h> @@ -42,6 +41,7 @@ #include <ParmDB/ParmCache.h> #include <ParmDB/Parm.h> +#include <Common/ParameterSet.h> #include <Common/LofarLogger.h> #include <Common/OpenMP.h> #include <Common/StreamUtil.h> @@ -70,7 +70,8 @@ namespace LOFAR { } //# end unnamed namespace Demixer::Demixer (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsInput (input), itsName (prefix), itsSkyName (parset.getString(prefix+"skymodel", "sky")), @@ -360,8 +361,21 @@ namespace LOFAR { } os << " targetsource: " << itsTargetSource << std::endl; os << " subtractsources: " << itsSubtrSources << std::endl; + uint inx=0; + for (uint i=0; i<itsSubtrSources.size(); ++i ) { + os << " " + << itsPhaseShifts[inx++]->getPhaseCenter() << std::endl; + } os << " modelsources: " << itsModelSources << std::endl; + for (uint i=0; i<itsModelSources.size(); ++i ) { + os << " " + << itsPhaseShifts[inx++]->getPhaseCenter() << std::endl; + } os << " extrasources: " << itsExtraSources << std::endl; + for (uint i=0; i<itsExtraSources.size(); ++i ) { + os << " " + << itsPhaseShifts[inx++]->getPhaseCenter() << std::endl; + } // os << " elevationcutoffs: " << itsCutOffs << std::endl; // os << " jointsolve: " << itsJointSolve << std::endl; os << " propagatesolutions: " << std::boolalpha << itsPropagateSolutions diff --git a/CEP/DP3/DPPP/src/Filter.cc b/CEP/DP3/DPPP/src/Filter.cc index 9b4bb455897..e6f77493247 100644 --- a/CEP/DP3/DPPP/src/Filter.cc +++ b/CEP/DP3/DPPP/src/Filter.cc @@ -25,8 +25,8 @@ #include <DPPP/Filter.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> #include <DPPP/DPLogger.h> +#include <Common/ParameterSet.h> #include <tables/Tables/ExprNode.h> #include <tables/Tables/RecordGram.h> @@ -38,7 +38,8 @@ namespace LOFAR { namespace DPPP { Filter::Filter (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsInput (input), itsName (prefix), itsStartChanStr (parset.getString(prefix+"startchan", "0")), diff --git a/CEP/DP3/DPPP/src/FlagCounter.cc b/CEP/DP3/DPPP/src/FlagCounter.cc index aa2ad7b48e8..edd1e366187 100644 --- a/CEP/DP3/DPPP/src/FlagCounter.cc +++ b/CEP/DP3/DPPP/src/FlagCounter.cc @@ -24,7 +24,7 @@ #include <lofar_config.h> #include <DPPP/FlagCounter.h> #include <DPPP/DPInput.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StreamUtil.h> #include <Common/LofarLogger.h> #include <tables/Tables/Table.h> @@ -50,7 +50,8 @@ namespace LOFAR { {} FlagCounter::FlagCounter (const string& msName, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) { itsWarnPerc = parset.getDouble (prefix+"warnperc", 0); itsShowFF = parset.getBool (prefix+"showfullyflagged", false); diff --git a/CEP/DP3/DPPP/src/MSReader.cc b/CEP/DP3/DPPP/src/MSReader.cc index dfe0c6eafd8..61326aef40e 100644 --- a/CEP/DP3/DPPP/src/MSReader.cc +++ b/CEP/DP3/DPPP/src/MSReader.cc @@ -26,8 +26,9 @@ #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> #include <DPPP/DPLogger.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/LofarLogger.h> + #include <tables/Tables/TableRecord.h> #include <tables/Tables/ScalarColumn.h> #include <tables/Tables/ArrayColumn.h> @@ -57,7 +58,8 @@ namespace LOFAR { {} MSReader::MSReader (const string& msName, - const ParSet& parset, const string& prefix, + const ParameterSet& parset, + const string& prefix, bool missingData) : itsReadVisData (False), itsMissingData (missingData), @@ -89,6 +91,7 @@ namespace LOFAR { // See if a selection on band needs to be done. // We assume that DATA_DESC_ID and SPW_ID map 1-1. if (itsSpw >= 0) { + DPLOG_INFO_STR (" MSReader selecting spectral window " << itsSpw << " ..."); Table subset = itsMS (itsMS.col("DATA_DESC_ID") == itsSpw); // If not all is selected, use the selection. if (subset.nrow() < itsMS.nrow()) { @@ -101,6 +104,7 @@ namespace LOFAR { } // See if a selection on baseline needs to be done. if (! itsSelBL.empty()) { + DPLOG_INFO_STR (" MSReader selecting baselines ..."); MSSelection select; // Set given selection strings. select.setAntennaExpr (itsSelBL); @@ -210,8 +214,8 @@ namespace LOFAR { // Skip time slot and give warning if MS data is not in time order. if (mstime < itsLastMSTime) { LOG_WARN_STR ("Time at rownr " - << itsIter.table().rowNumbers(itsMS)[0] - << " of MS " << itsMS.tableName() + << itsIter.table().rowNumbers()[0] + << " of MS " << itsMSName << " is less than previous time slot"); } else { // Use the time slot if near or < nexttime, but > starttime. @@ -251,7 +255,7 @@ namespace LOFAR { calcUVW(); itsNrInserted++; } else { - itsBuffer.setRowNrs (itsIter.table().rowNumbers(itsMS)); + itsBuffer.setRowNrs (itsIter.table().rowNumbers(itsMS, True)); if (itsMissingData) { // Data column not present, so fill a fully flagged time slot. itsBuffer.setExposure (itsTimeInterval); @@ -467,7 +471,7 @@ namespace LOFAR { ROScalarColumn<Int> ant2col(itsIter.table(), "ANTENNA2"); // Keep the row numbers of the first part to be used for the meta info // of possibly missing time slots. - itsBaseRowNrs = itsIter.table().rowNumbers(itsMS); + itsBaseRowNrs = itsIter.table().rowNumbers(itsMS, True); // Get the antenna names and positions. Table anttab(itsMS.keywordSet().asTable("ANTENNA")); ROScalarColumn<String> nameCol (anttab, "NAME"); @@ -553,8 +557,8 @@ namespace LOFAR { // Skip time slot and give warning if MS data is not in time order. if (mstime < itsLastMSTime) { LOG_WARN_STR ("Time at rownr " - << itsIter.table().rowNumbers(itsMS)[0] - << " of MS " << itsMS.tableName() + << itsIter.table().rowNumbers()[0] + << " of MS " << itsMSName << " is less than previous time slot"); } else { // Stop skipping if time equal to itsFirstTime. @@ -741,6 +745,7 @@ namespace LOFAR { return flags; } + /* Cube<Complex> MSReader::getData (const String& columnName, const RefRows& rowNrs) { @@ -753,6 +758,7 @@ namespace LOFAR { Cube<Complex> data = dataCol.getColumnCells (rowNrs); return (itsUseAllChan ? data : data(itsArrSlicer)); } + */ void MSReader::putFlags (const RefRows& rowNrs, const Cube<bool>& flags) @@ -771,7 +777,7 @@ namespace LOFAR { // If all new flags are set, we leave it because we might have a // subset of the channels, so other flags might still be clear. if (anyEQ (flagIter.array(), False)) { - flagRowCol.put (i, False); + flagRowCol.put (rows[i], False); } flagIter.next(); } diff --git a/CEP/DP3/DPPP/src/MSUpdater.cc b/CEP/DP3/DPPP/src/MSUpdater.cc index 2825aed88f7..89baabe4db4 100644 --- a/CEP/DP3/DPPP/src/MSUpdater.cc +++ b/CEP/DP3/DPPP/src/MSUpdater.cc @@ -26,7 +26,7 @@ #include <DPPP/MSReader.h> #include <DPPP/MSWriter.h> #include <DPPP/DPBuffer.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <iostream> using namespace casa; @@ -34,7 +34,7 @@ using namespace casa; namespace LOFAR { namespace DPPP { - MSUpdater::MSUpdater (MSReader* reader, const ParSet& parset, + MSUpdater::MSUpdater (MSReader* reader, const ParameterSet& parset, const string&) : itsReader (reader), itsNrCorr (reader->getInfo().ncorr()), @@ -43,7 +43,7 @@ namespace LOFAR { itsNrTimes (0) { NSTimer::StartStop sstime(itsTimer); - MSWriter::writeHistory (reader->table(), parset.parameterSet()); + MSWriter::writeHistory (reader->table(), parset); } MSUpdater::~MSUpdater() diff --git a/CEP/DP3/DPPP/src/MSWriter.cc b/CEP/DP3/DPPP/src/MSWriter.cc index 5a3f6b5cf9f..a075a61cac3 100644 --- a/CEP/DP3/DPPP/src/MSWriter.cc +++ b/CEP/DP3/DPPP/src/MSWriter.cc @@ -27,9 +27,9 @@ #include <DPPP/MSUpdater.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> #include <DPPP/DPLogger.h> #include <MS/VdsMaker.h> +#include <Common/ParameterSet.h> #include <tables/Tables/TableCopy.h> #include <tables/Tables/DataManInfo.h> #include <tables/Tables/SetupNewTab.h> @@ -50,7 +50,7 @@ namespace LOFAR { MSWriter::MSWriter (MSReader* reader, const std::string& outName, const DPInfo& info, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, const string& prefix) : itsReader (reader), itsInterval (info.timeInterval()), itsNrCorr (info.ncorr()), @@ -80,7 +80,7 @@ namespace LOFAR { } createMS (outName, info, tileSize, tileNChan); // Write the parset info into the history. - writeHistory (itsMS, parset.parameterSet()); + writeHistory (itsMS, parset); itsMS.flush (true, true); DPLOG_INFO ("Finished preparing output MS", false); } diff --git a/CEP/DP3/DPPP/src/MedFlagger.cc b/CEP/DP3/DPPP/src/MedFlagger.cc index a42a67ab49b..32ec6e6b8ab 100644 --- a/CEP/DP3/DPPP/src/MedFlagger.cc +++ b/CEP/DP3/DPPP/src/MedFlagger.cc @@ -25,7 +25,7 @@ #include <DPPP/MedFlagger.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StreamUtil.h> #include <Common/LofarLogger.h> #include <casa/Arrays/ArrayMath.h> @@ -42,7 +42,8 @@ namespace LOFAR { namespace DPPP { MedFlagger::MedFlagger (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsInput (input), itsName (prefix), itsThresholdStr (parset.getString (prefix+"threshold", "1")), diff --git a/CEP/DP3/DPPP/src/MultiMSReader.cc b/CEP/DP3/DPPP/src/MultiMSReader.cc index a7b24b40d4e..d127fd3e2ea 100644 --- a/CEP/DP3/DPPP/src/MultiMSReader.cc +++ b/CEP/DP3/DPPP/src/MultiMSReader.cc @@ -25,7 +25,7 @@ #include <DPPP/MultiMSReader.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StreamUtil.h> #include <Common/LofarLogger.h> #include <tables/Tables/TableRecord.h> @@ -48,7 +48,8 @@ namespace LOFAR { namespace DPPP { MultiMSReader::MultiMSReader (const vector<string>& msNames, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsFirst (-1), itsNMissing (0), itsMSNames (msNames) @@ -162,12 +163,14 @@ namespace LOFAR { for (uint i=0; i<itsReaders.size(); ++i) { if (itsReaders[i]) { ASSERTSTR (itsReaders[i]->getInfo().nchan() == itsFillNChan, - "An MS is missing; the others should have equal size"); + "An MS is missing; the others should have equal nchan"); // Check if all channels have the same width and are consecutive. const Vector<double>& freqs = itsReaders[i]->getInfo().chanFreqs(); const Vector<double>& width = itsReaders[i]->getInfo().chanWidths(); - ASSERTSTR (freqs[0] > freq || near(freqs[0], freq), - "Subbands should be in increasing order of frequency"); + ASSERTSTR (freqs[0] > freq || near(freqs[0], freq, 1e-5), + "Subbands should be in increasing order of frequency; found " + << freqs[0] << ", expected " << freq << " (diff=" + << freqs[0]-freq << ')'); freq = freqs[itsFillNChan-1] + width[itsFillNChan-1]; objcopy (chanFreqs.data() + inx, freqs.data(), itsFillNChan); objcopy (chanWidths.data() + inx, width.data(), itsFillNChan); @@ -401,6 +404,7 @@ namespace LOFAR { return flags; } + /* Cube<Complex> MultiMSReader::getData (const String& columnName, const RefRows& rowNrs) { @@ -420,6 +424,7 @@ namespace LOFAR { } return data; } + */ void MultiMSReader::combineFullResFlags (const vector<Cube<bool> >& vec, Cube<bool>& flags) const diff --git a/CEP/DP3/DPPP/src/ParSet.cc b/CEP/DP3/DPPP/src/ParSet.cc deleted file mode 100644 index 61e1430f2f2..00000000000 --- a/CEP/DP3/DPPP/src/ParSet.cc +++ /dev/null @@ -1,217 +0,0 @@ -//# ParSet.cc: Wrapper around ParaMeterSet to keep track of parameters asked for -//# Copyright (C) 2010 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite 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 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ -//# -//# @author Ger van Diepen - -#include <DPPP/ParSet.h> -#include <Common/ParameterRecord.h> -#include <set> - -namespace LOFAR { - namespace DPPP { - - ParSet::ParSet (const ParameterSet& parset ) - : itsParSet (parset) - {} - - bool ParSet::getBool (const string& aKey) const - { - itsAskedParms.insert (aKey); - return itsParSet.getBool (aKey); - } - - bool ParSet::getBool (const string& aKey, bool aValue) const - { - itsAskedParms.insert (aKey); - return itsParSet.getBool (aKey, aValue); - } - - int ParSet::getInt (const string& aKey) const - { - itsAskedParms.insert (aKey); - return itsParSet.getInt (aKey); - } - - int ParSet::getInt (const string& aKey, int aValue) const - { - itsAskedParms.insert (aKey); - return itsParSet.getInt (aKey, aValue); - } - - uint ParSet::getUint (const string& aKey) const - { - itsAskedParms.insert (aKey); - return itsParSet.getUint (aKey); - } - - uint ParSet::getUint (const string& aKey, uint aValue) const - { - itsAskedParms.insert (aKey); - return itsParSet.getUint (aKey, aValue); - } - - float ParSet::getFloat (const string& aKey) const - { - itsAskedParms.insert (aKey); - return itsParSet.getFloat (aKey); - } - - float ParSet::getFloat (const string& aKey, float aValue) const - { - itsAskedParms.insert (aKey); - return itsParSet.getFloat (aKey, aValue); - } - - double ParSet::getDouble(const string& aKey) const - { - itsAskedParms.insert (aKey); - return itsParSet.getDouble (aKey); - } - - double ParSet::getDouble(const string& aKey, double aValue) const - { - itsAskedParms.insert (aKey); - return itsParSet.getDouble (aKey, aValue); - } - - string ParSet::getString(const string& aKey) const - { - itsAskedParms.insert (aKey); - return itsParSet.getString (aKey); - } - - string ParSet::getString(const string& aKey, const string& aValue) const - { - itsAskedParms.insert (aKey); - return itsParSet.getString (aKey, aValue); - } - - vector<bool> ParSet::getBoolVector (const string& aKey, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getBoolVector (aKey, expandable); - } - - vector<bool> ParSet::getBoolVector (const string& aKey, - const vector<bool>& aValue, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getBoolVector (aKey, aValue, expandable); - } - - vector<int> ParSet::getIntVector (const string& aKey, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getIntVector (aKey, expandable); - } - - vector<int> ParSet::getIntVector (const string& aKey, - const vector<int>& aValue, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getIntVector (aKey, aValue, expandable); - } - - vector<uint> ParSet::getUintVector (const string& aKey, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getUintVector (aKey, expandable); - } - - vector<uint> ParSet::getUintVector (const string& aKey, - const vector<uint>& aValue, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getUintVector (aKey, aValue, expandable); - } - - vector<float> ParSet::getFloatVector (const string& aKey, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getFloatVector (aKey, expandable); - } - - vector<float> ParSet::getFloatVector (const string& aKey, - const vector<float>& aValue, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getFloatVector (aKey, aValue, expandable); - } - - vector<double> ParSet::getDoubleVector(const string& aKey, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getDoubleVector (aKey, expandable); - } - - vector<double> ParSet::getDoubleVector(const string& aKey, - const vector<double>& aValue, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getDoubleVector (aKey, aValue, expandable); - } - - vector<string> ParSet::getStringVector(const string& aKey, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getStringVector (aKey, expandable); - } - - vector<string> ParSet::getStringVector(const string& aKey, - const vector<string>& aValue, - bool expandable) const - { - itsAskedParms.insert (aKey); - return itsParSet.getStringVector (aKey, aValue, expandable); - } - - ParameterRecord ParSet::getRecord(const string& aKey) const - { - itsAskedParms.insert (aKey); - return itsParSet.getRecord (aKey); - } - - vector<string> ParSet::unusedKeys() const - { - vector<string> vec; - for (ParameterSet::const_iterator iter = itsParSet.begin(); - iter != itsParSet.end(); ++iter) { - if (itsAskedParms.find (iter->first) == itsAskedParms.end()) { - vec.push_back (iter->first); - } - } - return vec; - } - - - } //# end namespace -} diff --git a/CEP/DP3/DPPP/src/PhaseShift.cc b/CEP/DP3/DPPP/src/PhaseShift.cc index c2475222056..4501069dcd8 100644 --- a/CEP/DP3/DPPP/src/PhaseShift.cc +++ b/CEP/DP3/DPPP/src/PhaseShift.cc @@ -25,7 +25,7 @@ #include <DPPP/PhaseShift.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/LofarLogger.h> #include <Common/StreamUtil.h> #include <casa/Arrays/ArrayMath.h> @@ -43,14 +43,16 @@ namespace LOFAR { namespace DPPP { PhaseShift::PhaseShift (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsInput (input), itsName (prefix), itsCenter (parset.getStringVector(prefix+"phasecenter")) {} PhaseShift::PhaseShift (DPInput* input, - const ParSet& parset, const string& prefix, + const ParameterSet& parset, + const string& prefix, const vector<string>& defVal) : itsInput (input), itsName (prefix), diff --git a/CEP/DP3/DPPP/src/PreFlagger.cc b/CEP/DP3/DPPP/src/PreFlagger.cc index 2e24393113d..f9c6715efc9 100644 --- a/CEP/DP3/DPPP/src/PreFlagger.cc +++ b/CEP/DP3/DPPP/src/PreFlagger.cc @@ -25,8 +25,8 @@ #include <DPPP/PreFlagger.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> #include <DPPP/DPLogger.h> +#include <Common/ParameterSet.h> #include <Common/StreamUtil.h> #include <Common/LofarLogger.h> @@ -51,7 +51,8 @@ namespace LOFAR { namespace DPPP { PreFlagger::PreFlagger (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsName (prefix), itsInput (input), itsMode (SetFlag), @@ -225,7 +226,8 @@ namespace LOFAR { PreFlagger::PSet::PSet (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsInput (input), itsName (prefix), itsFlagOnUV (false), diff --git a/CEP/DP3/DPPP/src/StationAdder.cc b/CEP/DP3/DPPP/src/StationAdder.cc index 76356ad5669..1f6768bd5ac 100644 --- a/CEP/DP3/DPPP/src/StationAdder.cc +++ b/CEP/DP3/DPPP/src/StationAdder.cc @@ -25,8 +25,8 @@ #include <DPPP/StationAdder.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> #include <DPPP/DPLogger.h> +#include <Common/ParameterSet.h> #include <Common/ParameterRecord.h> #include <measures/Measures/MPosition.h> @@ -48,7 +48,8 @@ namespace LOFAR { namespace DPPP { StationAdder::StationAdder (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsInput (input), itsName (prefix), itsStatRec (parset.getRecord(prefix+"stations")), diff --git a/CEP/DP3/DPPP/src/UVWFlagger.cc b/CEP/DP3/DPPP/src/UVWFlagger.cc index dd70fc6ad2d..c5a0a5fea74 100644 --- a/CEP/DP3/DPPP/src/UVWFlagger.cc +++ b/CEP/DP3/DPPP/src/UVWFlagger.cc @@ -25,7 +25,7 @@ #include <DPPP/UVWFlagger.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StreamUtil.h> #include <Common/LofarLogger.h> #include <casa/Arrays/ArrayMath.h> @@ -42,7 +42,8 @@ namespace LOFAR { namespace DPPP { UVWFlagger::UVWFlagger (DPInput* input, - const ParSet& parset, const string& prefix) + const ParameterSet& parset, + const string& prefix) : itsInput (input), itsName (prefix), itsNTimes (0), @@ -242,7 +243,7 @@ namespace LOFAR { } } - vector<double> UVWFlagger::fillUVW (const ParSet& parset, + vector<double> UVWFlagger::fillUVW (const ParameterSet& parset, const string& prefix, const string& name, bool square) diff --git a/CEP/DP3/DPPP/test/CMakeLists.txt b/CEP/DP3/DPPP/test/CMakeLists.txt index b6bf34bbbfd..64f5d62d6a4 100644 --- a/CEP/DP3/DPPP/test/CMakeLists.txt +++ b/CEP/DP3/DPPP/test/CMakeLists.txt @@ -16,7 +16,6 @@ lofar_add_test(tFilter tFilter.cc) #lofar_add_test(tDemixer tDemixer.cc) lofar_add_test(tNDPPP tNDPPP.cc) lofar_add_test(tparse tparse.cc) -lofar_add_test(tParSet tParSet.cc) lofar_add_test(tBaselineSelection tBaselineSelection.cc) # lofar_add_test(tExpr tExpr.cc) # lofar_add_test(tmeqarray tmeqarray.cc) diff --git a/CEP/DP3/DPPP/test/tAORFlagger.cc b/CEP/DP3/DPPP/test/tAORFlagger.cc index ae2c060ad83..386a7f482f0 100644 --- a/CEP/DP3/DPPP/test/tAORFlagger.cc +++ b/CEP/DP3/DPPP/test/tAORFlagger.cc @@ -26,7 +26,7 @@ #include <DPPP/DPInput.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StringUtil.h> #include <casa/Arrays/ArrayMath.h> #include <casa/Arrays/ArrayLogical.h> diff --git a/CEP/DP3/DPPP/test/tAverager.cc b/CEP/DP3/DPPP/test/tAverager.cc index d6c4b9b4af5..80f7b2cee5d 100644 --- a/CEP/DP3/DPPP/test/tAverager.cc +++ b/CEP/DP3/DPPP/test/tAverager.cc @@ -25,7 +25,7 @@ #include <DPPP/Averager.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StringUtil.h> #include <casa/Arrays/ArrayMath.h> #include <casa/Arrays/ArrayLogical.h> diff --git a/CEP/DP3/DPPP/test/tBaselineSelection.cc b/CEP/DP3/DPPP/test/tBaselineSelection.cc index fc125a99b60..af1ba2f32b9 100644 --- a/CEP/DP3/DPPP/test/tBaselineSelection.cc +++ b/CEP/DP3/DPPP/test/tBaselineSelection.cc @@ -24,7 +24,7 @@ #include <lofar_config.h> #include <DPPP/BaselineSelection.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/LofarLogger.h> #include <Common/StreamUtil.h> #include <casa/Arrays/ArrayLogical.h> diff --git a/CEP/DP3/DPPP/test/tDemixer.cc b/CEP/DP3/DPPP/test/tDemixer.cc index fec79fc9913..97540f1524c 100644 --- a/CEP/DP3/DPPP/test/tDemixer.cc +++ b/CEP/DP3/DPPP/test/tDemixer.cc @@ -25,7 +25,7 @@ #include <DPPP/Demixer.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StringUtil.h> #include <casa/Arrays/ArrayMath.h> #include <casa/Arrays/ArrayLogical.h> diff --git a/CEP/DP3/DPPP/test/tFilter.cc b/CEP/DP3/DPPP/test/tFilter.cc index 758eb6633fb..9559d6b355f 100644 --- a/CEP/DP3/DPPP/test/tFilter.cc +++ b/CEP/DP3/DPPP/test/tFilter.cc @@ -25,7 +25,7 @@ #include <DPPP/Filter.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StringUtil.h> #include <casa/Arrays/ArrayMath.h> #include <casa/Arrays/ArrayLogical.h> diff --git a/CEP/DP3/DPPP/test/tMedFlagger.cc b/CEP/DP3/DPPP/test/tMedFlagger.cc index 767c478e564..fc3f883ad7f 100644 --- a/CEP/DP3/DPPP/test/tMedFlagger.cc +++ b/CEP/DP3/DPPP/test/tMedFlagger.cc @@ -26,7 +26,7 @@ #include <DPPP/DPInput.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StringUtil.h> #include <casa/Arrays/ArrayMath.h> #include <casa/Arrays/ArrayLogical.h> diff --git a/CEP/DP3/DPPP/test/tPSet.cc b/CEP/DP3/DPPP/test/tPSet.cc index f1b6a8204b4..6ac6264d9db 100644 --- a/CEP/DP3/DPPP/test/tPSet.cc +++ b/CEP/DP3/DPPP/test/tPSet.cc @@ -24,7 +24,7 @@ #include <lofar_config.h> #include <DPPP/PreFlagger.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/LofarLogger.h> #include <casa/Arrays/ArrayIO.h> #include <casa/Quanta/MVTime.h> diff --git a/CEP/DP3/DPPP/test/tParSet.cc b/CEP/DP3/DPPP/test/tParSet.cc deleted file mode 100644 index 37ea477cfc7..00000000000 --- a/CEP/DP3/DPPP/test/tParSet.cc +++ /dev/null @@ -1,57 +0,0 @@ -//# tParSet.cc: Test for class ParSet -//# Copyright (C) 2010 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite 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 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ -//# -//# @author Ger van Diepen - -#include <lofar_config.h> -#include <DPPP/ParSet.h> -#include <Common/LofarLogger.h> - -using namespace LOFAR; -using namespace LOFAR::DPPP; - -void doTest() -{ - ParameterSet parset; - parset.add ("key1", "abc"); - parset.add ("key2", "def"); - parset.add ("key3", "g"); - ParSet pset(parset); - ASSERT (pset.unusedKeys().size() == 3); - ASSERT (pset.getString("key1") == "abc"); - ASSERT (pset.getString("key1", "") == "abc"); - ASSERT (pset.getString("key1a", "12") == "12"); - ASSERT (pset.getString("key3") == "g"); - vector<string> unused = pset.unusedKeys(); - ASSERT (unused.size() == 1); - ASSERT (unused[0] == "key2"); -} - -int main() -{ - try { - doTest(); - } catch (std::exception& x) { - cout << "Unexpected exception: " << x.what() << endl; - return 1; - } - return 0; -} diff --git a/CEP/DP3/DPPP/test/tPhaseShift.cc b/CEP/DP3/DPPP/test/tPhaseShift.cc index 8ce174dc4d7..24a6d6440a5 100644 --- a/CEP/DP3/DPPP/test/tPhaseShift.cc +++ b/CEP/DP3/DPPP/test/tPhaseShift.cc @@ -25,7 +25,7 @@ #include <DPPP/PhaseShift.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StringUtil.h> #include <casa/Arrays/ArrayMath.h> #include <casa/Arrays/ArrayLogical.h> diff --git a/CEP/DP3/DPPP/test/tPreFlagger.cc b/CEP/DP3/DPPP/test/tPreFlagger.cc index af24d6dd9c0..e3ebcddf3e9 100644 --- a/CEP/DP3/DPPP/test/tPreFlagger.cc +++ b/CEP/DP3/DPPP/test/tPreFlagger.cc @@ -27,7 +27,7 @@ #include <DPPP/DPInput.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StringUtil.h> #include <casa/Arrays/ArrayMath.h> #include <casa/Arrays/ArrayLogical.h> diff --git a/CEP/DP3/DPPP/test/tStationAdder.cc b/CEP/DP3/DPPP/test/tStationAdder.cc index a666a8d6fd0..5b21004c854 100644 --- a/CEP/DP3/DPPP/test/tStationAdder.cc +++ b/CEP/DP3/DPPP/test/tStationAdder.cc @@ -26,7 +26,7 @@ #include <DPPP/DPInput.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StringUtil.h> #include <Common/StreamUtil.h> #include <casa/Arrays/ArrayMath.h> diff --git a/CEP/DP3/DPPP/test/tUVWFlagger.cc b/CEP/DP3/DPPP/test/tUVWFlagger.cc index a91b5975336..76dd46ba7ef 100644 --- a/CEP/DP3/DPPP/test/tUVWFlagger.cc +++ b/CEP/DP3/DPPP/test/tUVWFlagger.cc @@ -26,7 +26,7 @@ #include <DPPP/DPInput.h> #include <DPPP/DPBuffer.h> #include <DPPP/DPInfo.h> -#include <DPPP/ParSet.h> +#include <Common/ParameterSet.h> #include <Common/StringUtil.h> #include <casa/Arrays/ArrayMath.h> #include <casa/Arrays/ArrayLogical.h> diff --git a/LCS/Common/include/Common/ParameterSet.h b/LCS/Common/include/Common/ParameterSet.h index 241b80410ae..aee1f7f99ea 100644 --- a/LCS/Common/include/Common/ParameterSet.h +++ b/LCS/Common/include/Common/ParameterSet.h @@ -140,6 +140,10 @@ public: // <br>If theCollection is this collection, nothing will be done. void adoptCollection(const ParameterSet& theCollection, const string& thePrefix = ""); + + // Adds the Key-Values pairs in the argument list. + // It ignores arguments not having the Key=Value syntax. + void adoptArgv (int nr, char const * const argv[]); // @} @@ -340,6 +344,10 @@ public: // @} + // Get all unused parameter names, thus the names of parameters + // that have not been asked for. + vector<string> unusedKeys() const; + // \name Printing // Mostly for debug purposes the collection can be printed. // @{ @@ -425,6 +433,11 @@ inline void ParameterSet::adoptCollection (const ParameterSet& theCollection, co itsSet->adoptCollection (*theCollection.itsSet, thePrefix); } + inline void ParameterSet::adoptArgv (int nr, const char * const argv[]) +{ + itsSet->adoptArgv (nr, argv); +} + inline void ParameterSet::writeFile (const string& theFilename, bool append) const { itsSet->writeFile (theFilename, append); @@ -858,6 +871,11 @@ inline vector<time_t> ParameterSet::getTimeVector(const string& aKey, return itsSet->getTimeVector(aKey, aValue, expandable); } +inline vector<string> ParameterSet::unusedKeys() const +{ + return itsSet->unusedKeys(); +} + } // namespace LOFAR #endif diff --git a/LCS/Common/include/Common/ParameterSetImpl.h b/LCS/Common/include/Common/ParameterSetImpl.h index 359c3b2ab6f..f2e470beb3d 100644 --- a/LCS/Common/include/Common/ParameterSetImpl.h +++ b/LCS/Common/include/Common/ParameterSetImpl.h @@ -31,6 +31,7 @@ #include <Common/ParameterValue.h> #include <Common/LofarTypes.h> #include <Common/lofar_map.h> +#include <Common/lofar_set.h> #include <Common/lofar_string.h> #include <Common/lofar_vector.h> #include <Common/lofar_iostream.h> @@ -125,6 +126,10 @@ public: // thePrefix. void adoptCollection(const ParameterSetImpl& theCollection, const string& thePrefix = ""); + + // Adds the Key-Values pairs in the argument list. + // It ignores arguments not having the Key=Value syntax. + void adoptArgv (int nr, char const * const argv[]); // @} @@ -316,6 +321,9 @@ public: friend std::ostream& operator<<(std::ostream& os, const ParameterSetImpl &thePS); // @} + // Get all unused parameter names. + vector<string> unusedKeys() const; + private: // Copying is not needed, thus not allowed. // @{ @@ -347,6 +355,8 @@ private: int itsCount; // Key comparison mode. const KeyCompare::Mode itsMode; + // The set of keys that have been asked. + mutable set<string> itsAskedParms; }; //# -------------------- Global functions -------------------- diff --git a/LCS/Common/src/ParameterSetImpl.cc b/LCS/Common/src/ParameterSetImpl.cc index b7e1228120e..a1e751b63b5 100644 --- a/LCS/Common/src/ParameterSetImpl.cc +++ b/LCS/Common/src/ParameterSetImpl.cc @@ -104,6 +104,7 @@ ParameterSetImpl::makeSubset(const string& baseKey, // cut off baseString and copy to subset pos = subSet->insert(pos, make_pair(prefix + it->first.substr(base.size()), it->second)); + itsAskedParms.insert (it->first); } return (subSet); @@ -189,6 +190,18 @@ void ParameterSetImpl::adoptCollection(const ParameterSetImpl& theCollection, } } +void ParameterSetImpl::adoptArgv (int nr, char const * const argv[]) +{ + for (int i=0; i<nr; ++i) { + string arg(argv[i]); + // Only add arguments containing an =-sign. + string::size_type eqs = arg.find('='); + if (eqs != string::npos) { + replace (arg.substr(0, eqs), ParameterValue(arg.substr(eqs+1))); + } + } +} + // // readFile // (private) @@ -326,8 +339,12 @@ ParameterSetImpl::findKV(const string& aKey, bool doThrow) const const_iterator iter = find(aKey); - if (iter == end() && doThrow) { + if (iter == end()) { + if (doThrow) { THROW (APSException, formatString("Key %s unknown", aKey.c_str())); + } + } else { + itsAskedParms.insert (aKey); \ } return (iter); @@ -652,4 +669,15 @@ string ParameterSetImpl::fullModuleName(const string& shortKey) const return (""); } +vector<string> ParameterSetImpl::unusedKeys() const +{ + vector<string> vec; + for (const_iterator iter = begin(); iter != end(); ++iter) { + if (itsAskedParms.find (iter->first) == itsAskedParms.end()) { + vec.push_back (iter->first); + } + } + return vec; +} + } // namespace LOFAR diff --git a/LCS/Common/test/tParameterSet.cc b/LCS/Common/test/tParameterSet.cc index d473531adab..d071288f11d 100644 --- a/LCS/Common/test/tParameterSet.cc +++ b/LCS/Common/test/tParameterSet.cc @@ -1,4 +1,4 @@ -//# tParameterSet.cc: Simple testprogrm to test the ParameterSet class. +//# tParameterSet.cc: Program to test the ParameterSet class. //# //# Copyright (C) 2002-2003 //# ASTRON (Netherlands Institute for Radio Astronomy) @@ -272,6 +272,33 @@ int doIt(KeyCompare::Mode mode) return 0; } +void testUsed() +{ + ParameterSet parset; + const char* argv1[] = {"name", "k1=v1", "k2={k2=v2}", "-re"}; + parset.adoptArgv (4, argv1); + ASSERT (parset.getString("k1") == "v1"); + vector<string> unused = parset.unusedKeys(); + ASSERT (unused.size()==1 && unused[0]=="k2"); + ASSERT (parset.getString("k2") == "{k2=v2}"); + unused = parset.unusedKeys(); + ASSERT (unused.size()==0); + const char* argv2[] = {"s1.k1=v1a", "s1.sk1.k2=v2a"}; + parset.adoptArgv (2, argv2); + unused = parset.unusedKeys(); + ASSERT (unused.size()==2); + // Take a subset and check that such keys are marked as used. + ParameterSet subset = parset.makeSubset ("s1."); + unused = parset.unusedKeys(); + // Check the subset. + ASSERT (unused.size()==0); + unused = subset.unusedKeys(); + ASSERT (unused.size()==2); + ASSERT (subset.getString("k1") == "v1a"); + ASSERT (subset.getString("sk1.k2") == "v2a"); + unused = subset.unusedKeys(); + ASSERT (unused.size()==0); +} int main() { @@ -279,6 +306,7 @@ int main() uint fails(0); fails += doIt(KeyCompare::NORMAL); fails += doIt(KeyCompare::NOCASE); + testUsed(); if (fails > 0) { cout << fails << " test(s) failed" << endl; return 1; diff --git a/MAC/Deployment/data/OTDB/DPPP.comp b/MAC/Deployment/data/OTDB/DPPP.comp index c0d7fe4e234..f11d13c47ff 100644 --- a/MAC/Deployment/data/OTDB/DPPP.comp +++ b/MAC/Deployment/data/OTDB/DPPP.comp @@ -193,7 +193,7 @@ node DPPP 4.0.0 development 'node constraint' "DPPP" par steps I vtext - 10 0 ["aoflagger","averager"] - "Names of the steps to perform." par showprogress I bool - 10 0 F - "Show a progress bar?" par showtimings I bool - 10 0 F - "At the end the percentage of elapsed time each step took can be shown" -par checkparset I bool - 10 0 F - "Check if all parameters in parset are used?" +par checkparset I int - 10 0 0 - "Check if all parameters in parset are used? -1=no, 0=warn, 1=fatal" par uselogger I bool - 100 0 T - "Use logging framework for messages?" uses msin 4.0.0 development 1 "Input MeasurementSet" uses msout 4.0.0 development 1 "Output MeasurementSet" -- GitLab