Commit 4f9b688dd87903a06ad2afb679c00344b4a8739d
1 parent
d2145d7f
Correct a bunch of Sonar issues.
Showing
7 changed files
with
22 additions
and
26 deletions
cscripts/csmodelmerge.py
| ... | ... | @@ -47,7 +47,6 @@ class csmodelmerge(ctools.cscript): |
| 47 | 47 | # Initialise class members |
| 48 | 48 | self._files = None |
| 49 | 49 | self._models = gammalib.GModels() |
| 50 | - self._outmodel = "NONE" | |
| 51 | 50 | |
| 52 | 51 | # Initialise application |
| 53 | 52 | if len(argv) == 0: |
| ... | ... | @@ -105,7 +104,7 @@ class csmodelmerge(ctools.cscript): |
| 105 | 104 | |
| 106 | 105 | # Read ahead output filename |
| 107 | 106 | if self._read_ahead(): |
| 108 | - self.outmodel = self["outmodel"].filename() | |
| 107 | + self["outmodel"].filename() | |
| 109 | 108 | |
| 110 | 109 | # Write input parameters into logger |
| 111 | 110 | if self._logTerse(): |
| ... | ... | @@ -177,16 +176,16 @@ class csmodelmerge(ctools.cscript): |
| 177 | 176 | self._log.header1("Save models") |
| 178 | 177 | |
| 179 | 178 | # Get output filename in case it was not read ahead |
| 180 | - self._outmodel = self["outmodel"].filename() | |
| 179 | + outmodel = self["outmodel"].filename() | |
| 181 | 180 | |
| 182 | 181 | # Log filename |
| 183 | 182 | if self._logTerse(): |
| 184 | 183 | self._log(gammalib.parformat("Model definition XML file")) |
| 185 | - self._log(self._outmodel.url()) | |
| 184 | + self._log(outmodel.url()) | |
| 186 | 185 | self._log("\n") |
| 187 | 186 | |
| 188 | 187 | # Save models |
| 189 | - self._models.save(self._outmodel) | |
| 188 | + self._models.save(outmodel) | |
| 190 | 189 | |
| 191 | 190 | # Return |
| 192 | 191 | return | ... | ... |
cscripts/csobsdef.py
| ... | ... | @@ -85,7 +85,6 @@ class csobsdef(ctools.cscript): |
| 85 | 85 | self._obs = gammalib.GObservations() |
| 86 | 86 | self._inpnt = "" |
| 87 | 87 | self._tmin = 0.0 |
| 88 | - self._outobs = "NONE" | |
| 89 | 88 | self._chatter = 2 |
| 90 | 89 | self._clobber = True |
| 91 | 90 | self._debug = False |
| ... | ... | @@ -123,7 +122,7 @@ class csobsdef(ctools.cscript): |
| 123 | 122 | |
| 124 | 123 | # Read ahead parameters |
| 125 | 124 | if self._read_ahead(): |
| 126 | - self._outobs = self["outobs"].filename() | |
| 125 | + self["outobs"].filename() | |
| 127 | 126 | |
| 128 | 127 | # Set some fixed parameters |
| 129 | 128 | self._chatter = self["chatter"].integer() |
| ... | ... | @@ -346,19 +345,19 @@ class csobsdef(ctools.cscript): |
| 346 | 345 | self._log.header1("Save observation definition XML file") |
| 347 | 346 | |
| 348 | 347 | # Get output filename in case it was not read ahead |
| 349 | - self._outobs = self["outobs"].filename() | |
| 348 | + outobs = self["outobs"].filename() | |
| 350 | 349 | |
| 351 | 350 | # Check if observation definition XML file is valid |
| 352 | - if self._outobs != "NONE": | |
| 351 | + if outobs.url() != "NONE": | |
| 353 | 352 | |
| 354 | 353 | # Log filename |
| 355 | 354 | if self._logTerse(): |
| 356 | 355 | self._log(gammalib.parformat("Observation XML file")) |
| 357 | - self._log(self._outobs.url()) | |
| 356 | + self._log(outobs.url()) | |
| 358 | 357 | self._log("\n") |
| 359 | 358 | |
| 360 | 359 | # Save observation definition XML file |
| 361 | - self._obs.save(self._outobs) | |
| 360 | + self._obs.save(outobs) | |
| 362 | 361 | |
| 363 | 362 | # Return |
| 364 | 363 | return | ... | ... |
cscripts/csobsinfo.py
| ... | ... | @@ -43,7 +43,6 @@ class csobsinfo(ctools.cscript): |
| 43 | 43 | # Initialise class members |
| 44 | 44 | self._obj_dir = None |
| 45 | 45 | self._compute_offset = False |
| 46 | - self._ds9file = "" | |
| 47 | 46 | self._offsets = [] |
| 48 | 47 | self._zeniths = [] |
| 49 | 48 | self._azimuths = [] |
| ... | ... | @@ -105,7 +104,7 @@ class csobsinfo(ctools.cscript): |
| 105 | 104 | |
| 106 | 105 | # Read ahead DS9 filename |
| 107 | 106 | if self._read_ahead(): |
| 108 | - self._ds9file = self["ds9file"].filename() | |
| 107 | + self["ds9file"].filename() | |
| 109 | 108 | |
| 110 | 109 | # Write input parameters into logger |
| 111 | 110 | if self._logTerse(): |
| ... | ... | @@ -388,19 +387,19 @@ class csobsinfo(ctools.cscript): |
| 388 | 387 | self._log.header1("Save pointings in DS9 file") |
| 389 | 388 | |
| 390 | 389 | # Get output filename in case it was not read ahead |
| 391 | - self._ds9file = self["ds9file"].filename() | |
| 390 | + ds9file = self["ds9file"].filename() | |
| 392 | 391 | |
| 393 | 392 | # Check if DS9 file is valid |
| 394 | - if self._ds9file != "NONE": | |
| 393 | + if ds9file.url() != "NONE": | |
| 395 | 394 | |
| 396 | 395 | # Log filename |
| 397 | 396 | if self._logTerse(): |
| 398 | 397 | self._log(gammalib.parformat("DS9 filename")) |
| 399 | - self._log(self._ds9file.url()) | |
| 398 | + self._log(ds9file.url()) | |
| 400 | 399 | self._log("\n") |
| 401 | 400 | |
| 402 | 401 | # Open file |
| 403 | - f = open(self._ds9file.url(),"w") | |
| 402 | + f = open(ds9file.url(),"w") | |
| 404 | 403 | |
| 405 | 404 | # Write coordinate system |
| 406 | 405 | f.write("fk5\n") | ... | ... |
cscripts/cspull.py
| ... | ... | @@ -310,10 +310,10 @@ class cspull(ctools.cscript): |
| 310 | 310 | |
| 311 | 311 | # Fit model |
| 312 | 312 | if self._profile: |
| 313 | - models = _obs.models() | |
| 313 | + models = self._obs.models() | |
| 314 | 314 | for i in range(models.size()): |
| 315 | 315 | model_name = models[i].name() |
| 316 | - like = obsutils.cterror(_obs, model_name, | |
| 316 | + like = obsutils.cterror(self._obs, model_name, | |
| 317 | 317 | log=self._log_clients, |
| 318 | 318 | debug=self._debug, |
| 319 | 319 | chatter=self._chatter) | ... | ... |
cscripts/cssens.py
| ... | ... | @@ -54,7 +54,7 @@ class cssens(ctools.cscript): |
| 54 | 54 | self._obs = gammalib.GObservations() |
| 55 | 55 | self._ebounds = gammalib.GEbounds() |
| 56 | 56 | self._srcname = "" |
| 57 | - self._outfile = "" | |
| 57 | + self._outfile = gammalib.GFilename() | |
| 58 | 58 | self._ra = None |
| 59 | 59 | self._dec = None |
| 60 | 60 | self._edisp = False | ... | ... |
cscripts/cstsdist.py
cscripts/cstsmapmerge.py
| ... | ... | @@ -52,7 +52,6 @@ class cstsmapmerge(ctools.cscript): |
| 52 | 52 | self._merged_files = [] |
| 53 | 53 | self._overwrite = True |
| 54 | 54 | self._delete = False |
| 55 | - self._outmap = "NONE" | |
| 56 | 55 | |
| 57 | 56 | # Initialise application |
| 58 | 57 | if len(argv) == 0: |
| ... | ... | @@ -120,7 +119,7 @@ class cstsmapmerge(ctools.cscript): |
| 120 | 119 | |
| 121 | 120 | # Read ahead output filename |
| 122 | 121 | if self._read_ahead(): |
| 123 | - self._outmap = self["outmap"].filename() | |
| 122 | + self["outmap"].filename() | |
| 124 | 123 | |
| 125 | 124 | # Write input parameters into logger |
| 126 | 125 | if self._logTerse(): |
| ... | ... | @@ -390,12 +389,12 @@ class cstsmapmerge(ctools.cscript): |
| 390 | 389 | self._log.header1("Save TS map") |
| 391 | 390 | |
| 392 | 391 | # Get output filename in case it was not read ahead |
| 393 | - self._outmap = self["outmap"].filename() | |
| 392 | + outmap = self["outmap"].filename() | |
| 394 | 393 | |
| 395 | 394 | # Log filename |
| 396 | 395 | if self._logTerse(): |
| 397 | 396 | self._log(gammalib.parformat("TS map file")) |
| 398 | - self._log(self._outmap.url()) | |
| 397 | + self._log(outmap.url()) | |
| 399 | 398 | self._log("\n") |
| 400 | 399 | |
| 401 | 400 | # Create FITS file |
| ... | ... | @@ -425,7 +424,7 @@ class cstsmapmerge(ctools.cscript): |
| 425 | 424 | fits[fits.size()-1].extname("STATUS MAP") |
| 426 | 425 | |
| 427 | 426 | # Save FITS file |
| 428 | - fits.saveto(self._outmap, self._clobber()) | |
| 427 | + fits.saveto(outmap, self._clobber()) | |
| 429 | 428 | |
| 430 | 429 | # Delete TS input maps if requested |
| 431 | 430 | if self._delete: | ... | ... |