diff --git a/CEP/DP3/DPPP/include/DPPP/AORFlagger.h b/CEP/DP3/DPPP/include/DPPP/AORFlagger.h index 1d9a71928fafb144afabf975c62e98179a41c149..93a29d66ee89c8b482580331b5c6c3e174dbf48a 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 06b11b4c5b17c77682cec057ce96d36ea8fc76f5..f137ef49baebfe023b63d3ae0a0a511b57dceb2f 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 7f83ace2753098399f3f912ccfaf8c97aa3d1b0a..7fa3c694f3477d1b045d2ade325b4fdf7d2dc1c4 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 5ecc418523b596b7bec6eba3bb425d377163c75a..82df68d72afc7088885970b97b954e1494100068 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 0d8cbbca992faa983e07fa6147bc1203a11b46cb..8215f2383e12162f511a6bd992366e01ada4f2a6 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 3ba728f3d46e3ae23aab96c0d883dfaf7d1abd06..d00f0a8771f54493534187e7a42355a4a9aeec85 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 25b8258a8d695b16cbd46553d4fd2de653c07650..ffe995a871730abd92f78adb376acabc7e578668 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 ee63f38274933208b913bcfcabb5ad47766a4634..2ebe3e237017226bd1254d9b2670139eed01daf2 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 7a8fee17554082d031caae536d2d21083d24e2f8..92d7a596d2a0c185cf7b6f0660268097ab77ebb8 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 62ba12d5494b726e9871a30e6f068ed07aa6bc81..5d86df4ca81355e3650402d16df6d071611698be 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 49f84e208aebb277a1bae8e0535d579ab9420c5e..acb87da13ef10645b0d76b9cf8fb575968f87e9d 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 7d32aa282d0471c735b5dd5d26f8ba8b75f6473f..fad5c9432cdebac548b5a15d83e87276174fbdea 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 4e3e17434c7b373d9daad5ca64802c571feccb5a..3410d28bab401f92f322098fab2efcde1891dc9c 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 35623820d6486b0a3c4a912853753a41acd8471b..6a9c2255fee485420725afca95a178414b254dc5 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 69f5baa1ecb6f2c8d671962c1962acf7a61f1fed..0000000000000000000000000000000000000000 --- 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 13421919feba2ef8bbb92bccafd38440d4d5dda5..4018a9b06b5e5671e933495b2c5564697661f5a5 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 baa8c937b6acfb204930eff4a48cfcf1b5c17788..b335bc8c0714a354f5fa8f16d2c0e004dc21f7ee 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 755962612147f65330480876c0bf6d996084ad7d..3cd95859eae663f27a826436276abb2a855a58b0 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 f3a6b32adcfc5ccc38439cfa2d41fca814c231ed..3642f190ea3c8535812656baff027ee5cd241220 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 81eda1d4a83f92dc36c9dab33487ba162e241817..d74578eb729c90d670764e53429279c4e0c00eb7 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 24bf4720fdf494913ad9fd99267049891304ff28..028148c1a8d645c3f85f346de77bb241c14a6180 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 d5d3f45f5c15a820b04775f493d6f066c8cff951..b01f42050979337999def471bb6bf87d69c3ceaf 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 9c3b4f87d6d703f136684d223fa25ebc4e234bd2..708486fdc2d2f54c9b9f8808bf3a83f68c938fc9 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 832f074d5028f8e1cb453b1109a525f2d24d7500..771580217e1a948f350e8a2138a89160c8f2dcfe 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 3e3ec6b7925b5889d9d0d18dfb4d7d3ad8c86889..9bab26e89100cd29fece130ec5fcacc055583144 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 34a33b0e0c22d9d79085a8fe58115ca898ac8487..a74d159cf27710d586fe5cb6d218c86bb2bec029 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 9b4bb455897a5cd11f483f02ef27d8ac38481ae4..e6f77493247038839e59c1927047d760ef4a2da0 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 aa2ad7b48e888584689259441cf81484a745471b..edd1e3661870b965025b5e31290a1acc231fcaa7 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 dfe0c6eafd8778840759c63c9679cf51de51af08..61326aef40eb534546eec3e6f4c5e7a4f021bcf8 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 2825aed88f70e5a15fce7879d7d80946e4277855..89baabe4db45b1c91683eb6db74fdeeec57dd2ad 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 5a3f6b5cf9f382d80d02cfec564a4acbb1fd3284..a075a61cac358b13c7ce5b014738d16551be77c2 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 a42a67ab49b1fb9bee81021b71b9d7ef3c0d429b..32ec6e6b8ab8590f9e4e9114ecba6b3ab51deaf5 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 a7b24b40d4e35f8d93fcbdd667bbd129dd1ee78e..d127fd3e2eaf9a84ebf2ca7a8e77a8e4144f9b22 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 61e1430f2f2d1a35813f4f26a080f7c4033174f3..0000000000000000000000000000000000000000 --- 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 c24752220567c8641b180230feb544fb755f1942..4501069dcd8190ae3b017486a06be79e94b218a9 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 2e24393113dba9a21f85ac3c83ec3e153969b5f5..f9c6715efc9adb7bfebc7c24491ceaa4df5de5b2 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 76356ad5669a275280464be413c126310cc1da23..1f6768bd5ac613488315620e3d7865763887c473 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 dd70fc6ad2dd0d2db5c416654312e456fd21c15d..c5a0a5fea741c030d12320dc53b16dcaf26a56dd 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 b6bf34bbbfd74dbeeacefe887becddd05e649862..64f5d62d6a46acb026dc1fd8937272a8adb69fa9 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 ae2c060ad83c42eb052dc9751169cc6f409a9620..386a7f482f0c44462123565a24fadc936afd18cf 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 d6c4b9b4af5e25a7af10dfd00a0a2e161a11fc9c..80f7b2cee5d2fdd8d1a7d0eb9162ec4e6cb9d5cd 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 fc125a99b6046db3d4073fcc517cb04341cf012f..af1ba2f32b9668fed4852fc9f95fe8f10d07f69f 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 fec79fc9913705b1cefd410b2206718fc87f5d60..97540f1524cb3aa9a15cbd2b45e2e34aec5e487d 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 758eb6633fb84583d32ef0231ce536503587ca88..9559d6b355fc9ba9c73098cc37dc0bb1c83d8116 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 767c478e564767cbe8b213c3efd694e6e1dae4e7..fc3f883ad7fb458f4a249669d9ea5442d87c105d 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 f1b6a8204b4e8ccd85c3fcff12dcd5098caae539..6ac6264d9db38b9c006d944e5ed7c292ddcbeff4 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 37ea477cfc72fec6013461f64293596cc86af38d..0000000000000000000000000000000000000000 --- 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 8ce174dc4d7b38283a7437b93a148028a5dcb435..24a6d6440a5ebd70a75ab1c852414af8fc06a274 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 af24d6dd9c0fc2e44351d925acf2581472c139aa..e3ebcddf3e91dc6b73d61aada1ca573a5cfea0c5 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 a666a8d6fd0977a7846e94ec45a8ff9ab7d5f060..5b21004c8541b6ef0d3fb5b999cb2971d8481bc2 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 a91b59753368a57971173158cbb6cd9b4427cce2..76dd46ba7ef073e68bf28efa5a227e76b659b58a 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 241b80410ae7ed0c7c3eb29be392dcc109adb69a..aee1f7f99ea5897e05fc88f83b90d361f88e8dbf 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 359c3b2ab6f9856008bb85653fc9d26a5513ebc4..f2e470beb3d1f84533254472833b7ff6d0b9e153 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 b7e1228120eb8c9d0f078fed428ed8627fcc9feb..a1e751b63b5d969245a093e6e32e3788fd2863ff 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 d473531adabaa049e40cf1a7464274c739b4c38e..d071288f11deae7fddb6cd8bb6383d90dfb28931 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 c0d7fe4e234503c533f7d5491f1014af8910cc95..f11d13c47ff97da970cc377b7a15bb51c8d52dc1 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"