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