Commit e04fd4500a030450eadb92d066ae9fe056814b5c
1 parent
920b233b
Try solving some Sonar code quality issues.
Showing
4 changed files
with
33 additions
and
27 deletions
cscripts/csfindobs.py
cscripts/csobs2caldb.py
| ... | ... | @@ -56,6 +56,9 @@ class csobs2caldb(ctools.cscript): |
| 56 | 56 | self._outfile = gammalib.GFilename("irf_file.fits") |
| 57 | 57 | self._base_dir = "" |
| 58 | 58 | self._cal_dir = "" |
| 59 | + self._rsp_dir = "" | |
| 60 | + self._caldb_inx = gammalib.GFits() | |
| 61 | + self._irf_fits = gammalib.GFits() | |
| 59 | 62 | |
| 60 | 63 | # Initialise observation container from constructor arguments. |
| 61 | 64 | self._obs, argv = self._set_input_obs(argv) | ... | ... |
cscripts/csobsdef.py
| ... | ... | @@ -177,7 +177,7 @@ class csobsdef(ctools.cscript): |
| 177 | 177 | |
| 178 | 178 | # Clear observation container |
| 179 | 179 | self._obs.clear() |
| 180 | - self._id = 1 | |
| 180 | + identifier = 1 | |
| 181 | 181 | |
| 182 | 182 | # Extract header from pointing definition file |
| 183 | 183 | header = [] |
| ... | ... | @@ -202,11 +202,11 @@ class csobsdef(ctools.cscript): |
| 202 | 202 | |
| 203 | 203 | # Set identifier |
| 204 | 204 | if "id" in header: |
| 205 | - id = pntdef[row, header.index("id")] | |
| 205 | + id_ = pntdef[row, header.index("id")] | |
| 206 | 206 | else: |
| 207 | - id = "%6.6d" % self._id | |
| 208 | - self._id += 1 | |
| 209 | - obs.id(id) | |
| 207 | + id_ = "%6.6d" % identifier | |
| 208 | + identifier += 1 | |
| 209 | + obs.id(id_) | |
| 210 | 210 | |
| 211 | 211 | # Set pointing |
| 212 | 212 | if "ra" in header and "dec" in header: |
| ... | ... | @@ -293,17 +293,17 @@ class csobsdef(ctools.cscript): |
| 293 | 293 | roi = gammalib.GCTARoi(gammalib.GCTAInstDir(pntdir), rad) |
| 294 | 294 | |
| 295 | 295 | # Create an empty event list |
| 296 | - list = gammalib.GCTAEventList() | |
| 297 | - list.gti(gti) | |
| 296 | + list_ = gammalib.GCTAEventList() | |
| 297 | + list_.gti(gti) | |
| 298 | 298 | |
| 299 | 299 | # Set optional information |
| 300 | 300 | if has_ebounds: |
| 301 | - list.ebounds(ebounds) | |
| 301 | + list_.ebounds(ebounds) | |
| 302 | 302 | if has_roi: |
| 303 | - list.roi(roi) | |
| 303 | + list_.roi(roi) | |
| 304 | 304 | |
| 305 | 305 | # Attach event list to CTA observation |
| 306 | - obs.events(list) | |
| 306 | + obs.events(list_) | |
| 307 | 307 | |
| 308 | 308 | # Write observation into logger |
| 309 | 309 | if self._logExplicit(): | ... | ... |
cscripts/cspull.py
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | 19 | # |
| 20 | 20 | # ========================================================================== |
| 21 | -#import gammalib | |
| 21 | +import gammalib | |
| 22 | 22 | import ctools |
| 23 | 23 | from cscripts import obsutils |
| 24 | 24 | import sys |
| ... | ... | @@ -48,10 +48,7 @@ class cspull(ctools.cscript): |
| 48 | 48 | self._version = "1.1.0" |
| 49 | 49 | |
| 50 | 50 | # Initialise some members |
| 51 | - self._model = None | |
| 52 | - self._inmodel = None | |
| 53 | 51 | self._edisp = False |
| 54 | - self._profile = False | |
| 55 | 52 | self._exposure = None |
| 56 | 53 | self._psfcube = None |
| 57 | 54 | self._bckcube = None |
| ... | ... | @@ -60,6 +57,14 @@ class cspull(ctools.cscript): |
| 60 | 57 | self._coordsys = "CEL" |
| 61 | 58 | self._proj = "TAN" |
| 62 | 59 | self._log_clients = False |
| 60 | + self._offset = 0.0 | |
| 61 | + self._ntrials = 0 | |
| 62 | + self._outfile = gammalib.GFilename() | |
| 63 | + self._npix = 0 | |
| 64 | + self._binsz = 0.0 | |
| 65 | + self._pattern = "single" | |
| 66 | + self._enumbins = 0 | |
| 67 | + self._chatter = 2 | |
| 63 | 68 | |
| 64 | 69 | # Initialise observation container from constructor arguments. |
| 65 | 70 | self._obs, argv = self._set_input_obs(argv) |
| ... | ... | @@ -93,15 +98,11 @@ class cspull(ctools.cscript): |
| 93 | 98 | self._enumbins = self["enumbins"].integer() |
| 94 | 99 | |
| 95 | 100 | # Read parameters for binned if requested |
| 96 | - if not self._enumbins == 0: | |
| 101 | + if self._enumbins != 0: | |
| 97 | 102 | self._npix = self["npix"].integer() |
| 98 | 103 | self._binsz = self["binsz"].real() |
| 99 | 104 | self._coordsys = self["coordsys"].string() |
| 100 | 105 | self._proj = self["proj"].string() |
| 101 | - else: | |
| 102 | - # Set dummy values (required by obsutils) | |
| 103 | - self._npix = 0 | |
| 104 | - self._binsz = 0.0 | |
| 105 | 106 | |
| 106 | 107 | # Set models if we have none |
| 107 | 108 | if self._obs.models().size() == 0: |
| ... | ... | @@ -109,12 +110,13 @@ class cspull(ctools.cscript): |
| 109 | 110 | |
| 110 | 111 | # Read other parameters |
| 111 | 112 | self._outfile = self["outfile"].filename() |
| 112 | - self._ntrials = self["ntrials"].integer() | |
| 113 | + self._ntrials = self["ntrials"].integer() | |
| 113 | 114 | self._edisp = self["edisp"].boolean() |
| 114 | - self._offset = self["offset"].real() | |
| 115 | - self._profile = self["profile"].boolean() | |
| 115 | + self._offset = self["offset"].real() | |
| 116 | 116 | self._chatter = self["chatter"].integer() |
| 117 | - self._debug = self["debug"].boolean() | |
| 117 | + | |
| 118 | + # Query some parameters | |
| 119 | + self["profile"].boolean() | |
| 118 | 120 | |
| 119 | 121 | # Write input parameters into logger |
| 120 | 122 | if self._logTerse(): |
| ... | ... | @@ -270,7 +272,7 @@ class cspull(ctools.cscript): |
| 270 | 272 | coord=self._coordsys, |
| 271 | 273 | edisp=self._edisp, |
| 272 | 274 | log=self._log_clients, |
| 273 | - debug=self._debug, | |
| 275 | + debug=self._logDebug(), | |
| 274 | 276 | chatter=self._chatter) |
| 275 | 277 | |
| 276 | 278 | # Set response for a stacked observation |
| ... | ... | @@ -296,18 +298,18 @@ class cspull(ctools.cscript): |
| 296 | 298 | self._log("\n") |
| 297 | 299 | |
| 298 | 300 | # Fit model |
| 299 | - if self._profile: | |
| 301 | + if self["profile"].boolean(): | |
| 300 | 302 | models = self._obs.models() |
| 301 | 303 | for i in range(models.size()): |
| 302 | 304 | model_name = models[i].name() |
| 303 | 305 | like = obsutils.cterror(self._obs, model_name, |
| 304 | 306 | log=self._log_clients, |
| 305 | - debug=self._debug, | |
| 307 | + debug=self._logDebug(), | |
| 306 | 308 | chatter=self._chatter) |
| 307 | 309 | else: |
| 308 | 310 | like = obsutils.fit(obs, edisp=self._edisp, |
| 309 | 311 | log=self._log_clients, |
| 310 | - debug=self._debug, | |
| 312 | + debug=self._logDebug(), | |
| 311 | 313 | chatter=self._chatter) |
| 312 | 314 | |
| 313 | 315 | # Store results | ... | ... |