From afd3a311174dbb0d8539f1550a81d49cb45c0fe6 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 11 Mar 2016 23:09:28 +0100 Subject: [PATCH] Make ctools.cscript base class method private in Python by prepending an underscore. --- cscripts/cslightcrv.py | 8 ++++---- cscripts/csobsdef.py | 8 ++++---- cscripts/csobsinfo.py | 4 ++-- cscripts/cspull.py | 2 +- cscripts/csresmap.py | 8 ++++---- cscripts/csspec.py | 6 +++--- cscripts/cstsdist.py | 2 +- pyext/ctool.i | 27 ++++++++++++++++++++------- 8 files changed, 39 insertions(+), 26 deletions(-) diff --git a/cscripts/cslightcrv.py b/cscripts/cslightcrv.py index 3a8aa95..60f177d 100755 --- a/cscripts/cslightcrv.py +++ b/cscripts/cslightcrv.py @@ -182,8 +182,8 @@ class cslightcrv(ctools.cscript): """ # Set observation if not done before if self.obs == None or self.obs.size() == 0: - self.require_inobs("cslightcrv::get_parameters()") - self.obs = self.get_observations() + self._require_inobs("cslightcrv::get_parameters()") + self.obs = self._get_observations() # Set models if we have none if self.obs.models().size() == 0: @@ -379,8 +379,8 @@ class cslightcrv(ctools.cscript): select = ctools.ctselect(self.obs) select["emin"] = self.m_emin select["emax"] = self.m_emax - select["tmin"] = tmin.convert(select.time_reference()) - select["tmax"] = tmax.convert(select.time_reference()) + select["tmin"] = tmin.convert(select._time_reference()) + select["tmax"] = tmax.convert(select._time_reference()) select["rad"] = "UNDEFINED" select["ra"] = "UNDEFINED" select["dec"] = "UNDEFINED" diff --git a/cscripts/csobsdef.py b/cscripts/csobsdef.py index 0b4a4aa..cfd0f94 100755 --- a/cscripts/csobsdef.py +++ b/cscripts/csobsdef.py @@ -2,7 +2,7 @@ # ========================================================================== # Generation of an observation definition file. # -# Copyright (C) 2015 Juergen Knoedlseder +# Copyright (C) 2015-2016 Juergen Knoedlseder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -279,9 +279,9 @@ class csobsdef(ctools.cscript): duration = self["duration"].real() tmin = self.tmin tmax = self.tmin + duration - gti = gammalib.GGti(self.time_reference()) - tstart = gammalib.GTime(tmin, self.time_reference()) - tstop = gammalib.GTime(tmax, self.time_reference()) + gti = gammalib.GGti(self._time_reference()) + tstart = gammalib.GTime(tmin, self._time_reference()) + tstop = gammalib.GTime(tmax, self._time_reference()) self.tmin = tmax gti.append(tstart, tstop) obs.ontime(gti.ontime()) diff --git a/cscripts/csobsinfo.py b/cscripts/csobsinfo.py index 0dad0d3..ca0b09b 100755 --- a/cscripts/csobsinfo.py +++ b/cscripts/csobsinfo.py @@ -109,8 +109,8 @@ class csobsinfo(ctools.cscript): """ # Get parameters if self.obs.size() == 0: - self.require_inobs("csobsinfo::get_parameters") - self.obs = self.get_observations(False) + self._require_inobs("csobsinfo::get_parameters") + self.obs = self._get_observations(False) # Initialise object position self.obj_dir = gammalib.GSkyDir() diff --git a/cscripts/cspull.py b/cscripts/cspull.py index 32fac3b..fd0baf2 100755 --- a/cscripts/cspull.py +++ b/cscripts/cspull.py @@ -140,7 +140,7 @@ class cspull(ctools.cscript): # Set observation if not done before if self.obs == None or self.obs.size() == 0: - self.obs = self.get_observations() + self.obs = self._get_observations() # Check for requested pattern and use above # observation parameters to set wobble pattern diff --git a/cscripts/csresmap.py b/cscripts/csresmap.py index e1fab98..036c0e3 100755 --- a/cscripts/csresmap.py +++ b/cscripts/csresmap.py @@ -164,8 +164,8 @@ class csresmap(ctools.cscript): # Set observation if not done before if self.obs.size() == 0: - self.require_inobs("csresmap.get_parameters()") - self.obs = self.get_observations() + self._require_inobs("csresmap.get_parameters()") + self.obs = self._get_observations() # Check if we have exactly one binned CTA observation if self.obs.size() == 1: @@ -208,7 +208,7 @@ class csresmap(ctools.cscript): self.m_debug = self["debug"].boolean() # Read ahead output parameters - if (self.read_ahead()): + if (self._read_ahead()): self.m_outmap = self["outmap"].filename() # Return @@ -229,7 +229,7 @@ class csresmap(ctools.cscript): Execute the script. """ # Read ahead output parameters - self.read_ahead(True) + self._read_ahead(True) # Run the script self.run() diff --git a/cscripts/csspec.py b/cscripts/csspec.py index 89a4f49..98263a3 100755 --- a/cscripts/csspec.py +++ b/cscripts/csspec.py @@ -133,8 +133,8 @@ class csspec(ctools.cscript): """ # Set observation if not done before if self.obs == None or self.obs.size() == 0: - self.require_inobs("csspec::get_parameters()") - self.obs = self.get_observations() + self._require_inobs("csspec::get_parameters()") + self.obs = self._get_observations() # Check if we have one binned cta observation, i.e. if we are in binned mode self.m_binned_mode = False @@ -239,7 +239,7 @@ class csspec(ctools.cscript): # Unbinned mode else: - self.m_ebounds = self.create_ebounds() + self.m_ebounds = self._create_ebounds() # Return return diff --git a/cscripts/cstsdist.py b/cscripts/cstsdist.py index 952ff44..2b41d49 100755 --- a/cscripts/cstsdist.py +++ b/cscripts/cstsdist.py @@ -133,7 +133,7 @@ class cstsdist(ctools.cscript): # Set observation if not done before if self.obs == None or self.obs.size() == 0: - self.obs = self.get_observations() + self.obs = self._get_observations() # Check for requested pattern and use above # observation parameters to set wobble pattern diff --git a/pyext/ctool.i b/pyext/ctool.i index 4e3d25b..00eaff8 100644 --- a/pyext/ctool.i +++ b/pyext/ctool.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctool - ctool base class * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Juergen Knoedlseder * + * copyright (C) 2014-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -83,10 +83,24 @@ public: // Public methods virtual void execute(void); + // Make methods private in Python by prepending an underscore + %rename(_read_ahead) read_ahead() const; + %rename(_time_reference) time_reference() const; + %rename(_get_observations) get_observations(const bool& get_response = true); + %rename(_create_ebounds) create_ebounds(); + %rename(_create_map) create_map(const GObservations& obs); + %rename(_create_cube) create_cube(const GObservations& obs); + %rename(_create_cta_obs) create_cta_obs(); + %rename(_require_inobs) require_inobs(const std::string& method); + %rename(_require_inobs_nolist) require_inobs_nolist(const std::string& method); + %rename(_require_inobs_nocube) require_inobs_nocube(const std::string& method); + %rename(_set_response) set_response(GObservations& obs); + %rename(_set_obs_response) set_obs_response(GCTAObservation* obs); + %rename(_set_obs_bounds) set_obs_bounds(GObservations& obs); + %rename(_get_mean_pointing) get_mean_pointing(const GObservations& obs); + %rename(_get_current_rss) get_current_rss(); + // Protected methods - void init_members(void); - void copy_members(const ctool& app); - void free_members(void); const bool& read_ahead(void) const; const GTimeReference& time_reference(void) const; GObservations get_observations(const bool& get_response = true); @@ -117,7 +131,7 @@ public: * @brief cscript base class * * This is the base class from which all cscripts should derive. This - * enabled using of ctool base class methods for generic parameter + * enables using of ctool base class methods for generic parameter * handling. ***************************************************************************/ class cscript : public ctool { @@ -141,9 +155,8 @@ public: * @brief ctool base class Python extension ***************************************************************************/ %extend ctool { - void read_ahead(const bool& flag) { + void _read_ahead(const bool& flag) { self->m_read_ahead = flag; return; } } - -- libgit2 0.21.4