36 #define G_ACCESS "GModel::operator[](std::string&)"
37 #define G_AT "GModel::at(int&)"
38 #define G_SCALE "GModelPar& GModel::scale(int&)"
39 #define G_WRITE_SCALES "GModel::write_scales(GXmlElement&)"
135 if (
this != &model) {
169 for (; index <
size(); ++index) {
176 if (index >=
size()) {
177 std::string msg =
"Model parameter \""+name+
"\" not found in model. "
178 "Please specify a valid model parameter name.";
203 for (; index <
size(); ++index) {
210 if (index >=
size()) {
211 std::string msg =
"Model parameter \""+name+
"\" not found in model. "
212 "Please specify a valid model parameter name.";
242 if (index < 0 || index >=
size()) {
266 if (index < 0 || index >=
size()) {
290 for (
int i = 0; i <
size(); ++i) {
348 for (
int i = 0; i < inst.size(); ++i) {
372 if (index < 0 || index >=
scales()) {
397 if (index < 0 || index >=
scales()) {
423 scale.
name(instrument);
428 for (
int i = 0; i <
m_scales.size(); ++i) {
459 for (
int i = 0; i <
m_scales.size(); ++i) {
508 for (
int i = 0; i <
m_ids.size(); ++i) {
541 for (
int i = 0; i <
id.size(); ++i) {
571 const std::string&
id)
const
593 if (valid && !
m_ids.empty() && !
id.empty()) {
599 for (
int i = 0; i <
m_ids.size(); ++i) {
600 if (
id ==
m_ids[i]) {
733 if (instruments.length() > 0) {
734 xml.
attribute(
"instrument", instruments);
738 std::string identifiers =
ids();
739 if (identifiers.length() > 0) {
750 std::string ts_calc =
tscalc() ?
"1" :
"0";
789 result.append(
"all");
799 result.append(
"Computation requested");
804 if (!
m_ids.empty()) {
805 for (
int i = 0; i <
m_ids.size(); ++i) {
809 result.append(
m_ids[i]);
813 result.append(
"all");
861 int nscales = scales->
elements(
"instrument");
864 for (
int i = 0; i < nscales; ++i) {
911 scale = xml.
append(
"scaling");
912 for (
int i = 0; i < num; ++i) {
919 scale = xml.
element(
"scaling", 0);
925 " scale elements in XML file does not correspond "
927 " elements. Please verify the XML format.";
930 int npars = scale->
elements(
"instrument");
932 std::string msg =
"Number of "+
gammalib::str(npars)+
" \"instrument\" "
933 "scale elements in XML file does not correspond to "
935 " elements. Please verify the XML format.";
940 for (
int i = 0; i < num; ++i) {
virtual ~GModel(void)
Destructor.
void free_members(void)
Delete class members.
int scales(void) const
Return number of scale parameters in model.
Abstract model base class interface definition.
const std::string & name(void) const
Return parameter name.
std::string print_attributes(void) const
Print model attributes.
int size(void) const
Return number of associations in container.
double m_ts
Test Statistic of the model.
GModelAssociations m_associations
Model associations.
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
virtual int elements(void) const
Return number of GXMLElement children of node.
void clear(void)
Clear object.
std::string ids(void) const
Returns observation identifiers to which model applies.
bool m_tscalc
Signals if TS should be computed.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
bool has_par(const std::string &name) const
Checks if parameter name exists.
bool m_has_ts
Signals if TS is available.
std::vector< GModelPar > m_scales
Model instrument scale factors.
bool m_has_tscalc
Signals if tscalc attribute is available.
void write(GXmlElement &xml) const
Write models into XML element.
std::vector< GModelPar * > m_pars
Pointers to all model parameters.
int size(void) const
Return number of parameters in model.
void init_members(void)
Initialise class members.
bool is_valid(const std::string &instruments, const std::string &ids) const
Verifies if model is valid for a given instrument and identifier.
std::vector< std::string > m_instruments
Instruments to which model applies.
void copy_members(const GModel &model)
Copy class members.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
GModelPar & at(const int &index)
Returns reference to model parameter by index.
virtual GModelPar & operator[](const int &index)
Returns reference to model parameter by index.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
const std::string & name(void) const
Return parameter name.
void fix(void)
Fix a parameter.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
std::vector< std::string > m_ids
Identifiers to which model applies.
std::string instruments(void) const
Returns instruments to which model applies.
const double & ts(void) const
Return Test Statistic value.
GModelPar & scale(const int &index)
Returns reference to scale parameter by index.
void write_attributes(GXmlElement &xml) const
Write model attributes.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
void read(const GXmlElement &xml)
Read model associations from XML document.
bool is_empty(void) const
Signals if there are no associations in container.
std::string m_name
Model name.
GModel(void)
Void constructor.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double value(void) const
Return parameter value.
virtual std::string type(void) const =0
Exception handler interface definition.
std::vector< int > m_eval_inx
void read_scales(const GXmlElement &xml)
Read instrument scales from XML element.
void read_attributes(const GXmlElement &xml)
Read model attributes.
virtual GModel & operator=(const GModel &model)
Assignment operator.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void write_scales(GXmlElement &xml) const
Write instrument scales into XML element.
const bool & tscalc(void) const
Return Test Statistic computation flag.
double todouble(const std::string &arg)
Convert string into double precision value.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.