Commit 83ee3aeca3d4aead47f31015a53ad9a63fd52929

Authored by Jürgen Knödlseder
1 parent 53907f7d

In csresspec._residuals_3D(), replace 'NONE' by None for optional arguments

Showing 1 changed file with 7 additions and 7 deletions
cscripts/csresspec.py
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # ========================================================================== 2 # ==========================================================================
3 # Generates a residual spectrum. 3 # Generates a residual spectrum.
4 # 4 #
5 -# Copyright (C) 2017-2018 Luigi Tibaldo 5 +# Copyright (C) 2017-2019 Luigi Tibaldo
6 # 6 #
7 # This program is free software: you can redistribute it and/or modify 7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by 8 # it under the terms of the GNU General Public License as published by
@@ -447,7 +447,7 @@ class csresspec(ctools.csobservation): @@ -447,7 +447,7 @@ class csresspec(ctools.csobservation):
447 # Return modified table 447 # Return modified table
448 return table 448 return table
449 449
450 - def _residuals_3D(self, obs, obs_id, ccube='NONE'): 450 + def _residuals_3D(self, obs, obs_id, ccube=None):
451 """ 451 """
452 Calculate residuals for 3D observation 452 Calculate residuals for 3D observation
453 453
@@ -457,7 +457,7 @@ class csresspec(ctools.csobservation): @@ -457,7 +457,7 @@ class csresspec(ctools.csobservation):
457 Observation container with a single observations of type GCTAObservation 457 Observation container with a single observations of type GCTAObservation
458 obs_id : str 458 obs_id : str
459 Observation ID 459 Observation ID
460 - ccube : `~gammalib.GCTAEventCube' 460 + ccube : `~gammalib.GCTAEventCube', optional
461 Count cube with stacked events lists 461 Count cube with stacked events lists
462 462
463 Returns 463 Returns
@@ -468,7 +468,7 @@ class csresspec(ctools.csobservation): @@ -468,7 +468,7 @@ class csresspec(ctools.csobservation):
468 468
469 # If binned data already exist set the evlist_info dictionary to have 469 # If binned data already exist set the evlist_info dictionary to have
470 # attribute was_list False 470 # attribute was_list False
471 - if obs[0].eventtype() == 'CountsCube' or ccube!='NONE': 471 + if obs[0].eventtype() == 'CountsCube' or ccube is not None:
472 evlist_info = {'was_list': False} 472 evlist_info = {'was_list': False}
473 473
474 # ... otherwise bin now 474 # ... otherwise bin now
@@ -489,14 +489,14 @@ class csresspec(ctools.csobservation): @@ -489,14 +489,14 @@ class csresspec(ctools.csobservation):
489 msg = 'Computing model cube' 489 msg = 'Computing model cube'
490 self._log_string(gammalib.NORMAL, msg) 490 self._log_string(gammalib.NORMAL, msg)
491 modelcube = ctools.ctmodel(obs) 491 modelcube = ctools.ctmodel(obs)
492 - if ccube != 'NONE': 492 + if ccube is not None:
493 modelcube.cube(ccube) 493 modelcube.cube(ccube)
494 modelcube['edisp'] = self['edisp'].boolean() 494 modelcube['edisp'] = self['edisp'].boolean()
495 modelcube.run() 495 modelcube.run()
496 modcube = modelcube.cube().copy() 496 modcube = modelcube.cube().copy()
497 497
498 # Extract cntcube for residual computation 498 # Extract cntcube for residual computation
499 - if ccube != 'NONE': 499 + if ccube is not None:
500 cntcube = ccube 500 cntcube = ccube
501 else: 501 else:
502 cntcube = obs[0].events().copy() 502 cntcube = obs[0].events().copy()
@@ -533,7 +533,7 @@ class csresspec(ctools.csobservation): @@ -533,7 +533,7 @@ class csresspec(ctools.csobservation):
533 modelcube.obs().models(model_cont) 533 modelcube.obs().models(model_cont)
534 534
535 # Reset base cube that was modified internally by ctmodel 535 # Reset base cube that was modified internally by ctmodel
536 - if ccube != 'NONE': 536 + if ccube is not None:
537 modelcube.cube(ccube) 537 modelcube.cube(ccube)
538 538
539 # Run model cube 539 # Run model cube