Commit f1c51a6964f795b760bf452bb6afbaaae873a14d
1 parent
32017030
Make GCTAPsfKing save against invalid values (#2133)
Showing
10 changed files
with
63 additions
and
196 deletions
ChangeLog
NEWS
| 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 | 6 | 1. Introduction |
| ... | ... | @@ -12,15 +12,7 @@ made since the last release of GammaLib. |
| 12 | 12 | 2. Public interface modifications |
| 13 | 13 | --------------------------------- |
| 14 | 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 | 17 | The following classes have been removed: |
| 26 | 18 | - n.a. |
| ... | ... | @@ -29,48 +21,13 @@ The following classes have been renamed: |
| 29 | 21 | - n.a. |
| 30 | 22 | |
| 31 | 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 | 26 | The following methods have been removed: |
| 68 | -- GFitsTable::size() | |
| 27 | +- n.a. | |
| 69 | 28 | |
| 70 | 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 | 32 | The arguments for the following methods have been changed: |
| 76 | 33 | - n.a. |
| ... | ... | @@ -81,19 +38,7 @@ The return value of the following methods has been changed: |
| 81 | 38 | |
| 82 | 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 | 44 | 4. Application module |
| ... | ... | @@ -108,57 +53,17 @@ None |
| 108 | 53 | |
| 109 | 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 | 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 | 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 | 69 | 9. Numerics module |
| ... | ... | @@ -168,39 +73,22 @@ None |
| 168 | 73 | |
| 169 | 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 | 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 | 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 | 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 | 94 | 14. XML module |
| ... | ... | @@ -235,62 +123,10 @@ None |
| 235 | 123 | |
| 236 | 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 | 132 | 21. COMPTEL interface | ... | ... |
README.md
| 1 | 1 | GammaLib information |
| 2 | 2 | ==================== |
| 3 | -* Version: 1.3.0 (12 August 2016) | |
| 3 | +* Version: 1.3.1 (12 August 2016) | |
| 4 | 4 | * Author: Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu) |
| 5 | 5 | |
| 6 | 6 | [](https://cta-jenkins.irap.omp.eu/job/gammalib-integrate-os/) |
| ... | ... | @@ -184,7 +184,7 @@ If everything works successfully you should see |
| 184 | 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 | 189 | # TOTAL: 21 |
| 190 | 190 | # PASS: 21 | ... | ... |
configure.ac
| ... | ... | @@ -29,7 +29,7 @@ |
| 29 | 29 | ############################################################################# |
| 30 | 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 | 33 | AC_CONFIG_SRCDIR([src/support/GTools.cpp]) |
| 34 | 34 | AC_CONFIG_MACRO_DIR([m4]) |
| 35 | 35 | AC_CONFIG_AUX_DIR([.]) | ... | ... |
doc/Doxyfile
| ... | ... | @@ -32,7 +32,7 @@ PROJECT_NAME = GammaLib |
| 32 | 32 | # This could be handy for archiving the generated documentation or |
| 33 | 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 | 37 | # Using the PROJECT_BRIEF tag one can provide an optional one line description |
| 38 | 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'2006-2016, GammaLib developers' |
| 58 | 58 | version = '1.3' |
| 59 | 59 | |
| 60 | 60 | # The full version, including alpha/beta/rc tags. |
| 61 | -release = '1.3.0' | |
| 61 | +release = '1.3.1' | |
| 62 | 62 | |
| 63 | 63 | # The language for content autogenerated by Sphinx. Refer to documentation |
| 64 | 64 | # for a list of supported languages. | ... | ... |
gammalib.pc.in
| ... | ... | @@ -6,7 +6,7 @@ includedir=${prefix}/include |
| 6 | 6 | Name: GammaLib |
| 7 | 7 | Description: Versatile toolbox for analysis of astronomical gamma-ray data |
| 8 | 8 | URL: http://cta.irap.omp.eu/gammalib/ |
| 9 | -Version: 1.3.0 | |
| 9 | +Version: 1.3.1 | |
| 10 | 10 | Requires: |
| 11 | 11 | Requires.private: @CFITSIO@ |
| 12 | 12 | Conflicts: | ... | ... |
inst/cta/src/GCTAPsfKing.cpp
| ... | ... | @@ -518,7 +518,21 @@ double GCTAPsfKing::delta_max(const double& logE, |
| 518 | 518 | if (m_par_norm > 0.0) { |
| 519 | 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 | 536 | // Return maximum PSF radius |
| 523 | 537 | return radius; |
| 524 | 538 | } |
| ... | ... | @@ -760,6 +774,12 @@ void GCTAPsfKing::update(const double& logE, const double& theta) const |
| 760 | 774 | |
| 761 | 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 | 783 | } // endif: King profile parameters were valid |
| 764 | 784 | |
| 765 | 785 | } // endif: PSF parameters have changed |
| ... | ... | @@ -780,7 +800,8 @@ void GCTAPsfKing::update(const double& logE, const double& theta) const |
| 780 | 800 | * is set by this method to where the containment fraction become 99.9%. |
| 781 | 801 | * |
| 782 | 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 | 806 | double GCTAPsfKing::r_max(const double& logE, |
| 786 | 807 | const double& theta) const |
| ... | ... | @@ -791,7 +812,8 @@ double GCTAPsfKing::r_max(const double& logE, |
| 791 | 812 | // Compute maximum PSF radius for containment fraction |
| 792 | 813 | double u_max = (std::pow((1.0 - F), (1.0/(1.0-m_par_gamma))) - 1.0) * |
| 793 | 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 | 818 | // Return maximum PSF radius |
| 797 | 819 | return radius; | ... | ... |
inst/cta/src/GCTAResponseIrf.cpp
| ... | ... | @@ -2075,10 +2075,11 @@ double GCTAResponseIrf::npsf(const GSkyDir& srcDir, |
| 2075 | 2075 | std::cout << "*** ERROR: GCTAResponseIrf::npsf:"; |
| 2076 | 2076 | std::cout << " NaN/Inf encountered"; |
| 2077 | 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 | 2083 | std::cout << std::endl; |
| 2083 | 2084 | } |
| 2084 | 2085 | #endif | ... | ... |
sonar-project.properties