Commit 4e62eea0668f1e20fc7bdcf6efbc7b1ae7f362c6

Authored by Jürgen Knödlseder
1 parent 8e14f9ee

Add error() methods (#3606)

... ... @@ -66,6 +66,7 @@ The following methods have been added:
66 66 - GModelSpectralFunc::energy()
67 67 - GModelSpectralFunc::intensity()
68 68 - GModelSpectralFunc::save()
  69 +- GModelSpectralNodes::error()
69 70 - GSkyMap::correlate()
70 71 - GSkyMap::flux(GSkyRegion&, int&)
71 72 - GSkyMap::flux(GSkyRegions&, int&)
... ... @@ -161,7 +162,8 @@ Implemented GMatrixSparse::row() and GMatrixSparse::add_to_row() methods.
161 162 8. Model module
162 163 ---------------
163 164 Added GModelSpectralBins class that implements statistically independent spectral
164   -bins as the spectral model component (#3606).
  165 +bins as the spectral model component. In addition, added GModelSpectralNodes::error()
  166 +method so that intensity errors can be accessed directly (#3606).
165 167  
166 168 Added methods to GModelSpectralFunc to allow building of a file function
167 169 in memory (#3535).
... ...
include/GModelSpectralBins.hpp
... ... @@ -106,6 +106,7 @@ public:
106 106 void emax(const int& index, const GEnergy& emax);
107 107 double intensity(const int& index) const;
108 108 void intensity(const int& index, const double& intensity);
  109 + double error(const int& index) const;
109 110  
110 111 protected:
111 112 // Protected methods
... ...
include/GModelSpectralNodes.hpp
1 1 /***************************************************************************
2 2 * GModelSpectralNodes.hpp - Spectral nodes model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2017 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -126,6 +126,7 @@ public:
126 126 void energy(const int& index, const GEnergy& energy);
127 127 double intensity(const int& index) const;
128 128 void intensity(const int& index, const double& intensity);
  129 + double error(const int& index) const;
129 130  
130 131 protected:
131 132 // Protected methods
... ...
pyext/GModelSpectralBins.i
... ... @@ -82,6 +82,7 @@ public:
82 82 void emax(const int& index, const GEnergy& emax);
83 83 double intensity(const int& index) const;
84 84 void intensity(const int& index, const double& intensity);
  85 + double error(const int& index) const;
85 86 };
86 87  
87 88  
... ...
pyext/GModelSpectralNodes.i
1 1 /***************************************************************************
2 2 * GModelSpectralNodes.i - Spectral nodes model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2018 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -74,6 +74,7 @@ public:
74 74 void energy(const int& index, const GEnergy& energy);
75 75 double intensity(const int& index) const;
76 76 void intensity(const int& index, const double& intensity);
  77 + double error(const int& index) const;
77 78 };
78 79  
79 80  
... ...
src/model/GModelSpectralBins.cpp
... ... @@ -58,6 +58,7 @@ const GModelSpectralRegistry g_spectral_bins_registry(&g_spectral_bins_seed);
58 58 #define G_EMAX_SET "GModelSpectralBins::emax(int&, GEnergy&)"
59 59 #define G_INTENSITY_GET "GModelSpectralBins::intensity(int&)"
60 60 #define G_INTENSITY_SET "GModelSpectralBins::intensity(int&, double&)"
  61 +#define G_ERROR_GET "GModelSpectralBins::error(int&)"
61 62  
62 63 /* __ Macros _____________________________________________________________ */
63 64  
... ... @@ -1166,6 +1167,31 @@ double GModelSpectralBins::intensity(const int& index) const
1166 1167  
1167 1168  
1168 1169 /***********************************************************************//**
  1170 + * @brief Return intensity error of bin
  1171 + *
  1172 + * @param[in] index Bin index [0,...,bins()-1].
  1173 + * @return Intensity error of bin @p index.
  1174 + *
  1175 + * @exception GException::out_of_range
  1176 + * Index is out of range.
  1177 + *
  1178 + * Returns the intensity error of bin @p index.
  1179 + ***************************************************************************/
  1180 +double GModelSpectralBins::error(const int& index) const
  1181 +{
  1182 + // Raise an exception if index is out of range
  1183 + #if defined(G_RANGE_CHECK)
  1184 + if (index < 0 || index >= bins()) {
  1185 + throw GException::out_of_range(G_ERROR_GET, "Bin index", index, bins());
  1186 + }
  1187 + #endif
  1188 +
  1189 + // Return intensity error
  1190 + return (m_values[index].error());
  1191 +}
  1192 +
  1193 +
  1194 +/***********************************************************************//**
1169 1195 * @brief Set bin intensity
1170 1196 *
1171 1197 * @param[in] index Bin index [0,...,bins()-1].
... ...
src/model/GModelSpectralNodes.cpp
1 1 /***************************************************************************
2 2 * GModelSpectralNodes.cpp - Spectral nodes model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2018 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2021 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -55,6 +55,7 @@ const GModelSpectralRegistry g_spectral_nodes_registry(&amp;g_spectral_nodes_seed);
55 55 #define G_ENERGY_SET "GModelSpectralNodes::energy(int&, GEnergy&)"
56 56 #define G_INTENSITY_GET "GModelSpectralNodes::intensity(int&)"
57 57 #define G_INTENSITY_SET "GModelSpectralNodes::intensity(int&, double&)"
  58 +#define G_ERROR_GET "GModelSpectralNodes::error(int&)"
58 59  
59 60 /* __ Macros _____________________________________________________________ */
60 61  
... ... @@ -1116,6 +1117,31 @@ double GModelSpectralNodes::intensity(const int&amp; index) const
1116 1117  
1117 1118  
1118 1119 /***********************************************************************//**
  1120 + * @brief Return intensity error of node
  1121 + *
  1122 + * @param[in] index Node index [0,...,nodes()-1].
  1123 + * @return Intensity error of node @p index.
  1124 + *
  1125 + * @exception GException::out_of_range
  1126 + * Index is out of range.
  1127 + *
  1128 + * Returns the intensity error of node @p index.
  1129 + ***************************************************************************/
  1130 +double GModelSpectralNodes::error(const int& index) const
  1131 +{
  1132 + // Raise an exception if index is out of range
  1133 + #if defined(G_RANGE_CHECK)
  1134 + if (index < 0 || index >= nodes()) {
  1135 + throw GException::out_of_range(G_ERROR_GET, index, nodes()-1);
  1136 + }
  1137 + #endif
  1138 +
  1139 + // Return intensity error
  1140 + return (m_values[index].error());
  1141 +}
  1142 +
  1143 +
  1144 +/***********************************************************************//**
1119 1145 * @brief Set node intensity
1120 1146 *
1121 1147 * @param[in] index Node index [0,...,nodes()-1].
... ...