Action #2178

Add GModelSpectralNodes spectral model constructor

Added by Knödlseder Jürgen over 7 years ago. Updated over 7 years ago.

Status:ClosedStart date:08/10/2017
Priority:HighDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:1.5.0
Duration:

Description

Add a spectral model constructor to the GModelSpectralNodes class that transform any spectral model into a spectral node model. The format of the constructor should be

GModelSpectralNodes(const GModelSpectral& model, const GEnergies& energies);

where the energies argument specifies the energies for which the nodes should be set.


Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen over 7 years ago

  • Status changed from New to In Progress

The following code works now:

>>> import gammalib
>>> m=gammalib.GModels('${CTOOLS}/share/models/crab.xml')
>>> e=gammalib.GEnergies(10,gammalib.GEnergy(0.1,'TeV'),gammalib.GEnergy(100.0,'TeV'))
>>> n=gammalib.GModelSpectralNodes(m[0].spectral(),e)
>>> print n
=== GModelSpectralNodes ===
 Number of nodes ...........: 10
 Number of parameters ......: 20
  Energy0 ..................: 100000 MeV (fixed,scale=1)
  Intensity0 ...............: 8.69231722336369e-15 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)
  Energy1 ..................: 215443.469003188 MeV (fixed,scale=1)
  Intensity1 ...............: 1.29559391832094e-15 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)
  Energy2 ..................: 464158.883361278 MeV (fixed,scale=1)
  Intensity2 ...............: 1.93108875120027e-16 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)
  Energy3 ..................: 1000000 MeV (fixed,scale=1)
  Intensity3 ...............: 2.87829675045486e-17 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)
  Energy4 ..................: 2154434.69003188 MeV (fixed,scale=1)
  Intensity4 ...............: 4.29011467159638e-18 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)
  Energy5 ..................: 4641588.83361277 MeV (fixed,scale=1)
  Intensity5 ...............: 6.39443583867366e-19 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)
  Energy6 ..................: 10000000 MeV (fixed,scale=1)
  Intensity6 ...............: 9.53093630937816e-20 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)
  Energy7 ..................: 21544346.9003188 MeV (fixed,scale=1)
  Intensity7 ...............: 1.42059048249463e-20 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)
  Energy8 ..................: 46415888.3361277 MeV (fixed,scale=1)
  Intensity8 ...............: 2.11739671050848e-21 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)
  Energy9 ..................: 100000000 MeV (fixed,scale=1)
  Intensity9 ...............: 3.15598962890354e-22 +/- 0 ph/cm2/s/MeV (free,scale=1,gradient)

#2 Updated by Knödlseder Jürgen over 7 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

I added a unit test and merged the new code into devel.

Also available in: Atom PDF