From 0d08d71f219029b03c5989ef133341ad00de7ef2 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 31 Jul 2018 12:43:14 +0200 Subject: [PATCH] Revisit comments of cscripts --- cscripts/csphagen.py | 48 ++++++++++++++++++++++++++++++++++-------------- cscripts/cssens.py | 18 ++++++++++++------ 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/cscripts/csphagen.py b/cscripts/csphagen.py index fac4e41..8a99c0d 100755 --- a/cscripts/csphagen.py +++ b/cscripts/csphagen.py @@ -113,20 +113,30 @@ class csphagen(ctools.csobservation): # Private methods def _query_src_direction(self): """ - Set up the source direction parameter. - Query relevant parameters. + Set up the source direction parameter """ + # Initialise source direction self._src_dir = gammalib.GSkyDir() + + # Get coordinate systel coordsys = self['coordsys'].string() + + # If coordinate system is celestial then query "ra" and "dec" if coordsys == 'CEL': ra = self['ra'].real() dec = self['dec'].real() self._src_dir.radec_deg(ra, dec) + + # ... otherwise, if coordinate system is galactic then query "glon" + # and "glat" elif coordsys == 'GAL': glon = self['glon'].real() glat = self['glat'].real() self._src_dir.lb_deg(glon, glat) + # Return + return + def _get_parameters_bkgmethod_reflected(self): """ Get parameters for REFLECTED background method @@ -439,11 +449,16 @@ class csphagen(ctools.csobservation): """ Generate On/Off spectra for individual observation - :param i: int, observation number - :return: dictionary - On/Off spectra, background regions, observation id - """ + Parameters + ---------- + i : int + Observation number + Returns + ------- + result : dict + On/Off spectra, background regions, observation id + """ # Retrieve observation from container obs = self.obs()[i] @@ -486,17 +501,22 @@ class csphagen(ctools.csobservation): # Return results return result - def _unpack_result(self,outobs,result): + def _unpack_result(self, outobs, result): """ - Unpack result from calculation of On/Off regions and appends it to observation - container. + Unpack result from calculation of On/Off regions - :param outobs: `~gammalib.GObservations`, observation container - :param result: dict, result to unpack - :return: `~gammalib.GObservations` - observation container with result appended - """ + Parameters + ---------- + outobs : `~gammalib.GObservations` + Observation container + result : dict + On/Off spectra, background regions, observation id + Returns + ------- + outobs : `~gammalib.GObservations` + Observation container with result appended + """ # If the results contain an On/Off observation if result['onoff'].classname() == 'GCTAOnOffObservation': # Append observation to observation container diff --git a/cscripts/cssens.py b/cscripts/cssens.py index 6af4347..9d31875 100755 --- a/cscripts/cssens.py +++ b/cscripts/cssens.py @@ -617,15 +617,20 @@ class cssens(ctools.csobservation): # Return return (crab_flux_prediction, regcoeff) - - def _e_bin(self,ieng): + def _e_bin(self, ieng): """ - Determines sensivity in energy bin ieng - :param ieng: int, energy bin number - :return: dict, + Determines sensivity in energy bin + + Parameters + ---------- + ieng : int + Energy bin number + + Returns + ------- + result : dict Result dictionary """ - # Get sensitivity type sensitivity_type = self['type'].string() @@ -648,6 +653,7 @@ class cssens(ctools.csobservation): # Return results return result + # Public methods def run(self): """ -- libgit2 0.21.4