Commit d44271eeeaa49958e34524ecc59e42bc8bff8080
1 parent
53a86115
corectly sum all source model components
Showing
1 changed file
with
6 additions
and
5 deletions
inst/mwl/test/test_python.py
| ... | ... | @@ -81,9 +81,6 @@ def fit_spectrum(filename, xmlname): |
| 81 | 81 | obs.optimize(opt) |
| 82 | 82 | print obs |
| 83 | 83 | |
| 84 | - # Get pointer on Crab model | |
| 85 | - crab = cast_GModelSky(obs.models()[0]) | |
| 86 | - | |
| 87 | 84 | # Get model values |
| 88 | 85 | x = np.power(10., np.arange(-1., 8., 0.1)) |
| 89 | 86 | y = [] |
| ... | ... | @@ -93,8 +90,12 @@ def fit_spectrum(filename, xmlname): |
| 93 | 90 | t = GTime() |
| 94 | 91 | for energy in x: |
| 95 | 92 | e.MeV(energy) |
| 96 | - f = crab.value(d, e, t) * energy*energy*1.6021765e-6 | |
| 97 | - y.append(f) | |
| 93 | + yval = 0.0 | |
| 94 | + for model in obs.models(): | |
| 95 | + crab = cast_GModelSky(model) | |
| 96 | + if crab != None: | |
| 97 | + yval += crab.value(d, e, t) * energy*energy*1.6021765e-6 | |
| 98 | + y.append(yval) | |
| 98 | 99 | plt.plot(x, y) |
| 99 | 100 | |
| 100 | 101 | ... | ... |