Commit 839513724e3fd67e3daa467319a631bbebe987da
1 parent
c2961f62
Rename built-in variables in Python scripts
Showing
14 changed files
with
263 additions
and
263 deletions
cscripts/csresmap.py
| @@ -175,28 +175,28 @@ class csresmap(ctools.cscript): | @@ -175,28 +175,28 @@ class csresmap(ctools.cscript): | ||
| 175 | self._log_header1(gammalib.TERSE, 'Generate binned map (ctbin)') | 175 | self._log_header1(gammalib.TERSE, 'Generate binned map (ctbin)') |
| 176 | 176 | ||
| 177 | # Create countsmap | 177 | # Create countsmap |
| 178 | - bin = ctools.ctbin(self._obs) | ||
| 179 | - bin['xref'] = self['xref'].real() | ||
| 180 | - bin['yref'] = self['yref'].real() | ||
| 181 | - bin['proj'] = self['proj'].string() | ||
| 182 | - bin['coordsys'] = self['coordsys'].string() | ||
| 183 | - bin['ebinalg'] = self['ebinalg'].string() | ||
| 184 | - bin['nxpix'] = self['nxpix'].integer() | ||
| 185 | - bin['nypix'] = self['nypix'].integer() | ||
| 186 | - bin['binsz'] = self['binsz'].real() | 178 | + binning = ctools.ctbin(self._obs) |
| 179 | + binning['xref'] = self['xref'].real() | ||
| 180 | + binning['yref'] = self['yref'].real() | ||
| 181 | + binning['proj'] = self['proj'].string() | ||
| 182 | + binning['coordsys'] = self['coordsys'].string() | ||
| 183 | + binning['ebinalg'] = self['ebinalg'].string() | ||
| 184 | + binning['nxpix'] = self['nxpix'].integer() | ||
| 185 | + binning['nypix'] = self['nypix'].integer() | ||
| 186 | + binning['binsz'] = self['binsz'].real() | ||
| 187 | if self['ebinalg'].string() == "FILE": | 187 | if self['ebinalg'].string() == "FILE": |
| 188 | - bin['ebinfile'] = self['ebinfile'].filename().file() | 188 | + binning['ebinfile'] = self['ebinfile'].filename().file() |
| 189 | else: | 189 | else: |
| 190 | - bin['enumbins'] = self['enumbins'].integer() | ||
| 191 | - bin['emin'] = self['emin'].real() | ||
| 192 | - bin['emax'] = self['emax'].real() | ||
| 193 | - bin['chatter'] = self['chatter'].integer() | ||
| 194 | - bin['clobber'] = self['clobber'].boolean() | ||
| 195 | - bin['debug'] = self['debug'].boolean() | ||
| 196 | - bin.run() | 190 | + binning['enumbins'] = self['enumbins'].integer() |
| 191 | + binning['emin'] = self['emin'].real() | ||
| 192 | + binning['emax'] = self['emax'].real() | ||
| 193 | + binning['chatter'] = self['chatter'].integer() | ||
| 194 | + binning['clobber'] = self['clobber'].boolean() | ||
| 195 | + binning['debug'] = self['debug'].boolean() | ||
| 196 | + binning.run() | ||
| 197 | 197 | ||
| 198 | # Retrieve counts cube | 198 | # Retrieve counts cube |
| 199 | - cta_counts_cube = bin.cube() | 199 | + cta_counts_cube = binning.cube() |
| 200 | 200 | ||
| 201 | # Assign GCTAEventCube to skymap | 201 | # Assign GCTAEventCube to skymap |
| 202 | countmap = cta_counts_cube.counts() | 202 | countmap = cta_counts_cube.counts() |
| @@ -218,7 +218,7 @@ class csresmap(ctools.cscript): | @@ -218,7 +218,7 @@ class csresmap(ctools.cscript): | ||
| 218 | 218 | ||
| 219 | # Store counts map as residual map. Note that we need a special | 219 | # Store counts map as residual map. Note that we need a special |
| 220 | # construct here to avoid memory leaks. This seems to be a SWIG feature | 220 | # construct here to avoid memory leaks. This seems to be a SWIG feature |
| 221 | - # as SWIG creates a new object when calling bin.cube() | 221 | + # as SWIG creates a new object when calling binning.cube() |
| 222 | self._resmap = countmap.copy() | 222 | self._resmap = countmap.copy() |
| 223 | self._resmap.stack_maps() | 223 | self._resmap.stack_maps() |
| 224 | modelmap.stack_maps() | 224 | modelmap.stack_maps() |
cscripts/csspec.py
| @@ -363,15 +363,15 @@ class csspec(ctools.cslikelihood): | @@ -363,15 +363,15 @@ class csspec(ctools.cslikelihood): | ||
| 363 | 363 | ||
| 364 | # Make sure that all nodes are positive | 364 | # Make sure that all nodes are positive |
| 365 | for i in range(spectrum.nodes()): | 365 | for i in range(spectrum.nodes()): |
| 366 | - par = spectrum[i*2+1] | ||
| 367 | - value = par.value() | ||
| 368 | - min = 1.0e-30 * value | ||
| 369 | - if min <= 0.0: | ||
| 370 | - min = 1.0e-50 | ||
| 371 | - if min < value: | ||
| 372 | - value = min | 366 | + par = spectrum[i*2+1] |
| 367 | + value = par.value() | ||
| 368 | + minimum = 1.0e-30 * value | ||
| 369 | + if minimum <= 0.0: | ||
| 370 | + minimum = 1.0e-50 | ||
| 371 | + if minimum < value: | ||
| 372 | + value = minimum | ||
| 373 | par.value(value) | 373 | par.value(value) |
| 374 | - par.min(min) | 374 | + par.min(minimum) |
| 375 | 375 | ||
| 376 | # Set spectral component of source model | 376 | # Set spectral component of source model |
| 377 | model.spectral(spectrum) | 377 | model.spectral(spectrum) |
| @@ -459,10 +459,10 @@ class csspec(ctools.cslikelihood): | @@ -459,10 +459,10 @@ class csspec(ctools.cslikelihood): | ||
| 459 | rmf[idst_true, idst_reco] = obs.rmf()[isrc_true, isrc_reco] | 459 | rmf[idst_true, idst_reco] = obs.rmf()[isrc_true, isrc_reco] |
| 460 | 460 | ||
| 461 | # Set On/Off observations | 461 | # Set On/Off observations |
| 462 | - id = obs.id() | 462 | + obsid = obs.id() |
| 463 | statistic = obs.statistic() | 463 | statistic = obs.statistic() |
| 464 | obs = gammalib.GCTAOnOffObservation(pha_on, pha_off, arf, rmf) | 464 | obs = gammalib.GCTAOnOffObservation(pha_on, pha_off, arf, rmf) |
| 465 | - obs.id(id) | 465 | + obs.id(obsid) |
| 466 | obs.statistic(statistic) | 466 | obs.statistic(statistic) |
| 467 | 467 | ||
| 468 | # Return observation | 468 | # Return observation |
cscripts/cssrcdetect.py
| @@ -117,23 +117,23 @@ class cssrcdetect(ctools.cscript): | @@ -117,23 +117,23 @@ class cssrcdetect(ctools.cscript): | ||
| 117 | self._log_value(gammalib.NORMAL, 'Map threshold', threshold) | 117 | self._log_value(gammalib.NORMAL, 'Map threshold', threshold) |
| 118 | 118 | ||
| 119 | # Get maximum value and corresponding sky direction | 119 | # Get maximum value and corresponding sky direction |
| 120 | - value, dir = self._find_maximum(counts, threshold=threshold) | 120 | + value, pos = self._find_maximum(counts, threshold=threshold) |
| 121 | 121 | ||
| 122 | # If maximum found then log maximum and add model | 122 | # If maximum found then log maximum and add model |
| 123 | - if dir is not None: | 123 | + if pos is not None: |
| 124 | 124 | ||
| 125 | # Set source name | 125 | # Set source name |
| 126 | name = 'Src%3.3d' % (i+1) | 126 | name = 'Src%3.3d' % (i+1) |
| 127 | 127 | ||
| 128 | # Log maximum | 128 | # Log maximum |
| 129 | self._log_value(gammalib.NORMAL, 'Map maximum', str(value)) | 129 | self._log_value(gammalib.NORMAL, 'Map maximum', str(value)) |
| 130 | - self._log_value(gammalib.NORMAL, name+' position', str(dir)) | 130 | + self._log_value(gammalib.NORMAL, name+' position', str(pos)) |
| 131 | 131 | ||
| 132 | # Add model | 132 | # Add model |
| 133 | - self._add_model(dir, name) | 133 | + self._add_model(pos, name) |
| 134 | 134 | ||
| 135 | # Remove maximum from map | 135 | # Remove maximum from map |
| 136 | - counts = self._remove_maximum(counts, dir, mean, | 136 | + counts = self._remove_maximum(counts, pos, mean, |
| 137 | radius=self['exclrad'].real()) | 137 | radius=self['exclrad'].real()) |
| 138 | 138 | ||
| 139 | # ... otherwise log that no maximum was found and break iterations | 139 | # ... otherwise log that no maximum was found and break iterations |
| @@ -149,44 +149,44 @@ class cssrcdetect(ctools.cscript): | @@ -149,44 +149,44 @@ class cssrcdetect(ctools.cscript): | ||
| 149 | # Return | 149 | # Return |
| 150 | return | 150 | return |
| 151 | 151 | ||
| 152 | - def _find_maximum(self, map, threshold=0.0): | 152 | + def _find_maximum(self, skymap, threshold=0.0): |
| 153 | """ | 153 | """ |
| 154 | Find maximum in a sky map | 154 | Find maximum in a sky map |
| 155 | 155 | ||
| 156 | Parameters | 156 | Parameters |
| 157 | ---------- | 157 | ---------- |
| 158 | - map : `~gammalib.GSkyMap()` | 158 | + skymap : `~gammalib.GSkyMap()` |
| 159 | Sky map | 159 | Sky map |
| 160 | threshold : float, optional | 160 | threshold : float, optional |
| 161 | Threshold for maximum value | 161 | Threshold for maximum value |
| 162 | 162 | ||
| 163 | Returns | 163 | Returns |
| 164 | ------- | 164 | ------- |
| 165 | - value, dir : tuple of float and `~gammalib.GSkyDir()` | 165 | + value, pos : tuple of float and `~gammalib.GSkyDir()` |
| 166 | Maximum sky map value and corresponding sky direction | 166 | Maximum sky map value and corresponding sky direction |
| 167 | """ | 167 | """ |
| 168 | # Initialise maximum pixel value and sky direction | 168 | # Initialise maximum pixel value and sky direction |
| 169 | value = threshold | 169 | value = threshold |
| 170 | - dir = None | 170 | + pos = None |
| 171 | 171 | ||
| 172 | # Loop over all pixels and find maximum | 172 | # Loop over all pixels and find maximum |
| 173 | - for i in range(map.npix()): | ||
| 174 | - if map[i] > value: | ||
| 175 | - value = map[i] | ||
| 176 | - dir = map.inx2dir(i) | 173 | + for i in range(skymap.npix()): |
| 174 | + if skymap[i] > value: | ||
| 175 | + value = skymap[i] | ||
| 176 | + pos = skymap.inx2dir(i) | ||
| 177 | 177 | ||
| 178 | # Return sky direction of maximum | 178 | # Return sky direction of maximum |
| 179 | - return value, dir | 179 | + return value, pos |
| 180 | 180 | ||
| 181 | - def _remove_maximum(self, map, dir, value=0.0, radius=0.1): | 181 | + def _remove_maximum(self, skymap, pos, value=0.0, radius=0.1): |
| 182 | """ | 182 | """ |
| 183 | Remove maximum from sky map by replacing pixels with a given value | 183 | Remove maximum from sky map by replacing pixels with a given value |
| 184 | 184 | ||
| 185 | Parameters | 185 | Parameters |
| 186 | ---------- | 186 | ---------- |
| 187 | - map : `~gammalib.GSkyMap()` | 187 | + skymap : `~gammalib.GSkyMap()` |
| 188 | Sky map | 188 | Sky map |
| 189 | - dir : `~gammalib.GSkyDir()` | 189 | + pos : `~gammalib.GSkyDir()` |
| 190 | Sky direction of maximum | 190 | Sky direction of maximum |
| 191 | value : float, optional | 191 | value : float, optional |
| 192 | Replacement value | 192 | Replacement value |
| @@ -195,28 +195,28 @@ class cssrcdetect(ctools.cscript): | @@ -195,28 +195,28 @@ class cssrcdetect(ctools.cscript): | ||
| 195 | 195 | ||
| 196 | Returns | 196 | Returns |
| 197 | ------- | 197 | ------- |
| 198 | - map : `~gammalib.GSkyMap()` | 198 | + skymap : `~gammalib.GSkyMap()` |
| 199 | Sky map with maximum removed | 199 | Sky map with maximum removed |
| 200 | """ | 200 | """ |
| 201 | # Copy skymap | 201 | # Copy skymap |
| 202 | - map_copy = map.copy() | 202 | + skymap_copy = skymap.copy() |
| 203 | 203 | ||
| 204 | # Loop over all pixels and find maximum | 204 | # Loop over all pixels and find maximum |
| 205 | - for i in range(map_copy.npix()): | ||
| 206 | - mapdir = map_copy.inx2dir(i) | ||
| 207 | - if mapdir.dist_deg(dir) < radius: | ||
| 208 | - map_copy[i] = value | 205 | + for i in range(skymap_copy.npix()): |
| 206 | + skymap_dir = skymap_copy.inx2dir(i) | ||
| 207 | + if skymap_dir.dist_deg(pos) < radius: | ||
| 208 | + skymap_copy[i] = value | ||
| 209 | 209 | ||
| 210 | # Return copy of map | 210 | # Return copy of map |
| 211 | - return map_copy | 211 | + return skymap_copy |
| 212 | 212 | ||
| 213 | - def _map_moments(self, map): | 213 | + def _map_moments(self, skymap): |
| 214 | """ | 214 | """ |
| 215 | Determine moments of sky map pixels | 215 | Determine moments of sky map pixels |
| 216 | 216 | ||
| 217 | Parameters | 217 | Parameters |
| 218 | ---------- | 218 | ---------- |
| 219 | - map : `~gammalib.GSkyMap()` | 219 | + skymap : `~gammalib.GSkyMap()` |
| 220 | Sky map | 220 | Sky map |
| 221 | 221 | ||
| 222 | Returns | 222 | Returns |
| @@ -229,32 +229,32 @@ class cssrcdetect(ctools.cscript): | @@ -229,32 +229,32 @@ class cssrcdetect(ctools.cscript): | ||
| 229 | std = 0.0 | 229 | std = 0.0 |
| 230 | 230 | ||
| 231 | # Loop over all pixels | 231 | # Loop over all pixels |
| 232 | - for i in range(map.npix()): | ||
| 233 | - mean += map[i] | ||
| 234 | - std += map[i]*map[i] | 232 | + for i in range(skymap.npix()): |
| 233 | + mean += skymap[i] | ||
| 234 | + std += skymap[i]*skymap[i] | ||
| 235 | 235 | ||
| 236 | # Compute mean and standard deviation | 236 | # Compute mean and standard deviation |
| 237 | - mean /= float(map.npix()) | ||
| 238 | - std /= float(map.npix()) | 237 | + mean /= float(skymap.npix()) |
| 238 | + std /= float(skymap.npix()) | ||
| 239 | std -= mean * mean | 239 | std -= mean * mean |
| 240 | std = math.sqrt(std) | 240 | std = math.sqrt(std) |
| 241 | 241 | ||
| 242 | # Return mean and standard deviation | 242 | # Return mean and standard deviation |
| 243 | return mean, std | 243 | return mean, std |
| 244 | 244 | ||
| 245 | - def _add_model(self, dir, name): | 245 | + def _add_model(self, pos, name): |
| 246 | """ | 246 | """ |
| 247 | Add model to model container | 247 | Add model to model container |
| 248 | 248 | ||
| 249 | Parameters | 249 | Parameters |
| 250 | ---------- | 250 | ---------- |
| 251 | - dir : `~gammalib.GSkyDir()` | 251 | + pos : `~gammalib.GSkyDir()` |
| 252 | Sky direction of model | 252 | Sky direction of model |
| 253 | name : str | 253 | name : str |
| 254 | Model name | 254 | Model name |
| 255 | """ | 255 | """ |
| 256 | # Set point source model | 256 | # Set point source model |
| 257 | - model = self._set_ptsrc(dir) | 257 | + model = self._set_ptsrc(pos) |
| 258 | 258 | ||
| 259 | # Set model name | 259 | # Set model name |
| 260 | model.name(name) | 260 | model.name(name) |
| @@ -265,13 +265,13 @@ class cssrcdetect(ctools.cscript): | @@ -265,13 +265,13 @@ class cssrcdetect(ctools.cscript): | ||
| 265 | # Return | 265 | # Return |
| 266 | return | 266 | return |
| 267 | 267 | ||
| 268 | - def _set_bkg(self, type): | 268 | + def _set_bkg(self, modeltype): |
| 269 | """ | 269 | """ |
| 270 | Set background model | 270 | Set background model |
| 271 | 271 | ||
| 272 | Parameters | 272 | Parameters |
| 273 | ---------- | 273 | ---------- |
| 274 | - type : str | 274 | + modeltype : str |
| 275 | Model type ('IRF', 'AEFF' or 'CUBE') | 275 | Model type ('IRF', 'AEFF' or 'CUBE') |
| 276 | 276 | ||
| 277 | Returns | 277 | Returns |
| @@ -284,11 +284,11 @@ class cssrcdetect(ctools.cscript): | @@ -284,11 +284,11 @@ class cssrcdetect(ctools.cscript): | ||
| 284 | gammalib.GEnergy(1.0, 'TeV')) | 284 | gammalib.GEnergy(1.0, 'TeV')) |
| 285 | 285 | ||
| 286 | # Set background model | 286 | # Set background model |
| 287 | - if type == 'IRF': | 287 | + if modeltype == 'IRF': |
| 288 | model = gammalib.GCTAModelIrfBackground(spectral) | 288 | model = gammalib.GCTAModelIrfBackground(spectral) |
| 289 | - elif type == 'AEFF': | 289 | + elif modeltype == 'AEFF': |
| 290 | model = gammalib.GCTAModelAeffBackground(spectral) | 290 | model = gammalib.GCTAModelAeffBackground(spectral) |
| 291 | - elif type == 'CUBE': | 291 | + elif modeltype == 'CUBE': |
| 292 | model = gammalib.GCTAModelCubeBackground(spectral) | 292 | model = gammalib.GCTAModelCubeBackground(spectral) |
| 293 | else: | 293 | else: |
| 294 | model = None | 294 | model = None |
| @@ -300,13 +300,13 @@ class cssrcdetect(ctools.cscript): | @@ -300,13 +300,13 @@ class cssrcdetect(ctools.cscript): | ||
| 300 | # Return model | 300 | # Return model |
| 301 | return model | 301 | return model |
| 302 | 302 | ||
| 303 | - def _set_ptsrc(self, dir): | 303 | + def _set_ptsrc(self, pos): |
| 304 | """ | 304 | """ |
| 305 | Set point source model | 305 | Set point source model |
| 306 | 306 | ||
| 307 | Parameters | 307 | Parameters |
| 308 | ---------- | 308 | ---------- |
| 309 | - dir : `~gammalib.GSkyDir()` | 309 | + pos : `~gammalib.GSkyDir()` |
| 310 | Sky direction of model | 310 | Sky direction of model |
| 311 | 311 | ||
| 312 | Returns | 312 | Returns |
| @@ -315,7 +315,7 @@ class cssrcdetect(ctools.cscript): | @@ -315,7 +315,7 @@ class cssrcdetect(ctools.cscript): | ||
| 315 | Point source model | 315 | Point source model |
| 316 | """ | 316 | """ |
| 317 | # Set spatial component | 317 | # Set spatial component |
| 318 | - spatial = gammalib.GModelSpatialPointSource(dir) | 318 | + spatial = gammalib.GModelSpatialPointSource(pos) |
| 319 | 319 | ||
| 320 | # Get fit parameters | 320 | # Get fit parameters |
| 321 | fit_pos = self['fit_pos'].boolean() | 321 | fit_pos = self['fit_pos'].boolean() |
| @@ -348,7 +348,7 @@ class cssrcdetect(ctools.cscript): | @@ -348,7 +348,7 @@ class cssrcdetect(ctools.cscript): | ||
| 348 | 348 | ||
| 349 | Returns | 349 | Returns |
| 350 | ------- | 350 | ------- |
| 351 | - map : `~gammalib.GSkyMap()` | 351 | + skymap : `~gammalib.GSkyMap()` |
| 352 | Sky map | 352 | Sky map |
| 353 | """ | 353 | """ |
| 354 | # Get skymap filename | 354 | # Get skymap filename |
| @@ -358,13 +358,13 @@ class cssrcdetect(ctools.cscript): | @@ -358,13 +358,13 @@ class cssrcdetect(ctools.cscript): | ||
| 358 | fits = gammalib.GFits(inmap) | 358 | fits = gammalib.GFits(inmap) |
| 359 | 359 | ||
| 360 | # Extract primary extension as sky map | 360 | # Extract primary extension as sky map |
| 361 | - map = gammalib.GSkyMap(fits.image(0)) | 361 | + skymap = gammalib.GSkyMap(fits.image(0)) |
| 362 | 362 | ||
| 363 | # Close sky map file | 363 | # Close sky map file |
| 364 | fits.close() | 364 | fits.close() |
| 365 | 365 | ||
| 366 | # Return | 366 | # Return |
| 367 | - return map | 367 | + return skymap |
| 368 | 368 | ||
| 369 | 369 | ||
| 370 | # Public methods | 370 | # Public methods |
cscripts/csworkflow.py
| @@ -114,10 +114,10 @@ class csworkflow(ctools.cscript): | @@ -114,10 +114,10 @@ class csworkflow(ctools.cscript): | ||
| 114 | actor_inputs = actor.element('input') | 114 | actor_inputs = actor.element('input') |
| 115 | num_inputs = actor_inputs.elements('parameter') | 115 | num_inputs = actor_inputs.elements('parameter') |
| 116 | for k in range(num_inputs): | 116 | for k in range(num_inputs): |
| 117 | - input = actor_inputs.element('parameter', k) | ||
| 118 | - input_name = input.attribute('name') | ||
| 119 | - input_value = input.attribute('value') | ||
| 120 | - input_actor = input.attribute('actor') | 117 | + input_par = actor_inputs.element('parameter', k) |
| 118 | + input_name = input_par.attribute('name') | ||
| 119 | + input_value = input_par.attribute('value') | ||
| 120 | + input_actor = input_par.attribute('actor') | ||
| 121 | parameter = {'name': input_name, \ | 121 | parameter = {'name': input_name, \ |
| 122 | 'value': input_value, \ | 122 | 'value': input_value, \ |
| 123 | 'actor': input_actor} | 123 | 'actor': input_actor} |
| @@ -131,10 +131,10 @@ class csworkflow(ctools.cscript): | @@ -131,10 +131,10 @@ class csworkflow(ctools.cscript): | ||
| 131 | actor_output = actor.element('output') | 131 | actor_output = actor.element('output') |
| 132 | num_outputs = actor_output.elements('parameter') | 132 | num_outputs = actor_output.elements('parameter') |
| 133 | for k in range(num_outputs): | 133 | for k in range(num_outputs): |
| 134 | - output = actor_output.element('parameter', k) | ||
| 135 | - output_name = output.attribute('name') | ||
| 136 | - output_value = output.attribute('value') | ||
| 137 | - output_actor = output.attribute('actor') | 134 | + output_par = actor_output.element('parameter', k) |
| 135 | + output_name = output_par.attribute('name') | ||
| 136 | + output_value = output_par.attribute('value') | ||
| 137 | + output_actor = output_par.attribute('actor') | ||
| 138 | parameter = {'name': output_name, \ | 138 | parameter = {'name': output_name, \ |
| 139 | 'value': output_value, \ | 139 | 'value': output_value, \ |
| 140 | 'actor': output_actor} | 140 | 'actor': output_actor} |
| @@ -263,25 +263,25 @@ class csworkflow(ctools.cscript): | @@ -263,25 +263,25 @@ class csworkflow(ctools.cscript): | ||
| 263 | return | 263 | return |
| 264 | 264 | ||
| 265 | # Create actor tool object | 265 | # Create actor tool object |
| 266 | - object = eval(tool_eval) | 266 | + tool = eval(tool_eval) |
| 267 | 267 | ||
| 268 | # Set actor input parameters | 268 | # Set actor input parameters |
| 269 | pars = actor['input_parameters'] | 269 | pars = actor['input_parameters'] |
| 270 | for par in pars: | 270 | for par in pars: |
| 271 | - app_par = object[par['name']] | 271 | + app_par = tool[par['name']] |
| 272 | app_par.value(self._get_parameter_value(par)) | 272 | app_par.value(self._get_parameter_value(par)) |
| 273 | - object[par['name']] = app_par | 273 | + tool[par['name']] = app_par |
| 274 | 274 | ||
| 275 | # Set actor output parameters | 275 | # Set actor output parameters |
| 276 | pars = actor['output_parameters'] | 276 | pars = actor['output_parameters'] |
| 277 | for par in pars: | 277 | for par in pars: |
| 278 | - app_par = object[par['name']] | 278 | + app_par = tool[par['name']] |
| 279 | app_par.value(self._get_parameter_value(par)) | 279 | app_par.value(self._get_parameter_value(par)) |
| 280 | - object[par['name']] = app_par | 280 | + tool[par['name']] = app_par |
| 281 | 281 | ||
| 282 | # Execute actor | 282 | # Execute actor |
| 283 | - object.logFileOpen() | ||
| 284 | - object.execute() | 283 | + tool.logFileOpen() |
| 284 | + tool.execute() | ||
| 285 | 285 | ||
| 286 | # Return | 286 | # Return |
| 287 | return | 287 | return |
cscripts/obsutils.py
| @@ -106,27 +106,27 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, | @@ -106,27 +106,27 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, | ||
| 106 | emax = max(run.events().ebounds().emax().TeV(), emax) | 106 | emax = max(run.events().ebounds().emax().TeV(), emax) |
| 107 | 107 | ||
| 108 | # Allocate ctbin application and set parameters | 108 | # Allocate ctbin application and set parameters |
| 109 | - bin = ctools.ctbin(obssim.obs()) | ||
| 110 | - bin['ebinalg'] = 'LOG' | ||
| 111 | - bin['emin'] = emin | ||
| 112 | - bin['emax'] = emax | ||
| 113 | - bin['enumbins'] = nbins | ||
| 114 | - bin['usepnt'] = True # Use pointing for map centre | ||
| 115 | - bin['nxpix'] = npix | ||
| 116 | - bin['nypix'] = npix | ||
| 117 | - bin['binsz'] = binsz | ||
| 118 | - bin['coordsys'] = coord | ||
| 119 | - bin['proj'] = proj | ||
| 120 | - bin['chatter'] = chatter | ||
| 121 | - bin['debug'] = debug | 109 | + binning = ctools.ctbin(obssim.obs()) |
| 110 | + binning['ebinalg'] = 'LOG' | ||
| 111 | + binning['emin'] = emin | ||
| 112 | + binning['emax'] = emax | ||
| 113 | + binning['enumbins'] = nbins | ||
| 114 | + binning['usepnt'] = True # Use pointing for map centre | ||
| 115 | + binning['nxpix'] = npix | ||
| 116 | + binning['nypix'] = npix | ||
| 117 | + binning['binsz'] = binsz | ||
| 118 | + binning['coordsys'] = coord | ||
| 119 | + binning['proj'] = proj | ||
| 120 | + binning['chatter'] = chatter | ||
| 121 | + binning['debug'] = debug | ||
| 122 | 122 | ||
| 123 | # Optionally open the log file | 123 | # Optionally open the log file |
| 124 | if log: | 124 | if log: |
| 125 | - bin.logFileOpen() | 125 | + binning.logFileOpen() |
| 126 | 126 | ||
| 127 | # Run ctbin application. This will loop over all observations in | 127 | # Run ctbin application. This will loop over all observations in |
| 128 | # the container and bin the events in counts maps | 128 | # the container and bin the events in counts maps |
| 129 | - bin.run() | 129 | + binning.run() |
| 130 | 130 | ||
| 131 | # If we have multiple input observations then create stacked response | 131 | # If we have multiple input observations then create stacked response |
| 132 | # cubes and append them to the observation | 132 | # cubes and append them to the observation |
| @@ -144,22 +144,22 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, | @@ -144,22 +144,22 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, | ||
| 144 | 144 | ||
| 145 | # Set stacked response | 145 | # Set stacked response |
| 146 | if edisp: | 146 | if edisp: |
| 147 | - bin.obs()[0].response(response['expcube'], | ||
| 148 | - response['psfcube'], | ||
| 149 | - response['edispcube'], | ||
| 150 | - response['bkgcube']) | 147 | + binning.obs()[0].response(response['expcube'], |
| 148 | + response['psfcube'], | ||
| 149 | + response['edispcube'], | ||
| 150 | + response['bkgcube']) | ||
| 151 | else: | 151 | else: |
| 152 | - bin.obs()[0].response(response['expcube'], | ||
| 153 | - response['psfcube'], | ||
| 154 | - response['bkgcube']) | 152 | + binning.obs()[0].response(response['expcube'], |
| 153 | + response['psfcube'], | ||
| 154 | + response['bkgcube']) | ||
| 155 | 155 | ||
| 156 | # Set new models | 156 | # Set new models |
| 157 | - bin.obs().models(response['models']) | 157 | + binning.obs().models(response['models']) |
| 158 | 158 | ||
| 159 | # Make a deep copy of the observation that will be returned | 159 | # Make a deep copy of the observation that will be returned |
| 160 | # (the ctbin object will go out of scope one the function is | 160 | # (the ctbin object will go out of scope one the function is |
| 161 | # left) | 161 | # left) |
| 162 | - obs = bin.obs().copy() | 162 | + obs = binning.obs().copy() |
| 163 | 163 | ||
| 164 | else: | 164 | else: |
| 165 | 165 |
examples/make_pointings.py
| @@ -576,13 +576,13 @@ def write_obsdef(filename, obsdef, idstart): | @@ -576,13 +576,13 @@ def write_obsdef(filename, obsdef, idstart): | ||
| 576 | First identifier of observation definition file | 576 | First identifier of observation definition file |
| 577 | """ | 577 | """ |
| 578 | # Open file | 578 | # Open file |
| 579 | - file = open(filename, 'w') | 579 | + f = open(filename, 'w') |
| 580 | 580 | ||
| 581 | # Write header | 581 | # Write header |
| 582 | - file.write('id,ra,dec,tmin,duration,caldb,irf,emin,emax\n') | 582 | + f.write('id,ra,dec,tmin,duration,caldb,irf,emin,emax\n') |
| 583 | 583 | ||
| 584 | # Initialise identifier | 584 | # Initialise identifier |
| 585 | - id = idstart | 585 | + obsid = idstart |
| 586 | 586 | ||
| 587 | # Loop over pointings | 587 | # Loop over pointings |
| 588 | for obs in obsdef: | 588 | for obs in obsdef: |
| @@ -591,10 +591,10 @@ def write_obsdef(filename, obsdef, idstart): | @@ -591,10 +591,10 @@ def write_obsdef(filename, obsdef, idstart): | ||
| 591 | if 'lon' in obs and 'lat' in obs: | 591 | if 'lon' in obs and 'lat' in obs: |
| 592 | lon = obs['lon'] | 592 | lon = obs['lon'] |
| 593 | lat = obs['lat'] | 593 | lat = obs['lat'] |
| 594 | - dir = gammalib.GSkyDir() | ||
| 595 | - dir.lb_deg(lon,lat) | ||
| 596 | - ra = dir.ra_deg() | ||
| 597 | - dec = dir.dec_deg() | 594 | + pnt = gammalib.GSkyDir() |
| 595 | + pnt.lb_deg(lon,lat) | ||
| 596 | + ra = pnt.ra_deg() | ||
| 597 | + dec = pnt.dec_deg() | ||
| 598 | else: | 598 | else: |
| 599 | ra = obs['ra'] | 599 | ra = obs['ra'] |
| 600 | dec = obs['dec'] | 600 | dec = obs['dec'] |
| @@ -608,15 +608,15 @@ def write_obsdef(filename, obsdef, idstart): | @@ -608,15 +608,15 @@ def write_obsdef(filename, obsdef, idstart): | ||
| 608 | emax = 50.0 | 608 | emax = 50.0 |
| 609 | 609 | ||
| 610 | # Write information | 610 | # Write information |
| 611 | - file.write('%6.6d,%8.4f,%8.4f,%.4f,%.4f,%s,%s,%.3f,%.1f\n' % | ||
| 612 | - (id, ra, dec, obs['tmin'], obs['duration'], obs['caldb'], \ | ||
| 613 | - obs['irf'], emin, emax)) | 611 | + f.write('%6.6d,%8.4f,%8.4f,%.4f,%.4f,%s,%s,%.3f,%.1f\n' % |
| 612 | + (obsid, ra, dec, obs['tmin'], obs['duration'], obs['caldb'], \ | ||
| 613 | + obs['irf'], emin, emax)) | ||
| 614 | 614 | ||
| 615 | # Increment identifier | 615 | # Increment identifier |
| 616 | - id += 1 | 616 | + obsid += 1 |
| 617 | 617 | ||
| 618 | # Close file | 618 | # Close file |
| 619 | - file.close() | 619 | + f.close() |
| 620 | 620 | ||
| 621 | # Return | 621 | # Return |
| 622 | return | 622 | return |
examples/pipeline_binned_disk.py
| @@ -80,27 +80,27 @@ def run_pipeline(obs, emin=0.1, emax=100.0, | @@ -80,27 +80,27 @@ def run_pipeline(obs, emin=0.1, emax=100.0, | ||
| 80 | cubefile = 'cube_'+eventfile | 80 | cubefile = 'cube_'+eventfile |
| 81 | 81 | ||
| 82 | # Bin events for that observation | 82 | # Bin events for that observation |
| 83 | - bin = ctools.ctbin() | ||
| 84 | - bin['inobs'] = eventfile | ||
| 85 | - bin['outcube'] = cubefile | ||
| 86 | - bin['ebinalg'] = 'LOG' | ||
| 87 | - bin['emin'] = emin | ||
| 88 | - bin['emax'] = emax | ||
| 89 | - bin['enumbins'] = enumbins | ||
| 90 | - bin['nxpix'] = nxpix | ||
| 91 | - bin['nypix'] = nypix | ||
| 92 | - bin['binsz'] = binsz | ||
| 93 | - bin['coordsys'] = coordsys | ||
| 94 | - bin['usepnt'] = True | ||
| 95 | - bin['proj'] = proj | ||
| 96 | - bin.execute() | 83 | + binning = ctools.ctbin() |
| 84 | + binning['inobs'] = eventfile | ||
| 85 | + binning['outcube'] = cubefile | ||
| 86 | + binning['ebinalg'] = 'LOG' | ||
| 87 | + binning['emin'] = emin | ||
| 88 | + binning['emax'] = emax | ||
| 89 | + binning['enumbins'] = enumbins | ||
| 90 | + binning['nxpix'] = nxpix | ||
| 91 | + binning['nypix'] = nypix | ||
| 92 | + binning['binsz'] = binsz | ||
| 93 | + binning['coordsys'] = coordsys | ||
| 94 | + binning['usepnt'] = True | ||
| 95 | + binning['proj'] = proj | ||
| 96 | + binning.execute() | ||
| 97 | 97 | ||
| 98 | # Set observation ID | 98 | # Set observation ID |
| 99 | - bin.obs()[0].id(cubefile) | ||
| 100 | - bin.obs()[0].eventfile(cubefile) | 99 | + binning.obs()[0].id(cubefile) |
| 100 | + binning.obs()[0].eventfile(cubefile) | ||
| 101 | 101 | ||
| 102 | # Append result to observations | 102 | # Append result to observations |
| 103 | - obs.extend(bin.obs()) | 103 | + obs.extend(binning.obs()) |
| 104 | 104 | ||
| 105 | # Save XML file | 105 | # Save XML file |
| 106 | xml = gammalib.GXml() | 106 | xml = gammalib.GXml() |
examples/pipeline_binned_mem.py
| @@ -70,21 +70,21 @@ def run_pipeline(obs, emin=0.1, emax=100.0, | @@ -70,21 +70,21 @@ def run_pipeline(obs, emin=0.1, emax=100.0, | ||
| 70 | container.append(run) | 70 | container.append(run) |
| 71 | 71 | ||
| 72 | # Bin events for that observation | 72 | # Bin events for that observation |
| 73 | - bin = ctools.ctbin(container) | ||
| 74 | - bin['ebinalg'] = 'LOG' | ||
| 75 | - bin['emin'] = emin | ||
| 76 | - bin['emax'] = emax | ||
| 77 | - bin['enumbins'] = enumbins | ||
| 78 | - bin['nxpix'] = nxpix | ||
| 79 | - bin['nypix'] = nypix | ||
| 80 | - bin['binsz'] = binsz | ||
| 81 | - bin['coordsys'] = coordsys | ||
| 82 | - bin['usepnt'] = True | ||
| 83 | - bin['proj'] = proj | ||
| 84 | - bin.run() | 73 | + binning = ctools.ctbin(container) |
| 74 | + binning['ebinalg'] = 'LOG' | ||
| 75 | + binning['emin'] = emin | ||
| 76 | + binning['emax'] = emax | ||
| 77 | + binning['enumbins'] = enumbins | ||
| 78 | + binning['nxpix'] = nxpix | ||
| 79 | + binning['nypix'] = nypix | ||
| 80 | + binning['binsz'] = binsz | ||
| 81 | + binning['coordsys'] = coordsys | ||
| 82 | + binning['usepnt'] = True | ||
| 83 | + binning['proj'] = proj | ||
| 84 | + binning.run() | ||
| 85 | 85 | ||
| 86 | # Append result to observations | 86 | # Append result to observations |
| 87 | - obs.extend(bin.obs()) | 87 | + obs.extend(binning.obs()) |
| 88 | 88 | ||
| 89 | # Perform maximum likelihood fitting | 89 | # Perform maximum likelihood fitting |
| 90 | like = ctools.ctlike(obs) | 90 | like = ctools.ctlike(obs) |
examples/pipeline_stacked_disk.py
| @@ -75,22 +75,22 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, | @@ -75,22 +75,22 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, | ||
| 75 | sim.execute() | 75 | sim.execute() |
| 76 | 76 | ||
| 77 | # Bin events into counts map | 77 | # Bin events into counts map |
| 78 | - bin = ctools.ctbin() | ||
| 79 | - bin['inobs'] = 'obs.xml' | ||
| 80 | - bin['outcube'] = 'cntcube.fits' | ||
| 81 | - bin['ebinalg'] = 'LOG' | ||
| 82 | - bin['emin'] = emin | ||
| 83 | - bin['emax'] = emax | ||
| 84 | - bin['enumbins'] = enumbins | ||
| 85 | - bin['nxpix'] = nxpix | ||
| 86 | - bin['nypix'] = nypix | ||
| 87 | - bin['binsz'] = binsz | ||
| 88 | - bin['coordsys'] = coordsys | ||
| 89 | - bin['proj'] = proj | ||
| 90 | - bin['xref'] = ra | ||
| 91 | - bin['yref'] = dec | ||
| 92 | - bin['debug'] = debug | ||
| 93 | - bin.execute() | 78 | + binning = ctools.ctbin() |
| 79 | + binning['inobs'] = 'obs.xml' | ||
| 80 | + binning['outcube'] = 'cntcube.fits' | ||
| 81 | + binning['ebinalg'] = 'LOG' | ||
| 82 | + binning['emin'] = emin | ||
| 83 | + binning['emax'] = emax | ||
| 84 | + binning['enumbins'] = enumbins | ||
| 85 | + binning['nxpix'] = nxpix | ||
| 86 | + binning['nypix'] = nypix | ||
| 87 | + binning['binsz'] = binsz | ||
| 88 | + binning['coordsys'] = coordsys | ||
| 89 | + binning['proj'] = proj | ||
| 90 | + binning['xref'] = ra | ||
| 91 | + binning['yref'] = dec | ||
| 92 | + binning['debug'] = debug | ||
| 93 | + binning.execute() | ||
| 94 | 94 | ||
| 95 | # Create exposure cube | 95 | # Create exposure cube |
| 96 | expcube = ctools.ctexpcube() | 96 | expcube = ctools.ctexpcube() |
examples/pipeline_stacked_mem.py
| @@ -65,20 +65,20 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, | @@ -65,20 +65,20 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, | ||
| 65 | sim.run() | 65 | sim.run() |
| 66 | 66 | ||
| 67 | # Bin events into counts map | 67 | # Bin events into counts map |
| 68 | - bin = ctools.ctbin(sim.obs()) | ||
| 69 | - bin['ebinalg'] = 'LOG' | ||
| 70 | - bin['emin'] = emin | ||
| 71 | - bin['emax'] = emax | ||
| 72 | - bin['enumbins'] = enumbins | ||
| 73 | - bin['nxpix'] = nxpix | ||
| 74 | - bin['nypix'] = nypix | ||
| 75 | - bin['binsz'] = binsz | ||
| 76 | - bin['coordsys'] = coordsys | ||
| 77 | - bin['proj'] = proj | ||
| 78 | - bin['xref'] = ra | ||
| 79 | - bin['yref'] = dec | ||
| 80 | - bin['debug'] = debug | ||
| 81 | - bin.run() | 68 | + binning = ctools.ctbin(sim.obs()) |
| 69 | + binning['ebinalg'] = 'LOG' | ||
| 70 | + binning['emin'] = emin | ||
| 71 | + binning['emax'] = emax | ||
| 72 | + binning['enumbins'] = enumbins | ||
| 73 | + binning['nxpix'] = nxpix | ||
| 74 | + binning['nypix'] = nypix | ||
| 75 | + binning['binsz'] = binsz | ||
| 76 | + binning['coordsys'] = coordsys | ||
| 77 | + binning['proj'] = proj | ||
| 78 | + binning['xref'] = ra | ||
| 79 | + binning['yref'] = dec | ||
| 80 | + binning['debug'] = debug | ||
| 81 | + binning.run() | ||
| 82 | 82 | ||
| 83 | # Create exposure cube | 83 | # Create exposure cube |
| 84 | expcube = ctools.ctexpcube(sim.obs()) | 84 | expcube = ctools.ctexpcube(sim.obs()) |
| @@ -132,14 +132,14 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, | @@ -132,14 +132,14 @@ def run_pipeline(obs, ra=83.63, dec=22.01, emin=0.1, emax=100.0, | ||
| 132 | bkgcube.run() | 132 | bkgcube.run() |
| 133 | 133 | ||
| 134 | # Attach background model to observation container | 134 | # Attach background model to observation container |
| 135 | - bin.obs().models(bkgcube.models()) | 135 | + binning.obs().models(bkgcube.models()) |
| 136 | 136 | ||
| 137 | # Set Exposure and Psf cube for first CTA observation | 137 | # Set Exposure and Psf cube for first CTA observation |
| 138 | # (ctbin will create an observation with a single container) | 138 | # (ctbin will create an observation with a single container) |
| 139 | - bin.obs()[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube()) | 139 | + binning.obs()[0].response(expcube.expcube(), psfcube.psfcube(), bkgcube.bkgcube()) |
| 140 | 140 | ||
| 141 | # Perform maximum likelihood fitting | 141 | # Perform maximum likelihood fitting |
| 142 | - like = ctools.ctlike(bin.obs()) | 142 | + like = ctools.ctlike(binning.obs()) |
| 143 | like['debug'] = True # Switch this always on for results in console | 143 | like['debug'] = True # Switch this always on for results in console |
| 144 | like.run() | 144 | like.run() |
| 145 | 145 |
pyext/setup.py.in
| 1 | ############################################################################# | 1 | ############################################################################# |
| 2 | # Disutils setup file for ctools Python extension module # | 2 | # Disutils setup file for ctools Python extension module # |
| 3 | # ------------------------------------------------------------------------- # | 3 | # ------------------------------------------------------------------------- # |
| 4 | -# Copyright (C) 2011-2016 Juergen Knoedlseder # | 4 | +# Copyright (C) 2011-2017 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 # |
| @@ -84,9 +84,9 @@ if os.path.exists(prefix+'/lib'): | @@ -84,9 +84,9 @@ if os.path.exists(prefix+'/lib'): | ||
| 84 | # in the src directory. Once we added the ctools script we had to | 84 | # in the src directory. Once we added the ctools script we had to |
| 85 | # add an explicit filter to avoid appending those. | 85 | # add an explicit filter to avoid appending those. |
| 86 | dirs = glob.glob('@top_srcdir@/src/ct*') | 86 | dirs = glob.glob('@top_srcdir@/src/ct*') |
| 87 | -for dir in dirs: | ||
| 88 | - if len(dir) > 0 and 'ctools' not in dir: | ||
| 89 | - path = os.path.abspath(dir) | 87 | +for d in dirs: |
| 88 | + if len(d) > 0 and 'ctools' not in d: | ||
| 89 | + path = os.path.abspath(d) | ||
| 90 | include_dirs.append(path) | 90 | include_dirs.append(path) |
| 91 | include_dirs.append(os.path.abspath('@top_srcdir@/src/support')) | 91 | include_dirs.append(os.path.abspath('@top_srcdir@/src/support')) |
| 92 | 92 | ||
| @@ -100,18 +100,18 @@ for extra_lib in extra_libs: | @@ -100,18 +100,18 @@ for extra_lib in extra_libs: | ||
| 100 | extra_lib_paths = ('@LDFLAGS@').split(' ') | 100 | extra_lib_paths = ('@LDFLAGS@').split(' ') |
| 101 | for extra_lib_path in extra_lib_paths: | 101 | for extra_lib_path in extra_lib_paths: |
| 102 | if extra_lib_path.lstrip().find('-L') == 0: | 102 | if extra_lib_path.lstrip().find('-L') == 0: |
| 103 | - dir = extra_lib_path.lstrip().lstrip('-L') | ||
| 104 | - if len(dir) > 0: | ||
| 105 | - library_dirs.append(dir) | ||
| 106 | - runtime_library_dirs.append(dir) | 103 | + d = extra_lib_path.lstrip().lstrip('-L') |
| 104 | + if len(d) > 0: | ||
| 105 | + library_dirs.append(d) | ||
| 106 | + runtime_library_dirs.append(d) | ||
| 107 | 107 | ||
| 108 | # Get extra include directories | 108 | # Get extra include directories |
| 109 | extra_include_dirs = ('@CPPFLAGS@').split(' ') | 109 | extra_include_dirs = ('@CPPFLAGS@').split(' ') |
| 110 | for extra_include_dir in extra_include_dirs: | 110 | for extra_include_dir in extra_include_dirs: |
| 111 | if extra_include_dir.lstrip().find('-I') == 0: | 111 | if extra_include_dir.lstrip().find('-I') == 0: |
| 112 | - dir = extra_include_dir.lstrip().lstrip('-I') | ||
| 113 | - if len(dir) > 0: | ||
| 114 | - include_dirs.append(dir) | 112 | + d = extra_include_dir.lstrip().lstrip('-I') |
| 113 | + if len(d) > 0: | ||
| 114 | + include_dirs.append(d) | ||
| 115 | 115 | ||
| 116 | # Set data files to install. | 116 | # Set data files to install. |
| 117 | data_files=[(prefix+'/share/ctools/swig', install_files)] | 117 | data_files=[(prefix+'/share/ctools/swig', install_files)] |
test/test_ctbin.py
| @@ -129,56 +129,56 @@ class Test(test): | @@ -129,56 +129,56 @@ class Test(test): | ||
| 129 | Test ctbin from Python | 129 | Test ctbin from Python |
| 130 | """ | 130 | """ |
| 131 | # Allocate ctbin | 131 | # Allocate ctbin |
| 132 | - bin = ctools.ctbin() | 132 | + binning = ctools.ctbin() |
| 133 | 133 | ||
| 134 | # Check that empty ctbin has an empty observation container and counts | 134 | # Check that empty ctbin has an empty observation container and counts |
| 135 | # cube | 135 | # cube |
| 136 | - self.test_value(bin.obs().size(), 0, | 136 | + self.test_value(binning.obs().size(), 0, |
| 137 | 'Check that empty ctbin has an empty observation container') | 137 | 'Check that empty ctbin has an empty observation container') |
| 138 | - self.test_value(bin.cube().size(), 0, | 138 | + self.test_value(binning.cube().size(), 0, |
| 139 | 'Check that empty ctbin has an empty counts cube') | 139 | 'Check that empty ctbin has an empty counts cube') |
| 140 | 140 | ||
| 141 | # Check that saving does not nothing | 141 | # Check that saving does not nothing |
| 142 | - bin['logfile'] = 'ctbin_py0.log' | ||
| 143 | - bin['outcube'] = 'ctbin_py0.fits' | ||
| 144 | - bin.logFileOpen() | ||
| 145 | - bin.save() | 142 | + binning['logfile'] = 'ctbin_py0.log' |
| 143 | + binning['outcube'] = 'ctbin_py0.fits' | ||
| 144 | + binning.logFileOpen() | ||
| 145 | + binning.save() | ||
| 146 | self.test_assert(not os.path.isfile('ctbin_py0.fits'), | 146 | self.test_assert(not os.path.isfile('ctbin_py0.fits'), |
| 147 | 'Check that no counts cube has been created') | 147 | 'Check that no counts cube has been created') |
| 148 | 148 | ||
| 149 | # Check that publishing does not lead to an exception or segfault | 149 | # Check that publishing does not lead to an exception or segfault |
| 150 | - bin.publish() | 150 | + binning.publish() |
| 151 | 151 | ||
| 152 | # Check that clearing does not lead to an exception or segfault | 152 | # Check that clearing does not lead to an exception or segfault |
| 153 | - bin.clear() | 153 | + binning.clear() |
| 154 | 154 | ||
| 155 | # Now set ctbin parameters | 155 | # Now set ctbin parameters |
| 156 | - bin['inobs'] = self._events | ||
| 157 | - bin['outcube'] = 'ctbin_py1.fits' | ||
| 158 | - bin['ebinalg'] = 'LOG' | ||
| 159 | - bin['emin'] = 0.1 | ||
| 160 | - bin['emax'] = 100.0 | ||
| 161 | - bin['enumbins'] = 10 | ||
| 162 | - bin['nxpix'] = 40 | ||
| 163 | - bin['nypix'] = 40 | ||
| 164 | - bin['binsz'] = 0.1 | ||
| 165 | - bin['coordsys'] = 'CEL' | ||
| 166 | - bin['proj'] = 'CAR' | ||
| 167 | - bin['xref'] = 83.63 | ||
| 168 | - bin['yref'] = 22.01 | ||
| 169 | - bin['logfile'] = 'ctbin_py1.log' | ||
| 170 | - bin['chatter'] = 2 | 156 | + binning['inobs'] = self._events |
| 157 | + binning['outcube'] = 'ctbin_py1.fits' | ||
| 158 | + binning['ebinalg'] = 'LOG' | ||
| 159 | + binning['emin'] = 0.1 | ||
| 160 | + binning['emax'] = 100.0 | ||
| 161 | + binning['enumbins'] = 10 | ||
| 162 | + binning['nxpix'] = 40 | ||
| 163 | + binning['nypix'] = 40 | ||
| 164 | + binning['binsz'] = 0.1 | ||
| 165 | + binning['coordsys'] = 'CEL' | ||
| 166 | + binning['proj'] = 'CAR' | ||
| 167 | + binning['xref'] = 83.63 | ||
| 168 | + binning['yref'] = 22.01 | ||
| 169 | + binning['logfile'] = 'ctbin_py1.log' | ||
| 170 | + binning['chatter'] = 2 | ||
| 171 | 171 | ||
| 172 | # Run ctbin tool | 172 | # Run ctbin tool |
| 173 | - bin.logFileOpen() | ||
| 174 | - bin.run() | 173 | + binning.logFileOpen() |
| 174 | + binning.run() | ||
| 175 | 175 | ||
| 176 | # Check content of observation container and counts cube | 176 | # Check content of observation container and counts cube |
| 177 | - self._check_observation(bin, 5542) | ||
| 178 | - self._check_cube(bin.cube(), 5542) | 177 | + self._check_observation(binning, 5542) |
| 178 | + self._check_cube(binning.cube(), 5542) | ||
| 179 | 179 | ||
| 180 | # Copy ctbin tool | 180 | # Copy ctbin tool |
| 181 | - cpy_bin = bin.copy() | 181 | + cpy_bin = binning.copy() |
| 182 | 182 | ||
| 183 | # Check content of observation container and counts cube | 183 | # Check content of observation container and counts cube |
| 184 | self._check_observation(cpy_bin, 5542) | 184 | self._check_observation(cpy_bin, 5542) |
| @@ -197,20 +197,20 @@ class Test(test): | @@ -197,20 +197,20 @@ class Test(test): | ||
| 197 | self._check_cube(cpy_bin.cube(), 0) | 197 | self._check_cube(cpy_bin.cube(), 0) |
| 198 | 198 | ||
| 199 | # Save counts cube | 199 | # Save counts cube |
| 200 | - bin.save() | 200 | + binning.save() |
| 201 | 201 | ||
| 202 | # Load counts cube and check content | 202 | # Load counts cube and check content |
| 203 | evt = gammalib.GCTAEventCube('ctbin_py1.fits') | 203 | evt = gammalib.GCTAEventCube('ctbin_py1.fits') |
| 204 | self._check_cube(evt, 5542) | 204 | self._check_cube(evt, 5542) |
| 205 | 205 | ||
| 206 | # Now clear ctbin tool | 206 | # Now clear ctbin tool |
| 207 | - bin.clear() | 207 | + binning.clear() |
| 208 | 208 | ||
| 209 | # Check that cleared ctbin has an empty observation container and | 209 | # Check that cleared ctbin has an empty observation container and |
| 210 | # counts cube | 210 | # counts cube |
| 211 | - self.test_value(bin.obs().size(), 0, | 211 | + self.test_value(binning.obs().size(), 0, |
| 212 | 'Check that empty ctbin has an empty observation container') | 212 | 'Check that empty ctbin has an empty observation container') |
| 213 | - self.test_value(bin.cube().size(), 0, | 213 | + self.test_value(binning.cube().size(), 0, |
| 214 | 'Check that empty ctbin has an empty counts cube') | 214 | 'Check that empty ctbin has an empty counts cube') |
| 215 | 215 | ||
| 216 | # Prepare observation container for stacking of events into a | 216 | # Prepare observation container for stacking of events into a |
| @@ -218,31 +218,31 @@ class Test(test): | @@ -218,31 +218,31 @@ class Test(test): | ||
| 218 | obs = self._obs_events() | 218 | obs = self._obs_events() |
| 219 | 219 | ||
| 220 | # Set-up ctbin using an observation container | 220 | # Set-up ctbin using an observation container |
| 221 | - bin = ctools.ctbin(obs) | ||
| 222 | - bin['outcube'] = 'ctbin_py3.fits' | ||
| 223 | - bin['ebinalg'] = 'LOG' | ||
| 224 | - bin['emin'] = 0.1 | ||
| 225 | - bin['emax'] = 100.0 | ||
| 226 | - bin['enumbins'] = 10 | ||
| 227 | - bin['nxpix'] = 40 | ||
| 228 | - bin['nypix'] = 40 | ||
| 229 | - bin['binsz'] = 0.1 | ||
| 230 | - bin['coordsys'] = 'CEL' | ||
| 231 | - bin['proj'] = 'CAR' | ||
| 232 | - bin['xref'] = 83.63 | ||
| 233 | - bin['yref'] = 22.01 | ||
| 234 | - bin['publish'] = True | ||
| 235 | - bin['logfile'] = 'ctbin_py3.log' | ||
| 236 | - bin['chatter'] = 3 | 221 | + binning = ctools.ctbin(obs) |
| 222 | + binning['outcube'] = 'ctbin_py3.fits' | ||
| 223 | + binning['ebinalg'] = 'LOG' | ||
| 224 | + binning['emin'] = 0.1 | ||
| 225 | + binning['emax'] = 100.0 | ||
| 226 | + binning['enumbins'] = 10 | ||
| 227 | + binning['nxpix'] = 40 | ||
| 228 | + binning['nypix'] = 40 | ||
| 229 | + binning['binsz'] = 0.1 | ||
| 230 | + binning['coordsys'] = 'CEL' | ||
| 231 | + binning['proj'] = 'CAR' | ||
| 232 | + binning['xref'] = 83.63 | ||
| 233 | + binning['yref'] = 22.01 | ||
| 234 | + binning['publish'] = True | ||
| 235 | + binning['logfile'] = 'ctbin_py3.log' | ||
| 236 | + binning['chatter'] = 3 | ||
| 237 | 237 | ||
| 238 | # Execute ctbin tool | 238 | # Execute ctbin tool |
| 239 | - bin.logFileOpen() | ||
| 240 | - bin.execute() | 239 | + binning.logFileOpen() |
| 240 | + binning.execute() | ||
| 241 | 241 | ||
| 242 | # Check content of observation and cube (need multiplier=3 since | 242 | # Check content of observation and cube (need multiplier=3 since |
| 243 | # three identical observations have been appended) | 243 | # three identical observations have been appended) |
| 244 | - self._check_observation(bin, 5542, multiplier=3) | ||
| 245 | - self._check_cube(bin.cube(), 5542, multiplier=3) | 244 | + self._check_observation(binning, 5542, multiplier=3) |
| 245 | + self._check_cube(binning.cube(), 5542, multiplier=3) | ||
| 246 | 246 | ||
| 247 | # Load counts cube and check content. | 247 | # Load counts cube and check content. |
| 248 | evt = gammalib.GCTAEventCube('ctbin_py3.fits') | 248 | evt = gammalib.GCTAEventCube('ctbin_py3.fits') |
| @@ -255,10 +255,10 @@ class Test(test): | @@ -255,10 +255,10 @@ class Test(test): | ||
| 255 | 'binsz': 0.1, 'coordsys': 'CEL', 'proj': 'CAR', | 255 | 'binsz': 0.1, 'coordsys': 'CEL', 'proj': 'CAR', |
| 256 | 'xref': 83.63, 'yref': 22.01, 'outcube': 'ctbin_py4.fits', | 256 | 'xref': 83.63, 'yref': 22.01, 'outcube': 'ctbin_py4.fits', |
| 257 | 'logfile': 'ctbin_py4.log', 'chatter': 2} | 257 | 'logfile': 'ctbin_py4.log', 'chatter': 2} |
| 258 | - bin = ctools.ctbin() | ||
| 259 | - bin.pardict(pars) | ||
| 260 | - bin.logFileOpen() | ||
| 261 | - bin.execute() | 258 | + binning = ctools.ctbin() |
| 259 | + binning.pardict(pars) | ||
| 260 | + binning.logFileOpen() | ||
| 261 | + binning.execute() | ||
| 262 | 262 | ||
| 263 | # Load counts cube and check content | 263 | # Load counts cube and check content |
| 264 | evt = gammalib.GCTAEventCube('ctbin_py4.fits') | 264 | evt = gammalib.GCTAEventCube('ctbin_py4.fits') |
test/test_ctobssim.py
| @@ -274,20 +274,20 @@ class Test(test): | @@ -274,20 +274,20 @@ class Test(test): | ||
| 274 | return | 274 | return |
| 275 | 275 | ||
| 276 | # Check event list | 276 | # Check event list |
| 277 | - def _test_list(self, list, nevents): | 277 | + def _test_list(self, eventlist, nevents): |
| 278 | """ | 278 | """ |
| 279 | Test content of event list | 279 | Test content of event list |
| 280 | 280 | ||
| 281 | Parameters | 281 | Parameters |
| 282 | ---------- | 282 | ---------- |
| 283 | - list : `~gammalib.GCTAEventList` | 283 | + eventlist : `~gammalib.GCTAEventList` |
| 284 | Event list | 284 | Event list |
| 285 | nevents : int | 285 | nevents : int |
| 286 | Expected number of events | 286 | Expected number of events |
| 287 | """ | 287 | """ |
| 288 | # Test event list | 288 | # Test event list |
| 289 | - self.test_value(list.size(), nevents, str(nevents)+' elements') | ||
| 290 | - self.test_value(list.number(), nevents, str(nevents)+' events') | 289 | + self.test_value(eventlist.size(), nevents, str(nevents)+' elements') |
| 290 | + self.test_value(eventlist.number(), nevents, str(nevents)+' events') | ||
| 291 | 291 | ||
| 292 | # Return | 292 | # Return |
| 293 | return | 293 | return |
test/test_obsutils.py
| @@ -84,10 +84,10 @@ class Test(test): | @@ -84,10 +84,10 @@ class Test(test): | ||
| 84 | Setup method for sim() function test | 84 | Setup method for sim() function test |
| 85 | """ | 85 | """ |
| 86 | # Set-up observation container | 86 | # Set-up observation container |
| 87 | - dir = gammalib.GSkyDir() | ||
| 88 | - dir.radec_deg(83.6331, 22.0145) | 87 | + pnt = gammalib.GSkyDir() |
| 88 | + pnt.radec_deg(83.6331, 22.0145) | ||
| 89 | obs = gammalib.GObservations() | 89 | obs = gammalib.GObservations() |
| 90 | - run = obsutils.set_obs(dir, duration=100.0, emin=1.0, emax=10.0) | 90 | + run = obsutils.set_obs(pnt, duration=100.0, emin=1.0, emax=10.0) |
| 91 | run.id('0') | 91 | run.id('0') |
| 92 | obs.append(run) | 92 | obs.append(run) |
| 93 | if two: | 93 | if two: |