Commit dcbb4f71af30cefd6acd84a14f38df4096e85551

Authored by Jürgen Knödlseder
1 parent 500774b2

Integrate code

ChangeLog
1   -2018-06-21
  1 +2018-07-02
2 2  
3 3 * Version 1.6.0 released
4 4 ========================
... ... @@ -12,6 +12,7 @@
12 12 Speed up computation of diffuse map models for CTA (#2466)
13 13 Enhance GModelSpatialRadialProfileGauss class (#2463)
14 14 Increase integration precision for CTA diffuse model response (#2458)
  15 + Add GModelSpectralExponential class (#2454)
15 16 Add GCTAModelRadialAcceptance model component setter methods
16 17 Handle observation-specific energy thresholds in CTA On/Off analysis (#2429)
17 18 Add GCTAEdisp::prob_erecobin() method (#2422)
... ...
1 1 New Features and Important Changes in GammaLib 1.6.0
2 2  
3   -25 June 2018
  3 +2 July 2018
4 4  
5 5  
6 6 1. Introduction
... ... @@ -12,7 +12,7 @@ made since the last release of GammaLib.
12 12 2. Public interface modifications
13 13 ---------------------------------
14 14 The following classes have been added:
15   -- none
  15 +- GModelSpectralExponential
16 16  
17 17 The following classes have been removed:
18 18 - none
... ... @@ -132,6 +132,9 @@ None
132 132  
133 133 8. Model module
134 134 ---------------
  135 +The GModelSpectralExponential class was added that implements an exponential
  136 +function that can be used for EBL studies (#2454).
  137 +
135 138 Add a GModelSpatialRadialProfileGauss() position and width constructor, add
136 139 GModelSpatialRadialProfileGauss::sigma() getter and setter methods, and avoid
137 140 recomputations if the position of the Gaussian changed (#2463).
... ...
doc/source/admin/release_history/1.6.rst
... ... @@ -64,6 +64,8 @@ Improvements
64 64 New features
65 65 ------------
66 66  
  67 +* [`2454 <https://cta-redmine.irap.omp.eu/issues/2454>`_] -
  68 + Add ``GModelSpectralExponential`` class
67 69 * Add ``GCTAModelRadialAcceptance`` model component setter methods
68 70  
69 71  
... ...
doc/source/users/user_manual/modules/model.rst
... ... @@ -943,23 +943,28 @@ The XML format for specifying a multiplicative spectral model is:
943 943 </spectrum>
944 944 </spectrum>
945 945  
946   - Exponential model
947   - ====================
948 946  
949   - Yet another composite model is the exponential class model that is
950   - implemented by the :doxy:`GModelSpectralExponential class`. The class
951   -computes The exponential of a spectral model.
  947 +Exponential model
  948 +====================
952 949  
953   -The XML format for specifying a multiplicative spectral model is:
  950 +Yet another composite model is the exponential model that is implemented by
  951 +the :doxy:`GModelSpectralExponential class`. The class computes the
  952 +exponential of a spectral model
  953 +
  954 +.. math::
  955 + M_{\rm spectral}(E | t) = \exp \left( M_{\rm spectral}(E | t) \right)
  956 +
  957 +where :math:`M_{\rm spectral}(E | t)` is any spectral model component.
  958 +
  959 +The XML format for specifying an exponential spectral model is:
954 960  
955 961 .. code-block:: xml
956 962  
957 963 <spectrum type="Exponential">
958 964 <spectrum type="Constant">
959   - <parameter name="Normalization" scale="-10." value="3.5"
960   - min="0." max="1000." free="1"/>
961   - </spectrum>
962   - </spectrum>
  965 + <parameter name="Normalization" scale="-1.0" value="3.5" min="0.0" max="1000." free="1"/>
  966 + </spectrum>
  967 + </spectrum>
963 968  
964 969  
965 970 Temporal components
... ...
include/GException.hpp
... ... @@ -619,11 +619,6 @@ public:
619 619 xml_name_not_found(std::string origin, std::string type,
620 620 std::string message = "");
621 621 };
622   - class xml_invalid_nodenum : public GExceptionHandler {
623   - public:
624   - xml_invalid_nodenum(std::string origin, GXmlElement xml,
625   - std::string message = "");
626   - };
627 622 class xml_invalid_parnum : public GExceptionHandler {
628 623 public:
629 624 xml_invalid_parnum(std::string origin, GXmlElement xml,
... ...
include/GModelSpectralExponential.hpp
1 1 /***************************************************************************
2 2 * GModelSpectralExponential.hpp - Exponential spectral model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2018- by Luigi Tibaldo *
  4 + * copyright (C) 2018 by Luigi Tibaldo *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -44,9 +44,9 @@ class GXmlElement;
44 44 /***********************************************************************//**
45 45 * @class GModelSpectralExponential
46 46 *
47   - * @brief Multiplicative spectral model class
  47 + * @brief Exponential spectral model class
48 48 *
49   - * This class implements a spectral model that is the expoenential of a
  49 + * This class implements a spectral model that is the exponential of a
50 50 * spectral model component. The spectral model component can be defined in
51 51 * an XML file, or using the exponent() method.
52 52 ***************************************************************************/
... ... @@ -64,28 +64,28 @@ public:
64 64 virtual GModelSpectralExponential& operator=(const GModelSpectralExponential& model);
65 65  
66 66 // Implemented pure virtual methods
67   - virtual void clear(void);
68   - virtual GModelSpectralExponential* clone(void) const;
69   - virtual std::string classname(void) const;
70   - virtual std::string type(void) const;
71   - virtual double eval(const GEnergy& srcEng,
72   - const GTime& srcTime = GTime(),
73   - const bool& gradients = false) const;
74   - virtual double flux(const GEnergy& emin,
75   - const GEnergy& emax) const;
76   - virtual double eflux(const GEnergy& emin,
77   - const GEnergy& emax) const;
78   - virtual GEnergy mc(const GEnergy& emin,
79   - const GEnergy& emax,
80   - const GTime& time,
81   - GRan& ran) const;
82   - virtual void read(const GXmlElement& xml);
83   - virtual void write(GXmlElement& xml) const;
84   - virtual std::string print(const GChatter& chatter = NORMAL) const;
  67 + virtual void clear(void);
  68 + virtual GModelSpectralExponential* clone(void) const;
  69 + virtual std::string classname(void) const;
  70 + virtual std::string type(void) const;
  71 + virtual double eval(const GEnergy& srcEng,
  72 + const GTime& srcTime = GTime(),
  73 + const bool& gradients = false) const;
  74 + virtual double flux(const GEnergy& emin,
  75 + const GEnergy& emax) const;
  76 + virtual double eflux(const GEnergy& emin,
  77 + const GEnergy& emax) const;
  78 + virtual GEnergy mc(const GEnergy& emin,
  79 + const GEnergy& emax,
  80 + const GTime& time,
  81 + GRan& ran) const;
  82 + virtual void read(const GXmlElement& xml);
  83 + virtual void write(GXmlElement& xml) const;
  84 + virtual std::string print(const GChatter& chatter = NORMAL) const;
85 85  
86 86 // Other methods
87   - void exponent(const GModelSpectral* spec);
88   - const GModelSpectral* exponent(void) const;
  87 + void exponent(const GModelSpectral* spec);
  88 + const GModelSpectral* exponent(void) const;
89 89  
90 90 protected:
91 91 // Protected methods
... ... @@ -123,10 +123,9 @@ protected:
123 123 }
124 124 };
125 125  
126   -
127 126 // Protected members
128   - std::string m_type; //!< Model type
129   - GModelSpectral* m_exponent; //!< Exponent
  127 + std::string m_type; //!< Model type
  128 + GModelSpectral* m_exponent; //!< Exponent model component
130 129  
131 130 // MC cache
132 131 mutable GModelSpectralNodes m_mc_spectrum; //!< MC spectrum cache
... ...
include/Makefile.am
... ... @@ -183,7 +183,7 @@ pkginclude_HEADERS = GammaLib.hpp \
183 183 GModelSpectralConst.hpp \
184 184 GModelSpectralExpInvPlaw.hpp \
185 185 GModelSpectralExpPlaw.hpp \
186   - GModelSpectralExponential.hpp \
  186 + GModelSpectralExponential.hpp \
187 187 GModelSpectralSuperExpPlaw.hpp \
188 188 GModelSpectralFunc.hpp \
189 189 GModelSpectralGauss.hpp \
... ...
pyext/GModelSpectralExponential.i
1 1 /***************************************************************************
2 2 * GModelSpectralExponential.i - Exponential spectral model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2018- Luigi Tibaldo *
  4 + * copyright (C) 2018 Luigi Tibaldo *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -49,28 +49,27 @@ public:
49 49 virtual GModelSpectralExponential& operator=(const GModelSpectralExponential& model);
50 50  
51 51 // Implemented pure virtual methods
52   - virtual void clear(void);
53   - virtual GModelSpectralExponential* clone(void) const;
54   - virtual std::string classname(void) const;
55   - virtual std::string type(void) const;
56   - virtual double eval(const GEnergy& srcEng,
57   - const GTime& srcTime = GTime(),
58   - const bool& gradients = false) const;
59   - virtual double flux(const GEnergy& emin,
60   - const GEnergy& emax) const;
61   - virtual double eflux(const GEnergy& emin,
62   - const GEnergy& emax) const;
63   - virtual GEnergy mc(const GEnergy& emin,
64   - const GEnergy& emax,
65   - const GTime& time,
66   - GRan& ran) const;
67   - virtual void read(const GXmlElement& xml);
68   - virtual void write(GXmlElement& xml) const;
69   - virtual std::string print(const GChatter& chatter = NORMAL) const;
  52 + virtual void clear(void);
  53 + virtual GModelSpectralExponential* clone(void) const;
  54 + virtual std::string classname(void) const;
  55 + virtual std::string type(void) const;
  56 + virtual double eval(const GEnergy& srcEng,
  57 + const GTime& srcTime = GTime(),
  58 + const bool& gradients = false) const;
  59 + virtual double flux(const GEnergy& emin,
  60 + const GEnergy& emax) const;
  61 + virtual double eflux(const GEnergy& emin,
  62 + const GEnergy& emax) const;
  63 + virtual GEnergy mc(const GEnergy& emin,
  64 + const GEnergy& emax,
  65 + const GTime& time,
  66 + GRan& ran) const;
  67 + virtual void read(const GXmlElement& xml);
  68 + virtual void write(GXmlElement& xml) const;
70 69  
71 70 // Other methods
72   - void exponent(const GModelSpectral* spec);
73   - const GModelSpectral* exponent(void) const;
  71 + void exponent(const GModelSpectral* spec);
  72 + const GModelSpectral* exponent(void) const;
74 73  
75 74 };
76 75  
... ... @@ -86,7 +85,7 @@ public:
86 85 def __getstate__(self):
87 86 xml = gammalib.GXmlElement()
88 87 self.write(xml)
89   - state = xml,
  88 + state = (xml,)
90 89 return state
91 90 def __setstate__(self, state):
92 91 self.__init__(state[0])
... ...
src/model/GException_model.cpp
... ... @@ -174,25 +174,6 @@ GException::model_invalid_temporal::model_invalid_temporal(std::string origin,
174 174 return;
175 175 }
176 176  
177   -/***********************************************************************//**
178   - * @brief Invalid number of nodes in XML element
179   - *
180   - * @param[in] origin Method that throws the error.
181   - * @param[in] xml XML element.
182   - * @param[in] message Optional error message.
183   - ***************************************************************************/
184   -GException::model_invalid_nodenum::model_invalid_nodenum(std::string origin,
185   - GXmlElement xml,
186   - std::string message)
187   -{
188   - // Set origin and message
189   - m_origin = origin;
190   - m_message = "Invalid number of nodes found in XML element. " +
191   - message;
192   -
193   - // Return
194   - return;
195   -}
196 177  
197 178 /***********************************************************************//**
198 179 * @brief Invalid number of model parameters in XML element
... ...
src/model/GModelSpectralExponential.cpp
1 1 /***************************************************************************
2 2 * GModelSpectralExponential.cpp - Exponential spectral model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2018- by Lluigi Tibaldo *
  4 + * copyright (C) 2018 by Luigi Tibaldo *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -45,12 +45,9 @@ const GModelSpectralExponential g_spectral_expo_seed;
45 45 const GModelSpectralRegistry g_spectral_expo_registry(&g_spectral_expo_seed);
46 46  
47 47 /* __ Method name definitions ____________________________________________ */
48   -#define G_MC "GModelSpectralExponential::mc(GEnergy&, GEnergy&, GTime&, "\
  48 +#define G_MC "GModelSpectralExponential::mc(GEnergy&, GEnergy&, GTime&, "\
49 49 "GRan&)"
50   -#define G_WRITE "GModelSpectralExponential::write(GXmlElement&)"
51   -#define G_READ "GModelSpectralExponential::read(GXmlElement&)"
52   -#define G_SETEXPONENT "GModelSpectralExponential::exponent(GModelSpectral&)"
53   -#define G_RETURNEXPONENT "GModelSpectralExponential::exponent(void)"
  50 +#define G_WRITE "GModelSpectralExponential::write(GXmlElement&)"
54 51  
55 52  
56 53 /*==========================================================================
... ... @@ -63,7 +60,7 @@ const GModelSpectralRegistry g_spectral_expo_registry(&amp;g_spectral_expo_seed);
63 60 * @brief Void constructor
64 61 ***************************************************************************/
65 62 GModelSpectralExponential::GModelSpectralExponential(void) :
66   - GModelSpectral()
  63 + GModelSpectral()
67 64 {
68 65 // Initialise private members for clean destruction
69 66 init_members();
... ... @@ -78,12 +75,11 @@ GModelSpectralExponential::GModelSpectralExponential(void) :
78 75 *
79 76 * @param[in] xml XML element containing spectral model information.
80 77 *
81   - * Constructs a Exponential spectral model by extracting information from
82   - * an XML element. See the read() method for more information about the
83   - * expected structure of the XML element.
  78 + * Constructs an exponential spectral model by extracting information from
  79 + * an XML element.
84 80 ***************************************************************************/
85 81 GModelSpectralExponential::GModelSpectralExponential(const GXmlElement& xml) :
86   - GModelSpectral()
  82 + GModelSpectral()
87 83 {
88 84 // Initialise members
89 85 init_members();
... ... @@ -95,15 +91,16 @@ GModelSpectralExponential::GModelSpectralExponential(const GXmlElement&amp; xml) :
95 91 return;
96 92 }
97 93  
  94 +
98 95 /***********************************************************************//**
99 96 * @brief Model constructor
100 97 *
101   - * @param[in] GModelSpectral spectral model
  98 + * @param[in] spec Spectral model
102 99 *
103 100 * Constructs exponential spectral model by setting the exponent model.
104 101 ***************************************************************************/
105 102 GModelSpectralExponential::GModelSpectralExponential(const GModelSpectral* spec) :
106   - GModelSpectral()
  103 + GModelSpectral()
107 104 {
108 105 // Initialise members
109 106 init_members();
... ... @@ -122,7 +119,7 @@ GModelSpectralExponential::GModelSpectralExponential(const GModelSpectral* spec)
122 119 * @param[in] model Exponential spectral model.
123 120 ***************************************************************************/
124 121 GModelSpectralExponential::GModelSpectralExponential(const GModelSpectralExponential& model) :
125   - GModelSpectral(model)
  122 + GModelSpectral(model)
126 123 {
127 124 // Initialise members
128 125 init_members();
... ... @@ -246,8 +243,8 @@ GModelSpectralExponential* GModelSpectralExponential::clone(void) const
246 243 * where \f${P_{\rm i}}\f$ is the i-th parameter.
247 244 ***************************************************************************/
248 245 double GModelSpectralExponential::eval(const GEnergy& srcEng,
249   - const GTime& srcTime,
250   - const bool& gradients) const
  246 + const GTime& srcTime,
  247 + const bool& gradients) const
251 248 {
252 249 // Initialise result
253 250 double value = 0.0;
... ... @@ -257,26 +254,27 @@ double GModelSpectralExponential::eval(const GEnergy&amp; srcEng,
257 254  
258 255 // Calculate exponent value
259 256 value = m_exponent->eval(srcEng, srcTime, gradients);
260   - // calculate exponential
261   - value = exp(value);
262   -
  257 +
  258 + // Calculate exponential
  259 + value = std::exp(value);
  260 +
263 261 // Modify gradients if requested
264 262 if (gradients) {
265   -
266   - // Loop over model parameters
267   - for (int ipar = 0; ipar < m_exponent->size(); ++ipar) {
268   -
269   - // Get reference to model parameter
270   - GModelPar& par = m_exponent->operator[](ipar);
271   -
272   - // Scale parameter gradient
273   - par.gradient(par.gradient()*value);
274   -
275   - } // endfor: loop over model parameters
276   -
277   - }// endif: compute grdients
278   -
279   - }//endif compute value and gradients
  263 +
  264 + // Loop over model parameters
  265 + for (int ipar = 0; ipar < m_exponent->size(); ++ipar) {
  266 +
  267 + // Get reference to model parameter
  268 + GModelPar& par = m_exponent->operator[](ipar);
  269 +
  270 + // Scale parameter gradient
  271 + par.gradient(par.gradient()*value);
  272 +
  273 + } // endfor: loop over model parameters
  274 +
  275 + } // endif: compute grdients
  276 +
  277 + } //endif compute value and gradients
280 278  
281 279 // Compile option: Check for NaN/Inf
282 280 #if defined(G_NAN_CHECK)
... ... @@ -305,7 +303,7 @@ double GModelSpectralExponential::eval(const GEnergy&amp; srcEng,
305 303 * Computes the photon flux of Exponential spectral model
306 304 ***************************************************************************/
307 305 double GModelSpectralExponential::flux(const GEnergy& emin,
308   - const GEnergy& emax) const
  306 + const GEnergy& emax) const
309 307 {
310 308 // Initialise flux
311 309 double flux = 0.0;
... ... @@ -343,7 +341,7 @@ double GModelSpectralExponential::flux(const GEnergy&amp; emin,
343 341 * Computes the energy flux of Exponential spectral model
344 342 ***************************************************************************/
345 343 double GModelSpectralExponential::eflux(const GEnergy& emin,
346   - const GEnergy& emax) const
  344 + const GEnergy& emax) const
347 345 {
348 346 // Initialise eflux
349 347 double eflux = 0.0;
... ... @@ -387,20 +385,23 @@ double GModelSpectralExponential::eflux(const GEnergy&amp; emin,
387 385 * spectral model.
388 386 ***************************************************************************/
389 387 GEnergy GModelSpectralExponential::mc(const GEnergy& emin,
390   - const GEnergy& emax,
391   - const GTime& time,
392   - GRan& ran) const
  388 + const GEnergy& emax,
  389 + const GTime& time,
  390 + GRan& ran) const
393 391 {
394 392 // Throw an exception if energy range is invalid
395 393 if (emin >= emax) {
396   - throw GException::erange_invalid(G_MC, emin.MeV(), emax.MeV(),
397   - "Minimum energy < maximum energy required.");
  394 + std::string msg = "Minimum energy "+emin.print()+" is equal or larger "
  395 + "than maximum energy "+emax.print()+". Please specify "
  396 + "a minimum energy that is smaller than the maximum "
  397 + "energy.";
  398 + throw GException::invalid_argument(G_MC, msg);
398 399 }
399 400  
400 401 // Throw exception if exponent is undefined
401 402 if (m_exponent == NULL) {
402   - std::string msg = "Exponent is undefined";
403   - throw GException::runtime_error(G_MC, msg);
  403 + std::string msg = "Exponent model is undefined.";
  404 + throw GException::invalid_value(G_MC, msg);
404 405 }
405 406  
406 407 // Update MC cache
... ... @@ -419,50 +420,44 @@ GEnergy GModelSpectralExponential::mc(const GEnergy&amp; emin,
419 420 *
420 421 * @param[in] xml XML element.
421 422 *
422   - * Reads the spectral information from an XML element.
  423 + * Reads the spectral information from an XML element. The XML element shall
  424 + * have the following format
  425 + *
  426 + * <spectrum type="Exponential">
  427 + * <spectrum type="Constant">
  428 + * <parameter name="Normalization" scale="1" value="1" min="0" max="2" free="1"/>
  429 + * </spectrum>
  430 + * </spectrum>
  431 + *
423 432 ***************************************************************************/
424 433 void GModelSpectralExponential::read(const GXmlElement& xml)
425 434 {
426   - // Read number of spectrum nodes in xml
427   - int n_spectrals = xml.elements("spectrum");
428   -
429   - // If xml has no spectrum node pass
430   - if (n_spectrals == 0.){}
431   -
432   - // Otherwise check if there is one spectrum node
433   - else{
434   - // Check that there is only one spectrum node
435   - if (n_spectrals == 1.){
436   - // Get exponent XML element
437   - const GXmlElement* spec = xml.element("spectrum",0);
438   -
439   - // Allocate a spectral registry object
440   - GModelSpectralRegistry registry;
441   -
442   - // Read spectral model
443   - GModelSpectral* ptr = registry.alloc(*spec);
444   -
445   - // Set spectral component as exponent
446   - exponent(ptr);
447   -
448   - // Free spectral model
449   - delete ptr;
450   - }//endif check one spectrum node
451   -
452   - //Otherwise pass, TBD, implement exception
453   - else {
454   - throw GException::model_invalid_nodenum(G_READ, xml,
455   - "Exponential model requires only one spectrum node to define exponent.");
456   -
457   - }//endif check there is only one spectrum node
458   -
459   - }//endif check number of spectrum nodes
460   -
  435 + // Get exponent XML element
  436 + const GXmlElement* spec = xml.element("spectrum", 0);
  437 +
  438 + // Continue only if the XML element contains children
  439 + if (spec->elements() > 0) {
  440 +
  441 + // Allocate a spectral registry object
  442 + GModelSpectralRegistry registry;
  443 +
  444 + // Read spectral model
  445 + GModelSpectral* ptr = registry.alloc(*spec);
  446 +
  447 + // Set spectral component as exponent
  448 + exponent(ptr);
  449 +
  450 + // Free spectral model
  451 + delete ptr;
  452 +
  453 + } // endif: XML element contains children
  454 +
461 455 // Return
462 456 return;
463 457  
464 458 }
465 459  
  460 +
466 461 /***********************************************************************//**
467 462 * @brief Write model into XML element
468 463 *
... ... @@ -471,7 +466,21 @@ void GModelSpectralExponential::read(const GXmlElement&amp; xml)
471 466 * @exception GException::model_invalid_spectral
472 467 * Existing XML element is not of the expected type.
473 468 *
474   - * Writes the spectral information into an XML element.
  469 + * Writes the spectral information into an XML element. The XML element
  470 + * will have the following format:
  471 + *
  472 + * <spectrum type="Exponential">
  473 + * <spectrum type="Constant">
  474 + * <parameter name="Normalization" scale="1" value="1" min="0" max="2" free="1"/>
  475 + * </spectrum>
  476 + * </spectrum>
  477 + *
  478 + * If no exponential model component is defined the method writes the
  479 + * following XML structure
  480 + *
  481 + * <spectrum type="Exponential">
  482 + * </spectrum>
  483 + *
475 484 ***************************************************************************/
476 485 void GModelSpectralExponential::write(GXmlElement& xml) const
477 486 {
... ... @@ -485,52 +494,23 @@ void GModelSpectralExponential::write(GXmlElement&amp; xml) const
485 494 throw GException::model_invalid_spectral(G_WRITE, xml.attribute("type"),
486 495 "Spectral model is not of type \""+type()+"\".");
487 496 }
488   -
489   - // Check if exponent is defined
  497 +
  498 + // Create a spectrum node
  499 + xml.append(GXmlElement("spectrum"));
  500 +
  501 + // Get spectrum node
  502 + GXmlElement* spec = xml.element("spectrum", 0);
  503 +
  504 + // Write spectral component if it exists
490 505 if (m_exponent != NULL) {
491   -
492   - // Create a spectrum node
493   - xml.append(GXmlElement("spectrum"));
494   -
495   - // Get spectrum node
496   - GXmlElement* spec = xml.element("spectrum", 0);
497   -
498   - // Create temporary copy of the exponent. This is a kludge to
499   - // write out the original parameters.
500   - GModelSpectral* cpy = m_exponent->clone();
501   -
502   - // Loop over parameters of model
503   - for (int i = 0; i < cpy->size(); ++i) {
504   -
505   - // Get model parameter and name
506   - GModelPar& par = (*cpy)[i];
507   - std::string parname = par.name();
508   -
509   - // Check if name contains colon
510   - if (gammalib::contains(parname, ":")) {
511   -
512   - // Split at the colon
513   - std::vector<std::string> splits = gammalib::split(parname, ":");
514   -
515   - // Use second part of the string to recover original
516   - // parameter name
517   - par.name(splits[1]);
518   - }
519   -
520   - } // endfor: loop over parameters
521   -
522   - // Write spectral component
523   - cpy->write(*spec);
524   -
525   - // Remove temporary copy
526   - delete cpy;
527   -
  506 + m_exponent->write(*spec);
528 507 }
529 508  
530 509 // Return
531 510 return;
532 511 }
533 512  
  513 +
534 514 /***********************************************************************//**
535 515 * @brief Set exponent
536 516 *
... ... @@ -542,10 +522,10 @@ void GModelSpectralExponential::exponent(const GModelSpectral* spec)
542 522 {
543 523 // Set exponent
544 524 m_exponent = spec->clone();
545   -
  525 +
546 526 // Get number of spectral parameters from model
547 527 int npars = m_exponent->size();
548   -
  528 +
549 529 // Store pointers to spectral parameters
550 530 m_pars.clear();
551 531 for (int ipar = 0; ipar < npars; ++ipar) {
... ... @@ -571,9 +551,9 @@ const GModelSpectral* GModelSpectralExponential::exponent(void) const
571 551 {
572 552 // Returns exponent
573 553 return m_exponent;
574   -
575 554 }
576 555  
  556 +
577 557 /***********************************************************************//**
578 558 * @brief Print Exponential spectral model information
579 559 *
... ... @@ -652,9 +632,8 @@ void GModelSpectralExponential::copy_members(const GModelSpectralExponential&amp; mo
652 632 m_mc_values = model.m_mc_values;
653 633  
654 634 // Set exponent
655   - m_exponent = NULL;
656 635 if (model.m_exponent != NULL) {
657   - exponent(model.m_exponent);
  636 + exponent(model.m_exponent);
658 637 }
659 638  
660 639 // Return
... ... @@ -669,15 +648,15 @@ void GModelSpectralExponential::free_members(void)
669 648 {
670 649 // Free exponent
671 650 if (m_exponent != NULL) delete m_exponent;
672   -
  651 +
673 652 // Signal free pointer
674 653 m_exponent = NULL;
675   -
  654 +
676 655 // Return
677 656 return;
678   -
679 657 }
680 658  
  659 +
681 660 /***********************************************************************//**
682 661 * @brief Update Monte Carlo pre computation cache
683 662 *
... ... @@ -692,7 +671,7 @@ void GModelSpectralExponential::free_members(void)
692 671 * method for simulations.
693 672 ***************************************************************************/
694 673 void GModelSpectralExponential::update_mc_cache(const GEnergy& emin,
695   - const GEnergy& emax) const
  674 + const GEnergy& emax) const
696 675  
697 676 {
698 677 // Check if one of the parameters has changed. If the dimension of the
... ...
src/model/Makefile.am
... ... @@ -57,7 +57,7 @@ sources = GModelPar.cpp \
57 57 GModelSpectralConst.cpp \
58 58 GModelSpectralExpInvPlaw.cpp \
59 59 GModelSpectralExpPlaw.cpp \
60   - GModelSpectralExponential.cpp \
  60 + GModelSpectralExponential.cpp \
61 61 GModelSpectralSuperExpPlaw.cpp \
62 62 GModelSpectralFunc.cpp \
63 63 GModelSpectralGauss.cpp \
... ...