Commit 53907f7d565bb9a1247ebbe17ab488c402956ea1

Authored by Jürgen Knödlseder
1 parent 11838063

Remove duplicate exclusion_map() methods in Python scripts

Methods should not be duplicated in Python scripts but rather use optional parameters
cscripts/cslightcrv.py
... ... @@ -759,30 +759,24 @@ class cslightcrv(ctools.csobservation):
759 759 # Return
760 760 return
761 761  
762   - def exclusion_map(self, object):
  762 + def exclusion_map(self, object=None):
763 763 """
764   - Set exclusion regions map
  764 + Return and optionally set the exclusion regions map
765 765  
766 766 Parameters
767 767 ----------
768 768 object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename`
769 769 Exclusion regions object
770   - """
771   - # Set exclusion region map
772   - self._excl_reg_map = gammalib.GSkyRegionMap(object)
773   -
774   - # Return
775   - return
776   -
777   - def exclusion_map(self):
778   - """
779   - Get exclusion regions map
780 770  
781 771 Returns
782 772 -------
783 773 region : `~gammalib.GSkyRegionMap`
784 774 Exclusion regions map
785 775 """
  776 + # If a regions object is provided then set the regions ...
  777 + if object is not None:
  778 + self._excl_reg_map = gammalib.GSkyRegionMap(object)
  779 +
786 780 # Return
787 781 return self._excl_reg_map
788 782  
... ...
cscripts/csphagen.py
... ... @@ -883,32 +883,26 @@ class csphagen(ctools.csobservation):
883 883 # Return
884 884 return
885 885  
886   - def exclusion_map(self, object):
  886 + def exclusion_map(self, object=None):
887 887 """
888   - Set exclusion regions map
  888 + Return and optionally set the exclusion regions map
889 889  
890 890 Parameters
891 891 ----------
892 892 object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename`
893 893 Exclusion regions object
894   - """
895   - # Set exclusion region map
896   - self._excl_reg = gammalib.GSkyRegionMap(object)
897   -
898   - # Return
899   - return
900   -
901   - def exclusion_map(self):
902   - """
903   - Get exclusion regions map
904 894  
905 895 Returns
906 896 -------
907 897 region : `~gammalib.GSkyRegionMap`
908 898 Exclusion regions map
909 899 """
  900 + # If a regions object is provided then set the regions ...
  901 + if object is not None:
  902 + self._excl_reg_map = gammalib.GSkyRegionMap(object)
  903 +
910 904 # Return
911   - return self._excl_reg
  905 + return self._excl_reg_map
912 906  
913 907  
914 908 # ======================== #
... ...
cscripts/csphasecrv.py
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # Generates spectra as a function of phase
4 4 #
5   -# Copyright (C) 2017-2018 Rolf Buehler
  5 +# Copyright (C) 2017-2019 Rolf Buehler
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -548,30 +548,24 @@ class csphasecrv(ctools.csobservation):
548 548 # Return
549 549 return self._fitmodels
550 550  
551   - def exclusion_map(self, object):
  551 + def exclusion_map(self, object=None):
552 552 """
553   - Set exclusion regions map
  553 + Return and optionally set the exclusion regions map
554 554  
555 555 Parameters
556 556 ----------
557 557 object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename`
558 558 Exclusion regions object
559   - """
560   - # Set exclusion region map
561   - self._excl_reg_map = gammalib.GSkyRegionMap(object)
562   -
563   - # Return
564   - return
565   -
566   - def exclusion_map(self):
567   - """
568   - Get exclusion regions map
569 559  
570 560 Returns
571 561 -------
572 562 region : `~gammalib.GSkyRegionMap`
573 563 Exclusion regions map
574 564 """
  565 + # If a regions object is provided then set the regions ...
  566 + if object is not None:
  567 + self._excl_reg_map = gammalib.GSkyRegionMap(object)
  568 +
575 569 # Return
576 570 return self._excl_reg_map
577 571  
... ...