diff --git a/CEP/BB/BBS/src/MNS/MeqFunklet.cc b/CEP/BB/BBS/src/MNS/MeqFunklet.cc index 678a48cca3c4c47bc2e071f385b7cbee7ba10972..139ed7a3e3c9078918800f0c40f9c821e5f22474 100644 --- a/CEP/BB/BBS/src/MNS/MeqFunklet.cc +++ b/CEP/BB/BBS/src/MNS/MeqFunklet.cc @@ -24,6 +24,7 @@ #include <BBS/MNS/MeqFunklet.h> #include <BBS/MNS/MeqPolc.h> +#include <BBS/MNS/MeqTabular.h> #include <Common/LofarLogger.h> #include <casa/Arrays/Matrix.h> @@ -80,11 +81,15 @@ MeqFunklet& MeqFunklet::operator= (const MeqFunklet& that) MeqFunklet* MeqFunklet::make (const ParmDB::ParmValue& pvalue, const string& name) { - ASSERTSTR (pvalue.rep().itsType=="polc", - "No 'polc' funklet found for parameter " << name); ASSERTSTR (pvalue.rep().itsShape.size()==2, "No 2-dim funklet found for parameter " << name); - return new MeqPolc(pvalue); + if (pvalue.rep().itsType=="polc") { + return new MeqPolc(pvalue); + } else if (pvalue.rep().itsType=="polc") { + return new MeqTabular(pvalue); + } + ASSERTSTR (false, + "Unknown funklet found for parameter " << name); } int MeqFunklet::makeSolvable (int scidIndex) diff --git a/CEP/BB/BBS/src/MNS/MeqTabular.cc b/CEP/BB/BBS/src/MNS/MeqTabular.cc new file mode 100644 index 0000000000000000000000000000000000000000..a693a165da13f64090ebdb41ee0317eea24d3dfc --- /dev/null +++ b/CEP/BB/BBS/src/MNS/MeqTabular.cc @@ -0,0 +1,97 @@ +//# MeqTabular.cc: A tabular parameter value +//# +//# Copyright (C) 2006 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#include <lofar_config.h> + +#include <BBS/MNS/MeqTabular.h> +#include <BBS/MNS/MeqRequest.h> +#include <BBS/MNS/MeqResult.h> +#include <BBS/MNS/MeqMatrixTmp.h> +#include <Common/LofarLogger.h> + +using namespace casa; + +namespace LOFAR { + + +MeqTabular::MeqTabular (const ParmDB::ParmValue& pvalue) +: MeqFunklet (pvalue) +{ + const ParmDB::ParmValueRep& pval = pvalue.rep(); + ASSERTSTR (pval.itsType == "tabular", + "Funklet in ParmValue is not of type 'tabular'"); +} + +MeqTabular::~MeqTabular() +{} + +MeqTabular* MeqTabular::clone() const +{ + return new MeqTabular(*this); +} + +MeqResult MeqTabular::getResult (const MeqRequest& request, + int nrpert, int pertInx) +{ + ASSERTSTR (nrpert == 0, + "A tabular parameter value cannot be solvable"); + // It is not checked if the domain is valid. + // In that way any value can be used for the default domain [-1,1]. + // Because the values are calculated for the center of each cell, + // it is only checked if the centers are in the tabular domain. + const MeqDomain& reqDomain = request.domain(); + MeqResult result(request.nspid()); + // If there is only one value, the value is independent of x and y. + // Make sure it is turned into a scalar value. + if (itsCoeff.nelements() == 1) { + result.setValue (MeqMatrix(itsCoeff.getDouble())); + } else if (itsCoeff.ny() == 1) { + // The tabular has multiple values in frequency only. + // Get number of steps and values in x and y. + int ndx = request.nx(); + int ndy = request.ny(); + int ncx = itsCoeff.nx(); + int ncy = itsCoeff.ny(); + // Get the step and start values in the domain. + double stepdx = (reqDomain.endX() - reqDomain.startX()) / ndx; + double stepcx = (domain().endX() - domain().startX()) / ncx; + // Evaluate the expression (as double). + const double* coeffData = itsCoeff.doubleStorage(); + // Create matrix for the value itself and keep a pointer to its data. + result.setValue (MeqMatrix(double(0), ndx, ndy)); + double* value = result.getValueRW().doubleStorage(); + // Iterate over all cells in the frequency domain. + double valx = reqDomain.startX(); + for (int i=0; i<ndx; i++) { + valx += stepdx; + } + } + return result; +} + +MeqResult MeqTabular::getAnResult (const MeqRequest& request, + int nrpert, int pertInx) +{ + return getResult (request, nrpert, pertInx); +} + +} diff --git a/CEP/BB/BBS/src/MNS/MeqTabular.h b/CEP/BB/BBS/src/MNS/MeqTabular.h new file mode 100644 index 0000000000000000000000000000000000000000..33b691451f468909ff6e160829acf8b91790aaf6 --- /dev/null +++ b/CEP/BB/BBS/src/MNS/MeqTabular.h @@ -0,0 +1,68 @@ +//# MeqTabular.h: A tabular parameter value +//# +//# Copyright (C) 2006 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#ifndef MNS_MEQTABULAR_H +#define MNS_MEQTABULAR_H + +// \file +// A tabular (non-solvable) parameter value. + +//# Includes +#include <BBS/MNS/MeqFunklet.h> + +namespace LOFAR { + +// \ingroup BBS +// \addtogroup MNS +// @{ + +class MeqTabular: public MeqFunklet +{ +public: + // Create an empty object. + MeqTabular() + {} + + // Create a tabular from a ParmValue object. + MeqTabular (const ParmDB::ParmValue&); + + // Convert a tabular to a ParmValue object. + ParmDB::ParmValue toParmValue() const; + + virtual ~MeqTabular(); + + // Clone the polc. + virtual MeqTabular* clone() const; + + // Calculate the value. + // Perturbations are not allowed. + virtual MeqResult getResult (const MeqRequest&, + int nrpert, int pertInx); + virtual MeqResult getAnResult (const MeqRequest&, + int nrpert, int pertInx); +}; + +// @} + +} + +#endif diff --git a/CEP/BB/BBS/src/Makefile.am b/CEP/BB/BBS/src/Makefile.am index 898d34076c96dcf1eb28ba648a7c6e07de618944..f800eb5379ce7879691bca172a179e831d3822f9 100644 --- a/CEP/BB/BBS/src/Makefile.am +++ b/CEP/BB/BBS/src/Makefile.am @@ -50,6 +50,7 @@ MNS/MeqSourceList.h \ MNS/MeqStatExpr.h \ MNS/MeqStation.h \ MNS/MeqStatUVW.h \ +MNS/MeqTabular.h \ MNS/Pool.h noinst_HEADERS = @@ -102,7 +103,8 @@ MNS/MeqResultVec.cc \ MNS/MeqSourceList.cc \ MNS/MeqStatExpr.cc \ MNS/MeqStation.cc \ -MNS/MeqStatUVW.cc +MNS/MeqStatUVW.cc \ +MNS/MeqTabular.cc include $(top_srcdir)/Makefile.common diff --git a/CEP/BB/BBSKernel/include/BBSKernel/MNS/MeqTabular.h b/CEP/BB/BBSKernel/include/BBSKernel/MNS/MeqTabular.h new file mode 100644 index 0000000000000000000000000000000000000000..33b691451f468909ff6e160829acf8b91790aaf6 --- /dev/null +++ b/CEP/BB/BBSKernel/include/BBSKernel/MNS/MeqTabular.h @@ -0,0 +1,68 @@ +//# MeqTabular.h: A tabular parameter value +//# +//# Copyright (C) 2006 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#ifndef MNS_MEQTABULAR_H +#define MNS_MEQTABULAR_H + +// \file +// A tabular (non-solvable) parameter value. + +//# Includes +#include <BBS/MNS/MeqFunklet.h> + +namespace LOFAR { + +// \ingroup BBS +// \addtogroup MNS +// @{ + +class MeqTabular: public MeqFunklet +{ +public: + // Create an empty object. + MeqTabular() + {} + + // Create a tabular from a ParmValue object. + MeqTabular (const ParmDB::ParmValue&); + + // Convert a tabular to a ParmValue object. + ParmDB::ParmValue toParmValue() const; + + virtual ~MeqTabular(); + + // Clone the polc. + virtual MeqTabular* clone() const; + + // Calculate the value. + // Perturbations are not allowed. + virtual MeqResult getResult (const MeqRequest&, + int nrpert, int pertInx); + virtual MeqResult getAnResult (const MeqRequest&, + int nrpert, int pertInx); +}; + +// @} + +} + +#endif diff --git a/CEP/BB/BBSKernel/src/MNS/MeqFunklet.cc b/CEP/BB/BBSKernel/src/MNS/MeqFunklet.cc index 678a48cca3c4c47bc2e071f385b7cbee7ba10972..139ed7a3e3c9078918800f0c40f9c821e5f22474 100644 --- a/CEP/BB/BBSKernel/src/MNS/MeqFunklet.cc +++ b/CEP/BB/BBSKernel/src/MNS/MeqFunklet.cc @@ -24,6 +24,7 @@ #include <BBS/MNS/MeqFunklet.h> #include <BBS/MNS/MeqPolc.h> +#include <BBS/MNS/MeqTabular.h> #include <Common/LofarLogger.h> #include <casa/Arrays/Matrix.h> @@ -80,11 +81,15 @@ MeqFunklet& MeqFunklet::operator= (const MeqFunklet& that) MeqFunklet* MeqFunklet::make (const ParmDB::ParmValue& pvalue, const string& name) { - ASSERTSTR (pvalue.rep().itsType=="polc", - "No 'polc' funklet found for parameter " << name); ASSERTSTR (pvalue.rep().itsShape.size()==2, "No 2-dim funklet found for parameter " << name); - return new MeqPolc(pvalue); + if (pvalue.rep().itsType=="polc") { + return new MeqPolc(pvalue); + } else if (pvalue.rep().itsType=="polc") { + return new MeqTabular(pvalue); + } + ASSERTSTR (false, + "Unknown funklet found for parameter " << name); } int MeqFunklet::makeSolvable (int scidIndex) diff --git a/CEP/BB/BBSKernel/src/MNS/MeqTabular.cc b/CEP/BB/BBSKernel/src/MNS/MeqTabular.cc new file mode 100644 index 0000000000000000000000000000000000000000..a693a165da13f64090ebdb41ee0317eea24d3dfc --- /dev/null +++ b/CEP/BB/BBSKernel/src/MNS/MeqTabular.cc @@ -0,0 +1,97 @@ +//# MeqTabular.cc: A tabular parameter value +//# +//# Copyright (C) 2006 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#include <lofar_config.h> + +#include <BBS/MNS/MeqTabular.h> +#include <BBS/MNS/MeqRequest.h> +#include <BBS/MNS/MeqResult.h> +#include <BBS/MNS/MeqMatrixTmp.h> +#include <Common/LofarLogger.h> + +using namespace casa; + +namespace LOFAR { + + +MeqTabular::MeqTabular (const ParmDB::ParmValue& pvalue) +: MeqFunklet (pvalue) +{ + const ParmDB::ParmValueRep& pval = pvalue.rep(); + ASSERTSTR (pval.itsType == "tabular", + "Funklet in ParmValue is not of type 'tabular'"); +} + +MeqTabular::~MeqTabular() +{} + +MeqTabular* MeqTabular::clone() const +{ + return new MeqTabular(*this); +} + +MeqResult MeqTabular::getResult (const MeqRequest& request, + int nrpert, int pertInx) +{ + ASSERTSTR (nrpert == 0, + "A tabular parameter value cannot be solvable"); + // It is not checked if the domain is valid. + // In that way any value can be used for the default domain [-1,1]. + // Because the values are calculated for the center of each cell, + // it is only checked if the centers are in the tabular domain. + const MeqDomain& reqDomain = request.domain(); + MeqResult result(request.nspid()); + // If there is only one value, the value is independent of x and y. + // Make sure it is turned into a scalar value. + if (itsCoeff.nelements() == 1) { + result.setValue (MeqMatrix(itsCoeff.getDouble())); + } else if (itsCoeff.ny() == 1) { + // The tabular has multiple values in frequency only. + // Get number of steps and values in x and y. + int ndx = request.nx(); + int ndy = request.ny(); + int ncx = itsCoeff.nx(); + int ncy = itsCoeff.ny(); + // Get the step and start values in the domain. + double stepdx = (reqDomain.endX() - reqDomain.startX()) / ndx; + double stepcx = (domain().endX() - domain().startX()) / ncx; + // Evaluate the expression (as double). + const double* coeffData = itsCoeff.doubleStorage(); + // Create matrix for the value itself and keep a pointer to its data. + result.setValue (MeqMatrix(double(0), ndx, ndy)); + double* value = result.getValueRW().doubleStorage(); + // Iterate over all cells in the frequency domain. + double valx = reqDomain.startX(); + for (int i=0; i<ndx; i++) { + valx += stepdx; + } + } + return result; +} + +MeqResult MeqTabular::getAnResult (const MeqRequest& request, + int nrpert, int pertInx) +{ + return getResult (request, nrpert, pertInx); +} + +} diff --git a/CEP/BB/BBSKernel/src/MNS/MeqTabular.h b/CEP/BB/BBSKernel/src/MNS/MeqTabular.h new file mode 100644 index 0000000000000000000000000000000000000000..33b691451f468909ff6e160829acf8b91790aaf6 --- /dev/null +++ b/CEP/BB/BBSKernel/src/MNS/MeqTabular.h @@ -0,0 +1,68 @@ +//# MeqTabular.h: A tabular parameter value +//# +//# Copyright (C) 2006 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#ifndef MNS_MEQTABULAR_H +#define MNS_MEQTABULAR_H + +// \file +// A tabular (non-solvable) parameter value. + +//# Includes +#include <BBS/MNS/MeqFunklet.h> + +namespace LOFAR { + +// \ingroup BBS +// \addtogroup MNS +// @{ + +class MeqTabular: public MeqFunklet +{ +public: + // Create an empty object. + MeqTabular() + {} + + // Create a tabular from a ParmValue object. + MeqTabular (const ParmDB::ParmValue&); + + // Convert a tabular to a ParmValue object. + ParmDB::ParmValue toParmValue() const; + + virtual ~MeqTabular(); + + // Clone the polc. + virtual MeqTabular* clone() const; + + // Calculate the value. + // Perturbations are not allowed. + virtual MeqResult getResult (const MeqRequest&, + int nrpert, int pertInx); + virtual MeqResult getAnResult (const MeqRequest&, + int nrpert, int pertInx); +}; + +// @} + +} + +#endif diff --git a/CEP/BB/BBSKernel/src/Makefile.am b/CEP/BB/BBSKernel/src/Makefile.am index 898d34076c96dcf1eb28ba648a7c6e07de618944..f800eb5379ce7879691bca172a179e831d3822f9 100644 --- a/CEP/BB/BBSKernel/src/Makefile.am +++ b/CEP/BB/BBSKernel/src/Makefile.am @@ -50,6 +50,7 @@ MNS/MeqSourceList.h \ MNS/MeqStatExpr.h \ MNS/MeqStation.h \ MNS/MeqStatUVW.h \ +MNS/MeqTabular.h \ MNS/Pool.h noinst_HEADERS = @@ -102,7 +103,8 @@ MNS/MeqResultVec.cc \ MNS/MeqSourceList.cc \ MNS/MeqStatExpr.cc \ MNS/MeqStation.cc \ -MNS/MeqStatUVW.cc +MNS/MeqStatUVW.cc \ +MNS/MeqTabular.cc include $(top_srcdir)/Makefile.common