Commit 80f82c6d3b466bb3d2aeb43f820a5542785affa7
1 parent
ae4014dd
Integrate code
Showing
10 changed files
with
181 additions
and
154 deletions
ChangeLog
NEWS
| 1 | 1 | New Features and Important Changes in ctools 1.5.0 |
| 2 | 2 | |
| 3 | -8 August 2017 | |
| 3 | +11 October 2017 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | Introduction |
| ... | ... | @@ -119,6 +119,9 @@ None |
| 119 | 119 | |
| 120 | 120 | cscripts |
| 121 | 121 | -------- |
| 122 | +Add csmodelsois script that replaces selected models in a model container by | |
| 123 | +a diffuse map cube (#2180). | |
| 124 | + | |
| 122 | 125 | Use t-type parameters for "tmin" and "tmax" to all specifying times in various |
| 123 | 126 | formats (#1864). |
| 124 | 127 | ... | ... |
cscripts/__init__.py.in
| 1 | 1 | # ========================================================================== |
| 2 | 2 | # cscripts Python module |
| 3 | 3 | # |
| 4 | -# Copyright (C) 2015-2016 Juergen Knoedlseder | |
| 4 | +# Copyright (C) 2015-2017 Juergen Knoedlseder | |
| 5 | 5 | # |
| 6 | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | 7 | # it under the terms of the GNU General Public License as published by | ... | ... |
cscripts/csmodelsois.par
| ... | ... | @@ -16,11 +16,11 @@ |
| 16 | 16 | # |
| 17 | 17 | # General parameters |
| 18 | 18 | #=================== |
| 19 | -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Input model definition XML file" | |
| 20 | -outcube, f, a, "mapcube.fits",,, "Output map cube file" | |
| 19 | +inmodel, f, a, $CTOOLS/share/models/crab.xml,,, "Input model definition XML file" | |
| 20 | +outcube, f, a, mapcube.fits,,, "Output map cube file" | |
| 21 | 21 | ptsrcsig, r, h, 1.0,0,60, "Point source Gaussian sigma in arcmin" |
| 22 | -soilist, s, a, "",,, "CSV list of sources to exclude from cube model" | |
| 23 | -outmodel, f, a, "NONE",,, "Output model definition XML file" | |
| 22 | +soilist, s, a, ,,, "CSV list of sources to exclude from cube model" | |
| 23 | +outmodel, f, a, model.xml,,, "Output model definition XML file" | |
| 24 | 24 | |
| 25 | 25 | # |
| 26 | 26 | # Energy binning parameters |
| ... | ... | @@ -52,4 +52,4 @@ chatter, i, h, 2,0,4, "Chattiness of output" |
| 52 | 52 | clobber, b, h, yes,,, "Overwrite existing output files with new output files?" |
| 53 | 53 | debug, b, h, no,,, "Debugging mode activated" |
| 54 | 54 | mode, s, h, "ql",,, "Mode of automatic parameters" |
| 55 | -logfile, f, h, "ctmapcube.log",,, "Log filename" | |
| 55 | +logfile, f, h, "csmodelsois.log",,, "Log filename" | ... | ... |
cscripts/csmodelsois.py
| 1 | 1 | #! /usr/bin/env python |
| 2 | 2 | # ========================================================================== |
| 3 | -# Allows generation of DiffuseMapCube model from subset of sources in a | |
| 4 | -# model definition XML file | |
| 3 | +# Puts subset of sources in diffuse model cube | |
| 5 | 4 | # |
| 6 | 5 | # Copyright (C) 2017 Josh Cardenzana |
| 7 | 6 | # |
| ... | ... | @@ -23,19 +22,24 @@ import sys |
| 23 | 22 | import gammalib |
| 24 | 23 | import ctools |
| 25 | 24 | |
| 26 | -#=============# | |
| 27 | -# csmodelsois # | |
| 28 | -#=============# | |
| 25 | + | |
| 26 | +# ================= # | |
| 27 | +# csmodelsois class # | |
| 28 | +# ================= # | |
| 29 | 29 | class csmodelsois(ctools.cscript): |
| 30 | 30 | """ |
| 31 | - Generates a DiffuseMapCube model from a subset of sources in a model | |
| 32 | - definition XML file. All background models will be ignored! | |
| 31 | + Puts subset of sources in diffuse model cube | |
| 32 | + | |
| 33 | + The csmodelsois class puts a subset of sources in a model definition | |
| 34 | + XML file into a model cube and generates a new model definition XML file | |
| 35 | + in which the subset of sources is replaced by a model of type | |
| 36 | + DiffuseMapCube. | |
| 33 | 37 | """ |
| 34 | 38 | |
| 35 | 39 | # Constructor |
| 36 | 40 | def __init__(self, *argv): |
| 37 | 41 | """ |
| 38 | - Constructor. | |
| 42 | + Constructor | |
| 39 | 43 | |
| 40 | 44 | Parameters |
| 41 | 45 | ---------- |
| ... | ... | @@ -44,7 +48,7 @@ class csmodelsois(ctools.cscript): |
| 44 | 48 | Raises |
| 45 | 49 | ------ |
| 46 | 50 | TypeError |
| 47 | - An invalid number of command line arguments was provided. | |
| 51 | + An invalid number of command line arguments was provided. | |
| 48 | 52 | """ |
| 49 | 53 | # Set name and version |
| 50 | 54 | self._name = 'csmodelsois' |
| ... | ... | @@ -60,56 +64,60 @@ class csmodelsois(ctools.cscript): |
| 60 | 64 | return |
| 61 | 65 | |
| 62 | 66 | |
| 67 | + # Private methods | |
| 63 | 68 | def _init_members(self): |
| 64 | 69 | """ |
| 65 | 70 | Initialize the parameters for this object |
| 66 | 71 | """ |
| 67 | - self.cubegen = ctools.ctmapcube() # Implements ctmapcube for generate the cube | |
| 68 | - self.m_models = gammalib.GModels() # Stores the full list of input models | |
| 69 | - self.cubemodels = gammalib.GModels() # Stores the list of models to be written to file | |
| 70 | - return | |
| 72 | + # Initialise parameters | |
| 73 | + self.cubegen = ctools.ctmapcube() # Implements ctmapcube for generate the cube | |
| 74 | + self.m_models = gammalib.GModels() # Stores the full list of input models | |
| 75 | + self.cubemodels = gammalib.GModels() # Stores the list of models to be written to file | |
| 71 | 76 | |
| 77 | + # Return | |
| 78 | + return | |
| 72 | 79 | |
| 73 | - def _set_cube_parameters(self): | |
| 80 | + def _get_parameters(self): | |
| 74 | 81 | """ |
| 75 | - Fill in the parameters associated with this object | |
| 82 | + Get parameters from parfile | |
| 76 | 83 | """ |
| 84 | + # Query input parameters | |
| 85 | + self['inmodel'].filename() | |
| 86 | + self['soilist'].string() | |
| 87 | + | |
| 88 | + # Read input parameters | |
| 89 | + ptsrcsig = self['ptsrcsig'].real() | |
| 77 | 90 | |
| 78 | 91 | # Get the cube centre coordinates |
| 79 | - self.cubegen['coordsys'].string( self['coordsys'].string() ) | |
| 92 | + self.cubegen['coordsys'].string(self['coordsys'].string()) | |
| 80 | 93 | if self['coordsys'].string() == 'CEL': |
| 81 | - # Center in celestial coordinates | |
| 82 | - self.cubegen['xref'].real( self['ra'].real() ) | |
| 83 | - self.cubegen['yref'].real( self['dec'].real() ) | |
| 94 | + self.cubegen['xref'].real(self['ra'].real()) | |
| 95 | + self.cubegen['yref'].real(self['dec'].real()) | |
| 84 | 96 | else: |
| 85 | - # Otherwise assume center in galactic coordinates | |
| 86 | - self.cubegen['xref'].real( self['glon'].real() ) | |
| 87 | - self.cubegen['yref'].real( self['glat'].real() ) | |
| 97 | + self.cubegen['xref'].real(self['glon'].real()) | |
| 98 | + self.cubegen['yref'].real(self['glat'].real()) | |
| 88 | 99 | |
| 89 | 100 | # Get spatial binning parameters |
| 90 | - self.cubegen['binsz'].real( self['binsz'].real() ) | |
| 91 | - self.cubegen['nxpix'].integer( self['nxpix'].integer() ) | |
| 92 | - self.cubegen['nypix'].integer( self['nypix'].integer() ) | |
| 93 | - self.cubegen['proj'].string( self['proj'].string() ) | |
| 101 | + self.cubegen['binsz'].real(self['binsz'].real()) | |
| 102 | + self.cubegen['nxpix'].integer(self['nxpix'].integer()) | |
| 103 | + self.cubegen['nypix'].integer(self['nypix'].integer()) | |
| 104 | + self.cubegen['proj'].string(self['proj'].string()) | |
| 94 | 105 | |
| 95 | 106 | # Get the energy binning parameters |
| 96 | - self.cubegen['ebinalg'].string( self['ebinalg'].string() ) | |
| 97 | - if self['ebinalg'].string() == "FILE": | |
| 98 | - # Read energy binning from a file | |
| 99 | - self.cubegen['ebinfile'].filename( self['ebinfile'].filename() ) | |
| 107 | + self.cubegen['ebinalg'].string(self['ebinalg'].string()) | |
| 108 | + if self['ebinalg'].string() == 'FILE': | |
| 109 | + self.cubegen['ebinfile'].filename(self['ebinfile'].filename()) | |
| 100 | 110 | else: |
| 101 | - # Create the energy binning information | |
| 102 | - self.cubegen['emin'].real( self['emin'].real() ) | |
| 103 | - self.cubegen['emax'].real( self['emax'].real() ) | |
| 104 | - self.cubegen['enumbins'].integer( self['enumbins'].integer() ) | |
| 111 | + self.cubegen['emin'].real(self['emin'].real()) | |
| 112 | + self.cubegen['emax'].real(self['emax'].real()) | |
| 113 | + self.cubegen['enumbins'].integer(self['enumbins'].integer()) | |
| 105 | 114 | |
| 106 | 115 | # Get remaining hidden parameters |
| 107 | - self.cubegen['ptsrcsig'].real( self['ptsrcsig'].real() ) | |
| 116 | + self.cubegen['ptsrcsig'].real(ptsrcsig) | |
| 108 | 117 | |
| 109 | 118 | # Read optionally output cube filenames |
| 110 | 119 | if self._read_ahead(): |
| 111 | - self.cubegen['outcube'].filename( self['outcube'].filename() ) | |
| 112 | - self['soilist'].string() | |
| 120 | + self.cubegen['outcube'].filename(self['outcube'].filename()) | |
| 113 | 121 | self['outmodel'].filename() |
| 114 | 122 | |
| 115 | 123 | # Write parameters into logger |
| ... | ... | @@ -117,11 +125,9 @@ class csmodelsois(ctools.cscript): |
| 117 | 125 | |
| 118 | 126 | return |
| 119 | 127 | |
| 120 | - | |
| 121 | 128 | def _gen_cubemodel(self): |
| 122 | 129 | """ |
| 123 | 130 | Generates a binned model from the model file using ctmapcube |
| 124 | - returns: updated model filename | |
| 125 | 131 | """ |
| 126 | 132 | # Get a list of sources we DONT want to put into the cube |
| 127 | 133 | sources = self['soilist'].string().split(',') |
| ... | ... | @@ -129,52 +135,32 @@ class csmodelsois(ctools.cscript): |
| 129 | 135 | # Load the model into a model container |
| 130 | 136 | if (self.m_models.size() == 0): |
| 131 | 137 | self.m_models = gammalib.GModels(self['inmodel'].filename()) |
| 132 | - | |
| 138 | + | |
| 139 | + # Store a copy of the models | |
| 133 | 140 | self.cubemodels = self.m_models.copy() |
| 134 | 141 | |
| 135 | 142 | # Loop through models and pull out all models not in the list |
| 136 | 143 | models2remove = [] |
| 137 | 144 | for model in self.m_models: |
| 138 | - # Convert the model to a GModelSky | |
| 139 | - mod = model.classname() | |
| 140 | 145 | |
| 141 | - # Check the model | |
| 142 | - if mod != "GModelSky": | |
| 143 | - # Model is most likely a background model, so continue | |
| 146 | + # If model is not a sky model then continue | |
| 147 | + if model.classname() != 'GModelSky': | |
| 144 | 148 | self.cubemodels.remove(model.name()) |
| 149 | + | |
| 150 | + # ... otherwise, if model is in list of sources the remove it | |
| 151 | + # from the container | |
| 145 | 152 | elif model.name() in sources: |
| 146 | - # Model is a source of interest, so remove it from list of models | |
| 147 | - # to be used in generating the cube | |
| 148 | 153 | self.cubemodels.remove(model.name()) |
| 149 | 154 | |
| 150 | 155 | # Log the number of models to be put into the cube |
| 151 | - self._log_value(self['chatter'].integer(), 'Cube models', self.cubemodels.size()) | |
| 152 | - | |
| 153 | - return | |
| 154 | - | |
| 155 | - | |
| 156 | - def mapcube(self): | |
| 157 | - """ | |
| 158 | - Return the mapcube generated by the underlying 'ctmapcube' object | |
| 159 | - """ | |
| 160 | - return self.cubegen.mapcube() | |
| 156 | + self._log_value(self['chatter'].integer(), 'Numner of cube models', | |
| 157 | + self.cubemodels.size()) | |
| 161 | 158 | |
| 162 | - | |
| 163 | - def cubemodelname(self): | |
| 164 | - """ | |
| 165 | - Return the name to be given to the cube model in the output XML file | |
| 166 | - """ | |
| 167 | - return "FixedSourcesCube" | |
| 168 | - | |
| 169 | - | |
| 170 | - def models(self, models:gammalib.GModels): | |
| 171 | - """ | |
| 172 | - Set the models for analysis | |
| 173 | - """ | |
| 174 | - self.m_models = models | |
| 159 | + # Return | |
| 175 | 160 | return |
| 176 | 161 | |
| 177 | 162 | |
| 163 | + # Public methods | |
| 178 | 164 | def run(self): |
| 179 | 165 | """ |
| 180 | 166 | Implements the actual bulk of the script's tasks |
| ... | ... | @@ -184,41 +170,62 @@ class csmodelsois(ctools.cscript): |
| 184 | 170 | self._log.cout(True) |
| 185 | 171 | |
| 186 | 172 | # Get parameters |
| 187 | - self._set_cube_parameters() | |
| 173 | + self._get_parameters() | |
| 188 | 174 | |
| 189 | 175 | # Set the models to put into the cube |
| 190 | 176 | self._gen_cubemodel() |
| 191 | 177 | |
| 192 | 178 | # Only run if there still models to be filled into the cube |
| 193 | 179 | if not self.cubemodels.is_empty(): |
| 194 | - self._log_string(gammalib.NORMAL, 'Generting model cube') | |
| 180 | + | |
| 181 | + # Log action | |
| 182 | + self._log_string(gammalib.NORMAL, 'Generating model cube') | |
| 195 | 183 | |
| 196 | 184 | # Fill the cube models into the ctmapcube object |
| 197 | - self.cubegen.models( self.cubemodels ) | |
| 185 | + self.cubegen.models(self.cubemodels) | |
| 198 | 186 | |
| 199 | 187 | # Run the map generating method |
| 200 | 188 | self.cubegen.run() |
| 201 | 189 | |
| 202 | 190 | else: |
| 203 | - self._log_string(gammalib.NORMAL, 'List of models is empty, nothing will be done') | |
| 191 | + self._log_string(gammalib.NORMAL, | |
| 192 | + 'List of models is empty, nothing will be done') | |
| 204 | 193 | |
| 194 | + # Return | |
| 205 | 195 | return |
| 206 | 196 | |
| 197 | + def execute(self): | |
| 198 | + """ | |
| 199 | + Execute the script | |
| 200 | + """ | |
| 201 | + # Open logfile | |
| 202 | + self.logFileOpen() | |
| 203 | + | |
| 204 | + # Read ahead output parameters | |
| 205 | + self._read_ahead(True) | |
| 206 | + | |
| 207 | + # Run the script | |
| 208 | + self.run() | |
| 209 | + | |
| 210 | + # Save model | |
| 211 | + self.save() | |
| 212 | + | |
| 213 | + # Return | |
| 214 | + return | |
| 207 | 215 | |
| 208 | 216 | def save(self): |
| 209 | 217 | """ |
| 210 | 218 | Save the cube and optionally the updated XML model file |
| 211 | 219 | """ |
| 212 | - #cube = gammalib.GModelSpatialDiffuseCube(self.cubegen.mapcube()) | |
| 213 | - | |
| 214 | 220 | # Save the generated cube if the cube and filename are not empty |
| 215 | 221 | if ((not self.cubegen.mapcube().cube().is_empty()) and |
| 216 | 222 | self._is_valid_filename(self['outcube'].filename())): |
| 217 | - | |
| 218 | - self.cubegen.mapcube().save( self['outcube'].filename(), self['clobber'].boolean() ) | |
| 223 | + self.cubegen.mapcube().save(self['outcube'].filename(), | |
| 224 | + self['clobber'].boolean()) | |
| 219 | 225 | |
| 220 | 226 | # If requested, save the updated list of models |
| 221 | - if self._is_valid_filename( self['outmodel'].filename() ): | |
| 227 | + if self._is_valid_filename(self['outmodel'].filename()): | |
| 228 | + | |
| 222 | 229 | # Generate a list of models that will be output to file |
| 223 | 230 | outmodels = gammalib.GModels(self.m_models) |
| 224 | 231 | |
| ... | ... | @@ -227,35 +234,47 @@ class csmodelsois(ctools.cscript): |
| 227 | 234 | outmodels.remove(model.name()) |
| 228 | 235 | |
| 229 | 236 | # Generate the actual cube model |
| 230 | - spat = gammalib.GModelSpatialDiffuseCube( self['outcube'].filename() ) | |
| 237 | + spat = gammalib.GModelSpatialDiffuseCube(self['outcube'].filename()) | |
| 231 | 238 | spec = gammalib.GModelSpectralConst() |
| 232 | 239 | newmodel = gammalib.GModelSky(spat, spec) |
| 233 | 240 | |
| 234 | 241 | # Give the model a default name |
| 235 | - newmodel.name( self.cubemodelname() ) | |
| 242 | + newmodel.name(self.cubemodelname()) | |
| 236 | 243 | |
| 237 | 244 | # Now append the model to the list of output models |
| 238 | 245 | outmodels.append(newmodel) |
| 239 | 246 | |
| 240 | 247 | # Save the model list |
| 241 | - outmodels.save( self['outmodel'].filename() ) | |
| 248 | + outmodels.save(self['outmodel'].filename()) | |
| 242 | 249 | |
| 250 | + # Return | |
| 243 | 251 | return |
| 244 | 252 | |
| 253 | + def mapcube(self): | |
| 254 | + """ | |
| 255 | + Return the mapcube generated by the underlying 'ctmapcube' object | |
| 256 | + """ | |
| 257 | + # Return | |
| 258 | + return self.cubegen.mapcube() | |
| 245 | 259 | |
| 246 | - def execute(self): | |
| 260 | + def cubemodelname(self): | |
| 247 | 261 | """ |
| 248 | - Execute the script | |
| 262 | + Return the name to be given to the cube model in the output XML file | |
| 249 | 263 | """ |
| 250 | - # Open logfile | |
| 251 | - self.logFileOpen() | |
| 264 | + # Return | |
| 265 | + return 'FixedSourcesCube' | |
| 252 | 266 | |
| 253 | - # Read ahead output parameters | |
| 254 | - self._read_ahead(True) | |
| 267 | + def models(self, models): | |
| 268 | + """ | |
| 269 | + Set the models | |
| 255 | 270 | |
| 256 | - # Run the script | |
| 257 | - self.run() | |
| 258 | - self.save() | |
| 271 | + Parameters | |
| 272 | + ------- | |
| 273 | + models : `~gammalib.GModels` | |
| 274 | + Model container | |
| 275 | + """ | |
| 276 | + # Set models | |
| 277 | + self.m_models = models | |
| 259 | 278 | |
| 260 | 279 | # Return |
| 261 | 280 | return | ... | ... |
doc/source/admin/release_history/1.5.rst
| ... | ... | @@ -28,5 +28,7 @@ Improvements |
| 28 | 28 | New features |
| 29 | 29 | ------------ |
| 30 | 30 | |
| 31 | +* [`2180 <https://cta-redmine.irap.omp.eu/issues/2180>`_] - | |
| 32 | + Add :ref:`csmodelsois` script | |
| 31 | 33 | * [`1864 <https://cta-redmine.irap.omp.eu/issues/1864>`_] - |
| 32 | 34 | Use t-type parameters for all ``tmin`` and ``tmax`` parameters | ... | ... |
doc/source/users/reference_manual/csmodelsois.rst
| ... | ... | @@ -35,7 +35,7 @@ General parameters |
| 35 | 35 | Input model XML file. |
| 36 | 36 | |
| 37 | 37 | ``outmodel [file]`` |
| 38 | - Output model XML file (not generated if set to 'NONE'). | |
| 38 | + Output model XML file (not generated if set to ``NONE``). | |
| 39 | 39 | |
| 40 | 40 | ``outcube [file]`` |
| 41 | 41 | Output map cube file. |
| ... | ... | @@ -48,37 +48,37 @@ General parameters |
| 48 | 48 | |
| 49 | 49 | ``ebinalg <FILE|LIN|LOG> [string]`` |
| 50 | 50 | Algorithm for defining energy bins. |
| 51 | - | |
| 51 | + | |
| 52 | 52 | ``emin [real]`` |
| 53 | 53 | Lower energy value for first energy bin (in TeV). |
| 54 | - | |
| 54 | + | |
| 55 | 55 | ``emax [real]`` |
| 56 | 56 | Upper energy value for last energy bin (in TeV). |
| 57 | - | |
| 57 | + | |
| 58 | 58 | ``enumbins [integer]`` |
| 59 | 59 | Number of energy bins. |
| 60 | - | |
| 60 | + | |
| 61 | 61 | ``ebinfile [file]`` |
| 62 | 62 | Name of the file containing the energy bin definition. |
| 63 | - | |
| 63 | + | |
| 64 | 64 | ``nxpix [integer]`` |
| 65 | 65 | Number of cube bins in Right Ascension or Galactic longitude. |
| 66 | - | |
| 66 | + | |
| 67 | 67 | ``nypix [integer]`` |
| 68 | 68 | Number of cube bins in Declination or Galactic latitude. |
| 69 | - | |
| 69 | + | |
| 70 | 70 | ``binsz [real]`` |
| 71 | 71 | Image scale (in degrees/pixel). |
| 72 | - | |
| 72 | + | |
| 73 | 73 | ``coordsys <CEL|GAL> [string]`` |
| 74 | 74 | Coordinate system (CEL - celestial, GAL - galactic). |
| 75 | - | |
| 75 | + | |
| 76 | 76 | ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` |
| 77 | 77 | Projection method. |
| 78 | - | |
| 78 | + | |
| 79 | 79 | ``ra [real]`` |
| 80 | 80 | Right Ascension of cube centre (J2000, in degrees). |
| 81 | - | |
| 81 | + | |
| 82 | 82 | ``dec [real]`` |
| 83 | 83 | Declination of cube centre (J2000, in degrees). |
| 84 | 84 | |
| ... | ... | @@ -88,6 +88,7 @@ General parameters |
| 88 | 88 | ``glat [real]`` |
| 89 | 89 | Galactic latitude of cube centre (in degrees). |
| 90 | 90 | |
| 91 | + | |
| 91 | 92 | Standard parameters |
| 92 | 93 | ------------------- |
| 93 | 94 | |
| ... | ... | @@ -97,21 +98,21 @@ Standard parameters |
| 97 | 98 | ``(chatter = 2) [integer]`` |
| 98 | 99 | Verbosity of the executable: |
| 99 | 100 | ``chatter = 0``: no information will be logged |
| 100 | - | |
| 101 | + | |
| 101 | 102 | ``chatter = 1``: only errors will be logged |
| 102 | - | |
| 103 | + | |
| 103 | 104 | ``chatter = 2``: errors and actions will be logged |
| 104 | - | |
| 105 | + | |
| 105 | 106 | ``chatter = 3``: report about the task execution |
| 106 | - | |
| 107 | + | |
| 107 | 108 | ``chatter = 4``: detailed report about the task execution |
| 108 | - | |
| 109 | + | |
| 109 | 110 | ``(clobber = yes) [boolean]`` |
| 110 | 111 | Specifies whether an existing output counts cube file should be overwritten. |
| 111 | - | |
| 112 | + | |
| 112 | 113 | ``(debug = no) [boolean]`` |
| 113 | 114 | Enables debug mode. In debug mode the executable will dump any log file output to the console. |
| 114 | - | |
| 115 | + | |
| 115 | 116 | ``(mode = ql) [string]`` |
| 116 | 117 | Mode of automatic parameters (default is "ql", i.e. "query and learn"). |
| 117 | 118 | |
| ... | ... | @@ -122,4 +123,4 @@ Standard parameters |
| 122 | 123 | Related tools or scripts |
| 123 | 124 | ------------------------ |
| 124 | 125 | |
| 125 | -ctmapcube | |
| 126 | 126 | \ No newline at end of file |
| 127 | +:ref:`ctmapcube` | ... | ... |
doc/source/users/reference_manual/ctmapcube.rst
| ... | ... | @@ -36,40 +36,40 @@ General parameters |
| 36 | 36 | |
| 37 | 37 | ``ebinalg <FILE|LIN|LOG> [string]`` |
| 38 | 38 | Algorithm for defining energy bins. |
| 39 | - | |
| 39 | + | |
| 40 | 40 | ``emin [real]`` |
| 41 | 41 | Lower energy value for first energy bin (in TeV). |
| 42 | - | |
| 42 | + | |
| 43 | 43 | ``emax [real]`` |
| 44 | 44 | Upper energy value for last energy bin (in TeV). |
| 45 | - | |
| 45 | + | |
| 46 | 46 | ``enumbins [integer]`` |
| 47 | 47 | Number of energy bins. |
| 48 | - | |
| 48 | + | |
| 49 | 49 | ``ebinfile [file]`` |
| 50 | 50 | Name of the file containing the energy bin definition. |
| 51 | - | |
| 51 | + | |
| 52 | 52 | ``nxpix [integer]`` |
| 53 | 53 | Number of cube bins in Right Ascension or Galactic longitude. |
| 54 | - | |
| 54 | + | |
| 55 | 55 | ``nypix [integer]`` |
| 56 | 56 | Number of cube bins in Declination or Galactic latitude. |
| 57 | - | |
| 57 | + | |
| 58 | 58 | ``binsz [real]`` |
| 59 | 59 | Image scale (in degrees/pixel). |
| 60 | - | |
| 60 | + | |
| 61 | 61 | ``coordsys <CEL|GAL> [string]`` |
| 62 | 62 | Coordinate system (CEL - celestial, GAL - galactic). |
| 63 | - | |
| 63 | + | |
| 64 | 64 | ``proj <AIT|AZP|CAR|GLS|MER|MOL|SFL|SIN|STG|TAN> [string]`` |
| 65 | 65 | Projection method. |
| 66 | - | |
| 66 | + | |
| 67 | 67 | ``xref [real]`` |
| 68 | 68 | Right Ascension / Galactic longitude of cube centre (J2000, in degrees). |
| 69 | - | |
| 69 | + | |
| 70 | 70 | ``yref [real]`` |
| 71 | 71 | Declination / Galactic latitude of cube centre (J2000, in degrees). |
| 72 | - | |
| 72 | + | |
| 73 | 73 | |
| 74 | 74 | Standard parameters |
| 75 | 75 | ------------------- |
| ... | ... | @@ -80,21 +80,21 @@ Standard parameters |
| 80 | 80 | ``(chatter = 2) [integer]`` |
| 81 | 81 | Verbosity of the executable: |
| 82 | 82 | ``chatter = 0``: no information will be logged |
| 83 | - | |
| 83 | + | |
| 84 | 84 | ``chatter = 1``: only errors will be logged |
| 85 | - | |
| 85 | + | |
| 86 | 86 | ``chatter = 2``: errors and actions will be logged |
| 87 | - | |
| 87 | + | |
| 88 | 88 | ``chatter = 3``: report about the task execution |
| 89 | - | |
| 89 | + | |
| 90 | 90 | ``chatter = 4``: detailed report about the task execution |
| 91 | - | |
| 91 | + | |
| 92 | 92 | ``(clobber = yes) [boolean]`` |
| 93 | 93 | Specifies whether an existing output counts cube file should be overwritten. |
| 94 | - | |
| 94 | + | |
| 95 | 95 | ``(debug = no) [boolean]`` |
| 96 | 96 | Enables debug mode. In debug mode the executable will dump any log file output to the console. |
| 97 | - | |
| 97 | + | |
| 98 | 98 | ``(mode = ql) [string]`` |
| 99 | 99 | Mode of automatic parameters (default is "ql", i.e. "query and learn"). |
| 100 | 100 | |
| ... | ... | @@ -105,4 +105,4 @@ Standard parameters |
| 105 | 105 | Related tools or scripts |
| 106 | 106 | ------------------------ |
| 107 | 107 | |
| 108 | -csmodelsois | |
| 108 | +:ref:`csmodelsois` | ... | ... |
test/test_csmodelsois.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # This scripts performs unit tests for the csmodelsois tool. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016-2017 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2017 Josh Cardenzana | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -71,12 +71,12 @@ class Test(test): |
| 71 | 71 | |
| 72 | 72 | # Setup csmodelsois command |
| 73 | 73 | cmd = csmodelsois+' inmodel="'+self._model+'"'+ \ |
| 74 | - ' outcube="csmodelsois_cmd1.fits"'+\ | |
| 75 | - ' emin=0.1 emax=100.0 enumbins=10 ebinalg=LOG'+ \ | |
| 76 | - ' nxpix=100 nypix=100 binsz=0.04 coordsys=CEL'+ \ | |
| 77 | - ' soilist="" outmodel=NONE'+ \ | |
| 78 | - ' ra=83.63 dec=22.01 proj=CAR'+ \ | |
| 79 | - ' logfile="csmodelsois_cmd1.log" chatter=1' | |
| 74 | + ' outcube="csmodelsois_cmd1.fits"'+\ | |
| 75 | + ' emin=0.1 emax=100.0 enumbins=10 ebinalg=LOG'+ \ | |
| 76 | + ' nxpix=100 nypix=100 binsz=0.04 coordsys=CEL'+ \ | |
| 77 | + ' soilist="" outmodel=NONE'+ \ | |
| 78 | + ' ra=83.63 dec=22.01 proj=CAR'+ \ | |
| 79 | + ' logfile="csmodelsois_cmd1.log" chatter=1' | |
| 80 | 80 | |
| 81 | 81 | # Check if execution of wrong command fails |
| 82 | 82 | self.test_assert(self._execute('command_that_does_not_exist') != 0, |
| ... | ... | @@ -91,12 +91,12 @@ class Test(test): |
| 91 | 91 | |
| 92 | 92 | # Setup csmodelsois command |
| 93 | 93 | cmd = csmodelsois+' inmodel="events_that_do_not_exist.fits"'+ \ |
| 94 | - ' outcube="ccsmodelsois_cmd2.fits"'+\ | |
| 95 | - ' emin=0.1 emax=100.0 enumbins=10 ebinalg=LOG'+ \ | |
| 96 | - ' nxpix=100 nypix=100 binsz=0.04 coordsys=CEL'+ \ | |
| 97 | - ' soilist="" outmodel=NONE'+ \ | |
| 98 | - ' ra=83.63 dec=22.01 proj=CAR'+ \ | |
| 99 | - ' logfile="csmodelsois_cmd2.log"' | |
| 94 | + ' outcube="ccsmodelsois_cmd2.fits"'+\ | |
| 95 | + ' emin=0.1 emax=100.0 enumbins=10 ebinalg=LOG'+ \ | |
| 96 | + ' nxpix=100 nypix=100 binsz=0.04 coordsys=CEL'+ \ | |
| 97 | + ' soilist="" outmodel=NONE'+ \ | |
| 98 | + ' ra=83.63 dec=22.01 proj=CAR'+ \ | |
| 99 | + ' logfile="csmodelsois_cmd2.log"' | |
| 100 | 100 | |
| 101 | 101 | # Check if execution failed |
| 102 | 102 | self.test_assert(self._execute(cmd) != 0, |
| ... | ... | @@ -202,7 +202,8 @@ class Test(test): |
| 202 | 202 | |
| 203 | 203 | # Now check that the output model file doesnt contain a Crab Sources |
| 204 | 204 | models3 = gammalib.GModels('csmodelsois_py3.xml') |
| 205 | - self.test_assert(not models3.contains("Crab"), 'Check Crab model is not present') | |
| 205 | + self.test_assert(not models3.contains('Crab'), | |
| 206 | + 'Check Crab model is not present') | |
| 206 | 207 | self.test_assert(models3.contains(modelsois.cubemodelname()), |
| 207 | 208 | 'Check cube model is present') |
| 208 | 209 | self._check_result_file('csmodelsois_py3.fits') | ... | ... |
test/test_python_cscripts.py
| ... | ... | @@ -147,7 +147,7 @@ def test(installed=False, debug=False): |
| 147 | 147 | |
| 148 | 148 | # Check for VHEFITS environment variable |
| 149 | 149 | if 'VHEFITS' in os.environ: |
| 150 | - | |
| 150 | + | |
| 151 | 151 | # If the environment variable exists then unset it for the test |
| 152 | 152 | # cases. Since Python is executed in a subprocess this will not |
| 153 | 153 | # impact the environment variable in the parent shell. | ... | ... |