Commit 5499cfa5d1a89137d40c3181d56fc3286b5d1b1c
1 parent
ea84b18f
Add more spatial models to csbkgmodel (#2878)
Showing
7 changed files
with
123 additions
and
8 deletions
ChangeLog
| 1 | -2019-04-14 | 1 | +2019-04-26 |
| 2 | 2 | ||
| 3 | * Version 1.6.0 released | 3 | * Version 1.6.0 released |
| 4 | ======================== | 4 | ======================== |
| 5 | 5 | ||
| 6 | + Add more spatial models to csbkgmodel (#2878) | ||
| 6 | Add GAUSS(E) model to csbkgmodel (#2868) | 7 | Add GAUSS(E) model to csbkgmodel (#2868) |
| 7 | Move ctool::set_obs_bounds() to ctobservation::set_obs_bounds() | 8 | Move ctool::set_obs_bounds() to ctobservation::set_obs_bounds() |
| 8 | Log warning if edisp=no (#2842) | 9 | Log warning if edisp=no (#2842) |
NEWS
| 1 | New Features and Important Changes in ctools 1.6.0 | 1 | New Features and Important Changes in ctools 1.6.0 |
| 2 | 2 | ||
| 3 | -14 April 2019 | 3 | +26 April 2019 |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | Introduction | 6 | Introduction |
| @@ -270,6 +270,11 @@ None | @@ -270,6 +270,11 @@ None | ||
| 270 | 270 | ||
| 271 | csbkgmodel - Generate background model for 3D analysis | 271 | csbkgmodel - Generate background model for 3D analysis |
| 272 | ------------------------------------------------------ | 272 | ------------------------------------------------------ |
| 273 | +Three additional spatial models were added: LOOKUP which uses a 2D lookup table, | ||
| 274 | +PROFILE which uses an energy-independent profile, and POLYNOM which uses an | ||
| 275 | +energy-independent polynom of third order. The parameter "slufile" was added | ||
| 276 | +to allow specification of a lookup table file (#2878). | ||
| 277 | + | ||
| 273 | A model named GAUSS(E) was added to implement an energy-dependent Gaussian | 278 | A model named GAUSS(E) was added to implement an energy-dependent Gaussian |
| 274 | spatial function (#2868). | 279 | spatial function (#2868). |
| 275 | 280 |
cscripts/csbkgmodel.par
| @@ -25,7 +25,8 @@ outmodel, f, a, model.xml,,, "Output model definition XML file" | @@ -25,7 +25,8 @@ outmodel, f, a, model.xml,,, "Output model definition XML file" | ||
| 25 | # Script parameters | 25 | # Script parameters |
| 26 | #================== | 26 | #================== |
| 27 | instrument, s, a, CTA,,, "Instrument name (for multi-instrument analysis)" | 27 | instrument, s, a, CTA,,, "Instrument name (for multi-instrument analysis)" |
| 28 | -spatial, s, a, GAUSS,IRF|AEFF|GAUSS|GAUSS(E),, "Spatial model component" | 28 | +spatial, s, a, GAUSS,IRF|AEFF|LOOKUP|GAUSS|GAUSS(E)|PROFILE|POLYNOM,, "Spatial model component" |
| 29 | +slufile, f, a, lookup.fits,,, "Name of lookup table file for LOOKUP spatial model" | ||
| 29 | snumbins, i, a, 3,1,200, "Number of energy nodes for GAUSS(E) spatial model" | 30 | snumbins, i, a, 3,1,200, "Number of energy nodes for GAUSS(E) spatial model" |
| 30 | smin, r, a, 0.1,,, "Lower energy limit of energy nodes for GAUSS(E) spatial model (TeV)" | 31 | smin, r, a, 0.1,,, "Lower energy limit of energy nodes for GAUSS(E) spatial model (TeV)" |
| 31 | smax, r, a, 10.0,,, "Upper energy limit of energy nodes for GAUSS(E) spatial model (TeV)" | 32 | smax, r, a, 10.0,,, "Upper energy limit of energy nodes for GAUSS(E) spatial model (TeV)" |
cscripts/csbkgmodel.py
| @@ -100,7 +100,10 @@ class csbkgmodel(ctools.csobservation): | @@ -100,7 +100,10 @@ class csbkgmodel(ctools.csobservation): | ||
| 100 | if snumbins > 1: | 100 | if snumbins > 1: |
| 101 | self['smin'].real() | 101 | self['smin'].real() |
| 102 | self['smax'].real() | 102 | self['smax'].real() |
| 103 | - if spatial == 'GAUSS' or spatial == 'GAUSS(E)': | 103 | + if spatial == 'LOOKUP': |
| 104 | + self['slufile'].filename() | ||
| 105 | + if spatial == 'LOOKUP' or spatial == 'GAUSS' or \ | ||
| 106 | + spatial == 'GAUSS(E)' or spatial == 'PROFILE': | ||
| 104 | self['gradient'].boolean() | 107 | self['gradient'].boolean() |
| 105 | spectral = self['spectral'].string() | 108 | spectral = self['spectral'].string() |
| 106 | if spectral == 'NODES': | 109 | if spectral == 'NODES': |
| @@ -175,6 +178,29 @@ class csbkgmodel(ctools.csobservation): | @@ -175,6 +178,29 @@ class csbkgmodel(ctools.csobservation): | ||
| 175 | spectral = gammalib.GModelSpectralPlaw(1.0e-13, -2.5, epivot) | 178 | spectral = gammalib.GModelSpectralPlaw(1.0e-13, -2.5, epivot) |
| 176 | model = gammalib.GCTAModelAeffBackground(spectral) | 179 | model = gammalib.GCTAModelAeffBackground(spectral) |
| 177 | 180 | ||
| 181 | + # Handle LOOKUP model | ||
| 182 | + elif self['spatial'].string() == 'LOOKUP': | ||
| 183 | + | ||
| 184 | + # Set spatial model | ||
| 185 | + factor1 = gammalib.GCTAModelSpatialLookup(self['slufile'].filename()) | ||
| 186 | + | ||
| 187 | + # Optionally add gradient | ||
| 188 | + if self['gradient'].boolean(): | ||
| 189 | + spatial = gammalib.GCTAModelSpatialMultiplicative() | ||
| 190 | + factor2 = gammalib.GCTAModelSpatialGradient() | ||
| 191 | + spatial.append(factor1) | ||
| 192 | + spatial.append(factor2) | ||
| 193 | + else: | ||
| 194 | + spatial = factor1 | ||
| 195 | + | ||
| 196 | + # Set spectral model | ||
| 197 | + epivot = gammalib.GEnergy(1.0, 'TeV') | ||
| 198 | + spectral = gammalib.GModelSpectralPlaw(3.0e-4, -1.5, epivot) | ||
| 199 | + spectral['Prefactor'].min(1.0e-8) | ||
| 200 | + | ||
| 201 | + # Set background model | ||
| 202 | + model = gammalib.GCTAModelBackground(spatial, spectral) | ||
| 203 | + | ||
| 178 | # Handle GAUSS model | 204 | # Handle GAUSS model |
| 179 | elif self['spatial'].string() == 'GAUSS': | 205 | elif self['spatial'].string() == 'GAUSS': |
| 180 | 206 | ||
| @@ -237,6 +263,66 @@ class csbkgmodel(ctools.csobservation): | @@ -237,6 +263,66 @@ class csbkgmodel(ctools.csobservation): | ||
| 237 | # Set background model | 263 | # Set background model |
| 238 | model = gammalib.GCTAModelBackground(spatial, spectral) | 264 | model = gammalib.GCTAModelBackground(spatial, spectral) |
| 239 | 265 | ||
| 266 | + # Handle PROFILE model | ||
| 267 | + elif self['spatial'].string() == 'PROFILE': | ||
| 268 | + | ||
| 269 | + # Set spatial model | ||
| 270 | + factor1 = gammalib.GCTAModelRadialProfile(2.0, 4.0, 5.0) | ||
| 271 | + factor1['Width'].min(1.0) | ||
| 272 | + factor1['Width'].max(10.0) | ||
| 273 | + factor1['Core'].min(1.0) | ||
| 274 | + factor1['Core'].max(10.0) | ||
| 275 | + factor1['Tail'].min(-10.0) | ||
| 276 | + factor1['Tail'].max(10.0) | ||
| 277 | + factor1['Tail'].free() | ||
| 278 | + | ||
| 279 | + # Optionally add gradient | ||
| 280 | + if self['gradient'].boolean(): | ||
| 281 | + spatial = gammalib.GCTAModelSpatialMultiplicative() | ||
| 282 | + factor2 = gammalib.GCTAModelSpatialGradient() | ||
| 283 | + spatial.append(factor1) | ||
| 284 | + spatial.append(factor2) | ||
| 285 | + else: | ||
| 286 | + spatial = factor1 | ||
| 287 | + | ||
| 288 | + # Set spectral model | ||
| 289 | + epivot = gammalib.GEnergy(1.0, 'TeV') | ||
| 290 | + spectral = gammalib.GModelSpectralPlaw(3.0e-4, -1.5, epivot) | ||
| 291 | + spectral['Prefactor'].min(1.0e-8) | ||
| 292 | + | ||
| 293 | + # Set background model | ||
| 294 | + model = gammalib.GCTAModelBackground(spatial, spectral) | ||
| 295 | + | ||
| 296 | + # Handle POLYNOM model | ||
| 297 | + elif self['spatial'].string() == 'POLYNOM': | ||
| 298 | + | ||
| 299 | + # Set spatial model | ||
| 300 | + factor1 = gammalib.GCTAModelRadialPolynom([1.0, -0.1, +0.1]) | ||
| 301 | + factor1['Coeff0'].min(0.1) | ||
| 302 | + factor1['Coeff0'].max(10.0) | ||
| 303 | + factor1['Coeff0'].fix() | ||
| 304 | + factor1['Coeff1'].min(-10.0) | ||
| 305 | + factor1['Coeff1'].max(10.0) | ||
| 306 | + factor1['Coeff2'].min(-10.0) | ||
| 307 | + factor1['Coeff2'].max(10.0) | ||
| 308 | + | ||
| 309 | + # Optionally add gradient | ||
| 310 | + if self['gradient'].boolean(): | ||
| 311 | + spatial = gammalib.GCTAModelSpatialMultiplicative() | ||
| 312 | + factor2 = gammalib.GCTAModelSpatialGradient() | ||
| 313 | + spatial.append(factor1) | ||
| 314 | + spatial.append(factor2) | ||
| 315 | + else: | ||
| 316 | + spatial = factor1 | ||
| 317 | + | ||
| 318 | + # Set spectral model | ||
| 319 | + epivot = gammalib.GEnergy(1.0, 'TeV') | ||
| 320 | + spectral = gammalib.GModelSpectralPlaw(3.0e-4, -1.5, epivot) | ||
| 321 | + spectral['Prefactor'].min(1.0e-8) | ||
| 322 | + | ||
| 323 | + # Set background model | ||
| 324 | + model = gammalib.GCTAModelBackground(spatial, spectral) | ||
| 325 | + | ||
| 240 | # Any other strings (should never occur) | 326 | # Any other strings (should never occur) |
| 241 | else: | 327 | else: |
| 242 | model = None | 328 | model = None |
doc/source/admin/release_history/1.6.rst
| @@ -46,6 +46,8 @@ Bug fixes | @@ -46,6 +46,8 @@ Bug fixes | ||
| 46 | Improvements | 46 | Improvements |
| 47 | ------------ | 47 | ------------ |
| 48 | 48 | ||
| 49 | +* [`2878 <https://cta-redmine.irap.omp.eu/issues/2878>`_] - | ||
| 50 | + Add more spatial models to :ref:`csbkgmodel` | ||
| 49 | * [`2868 <https://cta-redmine.irap.omp.eu/issues/2868>`_] - | 51 | * [`2868 <https://cta-redmine.irap.omp.eu/issues/2868>`_] - |
| 50 | Add ``GAUSS(E)`` model to :ref:`csbkgmodel` | 52 | Add ``GAUSS(E)`` model to :ref:`csbkgmodel` |
| 51 | * [`2842 <https://cta-redmine.irap.omp.eu/issues/2842>`_] - | 53 | * [`2842 <https://cta-redmine.irap.omp.eu/issues/2842>`_] - |
doc/source/users/reference_manual/csbkgmodel.rst
| @@ -50,9 +50,29 @@ General parameters | @@ -50,9 +50,29 @@ General parameters | ||
| 50 | instrument, the instrument name will be extracted from the observation | 50 | instrument, the instrument name will be extracted from the observation |
| 51 | definition XML file. | 51 | definition XML file. |
| 52 | 52 | ||
| 53 | -``spatial <IRF|AEFF|GAUSS|GAUSS(E)> [string]`` | ||
| 54 | - Spatial model component. So far IRF template, effective area, a radial | ||
| 55 | - Gaussian and an energy-dependent radial Gaussian models are supported. | 53 | +``spatial <IRF|AEFF|LOOKUP|GAUSS|GAUSS(E)|PROFILE|POLYNOM> [string]`` |
| 54 | + Spatial model component. The following options exist: | ||
| 55 | + ``IRF``: The background template included in the Instrument Response | ||
| 56 | + Functions will be used (energy-dependent) | ||
| 57 | + | ||
| 58 | + ``AEFF``: The effective area will be used (energy-dependent) | ||
| 59 | + | ||
| 60 | + ``LOOKUP``: A lookup table, specified by the ``slufile`` parameter, will | ||
| 61 | + be used (energy-dependent). | ||
| 62 | + | ||
| 63 | + ``GAUSS``: A radial Gaussian in offset angle squared will be used. | ||
| 64 | + | ||
| 65 | + ``GAUSS(E)``: An energy-dependent radial Gaussian in offset angle squared | ||
| 66 | + will be used. The ``snumbins`` parameter specifies the number of energy | ||
| 67 | + nodes, the ``smin`` and ``smax`` parameters specify the energy range for | ||
| 68 | + the nodes. | ||
| 69 | + | ||
| 70 | + ``PROFILE``: A radial profile will be used. | ||
| 71 | + | ||
| 72 | + ``POLYNOM``: A third order polynomial will be used. | ||
| 73 | + | ||
| 74 | +``slufile [file]`` | ||
| 75 | + Name of the file containing the lookup table if ``spatial=LOOKUP``. | ||
| 56 | 76 | ||
| 57 | ``snumbins [integer]`` | 77 | ``snumbins [integer]`` |
| 58 | Number of energy nodes for GAUSS(E) spatial model. | 78 | Number of energy nodes for GAUSS(E) spatial model. |
test/test_csbkgmodel.py
| @@ -198,7 +198,7 @@ class Test(test): | @@ -198,7 +198,7 @@ class Test(test): | ||
| 198 | bkgmodel['caldb'] = self._caldb | 198 | bkgmodel['caldb'] = self._caldb |
| 199 | bkgmodel['irf'] = self._irf | 199 | bkgmodel['irf'] = self._irf |
| 200 | bkgmodel['instrument'] = 'CTA' | 200 | bkgmodel['instrument'] = 'CTA' |
| 201 | - bkgmodel['spatial'] = 'AEFF' | 201 | + bkgmodel['spatial'] = 'IRF' |
| 202 | bkgmodel['gradient'] = False | 202 | bkgmodel['gradient'] = False |
| 203 | bkgmodel['spectral'] = 'PLAW' | 203 | bkgmodel['spectral'] = 'PLAW' |
| 204 | bkgmodel['ebinalg'] = 'LOG' | 204 | bkgmodel['ebinalg'] = 'LOG' |