GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelPar Class Reference

Model parameter class. More...

#include <GModelPar.hpp>

Inheritance diagram for GModelPar:
GOptimizerPar GBase

Public Member Functions

 GModelPar (void)
 Void constructor. More...
 
 GModelPar (const std::string &name, const double &value)
 Parameter constructor. More...
 
 GModelPar (const std::string &name, const double &factor, const double &scale)
 Parameter constructor. More...
 
 GModelPar (const GModelPar &par)
 Copy constructor. More...
 
virtual ~GModelPar (void)
 Destructor. More...
 
GModelParoperator= (const GModelPar &par)
 Assignment operator. More...
 
GModelParclone (void) const
 Clone model parameter. More...
 
std::string classname (void) const
 Return class name. More...
 
void read (const GXmlElement &xml)
 Extract parameter attributes from XML element. More...
 
void write (GXmlElement &xml) const
 Set or update parameter attributes in XML element. More...
 
- Public Member Functions inherited from GOptimizerPar
 GOptimizerPar (void)
 Void constructor. More...
 
 GOptimizerPar (const std::string &name, const double &value)
 Parameter constructor. More...
 
 GOptimizerPar (const std::string &name, const double &factor, const double &scale)
 Parameter constructor. More...
 
 GOptimizerPar (const GOptimizerPar &par)
 Copy constructor. More...
 
virtual ~GOptimizerPar (void)
 Destructor. More...
 
GOptimizerParoperator= (const GOptimizerPar &par)
 Assignment operator. More...
 
double value (void) const
 Return parameter value. More...
 
double error (void) const
 Return parameter error. More...
 
double gradient (void) const
 Return parameter gradient. More...
 
double min (void) const
 Return parameter minimum boundary. More...
 
double max (void) const
 Return parameter maximum boundary. More...
 
void value (const double &value)
 Set parameter value. More...
 
void error (const double &error)
 Set parameter error. More...
 
void gradient (const double &gradient)
 Set parameter gradient. More...
 
void min (const double &min)
 Set minimum parameter boundary. More...
 
void max (const double &max)
 Set maximum parameter boundary. More...
 
void range (const double &min, const double &max)
 Set minimum and maximum parameter boundaries. More...
 
const double & factor_value (void) const
 Return parameter factor value. More...
 
const double & factor_error (void) const
 Return parameter factor error. More...
 
const double & factor_gradient (void) const
 Return parameter factor gradient. More...
 
const double & factor_min (void) const
 Return parameter minimum factor boundary. More...
 
const double & factor_max (void) const
 Return parameter maximum factor boundary. More...
 
const double & scale (void) const
 Return parameter scale. More...
 
void factor_value (const double &value)
 Set parameter value factor. More...
 
void factor_error (const double &error)
 Set parameter factor error. More...
 
void factor_gradient (const double &gradient) const
 Set parameter factor gradient. More...
 
void factor_min (const double &min)
 Set minimum parameter boundary factor. More...
 
void factor_max (const double &max)
 Set maximum parameter boundary factor. More...
 
void factor_range (const double &min, const double &max)
 Set minimum and maximum parameter boundary factors. More...
 
void scale (const double &scale)
 Set scale factor. More...
 
bool has_min (void) const
 Signal if parameter has minimum boundary. More...
 
bool has_max (void) const
 Signal if parameter has maximum boundary. More...
 
bool has_factor_min (void) const
 Signal if parameter has minimum factor boundary. More...
 
bool has_factor_max (void) const
 Signal if parameter has maximum factor boundary. More...
 
bool has_range (void) const
 Signal if parameter has minimum and maximum boundaries. More...
 
void remove_min (void)
 Removes minimum boundary. More...
 
void remove_max (void)
 Removes maximum boundary. More...
 
void remove_factor_min (void)
 Removes minimum factor boundary. More...
 
void remove_factor_max (void)
 Removes maximum factor boundary. More...
 
void remove_range (void)
 Removes minimum and maximum boundary. More...
 
bool is_free (void) const
 Signal if parameter is free. More...
 
bool is_fixed (void) const
 Signal if parameter is fixed. More...
 
bool has_grad (void) const
 Signal if parameter gradient is computed analytically. More...
 
void free (void)
 Free a parameter. More...
 
void fix (void)
 Fix a parameter. More...
 
void has_grad (const bool &grad)
 Set gradient property. More...
 
void clear (void)
 Clear parameter. More...
 
GOptimizerParclone (void) const
 Clone parameter. More...
 
std::string classname (void) const
 Return class name. More...
 
const std::string & name (void) const
 Return parameter name. More...
 
const std::string & unit (void) const
 Return parameter unit. More...
 
void name (const std::string &name)
 Set parameter name. More...
 
void unit (const std::string &unit)
 Set parameter unit. More...
 
void autoscale (void)
 Autoscale parameter. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print parameter information. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModelPar &par)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
- Protected Member Functions inherited from GOptimizerPar
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GOptimizerPar &par)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Additional Inherited Members

- Protected Attributes inherited from GOptimizerPar
std::string m_name
 Parameter name. More...
 
std::string m_unit
 Parameter unit. More...
 
double m_factor_value
 Parameter factor value. More...
 
double m_factor_error
 Uncertainty in parameter factor value. More...
 
double m_factor_min
 Parameter minimum factor value. More...
 
double m_factor_max
 Parameter maximum factor value. More...
 
double m_factor_gradient
 Function factor gradient. More...
 
double m_scale
 Parameter scaling (true = factor * scale) More...
 
bool m_free
 Parameter is free. More...
 
bool m_has_factor_min
 Parameter has minimum factor boundary. More...
 
bool m_has_factor_max
 Parameter has maximum factor boundary. More...
 
bool m_has_grad
 Parameter has analytic gradient. More...
 

Detailed Description

Model parameter class.

This class implements a model parameter. A model parameter is a numerical value that is used to describe a model. A model parameter has the following attributes:

  • value gives the numerical value of the parameter
  • error gives the statistical uncertainty in the parameter value
  • gradient gives the gradient of a the model with respect to the parameter
  • min gives the minimum value that the parameter value can take
  • max gives the maximum value that the parameter value can take

The parameter attributes are set and retrieved using the value(), error(), gradient(), min() and max() methods, respectively. Furthermore, the range() method is used to simultaneously set the minimum and maximum value of a parameter.

The minimum and maximum values are optional, and existence of these attributes is tested using the has_min() and has_max() methods, respectively. The minimum value, maximum value are removed using the remove_min() and remove_max() methods. Simultaneous removal of minimum and maximum values is done using the remove_range() method.

Each parameter has furthermore the following properties:

  • free specifies whether the parameter should be fitted
  • grad specifies whether the parameter gradient is computed analytically (true) or numerically (false)

The parameter property free is set using the free() and fix() methods and it is retrieved using the is_free() and is_fixed() methods. The attribute grad is set and retrieved using the has has_grad() methods.

Each model parameter is factorized into a factor and a scale term. The GModelPar class stores the factors and the scale factor has data members, and the true values are computed using the following relations:

value    = m_factor_value    * m_scale
error    = m_factor_error    * m_scale
gradient = m_factor_gradient * m_scale
min      = m_factor_min      * m_scale
max      = m_factor_max      * m_scale

The factor and scale terms can be set and retrieved using the factor_value(), factor_error(), factor_gradient(), factor_min(), factor_max() and scale() methods.

Definition at line 87 of file GModelPar.hpp.

Constructor & Destructor Documentation

GModelPar::GModelPar ( void  )

Void constructor.

Definition at line 59 of file GModelPar.cpp.

References init_members().

Referenced by clone().

GModelPar::GModelPar ( const std::string &  name,
const double &  value 
)

Parameter constructor.

Parameters
[in]nameParameter name.
[in]valueParameter value.

Constructs a parameter from a parameter name and a parameter value.

The parameter is auto-scaled, which for a value that differs from zero sets the scale factor to value and the factor_value to unity. For a value of zero, the scale factor will be set to unity and the factor_value will be set to value.

Definition at line 82 of file GModelPar.cpp.

References init_members().

GModelPar::GModelPar ( const std::string &  name,
const double &  factor,
const double &  scale 
)

Parameter constructor.

Parameters
[in]nameParameter name.
[in]factorParameter value factor.
[in]scaleParameter scaling (non-zero value).
Exceptions
GException::invalid_argumentSacle factor of 0 specified.

Constructs a parameter from a parameter name, value factor and scale factor. The scale factor needs to be a non-zero value. If the scale factor is zero, an exception is thrown.

Definition at line 107 of file GModelPar.cpp.

References init_members().

GModelPar::GModelPar ( const GModelPar par)

Copy constructor.

Parameters
[in]parModel parameter.

Definition at line 126 of file GModelPar.cpp.

References copy_members(), and init_members().

GModelPar::~GModelPar ( void  )
virtual

Destructor.

Definition at line 142 of file GModelPar.cpp.

References free_members().

Member Function Documentation

std::string GModelPar::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GModelPar").

Implements GBase.

Definition at line 121 of file GModelPar.hpp.

GModelPar * GModelPar::clone ( void  ) const
virtual

Clone model parameter.

Returns
Pointer to deep copy of model parameter.

Implements GBase.

Definition at line 199 of file GModelPar.cpp.

References GModelPar().

void GModelPar::copy_members ( const GModelPar par)
protected

Copy class members.

Parameters
[in]parModel parameter.

Definition at line 411 of file GModelPar.cpp.

Referenced by GModelPar(), and operator=().

void GModelPar::free_members ( void  )
protected

Delete class members.

Definition at line 421 of file GModelPar.cpp.

Referenced by operator=(), and ~GModelPar().

void GModelPar::init_members ( void  )
protected

Initialise class members.

Definition at line 399 of file GModelPar.cpp.

Referenced by GModelPar(), and operator=().

GModelPar & GModelPar::operator= ( const GModelPar par)

Assignment operator.

Parameters
[in]parModel parameter.
Returns
Model parameter.

Definition at line 164 of file GModelPar.cpp.

References copy_members(), free_members(), init_members(), and GOptimizerPar::operator=().

void GModelPar::read ( const GXmlElement xml)

Extract parameter attributes from XML element.

Parameters
[in]xmlXML element
Exceptions
GException::invalid_valueInvalid combination of parameter attributes encountered.

Extracts the parameter attributes from an XML element of the form

<parameter name=".." value=".." error=".." scale=".." min=".." max="..' free="..">

Each of the attributes are optional, with the following scheme for assigning default values in case that the attribute was not found:

@p name sets @p m_name (defaults to "Unknown")
@p value sets @p m_factor_value (defaults to 0.0)
@p error sets @p m_factor_error (defaults to 0.0)
@p scale sets @p m_scale (defaults to 1.0)
@p min sets @p m_factor_min (will remove_min() if not found)
@p max sets @p m_factor_max (will remove_max() if not found)
@p free sets @p m_free (papameter will be fixed if not found)

Definition at line 229 of file GModelPar.cpp.

References GXmlElement::attribute(), GOptimizerPar::factor_max(), GOptimizerPar::factor_min(), GOptimizerPar::fix(), GOptimizerPar::free(), G_READ, GOptimizerPar::has_max(), GOptimizerPar::has_min(), GOptimizerPar::m_factor_error, GOptimizerPar::m_factor_value, GOptimizerPar::m_name, GOptimizerPar::m_scale, GOptimizerPar::max(), GOptimizerPar::min(), GXmlElement::print(), GOptimizerPar::remove_factor_max(), GOptimizerPar::remove_factor_min(), gammalib::str(), gammalib::todouble(), gammalib::tolower(), and GOptimizerPar::value().

Referenced by GModelSpatialRadialProfileGauss::read(), GModelSpatialRadialProfileDMBurkert::read(), GModelSpatialRadialProfileDMEinasto::read(), GModelSpatialRadialProfileDMZhao::read(), GCOMModelDRM::read(), GCTAModelSpatialGradient::read(), GCOMModelDRBPhibarNodes::read(), GCOMModelDRBPhibarBins::read(), GModelSpatialDiffuseConst::read(), GModelTemporalConst::read(), GCTAModelRadialGauss::read(), GCTAModelRadialPolynom::read(), GModelSpatialDiffuseMap::read(), GModelSpatialRadialGauss::read(), GCTAModelRadialProfile::read(), GModelSpatialRadialDisk::read(), GModelSpatialRadialGeneralGauss::read(), GCTAModelSpatialLookup::read(), GModelTemporalLightCurve::read(), GModelSpatialRadialRing::read(), GModelSpectralBins::read(), GModelSpatialEllipticalDisk::read(), GSPIModelDataSpace::read(), GModelSpectralConst::read(), GModelSpatialEllipticalGauss::read(), GModelSpectralTable::read(), GModelSpatialEllipticalGeneralGauss::read(), GModelSpatialPointSource::read(), GModelSpatialElliptical::read(), GModelSpatialRadial::read(), GModelSpatialDiffuseCube::read(), GModelSpectralFunc::read(), GModelSpectralGauss::read(), GModelSpectralPlaw::read(), GModelSpatialRadialShell::read(), GModelSpectralExpPlaw::read(), GModelSpectralLogParabola::read(), GModelSpectralBrokenPlaw::read(), GModelSpectralSuperExpPlaw::read(), GModelSpectralExpInvPlaw::read(), GModelTemporalPhaseCurve::read(), GModelSpectralPlawPhotonFlux::read(), GModelSpectralPlawEnergyFlux::read(), GModelSpectralNodes::read(), GModelSpectralSmoothBrokenPlaw::read(), GModel::read_scales(), and GCTAModelSkyCube::read_xml_spatial().

void GModelPar::write ( GXmlElement xml) const

Set or update parameter attributes in XML element.

Parameters
[in]xmlXML element.

Sets or updates the parameter attributes in an XML element of the form

<parameter name=".." value=".." error=".." scale=".." min=".." max="..' free="..">

The following attributes will be set:

@p name
@p value
@p error (only in case that the parameter is free)
@p scale
@p min (only in case that a minimum exists)
@p max (only in case that a maximum exists)
@p free

Definition at line 351 of file GModelPar.cpp.

References GXmlElement::attribute(), GOptimizerPar::factor_max(), GOptimizerPar::factor_min(), GOptimizerPar::has_factor_max(), GOptimizerPar::has_factor_min(), GOptimizerPar::is_free(), GOptimizerPar::m_factor_error, GOptimizerPar::m_factor_value, GOptimizerPar::m_name, GOptimizerPar::m_scale, and gammalib::str().

Referenced by GModelSpatialRadialProfileGauss::write(), GModelSpatialRadialProfileDMEinasto::write(), GModelSpatialRadialProfileDMZhao::write(), GModelSpatialRadialProfileDMBurkert::write(), GCOMModelDRM::write(), GCTAModelSpatialGradient::write(), GModelSpatialDiffuseConst::write(), GCOMModelDRBPhibarNodes::write(), GCOMModelDRBPhibarBins::write(), GModelTemporalConst::write(), GCTAModelRadialGauss::write(), GModelSpatialDiffuseMap::write(), GModelSpatialRadialGauss::write(), GCTAModelRadialProfile::write(), GModelSpatialRadialDisk::write(), GModelSpatialRadialGeneralGauss::write(), GCTAModelSpatialLookup::write(), GModelTemporalLightCurve::write(), GModelSpatialRadialRing::write(), GModelSpectralBins::write(), GModelSpatialEllipticalDisk::write(), GModelSpectralTable::write(), GModelSpatialEllipticalGauss::write(), GModelSpectralConst::write(), GModelSpatialEllipticalGeneralGauss::write(), GModelSpatialPointSource::write(), GModelSpatialElliptical::write(), GModelSpatialRadial::write(), GModelSpatialDiffuseCube::write(), GModelSpectralFunc::write(), GModelSpectralGauss::write(), GModelSpectralPlaw::write(), GModelSpatialRadialShell::write(), GModelSpectralExpPlaw::write(), GModelSpectralLogParabola::write(), GModelSpectralBrokenPlaw::write(), GModelSpectralSuperExpPlaw::write(), GModelSpectralExpInvPlaw::write(), GModelTemporalPhaseCurve::write(), GModelSpectralPlawPhotonFlux::write(), GModelSpectralPlawEnergyFlux::write(), GModelSpectralNodes::write(), GModelSpectralSmoothBrokenPlaw::write(), and GCTAModelSkyCube::write_xml_spatial().


The documentation for this class was generated from the following files: