diff --git a/ChangeLog b/ChangeLog index dc48462..c079490 100755 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,16 @@ Add support of rectangular On/Off regions (#3248) +2021-04-28 + + * Bug fix version 1.7.4 released + ================================ + + Add conda activation and deactivation scripts for csh (#3628) + Replace spectral model by file function in csspec (#3624) + Update csinfo script (#3623) + + 2020-12-02 * Bug fix version 1.7.3 released diff --git a/Makefile.am b/Makefile.am index 4f9db82..bd1df1c 100755 --- a/Makefile.am +++ b/Makefile.am @@ -33,9 +33,11 @@ pkgconfig_DATA = ctools.pc # Conda activate directory condaactivatedir = $(sysconfdir)/conda/activate.d -condaactivate_DATA = dev/01-ctools-activate.sh +condaactivate_DATA = dev/01-ctools-activate.sh \ + dev/01-ctools-activate.csh condadeactivatedir = $(sysconfdir)/conda/deactivate.d -condadeactivate_DATA = dev/00-ctools-deactivate.sh +condadeactivate_DATA = dev/00-ctools-deactivate.sh \ + dev/00-ctools-deactivate.csh # Manual pages to install man_MANS = @@ -55,6 +57,7 @@ EXTRA_DIST = README.md \ doc/Doxyfile doc/source \ dev/testreport.py \ dev/01-ctools-activate.sh dev/00-ctools-deactivate.sh \ + dev/01-ctools-activate.csh dev/00-ctools-deactivate.csh \ dev/conda.recipe/build.sh \ dev/conda.recipe/conda_build_config.yaml \ dev/conda.recipe/meta.yaml.in diff --git a/cscripts/csinfo.py b/cscripts/csinfo.py index 6e0281f..fcd7bae 100755 --- a/cscripts/csinfo.py +++ b/cscripts/csinfo.py @@ -2,7 +2,7 @@ # ========================================================================== # Print info about Gammalib / ctools to the console # -# Copyright (C) 2015-2016 Christoph Deil +# Copyright (C) 2015-2021 Christoph Deil # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,10 +32,13 @@ CTOOL_LIST = """ ctedispcube Generates energy dispersion cube cterror Calculates likelihood profile errors ctexpcube Generates exposure cube + ctfindvar Search for source variability ctlike Performs maximum likelihood fitting ctmapcube Generates a map cube ctmodel Computes model counts cube ctobssim Simulate CTA observations + ctphase Computes the phase of each event + ctprob Computes event probability for a given model ctpsfcube Generates point spread function cube ctselect Selects event data ctskymap Generates sky map @@ -47,20 +50,31 @@ CTOOL_LIST = """ # `doc/source/users/reference_manual/index.rst` # and needs to be manually updated and kept in sync CSCRIPT_LIST = """ + csbkgmodel Generates background model for 3D analysis cscaldb Lists available instrument response functions + csebins Generates energy boundaries for stacked analysis cslightcrv Computes lightcurve csinfo Checks ctools and GammaLib installations csmodelinfo Shows model container content csmodelmerge Merges several model containers into one file + csmodelselect Select models from model definition file + csmodelsois Generate map cube from subset of models csobsdef Generates observation definition file csobsinfo Shows observation container content + csobsselect Select observations from observation definition file + csphagen Generates PHA, ARF, RMF files based on source/background regions + csphasecrv Computes phase curve cspull Generates pull distribution csresmap Generates residual map + csresspec Generates residual spectrum + csscs Performs spectral component separation cssens Computes CTA sensitivity csspec Computes spectral points + cssrcdetect Detects sources in sky map cstsdist Generates TS distribution + cstsmapmerge Merges slices from Test Statistic map computations cstsmapsplit Creates commands to split the Test Statistic map computations - cstsmapmerge Merges slices from Test Statistic map computations\n + csviscube Computes visibility cube\n csobs2caldb Creates a caldb entry from an input observation csroot2caldb Creates a caldb entry from a ROOT performance file csiactdata Shows information about IACT data available on the user machine diff --git a/cscripts/csspec.py b/cscripts/csspec.py index d5d4a31..6b6c6e5 100755 --- a/cscripts/csspec.py +++ b/cscripts/csspec.py @@ -20,6 +20,7 @@ # ========================================================================== import sys import math +import tempfile # Kludge for file function generation import gammalib import ctools from cscripts import mputils @@ -367,6 +368,24 @@ class csspec(ctools.csobservation): ' Fixing "'+par.name()+'"') par.fix() + # Kludge: convert spectral model into a file function + nbins = self._ebounds.size() + num = nbins * 20 + energies = gammalib.GEnergies(num, self._ebounds.emin(0), + self._ebounds.emax(nbins-1)) + _, filename = tempfile.mkstemp() + f = open(filename, 'w') + spectral = model.spectral() + for energy in energies: + value = spectral.eval(energy) + f.write('%20.6f %20e\n' % (energy.MeV(), value)) + f.close() + spectral = gammalib.GModelSpectralFunc(filename, 1.0) + model.spectral(spectral) + self._log_string(gammalib.EXPLICIT, ' Converting spectral model ' + 'into file function via temporary file "%s"' % + filename) + # Free the normalisation parameter which is assumed to be # the first spectral parameter normpar = model.spectral()[0] @@ -956,7 +975,7 @@ class csspec(ctools.csobservation): result['dloglike'] = dlogL result['logL'] = loglike - # Compute upper limit + # Compute upper flux limit if self['calc_ulim'].boolean(): # Logging information @@ -1072,7 +1091,7 @@ class csspec(ctools.csobservation): (not self['dll_freenodes'].boolean()): for par in spectral: par.fix() - + # Re-compute the log-likelihood like.run() loglike = like.obs().logL() @@ -1200,7 +1219,7 @@ class csspec(ctools.csobservation): table.append(dnde) table.append(TSvalues) table.append(Npred_values) - + # Define the SED type table.card('SED_TYPE', 'norm,e2dnde,dnde,npred', 'SED type') diff --git a/dev/00-ctools-deactivate.csh b/dev/00-ctools-deactivate.csh new file mode 100644 index 0000000..245fec7 --- /dev/null +++ b/dev/00-ctools-deactivate.csh @@ -0,0 +1,4 @@ +#!/bin/csh + +unsetenv CTOOLS +unsetenv CALDB diff --git a/dev/01-ctools-activate.csh b/dev/01-ctools-activate.csh new file mode 100644 index 0000000..16ce2f5 --- /dev/null +++ b/dev/01-ctools-activate.csh @@ -0,0 +1,7 @@ +#!/bin/csh + +setenv CTOOLS ${CONDA_PREFIX} +source ${CTOOLS}/bin/ctools-init.csh +unsetenv PYTHONPATH +unsetenv LD_LIBRARY_PATH +unsetenv DYLD_LIBRARY_PATH diff --git a/doc/source/admin/release_history/1.7.4.rst b/doc/source/admin/release_history/1.7.4.rst new file mode 100644 index 0000000..d521f3b --- /dev/null +++ b/doc/source/admin/release_history/1.7.4.rst @@ -0,0 +1,18 @@ +.. _1.7.4: + +ctools 1.7.4 release (28 April 2021) +==================================== + +Overview +-------- + +ctools 1.7.4 is a bug fix release for ctools release 1.7. + +The following bugs were fixed: + +* [`3628 `_] - + Add conda activation and deactivation scripts for csh +* [`3624 `_] - + Replace spectral model by file function in :ref:`csspec` +* [`3623 `_] - + Update csinfo script diff --git a/doc/source/admin/release_history/index.rst b/doc/source/admin/release_history/index.rst index 5149ff4..719e79c 100755 --- a/doc/source/admin/release_history/index.rst +++ b/doc/source/admin/release_history/index.rst @@ -7,6 +7,7 @@ Release History :maxdepth: 1 ctools 2.0 <2.0> + ctools 1.7.4 <1.7.4> ctools 1.7.3 <1.7.3> ctools 1.7.2 <1.7.2> ctools 1.7.1 <1.7.1> diff --git a/doc/source/develop/releasing/index.rst b/doc/source/develop/releasing/index.rst index 869a5ba..59851bc 100755 --- a/doc/source/develop/releasing/index.rst +++ b/doc/source/develop/releasing/index.rst @@ -21,4 +21,5 @@ To create a new ctools release you have to go through the following steps: * added unit tests for all new code * added a page about the software changes to the release history * updated the User documentation if necessary + * updated the csinfo script if necessary diff --git a/doc/source/users/reference_manual/csspec.rst b/doc/source/users/reference_manual/csspec.rst index 453ef7d..5e5b981 100755 --- a/doc/source/users/reference_manual/csspec.rst +++ b/doc/source/users/reference_manual/csspec.rst @@ -20,19 +20,28 @@ flux limit that is particularly useful in case that the source is not significantly detected within a spectral bin (hidden parameter ``calc_ulim``). There are three fundamental methods to run the script depending on the value of -the ``method`` parameter. If ``method=SLICE`` the energy interval defined by the -``emin`` and ``emax`` parameters is divided into a number of energy bins and an -independent maximum likelihood fit is performed in each of the energy bins. If -``method=NODES`` the spectral model will be replaced by a node function that will -be fit to all data. Alternatively, if ``method=BINS`` the spectral model will be -replaced by a bin function that will be fit to all data. While with the ``NODES`` -method the spectral points are in general not statistically independent, the -``BINS`` method assures that the spectral points are statistically independent. -The ``NODES`` and ``BINS`` methods are particularly useful if data from instruments -other than CTA should be analyses, such as data from Fermi/LAT, COMPTEL or -INTEGRAL/SPI. By default, ``method`` is set to ``AUTO`` which will automatically -select the method based on the input data. For CTA-only observations ``SLICE`` will -be used, otherwise ``NODES`` will be used. +the ``method`` parameter, ``SLICE``, ``BINS`` and ``NODES``. + +If ``method=SLICE`` the energy interval defined by the ``emin`` and ``emax`` +parameters is divided into a number of energy bins and an independent maximum +likelihood fit is performed in each of the energy bins. In order to cope with +all kinds of spectral models, including composite spectra, input spectrum will +be converted into a file function, with the normalisation of the file function +being the fit parameter for each energy bin. This implies that spectral +components are merged into a single function using the model parameters that +are specified in the input model. + +If ``method=BINS`` the spectral model will be replaced by a bin function that +will be fit to all data, with ``method=NODES`` the spectral model will be replaced +by a node function. The advantage of ``BINS`` over ``NODES`` is that with ``BINS`` +the spectral flux points are statistically independent, while with ``NODES`` the +underlying spectral model connects spectral flux points using a piecewise power +law. Both methods are particularly useful if non-CTA data should be fitted such +as data from Fermi/LAT, CGRO/COMPTEL or INTEGRAL/SPI. + +By default, ``method`` is set to ``AUTO`` which will automatically select the +method based on the input data. For CTA-only observations ``SLICE`` will be used, +otherwise ``NODES`` will be used. The spectral binning is either defined by a FITS file containing the energy 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 ``calc_ts=yes``), the upper flux limit (option ``calc_ulim=yes``) and the predicted number of events (only for unbinned data). -.. warning:: - The upper limit computation is not yet implemented for the ``NODES`` method. - General parameters ------------------