Commit 1c061c9d025a1dfdbcac6a25f96d8b70a4cbe829

Authored by Jürgen Knödlseder
1 parent 11528349

Correct diffuse map cube upper limit computation in ctulimit (#2298)

ChangeLog
1 -2018-01-24 1 +2018-01-25
2 2
3 * Version 1.5.0 released 3 * Version 1.5.0 released
4 ======================== 4 ========================
5 5
  6 + Correct diffuse map cube upper limit computation in ctulimit (#2298)
6 Add tmin and tmax parameters to csobsselect (#2297) 7 Add tmin and tmax parameters to csobsselect (#2297)
7 Change DATE_OBS, DATE_END, TIME_OBS and TIME_END FITS keywords into DATA-OBS, 8 Change DATE_OBS, DATE_END, TIME_OBS and TIME_END FITS keywords into DATA-OBS,
8 DATE-END, TIME-OBS and TIME-END 9 DATE-END, TIME-OBS and TIME-END
1 -24 January 2018 1 +25 January 2018
2 2
3 3
4 Introduction 4 Introduction
@@ -142,6 +142,10 @@ Add "statistic" parameter to allow setting of optimizer statistic (#2237). @@ -142,6 +142,10 @@ Add "statistic" parameter to allow setting of optimizer statistic (#2237).
142 142
143 ctulimit - Compute upper limit 143 ctulimit - Compute upper limit
144 ------------------------------ 144 ------------------------------
  145 +The tool now also computes correct upper flux limits for diffuse map cubes
  146 +for which the spectral component is a normalization of the spectral information
  147 +available in the map cube (#2298).
  148 +
145 Add "statistic" parameter to allow setting of optimizer statistic (#2237). 149 Add "statistic" parameter to allow setting of optimizer statistic (#2237).
146 150
147 151
doc/source/admin/release_history/1.5.rst
@@ -20,6 +20,8 @@ In particular, this release provides: @@ -20,6 +20,8 @@ In particular, this release provides:
20 Bug fixes 20 Bug fixes
21 --------- 21 ---------
22 22
  23 +* [`2298 <https://cta-redmine.irap.omp.eu/issues/2298>`_] -
  24 + Correct diffuse map cube upper limit computation in :ref:`ctulimit`
23 * Change ``DATE_OBS``, ``DATE_END``, ``TIME_OBS`` and ``TIME_END`` FITS keywords 25 * Change ``DATE_OBS``, ``DATE_END``, ``TIME_OBS`` and ``TIME_END`` FITS keywords
24 into ``DATA-OBS``, ``DATE-END``, ``TIME-OBS`` and ``TIME-END`` 26 into ``DATA-OBS``, ``DATE-END``, ``TIME-OBS`` and ``TIME-END``
25 * [`2287 <https://cta-redmine.irap.omp.eu/issues/2287>`_] - 27 * [`2287 <https://cta-redmine.irap.omp.eu/issues/2287>`_] -
doc/source/users/reference_manual/ctulimit.rst
@@ -19,7 +19,8 @@ using the hidden ``confidence`` parameter. @@ -19,7 +19,8 @@ using the hidden ``confidence`` parameter.
19 :ref:`ctulimit` writes the differential upper flux limit at a given reference 19 :ref:`ctulimit` writes the differential upper flux limit at a given reference
20 energy (specified by the hidden parameter ``eref``) and the integrated 20 energy (specified by the hidden parameter ``eref``) and the integrated
21 upper flux limit (specified by the hidden parameters ``emin`` and ``emax``) 21 upper flux limit (specified by the hidden parameters ``emin`` and ``emax``)
22 -into the log file. 22 +into the log file. This information can also be accessed using the ``diff_ulimit()``,
  23 +``flux_ulimit()``, and ``eflux_ulimit()`` methods.
23 24
24 25
25 General parameters 26 General parameters
src/ctulimit/ctulimit.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctulimit - Upper limit calculation tool * 2 * ctulimit - Upper limit calculation tool *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2015-2017 by Michael Mayer * 4 + * copyright (C) 2015-2018 by Michael Mayer *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
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 *
@@ -302,17 +302,8 @@ void ctulimit::run(void) @@ -302,17 +302,8 @@ void ctulimit::run(void)
302 // Write final parameter into logger 302 // Write final parameter into logger
303 log_value(NORMAL, "Final parameter", m_model_par->value()); 303 log_value(NORMAL, "Final parameter", m_model_par->value());
304 304
305 - // Get reference energy for differential upper limit  
306 - GEnergy eref = GEnergy(m_eref, "TeV");  
307 -  
308 - // Create energy range for flux limits  
309 - GEnergy emin = GEnergy(m_emin, "TeV");  
310 - GEnergy emax = GEnergy(m_emax, "TeV");  
311 -  
312 // Compute upper limit intensity and fluxes 305 // Compute upper limit intensity and fluxes
313 - m_diff_ulimit = m_skymodel->spectral()->eval(eref, GTime());  
314 - m_flux_ulimit = m_skymodel->spectral()->flux(emin, emax);  
315 - m_eflux_ulimit = m_skymodel->spectral()->eflux(emin, emax); 306 + compute_ulimit();
316 307
317 // Write header into logger 308 // Write header into logger
318 log_header1(TERSE, "Upper limit results"); 309 log_header1(TERSE, "Upper limit results");
@@ -640,3 +631,78 @@ void ctulimit::ulimit_bisection(const double&amp; min, const double&amp; max) @@ -640,3 +631,78 @@ void ctulimit::ulimit_bisection(const double&amp; min, const double&amp; max)
640 return; 631 return;
641 632
642 } 633 }
  634 +
  635 +
  636 +/***********************************************************************//**
  637 + * @brief Compute upper limit intensity and fluxes
  638 + *
  639 + * Compute upper limit intensity and fluxes, including a correct computation
  640 + * for the diffuse map cube models.
  641 + ***************************************************************************/
  642 +void ctulimit::compute_ulimit(void)
  643 +{
  644 + // Initialise upper limit intensity and fluxes
  645 + m_diff_ulimit = 0.0;
  646 + m_flux_ulimit = 0.0;
  647 + m_eflux_ulimit = 0.0;
  648 +
  649 + // Get reference energy for differential upper limit
  650 + GEnergy eref = GEnergy(m_eref, "TeV");
  651 +
  652 + // Create energy range for flux limits
  653 + GEnergy emin = GEnergy(m_emin, "TeV");
  654 + GEnergy emax = GEnergy(m_emax, "TeV");
  655 +
  656 + // Set pointer to spectral model and initialise spectral nodes model
  657 + // pointer
  658 + GModelSpectral* spectral = m_skymodel->spectral();
  659 + GModelSpectralNodes* nodes = NULL;
  660 +
  661 + // If the spectral model is a diffuse cube then create a node function
  662 + // spectral model that is the product of the diffuse cube node function
  663 + // and the spectral model evaluated at the energies of the node function
  664 + GModelSpatialDiffuseCube* cube =
  665 + dynamic_cast<GModelSpatialDiffuseCube*>(m_skymodel->spatial());
  666 + if (cube != NULL) {
  667 +
  668 +
  669 + // Set MC cone to the entire sky. This method call is needed to
  670 + // set-up the cube spectrum
  671 + cube->set_mc_cone(GSkyDir(), 180.0);
  672 +
  673 + // Allocate node function to replace the spectral component
  674 + nodes = new GModelSpectralNodes(cube->spectrum());
  675 + for (int i = 0; i < nodes->nodes(); ++i) {
  676 + GEnergy energy = nodes->energy(i);
  677 + double intensity = nodes->intensity(i);
  678 + double value = spectral->eval(energy);
  679 + nodes->intensity(i, value*intensity);
  680 + }
  681 +
  682 + // Set the spectral model pointer to the node function. If there are
  683 + // no nodes the spectral pointer is set to NULL since in this case the
  684 + // spectral->flux method will throw an exception
  685 + if (nodes->nodes() > 0) {
  686 + spectral = nodes;
  687 + }
  688 + else {
  689 + spectral = NULL;
  690 + }
  691 +
  692 + } // endif: spatial model was a diffuse cube
  693 +
  694 + // Compute upper limit intensity and fluxes
  695 + if (spectral != NULL) {
  696 + m_diff_ulimit = spectral->eval(eref);
  697 + m_flux_ulimit = spectral->flux(emin, emax);
  698 + m_eflux_ulimit = spectral->eflux(emin, emax);
  699 + }
  700 +
  701 + // Free spectral nodes if they have been allocated
  702 + if (nodes != NULL) {
  703 + delete nodes;
  704 + }
  705 +
  706 + // Return
  707 + return;
  708 +}
src/ctulimit/ctulimit.hpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctulimit - Upper limit calculation tool * 2 * ctulimit - Upper limit calculation tool *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2015-2016 by Michael Mayer * 4 + * copyright (C) 2015-2018 by Michael Mayer *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
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 *
@@ -70,12 +70,13 @@ public: @@ -70,12 +70,13 @@ public:
70 70
71 protected: 71 protected:
72 // Protected methods 72 // Protected methods
73 - void init_members(void);  
74 - void copy_members(const ctulimit& app);  
75 - void free_members(void);  
76 - void get_parameters(void);  
77 - void get_model_parameter(void);  
78 - void ulimit_bisection(const double& parmin, const double& parmax); 73 + void init_members(void);
  74 + void copy_members(const ctulimit& app);
  75 + void free_members(void);
  76 + void get_parameters(void);
  77 + void get_model_parameter(void);
  78 + void ulimit_bisection(const double& parmin, const double& parmax);
  79 + void compute_ulimit(void);
79 80
80 // User parameters 81 // User parameters
81 std::string m_srcname; //!< Name of source which is moved around 82 std::string m_srcname; //!< Name of source which is moved around