DP3
Parm.h
Go to the documentation of this file.
1 // Parm.h: Class giving access to a parameter
2 //
3 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 
9 
10 #ifndef LOFAR_PARMDB_PARM_H
11 #define LOFAR_PARMDB_PARM_H
12 
13 #include "Grid.h"
14 #include "ParmSet.h"
15 
16 #include <casacore/casa/Arrays/Array.h>
17 
18 namespace dp3 {
19 namespace parmdb {
20 
21 class ParmCache;
22 class ParmValue;
23 class ParmValueSet;
24 class AxisMappingCache;
25 
28 
30 
37 //
45 
46 class Parm {
47  public:
49  Parm(ParmCache&, ParmId parmid);
50 
53  Parm(ParmCache&, const std::string& name);
54 
58  void setSolveGrid(const Grid& solveGrid);
59 
61  unsigned int getCoeffSize(bool useMask = true);
62 
65  std::vector<double> getCoeff(const Grid::Location&, bool useMask = true);
66 
69  std::vector<double> getErrors(const Grid::Location&, bool useMask = true);
70 
76  void setCoeff(const Grid::Location&, const double* values,
77  unsigned int nvalues, const double* errors = nullptr,
78  bool useMask = true);
79 
83  void revertCoeff();
84 
87  const std::vector<double>& getPerturbations() const {
88  return itsPerturbations;
89  }
90 
92  double getPerturbation(unsigned int index) {
93  return itsPerturbations.at(index);
94  }
95 
110  void getResult(casacore::Array<double>& result, const Grid& predictGrid,
111  bool emptyResult = false);
112 
120  void getResult(std::vector<casacore::Array<double>>& result,
121  const Grid& predictGrid, bool perturb);
122 
124  static std::vector<double> copyValues(const casacore::Array<double>& values,
125  const casacore::Array<bool>& mask,
126  bool useMask);
127 
129  static void getResultCoeff(casacore::Array<double>* resultVec,
130  const Grid& predictGrid, const ParmValueSet& pvset,
131  const std::vector<double>& perturbations,
132  AxisMappingCache& axisMappingCache);
133 
135  static void getResultScalar(casacore::Array<double>& result,
136  const Grid& predictGrid, const ParmValue& pval,
137  AxisMappingCache& axisMappingCache);
138 
141  static void getResultScalar(casacore::Array<double>& result,
142  casacore::Array<double>* errors,
143  const Grid& predictGrid,
144  const ParmValueSet& pvset,
145  AxisMappingCache& axisMappingCache);
146 
148  static void fillArrayPV(double* resData, int nrx, int stx, int sty, int endx,
149  int endy, const double* data, const ParmValue& pval,
150  const Grid& predictGrid);
151 
154 
155  private:
156  ParmCache* itsCache;
157  ParmId itsParmId;
158  Grid itsSolveGrid;
159  std::vector<double> itsPerturbations;
160 };
161 
163 
164 } // namespace parmdb
165 } // namespace dp3
166 
167 #endif
Class representing a regular or irregular 2-D grid.
Set of parameters to be used.
This class caches axis mappings. It uses the unique id of the from-axis and to-axis as the key in the...
Definition: AxisMapping.h:102
The envelope class for a 2-D grid with regular or irregular axes. -.
Definition: Grid.h:83
std::pair< size_t, size_t > Location
Define Location: A location on a 2-D grid.
Definition: Grid.h:86
A class dealing with caching and handling ParmDB entries.
Definition: ParmCache.h:28
A class holding information of multiple domains of a parameter. ParmValueSet holds the information of...
Definition: ParmValue.h:146
A class containing the values of a parameter.
Definition: ParmValue.h:39
Class giving access to a parameter.
Definition: Parm.h:46
static void getResultScalar(casacore::Array< double > &result, const Grid &predictGrid, const ParmValue &pval, AxisMappingCache &axisMappingCache)
Get the result for a single ParmValue with an array of scalars.
double getPerturbation(unsigned int index)
Get a particular perturbation.
Definition: Parm.h:92
static void getResultCoeff(casacore::Array< double > *resultVec, const Grid &predictGrid, const ParmValueSet &pvset, const std::vector< double > &perturbations, AxisMappingCache &axisMappingCache)
Evaluate the result for funklet coefficients.
Parm(ParmCache &, ParmId parmid)
Construct the object for the given parmid.
std::vector< double > getErrors(const Grid::Location &, bool useMask=true)
static std::vector< double > copyValues(const casacore::Array< double > &values, const casacore::Array< bool > &mask, bool useMask)
Form the vector from values and mask.
unsigned int getCoeffSize(bool useMask=true)
Get the nr of coefficients.
std::vector< double > getCoeff(const Grid::Location &, bool useMask=true)
void setCoeff(const Grid::Location &, const double *values, unsigned int nvalues, const double *errors=nullptr, bool useMask=true)
void setSolveGrid(const Grid &solveGrid)
static void getResultScalar(casacore::Array< double > &result, casacore::Array< double > *errors, const Grid &predictGrid, const ParmValueSet &pvset, AxisMappingCache &axisMappingCache)
Parm(ParmCache &, const std::string &name)
void calcPerturbations()
Calculate the perturbations.
void getResult(casacore::Array< double > &result, const Grid &predictGrid, bool emptyResult=false)
void getResult(std::vector< casacore::Array< double >> &result, const Grid &predictGrid, bool perturb)
static void fillArrayPV(double *resData, int nrx, int stx, int sty, int endx, int endy, const double *data, const ParmValue &pval, const Grid &predictGrid)
Fill the result array partially for a single ParmValue.
const std::vector< double > & getPerturbations() const
Definition: Parm.h:87
unsigned int ParmId
Define the type of a parmId.
Definition: ParmSet.h:22
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53