Commit 358cc09746a1e3dab4a3f54f314f2dc841f4aa7f
Merge branch 'master' into devel
# Conflicts: # ChangeLog # NEWS # README.md # configure.ac # cscripts/csspec.py # doc/Doxyfile # doc/source/admin/download.rst # doc/source/admin/release_history/index.rst # doc/source/conf.py # doc/source/users/reference_manual/csspec.rst # sonar-project.properties
Showing
10 changed files
with
106 additions
and
23 deletions
ChangeLog
| @@ -16,6 +16,16 @@ | @@ -16,6 +16,16 @@ | ||
| 16 | Add support of rectangular On/Off regions (#3248) | 16 | Add support of rectangular On/Off regions (#3248) |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | +2021-04-28 | ||
| 20 | + | ||
| 21 | + * Bug fix version 1.7.4 released | ||
| 22 | + ================================ | ||
| 23 | + | ||
| 24 | + Add conda activation and deactivation scripts for csh (#3628) | ||
| 25 | + Replace spectral model by file function in csspec (#3624) | ||
| 26 | + Update csinfo script (#3623) | ||
| 27 | + | ||
| 28 | + | ||
| 19 | 2020-12-02 | 29 | 2020-12-02 |
| 20 | 30 | ||
| 21 | * Bug fix version 1.7.3 released | 31 | * Bug fix version 1.7.3 released |
Makefile.am
| @@ -33,9 +33,11 @@ pkgconfig_DATA = ctools.pc | @@ -33,9 +33,11 @@ pkgconfig_DATA = ctools.pc | ||
| 33 | 33 | ||
| 34 | # Conda activate directory | 34 | # Conda activate directory |
| 35 | condaactivatedir = $(sysconfdir)/conda/activate.d | 35 | condaactivatedir = $(sysconfdir)/conda/activate.d |
| 36 | -condaactivate_DATA = dev/01-ctools-activate.sh | 36 | +condaactivate_DATA = dev/01-ctools-activate.sh \ |
| 37 | + dev/01-ctools-activate.csh | ||
| 37 | condadeactivatedir = $(sysconfdir)/conda/deactivate.d | 38 | condadeactivatedir = $(sysconfdir)/conda/deactivate.d |
| 38 | -condadeactivate_DATA = dev/00-ctools-deactivate.sh | 39 | +condadeactivate_DATA = dev/00-ctools-deactivate.sh \ |
| 40 | + dev/00-ctools-deactivate.csh | ||
| 39 | 41 | ||
| 40 | # Manual pages to install | 42 | # Manual pages to install |
| 41 | man_MANS = | 43 | man_MANS = |
| @@ -55,6 +57,7 @@ EXTRA_DIST = README.md \ | @@ -55,6 +57,7 @@ EXTRA_DIST = README.md \ | ||
| 55 | doc/Doxyfile doc/source \ | 57 | doc/Doxyfile doc/source \ |
| 56 | dev/testreport.py \ | 58 | dev/testreport.py \ |
| 57 | dev/01-ctools-activate.sh dev/00-ctools-deactivate.sh \ | 59 | dev/01-ctools-activate.sh dev/00-ctools-deactivate.sh \ |
| 60 | + dev/01-ctools-activate.csh dev/00-ctools-deactivate.csh \ | ||
| 58 | dev/conda.recipe/build.sh \ | 61 | dev/conda.recipe/build.sh \ |
| 59 | dev/conda.recipe/conda_build_config.yaml \ | 62 | dev/conda.recipe/conda_build_config.yaml \ |
| 60 | dev/conda.recipe/meta.yaml.in | 63 | dev/conda.recipe/meta.yaml.in |
cscripts/csinfo.py
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | # ========================================================================== | 2 | # ========================================================================== |
| 3 | # Print info about Gammalib / ctools to the console | 3 | # Print info about Gammalib / ctools to the console |
| 4 | # | 4 | # |
| 5 | -# Copyright (C) 2015-2016 Christoph Deil | 5 | +# Copyright (C) 2015-2021 Christoph Deil |
| 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 |
| 8 | # it under the terms of the GNU General Public License as published by | 8 | # it under the terms of the GNU General Public License as published by |
| @@ -32,10 +32,13 @@ CTOOL_LIST = """ | @@ -32,10 +32,13 @@ CTOOL_LIST = """ | ||
| 32 | ctedispcube Generates energy dispersion cube | 32 | ctedispcube Generates energy dispersion cube |
| 33 | cterror Calculates likelihood profile errors | 33 | cterror Calculates likelihood profile errors |
| 34 | ctexpcube Generates exposure cube | 34 | ctexpcube Generates exposure cube |
| 35 | + ctfindvar Search for source variability | ||
| 35 | ctlike Performs maximum likelihood fitting | 36 | ctlike Performs maximum likelihood fitting |
| 36 | ctmapcube Generates a map cube | 37 | ctmapcube Generates a map cube |
| 37 | ctmodel Computes model counts cube | 38 | ctmodel Computes model counts cube |
| 38 | ctobssim Simulate CTA observations | 39 | ctobssim Simulate CTA observations |
| 40 | + ctphase Computes the phase of each event | ||
| 41 | + ctprob Computes event probability for a given model | ||
| 39 | ctpsfcube Generates point spread function cube | 42 | ctpsfcube Generates point spread function cube |
| 40 | ctselect Selects event data | 43 | ctselect Selects event data |
| 41 | ctskymap Generates sky map | 44 | ctskymap Generates sky map |
| @@ -47,20 +50,31 @@ CTOOL_LIST = """ | @@ -47,20 +50,31 @@ CTOOL_LIST = """ | ||
| 47 | # `doc/source/users/reference_manual/index.rst` | 50 | # `doc/source/users/reference_manual/index.rst` |
| 48 | # and needs to be manually updated and kept in sync | 51 | # and needs to be manually updated and kept in sync |
| 49 | CSCRIPT_LIST = """ | 52 | CSCRIPT_LIST = """ |
| 53 | + csbkgmodel Generates background model for 3D analysis | ||
| 50 | cscaldb Lists available instrument response functions | 54 | cscaldb Lists available instrument response functions |
| 55 | + csebins Generates energy boundaries for stacked analysis | ||
| 51 | cslightcrv Computes lightcurve | 56 | cslightcrv Computes lightcurve |
| 52 | csinfo Checks ctools and GammaLib installations | 57 | csinfo Checks ctools and GammaLib installations |
| 53 | csmodelinfo Shows model container content | 58 | csmodelinfo Shows model container content |
| 54 | csmodelmerge Merges several model containers into one file | 59 | csmodelmerge Merges several model containers into one file |
| 60 | + csmodelselect Select models from model definition file | ||
| 61 | + csmodelsois Generate map cube from subset of models | ||
| 55 | csobsdef Generates observation definition file | 62 | csobsdef Generates observation definition file |
| 56 | csobsinfo Shows observation container content | 63 | csobsinfo Shows observation container content |
| 64 | + csobsselect Select observations from observation definition file | ||
| 65 | + csphagen Generates PHA, ARF, RMF files based on source/background regions | ||
| 66 | + csphasecrv Computes phase curve | ||
| 57 | cspull Generates pull distribution | 67 | cspull Generates pull distribution |
| 58 | csresmap Generates residual map | 68 | csresmap Generates residual map |
| 69 | + csresspec Generates residual spectrum | ||
| 70 | + csscs Performs spectral component separation | ||
| 59 | cssens Computes CTA sensitivity | 71 | cssens Computes CTA sensitivity |
| 60 | csspec Computes spectral points | 72 | csspec Computes spectral points |
| 73 | + cssrcdetect Detects sources in sky map | ||
| 61 | cstsdist Generates TS distribution | 74 | cstsdist Generates TS distribution |
| 75 | + cstsmapmerge Merges slices from Test Statistic map computations | ||
| 62 | cstsmapsplit Creates commands to split the Test Statistic map computations | 76 | cstsmapsplit Creates commands to split the Test Statistic map computations |
| 63 | - cstsmapmerge Merges slices from Test Statistic map computations\n | 77 | + csviscube Computes visibility cube\n |
| 64 | csobs2caldb Creates a caldb entry from an input observation | 78 | csobs2caldb Creates a caldb entry from an input observation |
| 65 | csroot2caldb Creates a caldb entry from a ROOT performance file | 79 | csroot2caldb Creates a caldb entry from a ROOT performance file |
| 66 | csiactdata Shows information about IACT data available on the user machine | 80 | csiactdata Shows information about IACT data available on the user machine |
cscripts/csspec.py
| @@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
| 20 | # ========================================================================== | 20 | # ========================================================================== |
| 21 | import sys | 21 | import sys |
| 22 | import math | 22 | import math |
| 23 | +import tempfile # Kludge for file function generation | ||
| 23 | import gammalib | 24 | import gammalib |
| 24 | import ctools | 25 | import ctools |
| 25 | from cscripts import mputils | 26 | from cscripts import mputils |
| @@ -367,6 +368,24 @@ class csspec(ctools.csobservation): | @@ -367,6 +368,24 @@ class csspec(ctools.csobservation): | ||
| 367 | ' Fixing "'+par.name()+'"') | 368 | ' Fixing "'+par.name()+'"') |
| 368 | par.fix() | 369 | par.fix() |
| 369 | 370 | ||
| 371 | + # Kludge: convert spectral model into a file function | ||
| 372 | + nbins = self._ebounds.size() | ||
| 373 | + num = nbins * 20 | ||
| 374 | + energies = gammalib.GEnergies(num, self._ebounds.emin(0), | ||
| 375 | + self._ebounds.emax(nbins-1)) | ||
| 376 | + _, filename = tempfile.mkstemp() | ||
| 377 | + f = open(filename, 'w') | ||
| 378 | + spectral = model.spectral() | ||
| 379 | + for energy in energies: | ||
| 380 | + value = spectral.eval(energy) | ||
| 381 | + f.write('%20.6f %20e\n' % (energy.MeV(), value)) | ||
| 382 | + f.close() | ||
| 383 | + spectral = gammalib.GModelSpectralFunc(filename, 1.0) | ||
| 384 | + model.spectral(spectral) | ||
| 385 | + self._log_string(gammalib.EXPLICIT, ' Converting spectral model ' | ||
| 386 | + 'into file function via temporary file "%s"' % | ||
| 387 | + filename) | ||
| 388 | + | ||
| 370 | # Free the normalisation parameter which is assumed to be | 389 | # Free the normalisation parameter which is assumed to be |
| 371 | # the first spectral parameter | 390 | # the first spectral parameter |
| 372 | normpar = model.spectral()[0] | 391 | normpar = model.spectral()[0] |
| @@ -956,7 +975,7 @@ class csspec(ctools.csobservation): | @@ -956,7 +975,7 @@ class csspec(ctools.csobservation): | ||
| 956 | result['dloglike'] = dlogL | 975 | result['dloglike'] = dlogL |
| 957 | result['logL'] = loglike | 976 | result['logL'] = loglike |
| 958 | 977 | ||
| 959 | - # Compute upper limit | 978 | + # Compute upper flux limit |
| 960 | if self['calc_ulim'].boolean(): | 979 | if self['calc_ulim'].boolean(): |
| 961 | 980 | ||
| 962 | # Logging information | 981 | # Logging information |
| @@ -1072,7 +1091,7 @@ class csspec(ctools.csobservation): | @@ -1072,7 +1091,7 @@ class csspec(ctools.csobservation): | ||
| 1072 | (not self['dll_freenodes'].boolean()): | 1091 | (not self['dll_freenodes'].boolean()): |
| 1073 | for par in spectral: | 1092 | for par in spectral: |
| 1074 | par.fix() | 1093 | par.fix() |
| 1075 | - | 1094 | + |
| 1076 | # Re-compute the log-likelihood | 1095 | # Re-compute the log-likelihood |
| 1077 | like.run() | 1096 | like.run() |
| 1078 | loglike = like.obs().logL() | 1097 | loglike = like.obs().logL() |
| @@ -1200,7 +1219,7 @@ class csspec(ctools.csobservation): | @@ -1200,7 +1219,7 @@ class csspec(ctools.csobservation): | ||
| 1200 | table.append(dnde) | 1219 | table.append(dnde) |
| 1201 | table.append(TSvalues) | 1220 | table.append(TSvalues) |
| 1202 | table.append(Npred_values) | 1221 | table.append(Npred_values) |
| 1203 | - | 1222 | + |
| 1204 | # Define the SED type | 1223 | # Define the SED type |
| 1205 | table.card('SED_TYPE', 'norm,e2dnde,dnde,npred', 'SED type') | 1224 | table.card('SED_TYPE', 'norm,e2dnde,dnde,npred', 'SED type') |
| 1206 | 1225 |
dev/00-ctools-deactivate.csh
0 → 100644
dev/01-ctools-activate.csh
0 → 100644
doc/source/admin/release_history/1.7.4.rst
0 → 100644
| 1 | +.. _1.7.4: | ||
| 2 | + | ||
| 3 | +ctools 1.7.4 release (28 April 2021) | ||
| 4 | +==================================== | ||
| 5 | + | ||
| 6 | +Overview | ||
| 7 | +-------- | ||
| 8 | + | ||
| 9 | +ctools 1.7.4 is a bug fix release for ctools release 1.7. | ||
| 10 | + | ||
| 11 | +The following bugs were fixed: | ||
| 12 | + | ||
| 13 | +* [`3628 <https://cta-redmine.irap.omp.eu/issues/3628>`_] - | ||
| 14 | + Add conda activation and deactivation scripts for csh | ||
| 15 | +* [`3624 <https://cta-redmine.irap.omp.eu/issues/3624>`_] - | ||
| 16 | + Replace spectral model by file function in :ref:`csspec` | ||
| 17 | +* [`3623 <https://cta-redmine.irap.omp.eu/issues/3623>`_] - | ||
| 18 | + Update csinfo script |
doc/source/admin/release_history/index.rst
| @@ -7,6 +7,7 @@ Release History | @@ -7,6 +7,7 @@ Release History | ||
| 7 | :maxdepth: 1 | 7 | :maxdepth: 1 |
| 8 | 8 | ||
| 9 | ctools 2.0 <2.0> | 9 | ctools 2.0 <2.0> |
| 10 | + ctools 1.7.4 <1.7.4> | ||
| 10 | ctools 1.7.3 <1.7.3> | 11 | ctools 1.7.3 <1.7.3> |
| 11 | ctools 1.7.2 <1.7.2> | 12 | ctools 1.7.2 <1.7.2> |
| 12 | ctools 1.7.1 <1.7.1> | 13 | ctools 1.7.1 <1.7.1> |
doc/source/develop/releasing/index.rst
| @@ -21,4 +21,5 @@ To create a new ctools release you have to go through the following steps: | @@ -21,4 +21,5 @@ To create a new ctools release you have to go through the following steps: | ||
| 21 | * added unit tests for all new code | 21 | * added unit tests for all new code |
| 22 | * added a page about the software changes to the release history | 22 | * added a page about the software changes to the release history |
| 23 | * updated the User documentation if necessary | 23 | * updated the User documentation if necessary |
| 24 | + * updated the csinfo script if necessary | ||
| 24 | 25 |
doc/source/users/reference_manual/csspec.rst
| @@ -20,19 +20,28 @@ flux limit that is particularly useful in case that the source is not | @@ -20,19 +20,28 @@ flux limit that is particularly useful in case that the source is not | ||
| 20 | significantly detected within a spectral bin (hidden parameter ``calc_ulim``). | 20 | significantly detected within a spectral bin (hidden parameter ``calc_ulim``). |
| 21 | 21 | ||
| 22 | There are three fundamental methods to run the script depending on the value of | 22 | There are three fundamental methods to run the script depending on the value of |
| 23 | -the ``method`` parameter. If ``method=SLICE`` the energy interval defined by the | ||
| 24 | -``emin`` and ``emax`` parameters is divided into a number of energy bins and an | ||
| 25 | -independent maximum likelihood fit is performed in each of the energy bins. If | ||
| 26 | -``method=NODES`` the spectral model will be replaced by a node function that will | ||
| 27 | -be fit to all data. Alternatively, if ``method=BINS`` the spectral model will be | ||
| 28 | -replaced by a bin function that will be fit to all data. While with the ``NODES`` | ||
| 29 | -method the spectral points are in general not statistically independent, the | ||
| 30 | -``BINS`` method assures that the spectral points are statistically independent. | ||
| 31 | -The ``NODES`` and ``BINS`` methods are particularly useful if data from instruments | ||
| 32 | -other than CTA should be analyses, such as data from Fermi/LAT, COMPTEL or | ||
| 33 | -INTEGRAL/SPI. By default, ``method`` is set to ``AUTO`` which will automatically | ||
| 34 | -select the method based on the input data. For CTA-only observations ``SLICE`` will | ||
| 35 | -be used, otherwise ``NODES`` will be used. | 23 | +the ``method`` parameter, ``SLICE``, ``BINS`` and ``NODES``. |
| 24 | + | ||
| 25 | +If ``method=SLICE`` the energy interval defined by the ``emin`` and ``emax`` | ||
| 26 | +parameters is divided into a number of energy bins and an independent maximum | ||
| 27 | +likelihood fit is performed in each of the energy bins. In order to cope with | ||
| 28 | +all kinds of spectral models, including composite spectra, input spectrum will | ||
| 29 | +be converted into a file function, with the normalisation of the file function | ||
| 30 | +being the fit parameter for each energy bin. This implies that spectral | ||
| 31 | +components are merged into a single function using the model parameters that | ||
| 32 | +are specified in the input model. | ||
| 33 | + | ||
| 34 | +If ``method=BINS`` the spectral model will be replaced by a bin function that | ||
| 35 | +will be fit to all data, with ``method=NODES`` the spectral model will be replaced | ||
| 36 | +by a node function. The advantage of ``BINS`` over ``NODES`` is that with ``BINS`` | ||
| 37 | +the spectral flux points are statistically independent, while with ``NODES`` the | ||
| 38 | +underlying spectral model connects spectral flux points using a piecewise power | ||
| 39 | +law. Both methods are particularly useful if non-CTA data should be fitted such | ||
| 40 | +as data from Fermi/LAT, CGRO/COMPTEL or INTEGRAL/SPI. | ||
| 41 | + | ||
| 42 | +By default, ``method`` is set to ``AUTO`` which will automatically select the | ||
| 43 | +method based on the input data. For CTA-only observations ``SLICE`` will be used, | ||
| 44 | +otherwise ``NODES`` will be used. | ||
| 36 | 45 | ||
| 37 | The spectral binning is either defined by a FITS file containing the energy | 46 | The spectral binning is either defined by a FITS file containing the energy |
| 38 | boundaries of each bin (option ``ebinalg=FILE``) or as ``enumbins`` bins spread | 47 | boundaries of each bin (option ``ebinalg=FILE``) or as ``enumbins`` bins spread |
| @@ -59,9 +68,6 @@ the fitted flux and flux error, the Test Statistics value (option | @@ -59,9 +68,6 @@ the fitted flux and flux error, the Test Statistics value (option | ||
| 59 | ``calc_ts=yes``), the upper flux limit (option ``calc_ulim=yes``) and the | 68 | ``calc_ts=yes``), the upper flux limit (option ``calc_ulim=yes``) and the |
| 60 | predicted number of events (only for unbinned data). | 69 | predicted number of events (only for unbinned data). |
| 61 | 70 | ||
| 62 | -.. warning:: | ||
| 63 | - The upper limit computation is not yet implemented for the ``NODES`` method. | ||
| 64 | - | ||
| 65 | 71 | ||
| 66 | General parameters | 72 | General parameters |
| 67 | ------------------ | 73 | ------------------ |