diff --git a/ChangeLog b/ChangeLog index e390bdc..b3209b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2016-07-21 Juergen Knoedlseder +2016-07-24 Juergen Knoedlseder * Version 1.1.0 released ======================== + Adapt to new spatial (#1818) and spectral model names (#1821) Fix stacked analysis bias (#1819) Add background model science verification (#1815) Add cstsmapsplit script (#1797) diff --git a/NEWS b/NEWS index 6237436..27a7ad2 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 1.1.0 -21 July 2016 +24 July 2016 Introduction diff --git a/README.md b/README.md index 1962d06..d962b5f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ctools information ================== -* Version: 1.1.0.dev1 (21 July 2016) +* Version: 1.1.0.dev1 (24 July 2016) * Author: Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu) * GammaLib dependency: 1.1.0.dev1 diff --git a/cscripts/cspull.py b/cscripts/cspull.py index b0fcab2..f1bcf65 100755 --- a/cscripts/cspull.py +++ b/cscripts/cspull.py @@ -173,8 +173,8 @@ class cspull(ctools.cscript): # Compute spatial binning for point spread function and # energy dispersion cubes binsz = 10.0 * self['binsz'].real() - nxpix = self['nxpix'].integer() // 10 # Make sure result is int - nypix = self['nypix'].integer() // 10 # Make sure result is int + nxpix = self['npix'].integer() // 10 # Make sure result is int + nypix = self['npix'].integer() // 10 # Make sure result is int if nxpix < 2: nxpix = 2 if nypix < 2: diff --git a/doc/source/users/user_manual/getting_started/models.rst b/doc/source/users/user_manual/getting_started/models.rst index 972f773..03ee6c4 100644 --- a/doc/source/users/user_manual/getting_started/models.rst +++ b/doc/source/users/user_manual/getting_started/models.rst @@ -118,16 +118,14 @@ term will be appended to each ```` tag. parameters so that the effective parameters to be optimised (the ``value`` terms) are all of about unity. -.. warning:: +.. note:: - The syntax of the model definition XML file has been adopted from the - syntax used by the Fermi/LAT ScienceTools. - This should allow for exchange of model definition files between ctools - and the Fermi/LAT ScienceTools. - Note, however, that ctools implements a number of extensions with - respect to the Fermi/LAT ScienceTools syntax, hence eventually minor - manual adjustments may be needed to use ctools XML files for - Fermi/LAT analyses. + The syntax of the model definition XML file has been inspired from the + syntax used by the Fermi/LAT ScienceTools, but for reasons of clarity and + homogenity of the various model and parameter names we have made some + modifications. + Nevertheless, the exact format used by the Fermi/LAT ScienceTools is also + supported. .. _sec_spatial_models: @@ -155,8 +153,8 @@ Point source .. note:: - For compatibility with the Fermi/LAT ScienceTools the model type ``PointSource`` - can be replaced by ``SkyDirFunction``. + For compatibility with the Fermi/LAT ScienceTools the model type + ``PointSource`` can be replaced by ``SkyDirFunction``. Radial source @@ -373,8 +371,6 @@ in ctools. .. warning:: - The units of the spectral model depend on the spatial model component. - Units quoted below apply to spatial models for a source component. Source intensities are generally given in units of :math:`{\rm ph}\,\,{\rm cm}^{-2}\,{\rm s}^{-1}\,{\rm MeV}^{-1}`. @@ -405,11 +401,11 @@ Constant .. code-block:: xml - + - The ``ConstantValue`` model component implements the constant function + This spectral model component implements the constant function .. math:: \frac{dN}{dE} = N_0 @@ -419,6 +415,11 @@ Constant * :math:`N_0` = ``Normalization`` :math:`({\rm ph}\,\,{\rm cm}^{-2}\,{\rm s}^{-1}\,{\rm MeV}^{-1})` + .. note:: + + For compatibility with the Fermi/LAT ScienceTools the model type + ``Constant`` can be replaced by ``ConstantValue`` and the parameter + ``Normalization`` by ``Value``. Power law @@ -432,7 +433,7 @@ Power law - The ``PowerLaw`` model component implements the power law function + This spectral model component implements the power law function .. math:: \frac{dN}{dE} = k_0 \left( \frac{E}{E_0} \right)^{\gamma} @@ -454,19 +455,19 @@ Power law For compatibility with the Fermi/LAT ScienceTools the parameter ``PivotEnergy`` can be replaced by ``Scale``. - An alternative power law function that uses the integral photon flux as parameter - rather than the Prefactor is specified by + An alternative power law function that uses the integral photon flux as + parameter rather than the Prefactor is specified by .. code-block:: xml - + - The ``PowerLawPhotonFlux`` model component implements the power law function + This spectral model component implements the power law function .. math:: \frac{dN}{dE} = \frac{N(\gamma+1)E^{\gamma}} @@ -484,8 +485,8 @@ Power law .. warning:: - The ``LowerLimit`` and ``UpperLimit`` parameters are always treated as fixed and, - the flux given by the ``PhotonFlux`` parameter is computed over the + The ``LowerLimit`` and ``UpperLimit`` parameters are always treated as fixed + and the flux given by the ``PhotonFlux`` parameter is computed over the range set by these two parameters. Use of this model allows the errors on the integral flux to be evaluated directly by :ref:`ctlike`. @@ -493,8 +494,8 @@ Power law .. note:: For compatibility with the Fermi/LAT ScienceTools the model type - ``PowerLawPhotonFlux`` can be replaced by ``PowerLaw2`` and the parameter - ``PhotonFlux`` can be replaced by ``Integral``. + ``PowerLaw`` can be replaced by ``PowerLaw2`` and the parameter + ``PhotonFlux`` by ``Integral``. Exponentially cut-off power law @@ -502,18 +503,19 @@ Exponentially cut-off power law .. code-block:: xml - - - - - + + + + + - The ``ExpCutoff`` model component implements the exponentially cut-off power law function + This spectral model component implements the exponentially cut-off power law + function .. math:: \frac{dN}{dE} = k_0 \left( \frac{E}{E_0} \right)^{\gamma} - \exp \left( \frac{-E}{\tt E_{\rm cut}} \right) + \exp \left( \frac{-E}{E_{\rm cut}} \right) where @@ -522,7 +524,7 @@ Exponentially cut-off power law * :math:`\gamma` = ``Index`` * :math:`E_0` = ``PivotEnergy`` :math:`({\rm MeV})` - * :math:`E_{\rm cut}` = ``Cutoff`` + * :math:`E_{\rm cut}` = ``CutoffEnergy`` :math:`({\rm MeV})` .. warning:: @@ -531,8 +533,61 @@ Exponentially cut-off power law .. note:: - For compatibility with the Fermi/LAT ScienceTools the parameter - ``PivotEnergy`` can be replaced by ``Scale``. + For compatibility with the Fermi/LAT ScienceTools the model type + ``ExponentialCutoffPowerLaw`` can be replaced by ``ExpCutoff`` and + the parameters ``CutoffEnergy`` by ``Cutoff`` and ``PivotEnergy`` + by ``Scale``. + + +Super exponentially cut-off power law +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + .. code-block:: xml + + + + + + + + + + This spectral model component implements the super exponentially cut-off power + law function + + .. math:: + \frac{dN}{dE} = k_0 \left( \frac{E}{E_0} \right)^{\gamma} + \exp \left( + -\left( \frac{E}{E_{\rm cut}} \right)^{\alpha} + \right) + + where + + * :math:`k_0` = ``Prefactor`` + :math:`({\rm ph}\,\,{\rm cm}^{-2}\,{\rm s}^{-1}\,{\rm MeV}^{-1})` + * :math:`\gamma` = ``Index1`` + * :math:`\alpha` = ``Index2`` + * :math:`E_0` = ``PivotEnergy`` + :math:`({\rm MeV})` + * :math:`E_{\rm cut}` = ``CutoffEnergy`` + :math:`({\rm MeV})` + + .. warning:: + + The ``PivotEnergy`` parameter is not intended to be fitted. + + An alternative XML format is supported for compatibility with the Fermi/LAT + XML format: + + .. code-block:: xml + + + + + + + + Broken power law @@ -541,13 +596,13 @@ Broken power law .. code-block:: xml - - - - + + + + - The ``BrokenPowerLaw`` model component implements the broken power law function + This spectral model component implements the broken power law function .. math:: @@ -564,15 +619,20 @@ Broken power law :math:`({\rm ph}\,\,{\rm cm}^{-2}\,{\rm s}^{-1}\,{\rm MeV}^{-1})` * :math:`\gamma_1` = ``Index1`` * :math:`\gamma_2` = ``Index2`` - * :math:`E_b` = ``BreakValue`` + * :math:`E_b` = ``BreakEnergy`` :math:`({\rm MeV})` .. warning:: - Note that the ``BreakValue`` parameter may be poorly constrained if + Note that the ``BreakEnergy`` parameter may be poorly constrained if there is no clear spectral cut-off in the spectrum. This model may lead to complications in the maximum likelihood fitting. + .. note:: + + For compatibility with the Fermi/LAT ScienceTools the parameters + ``BreakEnergy`` can be replaced by ``BreakValue``. + Log parabola ^^^^^^^^^^^^ @@ -586,7 +646,7 @@ Log parabola - The ``LogParabola`` model component implements the log parabola function + This spectral model component implements the log parabola function .. math:: \frac{dN}{dE} = k_0 \left( \frac{E}{E_0} \right)^{\gamma+\eta \ln(E/E_0)} @@ -633,7 +693,7 @@ Gaussian - The ``Gaussian`` model component implements the gaussian function + This spectral model component implements the gaussian function .. math:: \frac{dN}{dE} = \frac{N_0}{\sqrt{2\pi}\sigma} @@ -658,7 +718,7 @@ File function - The ``FileFunction`` model component implements an arbitrary function + This spectral model component implements an arbitrary function that is defined by intensity values at specific energies. The energy and intensity values are defined using an ASCII file with columns of energy and differential flux values. @@ -677,9 +737,10 @@ File function .. warning:: - If the file name is given as relative path, the path is relative to the - working directory where the ctool has been launched. - Alternatively, an absolute path may be specified. + If the file name is given without a path it is expected that the file + resides in the same directory than the XML file. + If the file resides in a different directory, an absolute path name should + be specified. Any environment variable present in the path name will be expanded. @@ -699,7 +760,7 @@ Node function - The ``NodeFunction`` model component implements a generalised broken + This spectral model component implements a generalised broken power law which is defined by a set of energy and intensity values (the so called nodes) that are piecewise connected by power laws. Energies are given in units of diff --git a/test/data/obs_stacked_two.xml b/test/data/obs_stacked_two.xml new file mode 100644 index 0000000..d47236b --- /dev/null +++ b/test/data/obs_stacked_two.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/test/data/sciver/crab_eplaw.xml b/test/data/sciver/crab_eplaw.xml index eb0ba7d..ce8045c 100644 --- a/test/data/sciver/crab_eplaw.xml +++ b/test/data/sciver/crab_eplaw.xml @@ -1,11 +1,11 @@ - - - - - + + + + + diff --git a/test/data/sciver/crab_plaw2.xml b/test/data/sciver/crab_plaw2.xml index 1384507..99d9ca1 100644 --- a/test/data/sciver/crab_plaw2.xml +++ b/test/data/sciver/crab_plaw2.xml @@ -1,7 +1,7 @@ - + diff --git a/test/data/sciver/crab_supeplaw.xml b/test/data/sciver/crab_supeplaw.xml index 03369b0..999f3e3 100644 --- a/test/data/sciver/crab_supeplaw.xml +++ b/test/data/sciver/crab_supeplaw.xml @@ -1,12 +1,12 @@ - - - - - - + + + + + + diff --git a/test/science_verification.py b/test/science_verification.py index ecca0ea..b596ceb 100755 --- a/test/science_verification.py +++ b/test/science_verification.py @@ -424,7 +424,7 @@ class sciver(gammalib.GPythonTestSuite): self.pull('data/sciver/crab_eplaw') self.test('Pull_Crab_Prefactor') self.test('Pull_Crab_Index') - self.test('Pull_Crab_Cutoff') + self.test('Pull_Crab_CutoffEnergy') self.test('Pull_Background_Prefactor') self.test('Pull_Background_Index') return @@ -438,7 +438,7 @@ class sciver(gammalib.GPythonTestSuite): self.test('Pull_Crab_Prefactor') self.test('Pull_Crab_Index1') self.test('Pull_Crab_Index2') - self.test('Pull_Crab_Cutoff') + self.test('Pull_Crab_CutoffEnergy') self.test('Pull_Background_Prefactor') self.test('Pull_Background_Index') return diff --git a/test/test_cspull.py b/test/test_cspull.py index ea281dc..dac960a 100755 --- a/test/test_cspull.py +++ b/test/test_cspull.py @@ -44,6 +44,7 @@ class Test(test): # Set members self._inobs = self._datadir + '/obs_stacked.xml' + self._inobs_two = self._datadir + '/obs_stacked_two.xml' self._stacked_model = self._datadir + '/crab_bkgcube.xml' # Return @@ -209,14 +210,13 @@ class Test(test): # Check pull distribution file self._check_pull_file('cspull_py4.dat') - # Set-up stacked cspull + # Set-up stacked cspull with one observation where response cubes + # are specified in the input observation pull = cscripts.cspull() pull['inobs'] = self._inobs pull['inmodel'] = self._stacked_model pull['outfile'] = 'cspull_py5.dat' pull['ntrials'] = 3 - pull['caldb'] = self._caldb - pull['irf'] = self._irf pull['enumbins'] = 0 pull['logfile'] = 'cspull_py5.log' pull['chatter'] = 4 @@ -227,6 +227,31 @@ class Test(test): # Check pull distribution file self._check_pull_file('cspull_py5.dat') + # Set-up stacked cspull with two observations from which response + # cubes will be computed internally. The IRFs are also specified + # in the input observation, hence we do not need to query the IRF + # parameters. + pull = cscripts.cspull() + pull['inobs'] = self._inobs_two + pull['inmodel'] = self._model + pull['outfile'] = 'cspull_py6.dat' + pull['ntrials'] = 3 + pull['emin'] = 0.02 + pull['emax'] = 100.0 + pull['enumbins'] = 10 + pull['npix'] = 20 + pull['binsz'] = 0.2 + pull['coordsys'] = 'CEL' + pull['proj'] = 'TAN' + pull['logfile'] = 'cspull_py6.log' + pull['chatter'] = 4 + + # Execute cspull script + pull.execute() + + # Check pull distribution file + self._check_pull_file('cspull_py6.dat') + # Return return