Commit 29e6ebfd38204276810f681b589e52dd0347da5b
1 parent
04e6a281
Remove energy nodes with zero error from model in csbkgmodel
Showing
1 changed file
with
10 additions
and
0 deletions
cscripts/csbkgmodel.py
| ... | ... | @@ -285,6 +285,16 @@ class csbkgmodel(ctools.csobservation): |
| 285 | 285 | # Extract fitted model |
| 286 | 286 | model = like.obs().models()[0].copy() |
| 287 | 287 | |
| 288 | + # Remove nodes with zero errors as they are not constrained | |
| 289 | + # by the data and may lead to fitting problems later | |
| 290 | + spectral = model.spectral() | |
| 291 | + nodes = spectral.nodes() | |
| 292 | + for i in range(nodes): | |
| 293 | + ieng = 2*(nodes - i) - 2 | |
| 294 | + iint = 2*(nodes - i) - 1 | |
| 295 | + if spectral[iint].error() == 0.0: | |
| 296 | + spectral.remove(nodes - i - 1) | |
| 297 | + | |
| 288 | 298 | # Return model |
| 289 | 299 | return model |
| 290 | 300 | ... | ... |