Commit afd3a311174dbb0d8539f1550a81d49cb45c0fe6
1 parent
efb7eaae
Make ctools.cscript base class method private in Python by prepending an underscore.
Showing
8 changed files
with
39 additions
and
26 deletions
cscripts/cslightcrv.py
| @@ -182,8 +182,8 @@ class cslightcrv(ctools.cscript): | @@ -182,8 +182,8 @@ class cslightcrv(ctools.cscript): | ||
| 182 | """ | 182 | """ |
| 183 | # Set observation if not done before | 183 | # Set observation if not done before |
| 184 | if self.obs == None or self.obs.size() == 0: | 184 | if self.obs == None or self.obs.size() == 0: |
| 185 | - self.require_inobs("cslightcrv::get_parameters()") | ||
| 186 | - self.obs = self.get_observations() | 185 | + self._require_inobs("cslightcrv::get_parameters()") |
| 186 | + self.obs = self._get_observations() | ||
| 187 | 187 | ||
| 188 | # Set models if we have none | 188 | # Set models if we have none |
| 189 | if self.obs.models().size() == 0: | 189 | if self.obs.models().size() == 0: |
| @@ -379,8 +379,8 @@ class cslightcrv(ctools.cscript): | @@ -379,8 +379,8 @@ class cslightcrv(ctools.cscript): | ||
| 379 | select = ctools.ctselect(self.obs) | 379 | select = ctools.ctselect(self.obs) |
| 380 | select["emin"] = self.m_emin | 380 | select["emin"] = self.m_emin |
| 381 | select["emax"] = self.m_emax | 381 | select["emax"] = self.m_emax |
| 382 | - select["tmin"] = tmin.convert(select.time_reference()) | ||
| 383 | - select["tmax"] = tmax.convert(select.time_reference()) | 382 | + select["tmin"] = tmin.convert(select._time_reference()) |
| 383 | + select["tmax"] = tmax.convert(select._time_reference()) | ||
| 384 | select["rad"] = "UNDEFINED" | 384 | select["rad"] = "UNDEFINED" |
| 385 | select["ra"] = "UNDEFINED" | 385 | select["ra"] = "UNDEFINED" |
| 386 | select["dec"] = "UNDEFINED" | 386 | select["dec"] = "UNDEFINED" |
cscripts/csobsdef.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # Generation of an observation definition file. | 3 | # Generation of an observation definition file. |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2015 Juergen Knoedlseder | 5 | +# Copyright (C) 2015-2016 Juergen Knoedlseder |
| 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 |
| @@ -279,9 +279,9 @@ class csobsdef(ctools.cscript): | @@ -279,9 +279,9 @@ class csobsdef(ctools.cscript): | ||
| 279 | duration = self["duration"].real() | 279 | duration = self["duration"].real() |
| 280 | tmin = self.tmin | 280 | tmin = self.tmin |
| 281 | tmax = self.tmin + duration | 281 | tmax = self.tmin + duration |
| 282 | - gti = gammalib.GGti(self.time_reference()) | ||
| 283 | - tstart = gammalib.GTime(tmin, self.time_reference()) | ||
| 284 | - tstop = gammalib.GTime(tmax, self.time_reference()) | 282 | + gti = gammalib.GGti(self._time_reference()) |
| 283 | + tstart = gammalib.GTime(tmin, self._time_reference()) | ||
| 284 | + tstop = gammalib.GTime(tmax, self._time_reference()) | ||
| 285 | self.tmin = tmax | 285 | self.tmin = tmax |
| 286 | gti.append(tstart, tstop) | 286 | gti.append(tstart, tstop) |
| 287 | obs.ontime(gti.ontime()) | 287 | obs.ontime(gti.ontime()) |
cscripts/csobsinfo.py
| @@ -109,8 +109,8 @@ class csobsinfo(ctools.cscript): | @@ -109,8 +109,8 @@ class csobsinfo(ctools.cscript): | ||
| 109 | """ | 109 | """ |
| 110 | # Get parameters | 110 | # Get parameters |
| 111 | if self.obs.size() == 0: | 111 | if self.obs.size() == 0: |
| 112 | - self.require_inobs("csobsinfo::get_parameters") | ||
| 113 | - self.obs = self.get_observations(False) | 112 | + self._require_inobs("csobsinfo::get_parameters") |
| 113 | + self.obs = self._get_observations(False) | ||
| 114 | 114 | ||
| 115 | # Initialise object position | 115 | # Initialise object position |
| 116 | self.obj_dir = gammalib.GSkyDir() | 116 | self.obj_dir = gammalib.GSkyDir() |
cscripts/cspull.py
| @@ -140,7 +140,7 @@ class cspull(ctools.cscript): | @@ -140,7 +140,7 @@ class cspull(ctools.cscript): | ||
| 140 | 140 | ||
| 141 | # Set observation if not done before | 141 | # Set observation if not done before |
| 142 | if self.obs == None or self.obs.size() == 0: | 142 | if self.obs == None or self.obs.size() == 0: |
| 143 | - self.obs = self.get_observations() | 143 | + self.obs = self._get_observations() |
| 144 | 144 | ||
| 145 | # Check for requested pattern and use above | 145 | # Check for requested pattern and use above |
| 146 | # observation parameters to set wobble pattern | 146 | # observation parameters to set wobble pattern |
cscripts/csresmap.py
| @@ -164,8 +164,8 @@ class csresmap(ctools.cscript): | @@ -164,8 +164,8 @@ class csresmap(ctools.cscript): | ||
| 164 | 164 | ||
| 165 | # Set observation if not done before | 165 | # Set observation if not done before |
| 166 | if self.obs.size() == 0: | 166 | if self.obs.size() == 0: |
| 167 | - self.require_inobs("csresmap.get_parameters()") | ||
| 168 | - self.obs = self.get_observations() | 167 | + self._require_inobs("csresmap.get_parameters()") |
| 168 | + self.obs = self._get_observations() | ||
| 169 | 169 | ||
| 170 | # Check if we have exactly one binned CTA observation | 170 | # Check if we have exactly one binned CTA observation |
| 171 | if self.obs.size() == 1: | 171 | if self.obs.size() == 1: |
| @@ -208,7 +208,7 @@ class csresmap(ctools.cscript): | @@ -208,7 +208,7 @@ class csresmap(ctools.cscript): | ||
| 208 | self.m_debug = self["debug"].boolean() | 208 | self.m_debug = self["debug"].boolean() |
| 209 | 209 | ||
| 210 | # Read ahead output parameters | 210 | # Read ahead output parameters |
| 211 | - if (self.read_ahead()): | 211 | + if (self._read_ahead()): |
| 212 | self.m_outmap = self["outmap"].filename() | 212 | self.m_outmap = self["outmap"].filename() |
| 213 | 213 | ||
| 214 | # Return | 214 | # Return |
| @@ -229,7 +229,7 @@ class csresmap(ctools.cscript): | @@ -229,7 +229,7 @@ class csresmap(ctools.cscript): | ||
| 229 | Execute the script. | 229 | Execute the script. |
| 230 | """ | 230 | """ |
| 231 | # Read ahead output parameters | 231 | # Read ahead output parameters |
| 232 | - self.read_ahead(True) | 232 | + self._read_ahead(True) |
| 233 | 233 | ||
| 234 | # Run the script | 234 | # Run the script |
| 235 | self.run() | 235 | self.run() |
cscripts/csspec.py
| @@ -133,8 +133,8 @@ class csspec(ctools.cscript): | @@ -133,8 +133,8 @@ class csspec(ctools.cscript): | ||
| 133 | """ | 133 | """ |
| 134 | # Set observation if not done before | 134 | # Set observation if not done before |
| 135 | if self.obs == None or self.obs.size() == 0: | 135 | if self.obs == None or self.obs.size() == 0: |
| 136 | - self.require_inobs("csspec::get_parameters()") | ||
| 137 | - self.obs = self.get_observations() | 136 | + self._require_inobs("csspec::get_parameters()") |
| 137 | + self.obs = self._get_observations() | ||
| 138 | 138 | ||
| 139 | # Check if we have one binned cta observation, i.e. if we are in binned mode | 139 | # Check if we have one binned cta observation, i.e. if we are in binned mode |
| 140 | self.m_binned_mode = False | 140 | self.m_binned_mode = False |
| @@ -239,7 +239,7 @@ class csspec(ctools.cscript): | @@ -239,7 +239,7 @@ class csspec(ctools.cscript): | ||
| 239 | 239 | ||
| 240 | # Unbinned mode | 240 | # Unbinned mode |
| 241 | else: | 241 | else: |
| 242 | - self.m_ebounds = self.create_ebounds() | 242 | + self.m_ebounds = self._create_ebounds() |
| 243 | 243 | ||
| 244 | # Return | 244 | # Return |
| 245 | return | 245 | return |
cscripts/cstsdist.py
| @@ -133,7 +133,7 @@ class cstsdist(ctools.cscript): | @@ -133,7 +133,7 @@ class cstsdist(ctools.cscript): | ||
| 133 | 133 | ||
| 134 | # Set observation if not done before | 134 | # Set observation if not done before |
| 135 | if self.obs == None or self.obs.size() == 0: | 135 | if self.obs == None or self.obs.size() == 0: |
| 136 | - self.obs = self.get_observations() | 136 | + self.obs = self._get_observations() |
| 137 | 137 | ||
| 138 | # Check for requested pattern and use above | 138 | # Check for requested pattern and use above |
| 139 | # observation parameters to set wobble pattern | 139 | # observation parameters to set wobble pattern |
pyext/ctool.i
| 1 | /*************************************************************************** | 1 | /*************************************************************************** |
| 2 | * ctool - ctool base class * | 2 | * ctool - ctool base class * |
| 3 | * ----------------------------------------------------------------------- * | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2014-2015 by Juergen Knoedlseder * | 4 | + * copyright (C) 2014-2016 by Juergen Knoedlseder * |
| 5 | * ----------------------------------------------------------------------- * | 5 | * ----------------------------------------------------------------------- * |
| 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 * |
| @@ -83,10 +83,24 @@ public: | @@ -83,10 +83,24 @@ public: | ||
| 83 | // Public methods | 83 | // Public methods |
| 84 | virtual void execute(void); | 84 | virtual void execute(void); |
| 85 | 85 | ||
| 86 | + // Make methods private in Python by prepending an underscore | ||
| 87 | + %rename(_read_ahead) read_ahead() const; | ||
| 88 | + %rename(_time_reference) time_reference() const; | ||
| 89 | + %rename(_get_observations) get_observations(const bool& get_response = true); | ||
| 90 | + %rename(_create_ebounds) create_ebounds(); | ||
| 91 | + %rename(_create_map) create_map(const GObservations& obs); | ||
| 92 | + %rename(_create_cube) create_cube(const GObservations& obs); | ||
| 93 | + %rename(_create_cta_obs) create_cta_obs(); | ||
| 94 | + %rename(_require_inobs) require_inobs(const std::string& method); | ||
| 95 | + %rename(_require_inobs_nolist) require_inobs_nolist(const std::string& method); | ||
| 96 | + %rename(_require_inobs_nocube) require_inobs_nocube(const std::string& method); | ||
| 97 | + %rename(_set_response) set_response(GObservations& obs); | ||
| 98 | + %rename(_set_obs_response) set_obs_response(GCTAObservation* obs); | ||
| 99 | + %rename(_set_obs_bounds) set_obs_bounds(GObservations& obs); | ||
| 100 | + %rename(_get_mean_pointing) get_mean_pointing(const GObservations& obs); | ||
| 101 | + %rename(_get_current_rss) get_current_rss(); | ||
| 102 | + | ||
| 86 | // Protected methods | 103 | // Protected methods |
| 87 | - void init_members(void); | ||
| 88 | - void copy_members(const ctool& app); | ||
| 89 | - void free_members(void); | ||
| 90 | const bool& read_ahead(void) const; | 104 | const bool& read_ahead(void) const; |
| 91 | const GTimeReference& time_reference(void) const; | 105 | const GTimeReference& time_reference(void) const; |
| 92 | GObservations get_observations(const bool& get_response = true); | 106 | GObservations get_observations(const bool& get_response = true); |
| @@ -117,7 +131,7 @@ public: | @@ -117,7 +131,7 @@ public: | ||
| 117 | * @brief cscript base class | 131 | * @brief cscript base class |
| 118 | * | 132 | * |
| 119 | * This is the base class from which all cscripts should derive. This | 133 | * This is the base class from which all cscripts should derive. This |
| 120 | - * enabled using of ctool base class methods for generic parameter | 134 | + * enables using of ctool base class methods for generic parameter |
| 121 | * handling. | 135 | * handling. |
| 122 | ***************************************************************************/ | 136 | ***************************************************************************/ |
| 123 | class cscript : public ctool { | 137 | class cscript : public ctool { |
| @@ -141,9 +155,8 @@ public: | @@ -141,9 +155,8 @@ public: | ||
| 141 | * @brief ctool base class Python extension | 155 | * @brief ctool base class Python extension |
| 142 | ***************************************************************************/ | 156 | ***************************************************************************/ |
| 143 | %extend ctool { | 157 | %extend ctool { |
| 144 | - void read_ahead(const bool& flag) { | 158 | + void _read_ahead(const bool& flag) { |
| 145 | self->m_read_ahead = flag; | 159 | self->m_read_ahead = flag; |
| 146 | return; | 160 | return; |
| 147 | } | 161 | } |
| 148 | } | 162 | } |
| 149 | - |