Commit f1c51a6964f795b760bf452bb6afbaaae873a14d

Authored by Jürgen Knödlseder
1 parent 32017030

Make GCTAPsfKing save against invalid values (#2133)

ChangeLog
  1 +2017-06-26
  2 +
  3 + * Bug fix version 1.3.1 released
  4 + ================================
  5 +
  6 + Make GCTAPsfKing save against invalid values (#2133)
  7 +
  8 +
1 2017-06-06 9 2017-06-06
2 10
3 * Version 1.3.0 released 11 * Version 1.3.0 released
1 -New Features and Important Changes in GammaLib 1.3.0 1 +New Features and Important Changes in GammaLib 1.3.1
2 2
3 -6 June 2017 3 +26 June 2017
4 4
5 5
6 1. Introduction 6 1. Introduction
@@ -12,15 +12,7 @@ made since the last release of GammaLib. @@ -12,15 +12,7 @@ made since the last release of GammaLib.
12 2. Public interface modifications 12 2. Public interface modifications
13 --------------------------------- 13 ---------------------------------
14 The following classes have been added: 14 The following classes have been added:
15 -- GPhases  
16 -- GWcsGLS  
17 -- GWcsSFL  
18 -- GModelSpectralSmoothBrokenPlaw  
19 -- GModelSpatialRadialProfile  
20 -- GModelSpatialRadialProfileGauss  
21 -- GModelSpatialRadialProfileDMBurkert  
22 -- GModelSpatialRadialProfileDMEinasto  
23 -- GModelSpatialRadialProfileDMZhao 15 +- n.a.
24 16
25 The following classes have been removed: 17 The following classes have been removed:
26 - n.a. 18 - n.a.
@@ -29,48 +21,13 @@ The following classes have been renamed: @@ -29,48 +21,13 @@ The following classes have been renamed:
29 - n.a. 21 - n.a.
30 22
31 The following methods have been added: 23 The following methods have been added:
32 -- GEbounds::set(GEnergies&)  
33 -- GEbounds::emin(int&, GEnergy&)  
34 -- GEbounds::emax(int&, GEnergy&)  
35 -- GEnergies::set(GEbounds&)  
36 -- GFilename::type()  
37 -- GMatrix::operator+(double&)  
38 -- GMatrix::operator-(double&)  
39 -- GMatrix::operator+=(double&)  
40 -- GMatrix::operator-=(double&)  
41 -- GMatrixSymmetric::operator+(double&)  
42 -- GMatrixSymmetric::operator-(double&)  
43 -- GMatrixSymmetric::operator+=(double&)  
44 -- GMatrixSymmetric::operator-=(double&)  
45 -- GMatrixSparse::operator+(double&)  
46 -- GMatrixSparse::operator-(double&)  
47 -- GMatrixSparse::operator+=(double&)  
48 -- GMatrixSparse::operator-=(double&)  
49 -- GCTAResponseIrf::rspname()  
50 -- GCTARoi::contains(GCTAInstDir&)  
51 -- GCTAEdisp2D::fetch()  
52 -- GCTAAeff::ebounds()  
53 -- GCTAAeff2D::ebounds()  
54 -- GCTAAeffArf::ebounds()  
55 -- GCTAAeffPerfTable::ebounds()  
56 -- GCTAEventList::append_column(GFitsTableCol&)  
57 -- GCTAEventList::has_phase(bool&)  
58 -- GCTAEventList::has_phase()  
59 -- GCTAEventList::has_detxy(bool&)  
60 -- GCTAEventList::has_detxy()  
61 -- GCTAEventList::has_mc_id(bool&)  
62 -- GCTAEventList::has_mc_id()  
63 -- GCTAEventList::set_mc_id_names(std::vector<int>&, std::vector<std::string>&)  
64 -- GCTAEventAtom::mc_id(int&)  
65 -- GCTAEventAtom::mc_id() 24 +- n.a.
66 25
67 The following methods have been removed: 26 The following methods have been removed:
68 -- GFitsTable::size() 27 +- n.a.
69 28
70 The following methods have been renamed: 29 The following methods have been renamed:
71 -- GFitsImage::size() => GFitsImage::npix()  
72 -- GFitsHDU::size() => GFitsHDU::cards()  
73 -- GFitsTableCol::length() => GFitsTableCol::nrows() 30 +- n.a.
74 31
75 The arguments for the following methods have been changed: 32 The arguments for the following methods have been changed:
76 - n.a. 33 - n.a.
@@ -81,19 +38,7 @@ The return value of the following methods has been changed: @@ -81,19 +38,7 @@ The return value of the following methods has been changed:
81 38
82 3. Configuration 39 3. Configuration
83 ----------------- 40 -----------------
84 -The Python unit tests now raise exceptions instead of exiting with a non-  
85 -zero return code so that the user is not thrown out of Python after calling  
86 -gammalib.test() (#1983).  
87 -  
88 -If the code originates from the Git repository the configuration now switches  
89 -to developer mode which implies that the Python bindings are always built.  
90 -This solves the problem that occured for developers that could not get rid  
91 -of existing Python wrappers, even if they modified the Python interface  
92 -(#1985).  
93 -  
94 -The shared libraries needed by the Python wrappers are now copied into a  
95 -build/gammalib directory for unit testing instead of creating a symbolic  
96 -link since on shared VM file systems symbolic links may not work (#1987). 41 +None
97 42
98 43
99 4. Application module 44 4. Application module
@@ -108,57 +53,17 @@ None @@ -108,57 +53,17 @@ None
108 53
109 6. FITS I/O Interface 54 6. FITS I/O Interface
110 --------------------- 55 ---------------------
111 -FITS image type conversion constructors have been added to convert a FITS  
112 -image of any type into a specific storage class (#1986).  
113 -  
114 -A map between header card keywords and header card pointers was added to  
115 -GFitsHeader to speed up the access of FITS header cards (#2120).  
116 -  
117 -The GFitsImage::size() method has been renamed to GFitsImage::npix() since  
118 -the size() method overloaded the GFitsHDU::size() method (#1858).  
119 -  
120 -The GFitsTable::size() method has been removed since the meaning of the  
121 -method was ambiguous. It returned the number of table columns, but the  
122 -GFitsTable::ncols() does exactly the same thing, hence the method was  
123 -redundant (#1857).  
124 -  
125 -The GFitsHDU::size() method has been renamed to GFitsHDU::cards() since the  
126 -meaning of the size() method was not clear (#1859).  
127 -  
128 -The GFitsTableCol::length() method was renamed to GFitsTableCol::nrows()  
129 -to clarify the meaning of thie method (#1860). 56 +None
130 57
131 58
132 7. Linear algebra module 59 7. Linear algebra module
133 ------------------------ 60 ------------------------
134 -Add operators for addition and subtraction of scalars to all matrix classes  
135 -(#1990). 61 +None
136 62
137 63
138 8. Model module 64 8. Model module
139 --------------- 65 ---------------
140 -The GModelSpectralNodes class now throws an exception if the energy or  
141 -intensity of a node is set to a non-positive value (#990).  
142 -  
143 -The GModelSpectralSmoothBrokenPlaw class that implements a smoothly broken  
144 -power law spectrum has been added (#1948).  
145 -  
146 -The scale of the composite spatial models can now be fitted by adding the  
147 -free_scale="1" attribute to the XML file (#1992).  
148 -  
149 -Add GModelSpatialRadialProfile class to handle arbitrary radial profiles.  
150 -The method deals with pre-computation and normalization of the profiles,  
151 -and implements the eval() and mc() methods. The following derived classes  
152 -have been implemented:  
153 -- GModelSpatialRadialProfileGauss: radial Gaussian profile  
154 -- GModelSpatialRadialProfileDMBurkert: Burkert Dark Matter profile  
155 -- GModelSpatialRadialProfileDMEinasto: Einasto Dark Matter profile  
156 -- GModelSpatialRadialProfileDMZhao: Zhao Dark matter profile  
157 -Please note that these models are not deeply tested so far and the code  
158 -and interface is still subject to change (#1520).  
159 -  
160 -The names of spatial model parameters are now always set to RA/DEC even if  
161 -the input parameters were GLON/GLAT (#2113). 66 +None
162 67
163 68
164 9. Numerics module 69 9. Numerics module
@@ -168,39 +73,22 @@ None @@ -168,39 +73,22 @@ None
168 73
169 10. Observation module 74 10. Observation module
170 ---------------------- 75 ----------------------
171 -A set() method has been added to GEbounds and GEnergies to allow converting  
172 -energy boundaries into an energy container and vice versa. In addition,  
173 -conversion constructors have been added (#1977).  
174 -  
175 -The GEbounds::set_lin() and GEbounds::set_log() method now throw exceptions  
176 -if the minimum energy is larger than the maximum energy. In addition, the  
177 -GEbounds::set_log() method throws an exception if either the minimum or  
178 -maximum energy are zero. Furthermore, the methods clear the energy boundaries  
179 -if the requested number of intervals is non-zero (#1989).  
180 -  
181 -The GPhases class has been added to handle phase selections of events (#1996). 76 +None
182 77
183 78
184 11. Optimization module 79 11. Optimization module
185 ----------------------- 80 -----------------------
186 -The Levenberg-Marquardt optimiser convergence criterion is now scaled with the  
187 -step size so that a small step size does no longer lead to a stop of the  
188 -iterative process (#2022). 81 +None
189 82
190 83
191 12. Sky module 84 12. Sky module
192 -------------- 85 --------------
193 -The GWcsGLS and GWcsSFL classes have been added to support the GLS and SFL  
194 -World Coordinate System projections (#1851).  
195 -  
196 -The GWcs base class now also supports CD keywords instead of CDELT keywords  
197 -(#1951). 86 +None
198 87
199 88
200 13. Support module 89 13. Support module
201 ------------------ 90 ------------------
202 -A GFilename::type() method has been added that returns the type of the file  
203 -based on the file type extension (e.g. ".fits") (#1863). 91 +None
204 92
205 93
206 14. XML module 94 14. XML module
@@ -235,62 +123,10 @@ None @@ -235,62 +123,10 @@ None
235 123
236 20. CTA interface 124 20. CTA interface
237 ----------------- 125 -----------------
238 -Correct the containment radius computation in GCTAPsf2D (#1876).  
239 -  
240 -The GCTAResponseIrf::rspname() method has been added that returns the name  
241 -of the response function (attribute m_rspname).  
242 -  
243 -Do no longer interpret a CTA calibration database as a file path in the  
244 -GCTAResponseIrf::read() method (#1969).  
245 -  
246 -Add GCTARoi::contains() method that checks whether an instrument direction  
247 -is contained within the region of interest.  
248 -  
249 -Lazy loading of the energy dispersion in GCTAEdisp2D has been implemented by  
250 -adding a fetch() method to the class. Now the energy dispersion is only loaded  
251 -when needed, for example for function evaluation or Monte Carlo sampling (#1940).  
252 -  
253 -The GCTAEdisp2D::compute_ebounds_src() method now loops over the migration to  
254 -enhance the precision in the true energy boundaries that are returned by this  
255 -method. In addition, the validity range of the table is now stored in members  
256 -of the class, and a non-zero energy dispersion is only returned for valid  
257 -elements of the response table.  
258 -  
259 -An GCTAAeff::ebounds() method has been added to the abstract interface for  
260 -effective area responses to return the valid energy range of the effective  
261 -area (#1989).  
262 -  
263 -The GCTAModelAeffBackground::mc() could get stuck in the rejection loop if the  
264 -effective area returned is always zero. A counter has been added that leads to  
265 -the exit of the loop in case that 1000 subsequent zero values are returned  
266 -(#1988).  
267 -  
268 -A GCTAEventList::append_column() method has been added to allow appending of  
269 -FITS columns to an event list. The method checks whether the length of the  
270 -FITS column is compatible with the number of events that are present in the  
271 -event list (#1991).  
272 -  
273 -Add GCTAEventList::has_phase() and GCTAEventList::has_detxy() getter and setter  
274 -methods to manipulate the event list information flags (#1982).  
275 -  
276 -Add GCTAEventList::has_mc_id() and GCTAEventAtom::mc_id() getter and setter methods  
277 -to set the Monte Carlo identifier of a given event. This allows to attribute a  
278 -Monte Carlo simulated event to a specific model (#1483).  
279 -  
280 -Add GCTAEventList::set_mc_id_names() method to store Monte Carlo metadata into an  
281 -event list and to write this information into the FITS header. Furthermore, the  
282 -information is read back when loading an event list (#1483).  
283 -  
284 -The loading and saving of CTA response cubes was put into an OpenMP critial zone to  
285 -avoid FITS file pointer exceptions (#2021).  
286 -  
287 -The CTA background template HDUCLAS2 was changed from "BGD" to "BKG". Both strings  
288 -are supported by GammaLib.  
289 -  
290 -The maximum radius of the King PSF has been increased from 0.7 to 2 degrees to cope  
291 -with some extreme cases. Now also the maximum PSF radius is computed for a given  
292 -energy so that if the PSF is smaller than the maximum radius of 2 degrees a smaller  
293 -region of interest will be used for the computation (#2112). 126 +The GCTAPsfKing::r_max() method returned an infinite radius for a too small
  127 +gamma parameter. If the gamma parameter is too small the method now returns
  128 +a maximum radius of zero, and the GCTAPsfKing::update() method will set the
  129 +normalization to zero (#2133).
294 130
295 131
296 21. COMPTEL interface 132 21. COMPTEL interface
README.md
1 GammaLib information 1 GammaLib information
2 ==================== 2 ====================
3 -* Version: 1.3.0 (12 August 2016) 3 +* Version: 1.3.1 (12 August 2016)
4 * Author: Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu) 4 * Author: Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu)
5 5
6 [![Build Status](https://cta-jenkins.irap.omp.eu/buildStatus/icon?job=gammalib-integrate-os)](https://cta-jenkins.irap.omp.eu/job/gammalib-integrate-os/) 6 [![Build Status](https://cta-jenkins.irap.omp.eu/buildStatus/icon?job=gammalib-integrate-os)](https://cta-jenkins.irap.omp.eu/job/gammalib-integrate-os/)
@@ -184,7 +184,7 @@ If everything works successfully you should see @@ -184,7 +184,7 @@ If everything works successfully you should see
184 or 184 or
185 185
186 ============================================================================ 186 ============================================================================
187 - Testsuite summary for gammalib 1.3.0 187 + Testsuite summary for gammalib 1.3.1
188 ============================================================================ 188 ============================================================================
189 # TOTAL: 21 189 # TOTAL: 21
190 # PASS: 21 190 # PASS: 21
configure.ac
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 ############################################################################# 29 #############################################################################
30 # Initialisation # 30 # Initialisation #
31 ############################################################################# 31 #############################################################################
32 -AC_INIT([gammalib], [1.3.0], [jurgen.knodlseder@irap.omp.eu], [gammalib]) 32 +AC_INIT([gammalib], [1.3.1], [jurgen.knodlseder@irap.omp.eu], [gammalib])
33 AC_CONFIG_SRCDIR([src/support/GTools.cpp]) 33 AC_CONFIG_SRCDIR([src/support/GTools.cpp])
34 AC_CONFIG_MACRO_DIR([m4]) 34 AC_CONFIG_MACRO_DIR([m4])
35 AC_CONFIG_AUX_DIR([.]) 35 AC_CONFIG_AUX_DIR([.])
doc/Doxyfile
@@ -32,7 +32,7 @@ PROJECT_NAME = GammaLib @@ -32,7 +32,7 @@ PROJECT_NAME = GammaLib
32 # This could be handy for archiving the generated documentation or 32 # This could be handy for archiving the generated documentation or
33 # if some version control system is used. 33 # if some version control system is used.
34 34
35 -PROJECT_NUMBER = 1.3.0 35 +PROJECT_NUMBER = 1.3.1
36 36
37 # Using the PROJECT_BRIEF tag one can provide an optional one line description 37 # Using the PROJECT_BRIEF tag one can provide an optional one line description
38 # for a project that appears at the top of each page and should give viewer 38 # for a project that appears at the top of each page and should give viewer
doc/source/conf.py
@@ -58,7 +58,7 @@ copyright = u&#39;2006-2016, GammaLib developers&#39; @@ -58,7 +58,7 @@ copyright = u&#39;2006-2016, GammaLib developers&#39;
58 version = '1.3' 58 version = '1.3'
59 59
60 # The full version, including alpha/beta/rc tags. 60 # The full version, including alpha/beta/rc tags.
61 -release = '1.3.0' 61 +release = '1.3.1'
62 62
63 # The language for content autogenerated by Sphinx. Refer to documentation 63 # The language for content autogenerated by Sphinx. Refer to documentation
64 # for a list of supported languages. 64 # for a list of supported languages.
gammalib.pc.in
@@ -6,7 +6,7 @@ includedir=${prefix}/include @@ -6,7 +6,7 @@ includedir=${prefix}/include
6 Name: GammaLib 6 Name: GammaLib
7 Description: Versatile toolbox for analysis of astronomical gamma-ray data 7 Description: Versatile toolbox for analysis of astronomical gamma-ray data
8 URL: http://cta.irap.omp.eu/gammalib/ 8 URL: http://cta.irap.omp.eu/gammalib/
9 -Version: 1.3.0 9 +Version: 1.3.1
10 Requires: 10 Requires:
11 Requires.private: @CFITSIO@ 11 Requires.private: @CFITSIO@
12 Conflicts: 12 Conflicts:
inst/cta/src/GCTAPsfKing.cpp
@@ -518,7 +518,21 @@ double GCTAPsfKing::delta_max(const double&amp; logE, @@ -518,7 +518,21 @@ double GCTAPsfKing::delta_max(const double&amp; logE,
518 if (m_par_norm > 0.0) { 518 if (m_par_norm > 0.0) {
519 radius = r_max(logE, theta); 519 radius = r_max(logE, theta);
520 } 520 }
521 - 521 +if (gammalib::is_notanumber(radius) || gammalib::is_infinite(radius)) {
  522 + const double F = 0.999;
  523 + double u_max = (std::pow((1.0 - F), (1.0/(1.0-m_par_gamma))) - 1.0) *
  524 + m_par_gamma;
  525 + radius = m_par_sigma * std::sqrt(2.0 * u_max);
  526 +std::cout << "GCTAPsfKing::delta_max";
  527 +std::cout << " base=" << (1.0 - F);
  528 +std::cout << " exponent=" << (1.0/(1.0-m_par_gamma));
  529 +std::cout << " u_max=" << u_max;
  530 +std::cout << " radius=" << radius;
  531 +std::cout << " m_par_norm=" << m_par_norm;
  532 +std::cout << " m_par_gamma=" << m_par_gamma;
  533 +std::cout << " m_par_sigma=" << m_par_sigma << std::endl;
  534 +}
  535 +
522 // Return maximum PSF radius 536 // Return maximum PSF radius
523 return radius; 537 return radius;
524 } 538 }
@@ -760,6 +774,12 @@ void GCTAPsfKing::update(const double&amp; logE, const double&amp; theta) const @@ -760,6 +774,12 @@ void GCTAPsfKing::update(const double&amp; logE, const double&amp; theta) const
760 774
761 } // endif: restricted PSF radius 775 } // endif: restricted PSF radius
762 776
  777 + // If maximum PSF radius is zero then also set the normalization
  778 + // to zero
  779 + else if (m_par_rmax == 0.0) {
  780 + m_par_norm = 0.0;
  781 + }
  782 +
763 } // endif: King profile parameters were valid 783 } // endif: King profile parameters were valid
764 784
765 } // endif: PSF parameters have changed 785 } // endif: PSF parameters have changed
@@ -780,7 +800,8 @@ void GCTAPsfKing::update(const double&amp; logE, const double&amp; theta) const @@ -780,7 +800,8 @@ void GCTAPsfKing::update(const double&amp; logE, const double&amp; theta) const
780 * is set by this method to where the containment fraction become 99.9%. 800 * is set by this method to where the containment fraction become 99.9%.
781 * 801 *
782 * This method requires the m_par_gamma and m_par_sigma to be set to valid 802 * This method requires the m_par_gamma and m_par_sigma to be set to valid
783 - * values. 803 + * values. In case that the parameters lead to an infinite result the method
  804 + * will return a maximum size of zero.
784 ***************************************************************************/ 805 ***************************************************************************/
785 double GCTAPsfKing::r_max(const double& logE, 806 double GCTAPsfKing::r_max(const double& logE,
786 const double& theta) const 807 const double& theta) const
@@ -791,7 +812,8 @@ double GCTAPsfKing::r_max(const double&amp; logE, @@ -791,7 +812,8 @@ double GCTAPsfKing::r_max(const double&amp; logE,
791 // Compute maximum PSF radius for containment fraction 812 // Compute maximum PSF radius for containment fraction
792 double u_max = (std::pow((1.0 - F), (1.0/(1.0-m_par_gamma))) - 1.0) * 813 double u_max = (std::pow((1.0 - F), (1.0/(1.0-m_par_gamma))) - 1.0) *
793 m_par_gamma; 814 m_par_gamma;
794 - double radius = m_par_sigma * std::sqrt(2.0 * u_max); 815 + double radius = (gammalib::is_infinite(u_max)) ? 0.0 :
  816 + m_par_sigma * std::sqrt(2.0 * u_max);
795 817
796 // Return maximum PSF radius 818 // Return maximum PSF radius
797 return radius; 819 return radius;
inst/cta/src/GCTAResponseIrf.cpp
@@ -2075,10 +2075,11 @@ double GCTAResponseIrf::npsf(const GSkyDir&amp; srcDir, @@ -2075,10 +2075,11 @@ double GCTAResponseIrf::npsf(const GSkyDir&amp; srcDir,
2075 std::cout << "*** ERROR: GCTAResponseIrf::npsf:"; 2075 std::cout << "*** ERROR: GCTAResponseIrf::npsf:";
2076 std::cout << " NaN/Inf encountered"; 2076 std::cout << " NaN/Inf encountered";
2077 std::cout << " (value=" << value; 2077 std::cout << " (value=" << value;
2078 - std::cout << ", roi_radius=" << roi_radius;  
2079 - std::cout << ", roi_psf_distance=" << roi_psf_distance;  
2080 - //std::cout << ", sigma=" << sigma;  
2081 - std::cout << ", r=[" << rmin << "," << rmax << "])"; 2078 + std::cout << ", roi_radius=" << roi_radius * gammalib::rad2deg;
  2079 + std::cout << ", roi_psf_distance=";
  2080 + std::cout << roi_psf_distance * gammalib::rad2deg;
  2081 + std::cout << ", r=[" << rmin * gammalib::rad2deg;
  2082 + std::cout << "," << rmax * gammalib::rad2deg << "])";
2082 std::cout << std::endl; 2083 std::cout << std::endl;
2083 } 2084 }
2084 #endif 2085 #endif
sonar-project.properties
1 # Required metadata 1 # Required metadata
2 sonar.projectKey=gammalib 2 sonar.projectKey=gammalib
3 sonar.projectName=GammaLib 3 sonar.projectName=GammaLib
4 -sonar.projectVersion=1.3.0 4 +sonar.projectVersion=1.3.1
5 5
6 # Description 6 # Description
7 sonar.projectDescription="Versatile toolbox for scientific analysis of astronomical gamma-ray data" 7 sonar.projectDescription="Versatile toolbox for scientific analysis of astronomical gamma-ray data"