Commit 45f8d7fd88202ff4777b8958c0b86de9cb02f813
1 parent
add26053
Replace Python string.format() by % formatting in csphagen (#2208)
Showing
1 changed file
with
16 additions
and
16 deletions
cscripts/csphagen.py
| @@ -144,8 +144,8 @@ class csphagen(ctools.cscript): | @@ -144,8 +144,8 @@ class csphagen(ctools.cscript): | ||
| 144 | 144 | ||
| 145 | # If ... | 145 | # If ... |
| 146 | if offset <= self._rad or offset >= self['maxoffset'].real(): | 146 | if offset <= self._rad or offset >= self['maxoffset'].real(): |
| 147 | - self._log_string(gammalib.EXPLICIT, 'Observation {} pointed at {} ' | ||
| 148 | - 'deg from source'.format(obs.id(), offset)) | 147 | + self._log_string(gammalib.EXPLICIT, 'Observation %s pointed at %.3f ' |
| 148 | + 'deg from source' % ((obs.id(), offset))) | ||
| 149 | 149 | ||
| 150 | # ... otherwise | 150 | # ... otherwise |
| 151 | else: | 151 | else: |
| @@ -158,9 +158,9 @@ class csphagen(ctools.cscript): | @@ -158,9 +158,9 @@ class csphagen(ctools.cscript): | ||
| 158 | # numerical precision issues | 158 | # numerical precision issues |
| 159 | N = int(2.0 * math.pi / alpha) | 159 | N = int(2.0 * math.pi / alpha) |
| 160 | if N < self['bkgregmin'].integer() + 3: | 160 | if N < self['bkgregmin'].integer() + 3: |
| 161 | - self._log_string(gammalib.EXPLICIT, 'Observation {}: ' | 161 | + self._log_string(gammalib.EXPLICIT, 'Observation %s: ' |
| 162 | 'insufficient regions for background ' | 162 | 'insufficient regions for background ' |
| 163 | - 'estimation'.format(obs.id(), offset)) | 163 | + 'estimation' % (obs.id())) |
| 164 | 164 | ||
| 165 | # Otherwise loop over position angle to create reflected | 165 | # Otherwise loop over position angle to create reflected |
| 166 | # regions | 166 | # regions |
| @@ -174,9 +174,9 @@ class csphagen(ctools.cscript): | @@ -174,9 +174,9 @@ class csphagen(ctools.cscript): | ||
| 174 | if self._has_exclusion: | 174 | if self._has_exclusion: |
| 175 | if self._excl_reg.overlaps(region): | 175 | if self._excl_reg.overlaps(region): |
| 176 | self._log_string(gammalib.VERBOSE, 'Observation ' | 176 | self._log_string(gammalib.VERBOSE, 'Observation ' |
| 177 | - '{}: reflected region overlaps ' | ||
| 178 | - 'with exclusion region'. | ||
| 179 | - format(obs.id(), offset)) | 177 | + '%s: reflected region overlaps ' |
| 178 | + 'with exclusion region' % | ||
| 179 | + (obs.id())) | ||
| 180 | else: | 180 | else: |
| 181 | regions.append(region) | 181 | regions.append(region) |
| 182 | else: | 182 | else: |
| @@ -231,15 +231,15 @@ class csphagen(ctools.cscript): | @@ -231,15 +231,15 @@ class csphagen(ctools.cscript): | ||
| 231 | self._outobs.append(onoff) | 231 | self._outobs.append(onoff) |
| 232 | self._bkg_regs.append({'regions': bkg_reg, 'id': obs.id()}) | 232 | self._bkg_regs.append({'regions': bkg_reg, 'id': obs.id()}) |
| 233 | else: | 233 | else: |
| 234 | - self._log_string(gammalib.NORMAL, 'Observation {} not included ' | ||
| 235 | - 'in spectra generation'.format(obs.id())) | 234 | + self._log_string(gammalib.NORMAL, 'Observation %s not included ' |
| 235 | + 'in spectra generation' % (obs.id())) | ||
| 236 | 236 | ||
| 237 | # Stack observations | 237 | # Stack observations |
| 238 | if self._outobs.size() > 1 and self['stack'].boolean() == True: | 238 | if self._outobs.size() > 1 and self['stack'].boolean() == True: |
| 239 | 239 | ||
| 240 | # Write header | 240 | # Write header |
| 241 | - self._log_header1(gammalib.NORMAL, | ||
| 242 | - 'Stacking {} observations'.format(self._outobs.size())) | 241 | + self._log_header1(gammalib.NORMAL, 'Stacking %d observations' % |
| 242 | + (self._outobs.size())) | ||
| 243 | 243 | ||
| 244 | # Stack observations | 244 | # Stack observations |
| 245 | stacked_obs = gammalib.GCTAOnOffObservation(self._outobs) | 245 | stacked_obs = gammalib.GCTAOnOffObservation(self._outobs) |
| @@ -273,10 +273,10 @@ class csphagen(ctools.cscript): | @@ -273,10 +273,10 @@ class csphagen(ctools.cscript): | ||
| 273 | arfname = prefix + '_stacked_arf.fits' | 273 | arfname = prefix + '_stacked_arf.fits' |
| 274 | rmfname = prefix + '_stacked_rmf.fits' | 274 | rmfname = prefix + '_stacked_rmf.fits' |
| 275 | elif self._outobs.size() > 1: | 275 | elif self._outobs.size() > 1: |
| 276 | - onname = prefix + '_{}_pha_on.fits'.format(obs.id()) | ||
| 277 | - offname = prefix + '_{}_pha_off.fits'.format(obs.id()) | ||
| 278 | - arfname = prefix + '_{}_arf.fits'.format(obs.id()) | ||
| 279 | - rmfname = prefix + '_{}_rmf.fits'.format(obs.id()) | 276 | + onname = prefix + '_%s_pha_on.fits' % (obs.id()) |
| 277 | + offname = prefix + '_%s_pha_off.fits' % (obs.id()) | ||
| 278 | + arfname = prefix + '_%s_arf.fits' % (obs.id()) | ||
| 279 | + rmfname = prefix + '_%s_rmf.fits' % (obs.id()) | ||
| 280 | else: | 280 | else: |
| 281 | onname = prefix + '_pha_on.fits' | 281 | onname = prefix + '_pha_on.fits' |
| 282 | offname = prefix + '_pha_off.fits' | 282 | offname = prefix + '_pha_off.fits' |
| @@ -311,7 +311,7 @@ class csphagen(ctools.cscript): | @@ -311,7 +311,7 @@ class csphagen(ctools.cscript): | ||
| 311 | 311 | ||
| 312 | # Set filename | 312 | # Set filename |
| 313 | if len(self._bkg_regs) > 1: | 313 | if len(self._bkg_regs) > 1: |
| 314 | - regname = prefix + '_{}_off.reg'.format(bkg_reg['id']) | 314 | + regname = prefix + '_%s_off.reg' % (bkg_reg['id']) |
| 315 | else: | 315 | else: |
| 316 | regname = prefix + '_off.reg' | 316 | regname = prefix + '_off.reg' |
| 317 | 317 |