Commit 65c59fbcf9e5c8bc44f34ba97d45e01be560a00c

Authored by Jürgen Knödlseder
2 parents 42502f5c c3f23172

Merge branch 'integration' into devel

include/GApplicationPars.hpp
1 1 /***************************************************************************
2 2 * GApplicationPars.hpp - Application parameters *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -160,7 +160,7 @@ const GApplicationPar& GApplicationPars::operator[](const int& index) const
160 160 inline
161 161 int GApplicationPars::size(void) const
162 162 {
163   - return (m_pars.size());
  163 + return (int)m_pars.size();
164 164 }
165 165  
166 166  
... ...
include/GArf.hpp
1 1 /***************************************************************************
2 2 * GArf.hpp - XSPEC Auxiliary Response File class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2013-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -134,7 +134,7 @@ const double& GArf::operator[](const int& index) const
134 134 inline
135 135 int GArf::size(void) const
136 136 {
137   - return (m_specresp.size());
  137 + return (int)m_specresp.size();
138 138 }
139 139  
140 140  
... ...
include/GEnergies.hpp
... ... @@ -149,7 +149,7 @@ const GEnergy& GEnergies::operator[](const int& index) const
149 149 inline
150 150 int GEnergies::size(void) const
151 151 {
152   - return (m_energies.size());
  152 + return (int)m_energies.size();
153 153 }
154 154  
155 155  
... ...
include/GFits.hpp
1 1 /***************************************************************************
2 2 * GFits.hpp - FITS file class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2008-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -231,7 +231,7 @@ const GFitsHDU* GFits::operator[](const std::string& extname) const
231 231 inline
232 232 int GFits::size(void) const
233 233 {
234   - return (m_hdu.size());
  234 + return (int)m_hdu.size();
235 235 }
236 236  
237 237  
... ...
include/GFitsHeader.hpp
1 1 /***************************************************************************
2 2 * GFitsHeader.hpp - FITS header cards container class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2008-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -175,7 +175,7 @@ const GFitsHeaderCard& GFitsHeader::operator[](const std::string& keyname) const
175 175 inline
176 176 int GFitsHeader::size(void) const
177 177 {
178   - return (m_cards.size());
  178 + return (int)m_cards.size();
179 179 }
180 180  
181 181  
... ...
include/GModel.hpp
1 1 /***************************************************************************
2 2 * GModel.hpp - Abstract virtual model base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2009-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2009-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -212,7 +212,7 @@ const GModelPar& GModel::operator[](const int& index) const
212 212 inline
213 213 int GModel::size(void) const
214 214 {
215   - return (m_pars.size());
  215 + return (int)m_pars.size();
216 216 }
217 217  
218 218  
... ...
include/GModelSpatial.hpp
... ... @@ -157,7 +157,7 @@ const GModelPar& GModelSpatial::operator[](const int& index) const
157 157 inline
158 158 int GModelSpatial::size(void) const
159 159 {
160   - return (m_pars.size());
  160 + return (int)m_pars.size();
161 161 }
162 162  
163 163 #endif /* GMODELSPATIAL_HPP */
... ...
include/GModelSpectral.hpp
1 1 /***************************************************************************
2 2 * GModelSpectral.hpp - Abstract spectral model base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2009-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2009-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -155,7 +155,7 @@ const GModelPar& GModelSpectral::operator[](const int& index) const
155 155 inline
156 156 int GModelSpectral::size(void) const
157 157 {
158   - return (m_pars.size());
  158 + return (int)m_pars.size();
159 159 }
160 160  
161 161 #endif /* GMODELSPECTRAL_HPP */
... ...
include/GModelSpectralNodes.hpp
1 1 /***************************************************************************
2 2 * GModelSpectralNodes.hpp - Spectral nodes model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -201,7 +201,7 @@ std::string GModelSpectralNodes::type(void) const
201 201 inline
202 202 int GModelSpectralNodes::nodes(void) const
203 203 {
204   - return (m_energies.size());
  204 + return (int)m_energies.size();
205 205 }
206 206  
207 207 #endif /* GMODELSPECTRALNODES_HPP */
... ...
include/GModelTemporal.hpp
... ... @@ -134,7 +134,7 @@ const GModelPar& GModelTemporal::operator[](const int& index) const
134 134 inline
135 135 int GModelTemporal::size(void) const
136 136 {
137   - return (m_pars.size());
  137 + return (int)m_pars.size();
138 138 }
139 139  
140 140 #endif /* GMODELTEMPORAL_HPP */
... ...
include/GModels.hpp
1 1 /***************************************************************************
2 2 * GModels.hpp - Model container class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2009-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2009-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -248,7 +248,7 @@ const GModel* GModels::operator[](const int& index) const
248 248 inline
249 249 int GModels::size(void) const
250 250 {
251   - return (m_models.size());
  251 + return (int)m_models.size();
252 252 }
253 253  
254 254  
... ...
include/GNodeArray.hpp
... ... @@ -184,7 +184,7 @@ const double& GNodeArray::operator[](const int& index) const
184 184 inline
185 185 int GNodeArray::size(void) const
186 186 {
187   - return (m_node.size());
  187 + return (int)m_node.size();
188 188 }
189 189  
190 190  
... ...
include/GObservations.hpp
... ... @@ -238,7 +238,7 @@ const GObservation* GObservations::operator[](const int& index) const
238 238 inline
239 239 int GObservations::size(void) const
240 240 {
241   - return (m_obs.size());
  241 + return (int)m_obs.size();
242 242 }
243 243  
244 244  
... ...
include/GOptimizerPars.hpp
1 1 /***************************************************************************
2 2 * GOptimizerPars.hpp - Optimizer parameter container class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2009-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2009-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -152,7 +152,7 @@ const GOptimizerPar* GOptimizerPars::operator[](const int& index) const
152 152 inline
153 153 int GOptimizerPars::size(void) const
154 154 {
155   - return (m_pars.size());
  155 + return (int)m_pars.size();
156 156 }
157 157  
158 158  
... ...
include/GPha.hpp
1 1 /***************************************************************************
2 2 * GPha.hpp - XSPEC Pulse Height Analyzer class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2013-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -154,7 +154,7 @@ const double& GPha::operator[](const int& index) const
154 154 inline
155 155 int GPha::size(void) const
156 156 {
157   - return (m_counts.size());
  157 + return (int)m_counts.size();
158 158 }
159 159  
160 160  
... ...
include/GPhotons.hpp
1 1 /***************************************************************************
2 2 * GPhotons.hpp - Photon container class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -99,7 +99,7 @@ std::string GPhotons::classname(void) const
99 99 inline
100 100 int GPhotons::size(void) const
101 101 {
102   - return m_photons.size();
  102 + return (int)m_photons.size();
103 103 }
104 104  
105 105  
... ...
include/GSkyRegions.hpp
1 1 /***************************************************************************
2 2 * GSkyRegions.hpp - Sky region container class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2014 by Pierrick Martin *
  4 + * copyright (C) 2013-2015 by Pierrick Martin *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -154,7 +154,7 @@ const GSkyRegion* GSkyRegions::operator[](const int& index) const
154 154 inline
155 155 int GSkyRegions::size(void) const
156 156 {
157   - return (m_regions.size());
  157 + return (int)m_regions.size();
158 158 }
159 159  
160 160  
... ...
include/GTestSuite.hpp
1 1 /***************************************************************************
2 2 * GTestSuite.hpp - Abstract test suite base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2014 by Jean-Baptiste Cayrou *
  4 + * copyright (C) 2012-2015 by Jean-Baptiste Cayrou *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -129,7 +129,7 @@ protected:
129 129 inline
130 130 int GTestSuite::size(void) const
131 131 {
132   - return m_tests.size();
  132 + return (int)m_tests.size();
133 133 }
134 134  
135 135  
... ...
include/GTestSuites.hpp
1 1 /***************************************************************************
2 2 * GTestSuites.hpp - Test suite container class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2014 by Jean-Baptiste Cayrou *
  4 + * copyright (C) 2012-2015 by Jean-Baptiste Cayrou *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -155,7 +155,7 @@ const GTestSuite* GTestSuites::operator[](const int& index) const
155 155 inline
156 156 int GTestSuites::size(void) const
157 157 {
158   - return m_testsuites.size();
  158 + return (int)m_testsuites.size();
159 159 }
160 160  
161 161  
... ...
include/GTimes.hpp
1 1 /***************************************************************************
2 2 * GTimes.hpp - Time container class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -99,7 +99,7 @@ std::string GTimes::classname(void) const
99 99 inline
100 100 int GTimes::size(void) const
101 101 {
102   - return m_times.size();
  102 + return (int)m_times.size();
103 103 }
104 104  
105 105  
... ...
include/GVOHub.hpp
... ... @@ -138,7 +138,7 @@ protected:
138 138 std::string m_hub_path; //!< Hub path
139 139 std::string m_version; //!< The version of the SAMP Standard Profile implemented by the hub
140 140 std::string m_hub_id; //!< Hub identifier used by the hub when it sends message itself rather than forwarding from others
141   - socklen_t m_socket; //!< Hub socket
  141 + int m_socket; //!< Hub socket
142 142 bool m_shutdown; //!< Shutdown request
143 143 std::vector<client> m_clients; //!< Clients
144 144 };
... ...
include/GXmlNode.hpp
1 1 /***************************************************************************
2 2 * GXmlNode.hpp - Abstract XML node base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -125,7 +125,7 @@ protected:
125 125 inline
126 126 int GXmlNode::size(void) const
127 127 {
128   - return m_nodes.size();
  128 + return (int)m_nodes.size();
129 129 }
130 130  
131 131  
... ...
inst/cta/include/GCTAEventList.hpp
... ... @@ -128,7 +128,7 @@ std::string GCTAEventList::classname(void) const
128 128 inline
129 129 int GCTAEventList::size(void) const
130 130 {
131   - return (m_events.size());
  131 + return (int)m_events.size();
132 132 }
133 133  
134 134  
... ... @@ -140,7 +140,7 @@ int GCTAEventList::size(void) const
140 140 inline
141 141 int GCTAEventList::number(void) const
142 142 {
143   - return (m_events.size());
  143 + return (int)m_events.size();
144 144 }
145 145  
146 146  
... ...
inst/cta/include/GCTAModelRadial.hpp
1 1 /***************************************************************************
2 2 * GCTAModelRadial.hpp - Radial model abstract base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -73,7 +73,7 @@ public:
73 73 virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
74 74  
75 75 // Methods
76   - int size(void) const { return m_pars.size(); }
  76 + int size(void) const { return (int)m_pars.size(); }
77 77  
78 78 protected:
79 79 // Protected methods
... ...
inst/cta/include/GCTAModelRadialPolynom.hpp
1 1 /***************************************************************************
2 2 * GCTAModelRadialPolynom.hpp - Radial Polynom CTA model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -139,7 +139,7 @@ std::string GCTAModelRadialPolynom::type(void) const
139 139 inline
140 140 int GCTAModelRadialPolynom::size(void) const
141 141 {
142   - return (m_coeffs.size());
  142 + return (int)m_coeffs.size();
143 143 }
144 144  
145 145 #endif /* GCTAMODELRADIALPOLYNOM_HPP */
... ...
inst/cta/include/GCTAOnOffObservations.hpp
1 1 /***************************************************************************
2 2 * GCTAOnOffObservations.hpp - CTA on-off observation container class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2014 by Pierrick Martin *
  4 + * copyright (C) 2013-2015 by Pierrick Martin *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -158,7 +158,7 @@ const GCTAOnOffObservation* GCTAOnOffObservations::operator[](const int&amp; index)
158 158 inline
159 159 int GCTAOnOffObservations::size(void) const
160 160 {
161   - return (m_obs.size());
  161 + return (int)m_obs.size();
162 162 }
163 163  
164 164  
... ...
inst/cta/src/GCTAResponse_helpers.cpp
... ... @@ -864,11 +864,15 @@ double cta_irf_elliptical_kern_omega::eval(const double&amp; omega)
864 864 double arg2 = m_semimajor_rad * sinus;
865 865 double r_ellipse = m_semiminor_rad * m_semimajor_rad /
866 866 std::sqrt(arg1*arg1 + arg2*arg2);
867   - std::cout << "*** WARNING: cta_irf_elliptical_kern_omega::eval";
  867 + std::cout << "*** WARNING: cta_irf_elliptical_kern_omega::eval:";
868 868 std::cout << " zero model for (rho,omega)=(";
869 869 std::cout << m_rho*gammalib::rad2deg << ",";
870 870 std::cout << omega*gammalib::rad2deg << ")";
871   - std::cout << " rho-r_ellipse=" << (m_rho-r_ellipse) << " radians";
  871 + std::cout << " semiminor=" << m_semiminor_rad;
  872 + std::cout << " semimajor=" << m_semimajor_rad;
  873 + std::cout << " posang=" << m_model->posangle() * gammalib::deg2rad;
  874 + std::cout << " rel_posang=" << diff_angle * gammalib::deg2rad;
  875 + std::cout << " rho/r_ellipse=" << (m_rho/r_ellipse);
872 876 std::cout << std::endl;
873 877 }
874 878 #endif
... ...
inst/lat/include/GLATEventCube.hpp
... ... @@ -278,7 +278,7 @@ int GLATEventCube::ebins(void) const
278 278 inline
279 279 int GLATEventCube::ndiffrsp(void) const
280 280 {
281   - return m_srcmap.size();
  281 + return (int)m_srcmap.size();
282 282 }
283 283  
284 284 #endif /* GLATEVENTCUBE_HPP */
... ...
inst/lat/include/GLATEventList.hpp
... ... @@ -115,7 +115,7 @@ std::string GLATEventList::classname(void) const
115 115 inline
116 116 int GLATEventList::size(void) const
117 117 {
118   - return m_events.size();
  118 + return (int)m_events.size();
119 119 }
120 120  
121 121  
... ... @@ -127,7 +127,7 @@ int GLATEventList::size(void) const
127 127 inline
128 128 int GLATEventList::number(void) const
129 129 {
130   - return m_events.size();
  130 + return (int)m_events.size();
131 131 }
132 132  
133 133  
... ...
inst/lat/include/GLATResponse.hpp
... ... @@ -164,7 +164,7 @@ bool GLATResponse::use_tdisp(void) const
164 164 inline
165 165 int GLATResponse::size(void) const
166 166 {
167   - return m_aeff.size();
  167 + return (int)m_aeff.size();
168 168 }
169 169  
170 170  
... ...
inst/mwl/include/GMWLSpectrum.hpp
1 1 /***************************************************************************
2 2 * GMWLSpectrum.hpp - Multi-wavelength spectrum class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -119,7 +119,7 @@ std::string GMWLSpectrum::classname(void) const
119 119 inline
120 120 int GMWLSpectrum::size(void) const
121 121 {
122   - return m_data.size();
  122 + return (int)m_data.size();
123 123 }
124 124  
125 125  
... ... @@ -144,7 +144,7 @@ int GMWLSpectrum::dim(void) const
144 144 inline
145 145 int GMWLSpectrum::naxis(const int& axis) const
146 146 {
147   - return m_data.size();
  147 + return (int)m_data.size();
148 148 }
149 149  
150 150  
... ...
pyext/GSkyMap.i
... ... @@ -138,8 +138,8 @@ public:
138 138 GSkyMap operator-(const GSkyMap& map) const;
139 139 GSkyMap operator*(const GSkyMap& map) const;
140 140 GSkyMap operator/(const GSkyMap& map) const;
141   - double& operator()(const int& index, const int& map = 0);
142   - double& operator()(const GSkyPixel& pixel, const int& map = 0);
  141 + double operator()(const int& index, const int& map = 0);
  142 + double operator()(const GSkyPixel& pixel, const int& map = 0);
143 143 double operator()(const GSkyDir& dir, const int& map = 0) const;
144 144  
145 145 // Methods
... ...
src/model/GModelSpatialEllipticalGauss.cpp
... ... @@ -36,6 +36,11 @@
36 36 #include "GModelSpatialRegistry.hpp"
37 37  
38 38 /* __ Constants __________________________________________________________ */
  39 +namespace {
  40 + const double c_theta_max = 3.0; //!< semiaxis multiplied for theta_max()
  41 + const double c_max_exponent = 0.5 * c_theta_max * c_theta_max;
  42 + const double c_fraction = 1.0 - std::exp(-c_max_exponent);
  43 +}
39 44  
40 45 /* __ Globals ____________________________________________________________ */
41 46 const GModelSpatialEllipticalGauss g_elliptical_gauss_seed;
... ... @@ -48,6 +53,7 @@ const GModelSpatialRegistry g_elliptical_gauss_registry(&amp;g_elliptical_gauss_seed
48 53 /* __ Macros _____________________________________________________________ */
49 54  
50 55 /* __ Coding definitions _________________________________________________ */
  56 +#define G_SMALL_ANGLE_APPROXIMATION //!< Use small angle approximation
51 57  
52 58 /* __ Debug definitions __________________________________________________ */
53 59  
... ... @@ -73,14 +79,14 @@ GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss(void) :
73 79  
74 80  
75 81 /***********************************************************************//**
76   - * @brief Elliptical Gauss constructor
  82 + * @brief Elliptical Gaussian constructor
77 83 *
78   - * @param[in] dir Sky position of gauss centre.
  84 + * @param[in] dir Centre of elliptical Gaussian.
79 85 * @param[in] semimajor Semi-major axis (degrees).
80 86 * @param[in] semiminor Semi-minor axis (degrees).
81 87 * @param[in] posangle Position angle of semi-major axis (degrees).
82 88 *
83   - * Construct elliptical gauss model from sky position of the ellipse centre
  89 + * Construct elliptical Gaussian model from the ellipse centre direction
84 90 * (@p dir), the @p semimajor and @p semiminor axes, and the position
85 91 * angle (@p posangle).
86 92 ***************************************************************************/
... ... @@ -109,7 +115,7 @@ GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss(const GSkyDir&amp; dir,
109 115 *
110 116 * @param[in] xml XML element.
111 117 *
112   - * Constructs elliptical gauss model by extracting information from an XML
  118 + * Constructs elliptical Gaussian model by extracting information from an XML
113 119 * element. See the read() method for more information about the expected
114 120 * structure of the XML element.
115 121 ***************************************************************************/
... ... @@ -130,7 +136,7 @@ GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss(const GXmlElement&amp; xm
130 136 /***********************************************************************//**
131 137 * @brief Copy constructor
132 138 *
133   - * @param[in] model Elliptical gauss model.
  139 + * @param[in] model Elliptical Gaussian model.
134 140 ***************************************************************************/
135 141 GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss(const GModelSpatialEllipticalGauss& model) :
136 142 GModelSpatialElliptical(model)
... ... @@ -169,7 +175,7 @@ GModelSpatialEllipticalGauss::~GModelSpatialEllipticalGauss(void)
169 175 * @brief Assignment operator
170 176 *
171 177 * @param[in] model Elliptical gauss model.
172   - * @return Elliptical gauss model.
  178 + * @return Elliptical Gaussian model.
173 179 ***************************************************************************/
174 180 GModelSpatialEllipticalGauss& GModelSpatialEllipticalGauss::operator=(const GModelSpatialEllipticalGauss& model)
175 181 {
... ... @@ -202,7 +208,7 @@ GModelSpatialEllipticalGauss&amp; GModelSpatialEllipticalGauss::operator=(const GMod
202 208 ==========================================================================*/
203 209  
204 210 /***********************************************************************//**
205   - * @brief Clear elliptical gauss model
  211 + * @brief Clear elliptical Gaussian model
206 212 ***************************************************************************/
207 213 void GModelSpatialEllipticalGauss::clear(void)
208 214 {
... ... @@ -222,13 +228,13 @@ void GModelSpatialEllipticalGauss::clear(void)
222 228  
223 229  
224 230 /***********************************************************************//**
225   - * @brief Clone elliptical gauss model
  231 + * @brief Clone elliptical Gaussian model
226 232 *
227   - * @return Pointer to deep copy of elliptical gauss model.
  233 + * @return Pointer to deep copy of elliptical Gaussian model.
228 234 ***************************************************************************/
229 235 GModelSpatialEllipticalGauss* GModelSpatialEllipticalGauss::clone(void) const
230 236 {
231   - // Clone elliptical gauss model
  237 + // Clone elliptical Gaussian model
232 238 return new GModelSpatialEllipticalGauss(*this);
233 239 }
234 240  
... ... @@ -242,44 +248,50 @@ GModelSpatialEllipticalGauss* GModelSpatialEllipticalGauss::clone(void) const
242 248 * @param[in] time Photon arrival time.
243 249 * @return Model value.
244 250 *
245   - * Evaluates the spatial component for an elliptical gauss source model. The
246   - * source model is an elliptical gaussian function
  251 + * Evaluates the spatial component for an elliptical Gaussian source model.
  252 + *
  253 + * The elliptical Gaussian function is defined by
247 254 * \f$S_{\rm p}(\theta, \phi | E, t)\f$, where
248   - * \f$\theta\f$ is the angular separation between elliptical gauss centre and
249   - * the actual location and \f$\phi\f$ the position angle with respect to the
250   - * model centre, counted counterclockwise from North.
  255 + * \f$\theta\f$ is the angular separation between elliptical Gaussian centre
  256 + * and the actual location and \f$\phi\f$ the position angle with respect to
  257 + * the model centre, counted counterclockwise from North.
251 258 *
252   - * The function \f$f(\theta, \phi)\f$ is given by
  259 + * The function \f$S_{\rm p}(\theta, \phi | E, t)\f$ is given by
253 260 *
254 261 * \f[
255   - * S_{\rm p}(\theta, \phi | E, t) = \left \{
256   - * \begin{array}{l l}
257   - * {\tt m\_norm}
258   - * & \mbox{if} \, \, \theta \le \theta_0 \\
259   - * \\
260   - * 0 & \mbox{else}
261   - * \end{array}
262   - * \right .
  262 + * S_{\rm p}(\theta, \phi | E, t) = {\tt m\_norm} \times
  263 + * \exp \left( -\frac{\theta^2}{2 r_{rm eff}} \right)
263 264 * \f]
264 265 *
265   - * where \f$\theta_0\f$ is the effective radius of the ellipse on the sphere
266   - * given by
267   - *
268   - * \f[\theta_0\ =
269   - * \frac{ab}{\sqrt{b^2 \cos^2(\phi-\phi_0) + a^2 \sin^2(\phi-\phi_0)}}\f]
  266 + * where the effective ellipse radius \f$r_{rm eff}\f$ towards a given
  267 + * position angle is given by
270 268 *
271   - * and
  269 + * \f[
  270 + * r_{rm eff} = \frac{ab}
  271 + * {\sqrt{\left( a \sin (\phi - \phi_0) \right)^2 +
  272 + * \sqrt{\left( b \cos (\phi - \phi_0) \right)^2}
  273 + * \f]
  274 + * and
272 275 * \f$a\f$ is the semi-major axis of the ellipse,
273 276 * \f$b\f$ is the semi-minor axis, and
274 277 * \f$\phi_0\f$ is the position angle of the ellipse, counted
275 278 * counterclockwise from North.
  279 + * \f${\tt m\_norm}\f$ is a normalization constant given by
276 280 *
277   - * The normalisation constant \f${\tt m\_norm}\f$ which is the inverse of the
278   - * solid angle subtended by an ellipse is given by
  281 + * \f[
  282 + * {\tt m\_norm} = \frac{1}{2 \pi \times a \times b}
  283 + * \f]
279 284 *
280   - * @todo Quote formula for ellipse solid angle
  285 + * @warning
  286 + * The above formula for an elliptical Gaussian are accurate for small
  287 + * angles, with semimajor and semiminor axes below a few degrees. This
  288 + * should be fine for most use cases, but you should be aware that the
  289 + * ellipse will get distorted for larger angles.
281 290 *
282   - * (see the update() method).
  291 + * @warning
  292 + * For numerical reasons the elliptical Gaussian will be truncated for
  293 + * \f$\theta\f$ angles that correspond to 3.0 times the effective ellipse
  294 + * radius.
283 295 ***************************************************************************/
284 296 double GModelSpatialEllipticalGauss::eval(const double& theta,
285 297 const double& posangle,
... ... @@ -295,6 +307,18 @@ double GModelSpatialEllipticalGauss::eval(const double&amp; theta,
295 307 // Update precomputation cache
296 308 update();
297 309  
  310 + // Perform computations to compute exponent
  311 + #if defined(G_SMALL_ANGLE_APPROXIMATION)
  312 + double rel_posangle = posangle - this->posangle() * gammalib::deg2rad;
  313 + double cosinus = std::cos(rel_posangle);
  314 + double sinus = std::sin(rel_posangle);
  315 + double arg1 = m_minor_rad * cosinus;
  316 + double arg2 = m_major_rad * sinus;
  317 + double r_ellipse = m_minor_rad * m_major_rad /
  318 + std::sqrt(arg1*arg1 + arg2*arg2); //!< small angle
  319 + double r_relative = theta/r_ellipse;
  320 + double exponent = 0.5*r_relative*r_relative;
  321 + #else
298 322 // Perform computations
299 323 double sinphi = std::sin(posangle);
300 324 double cosphi = std::cos(posangle);
... ... @@ -305,10 +329,13 @@ double GModelSpatialEllipticalGauss::eval(const double&amp; theta,
305 329 double term3 = m_term3 * sinphi * cosphi;
306 330  
307 331 // Compute exponent
308   - double exponent = theta * theta * (term1 + term2 + term3);
  332 + double exponent = theta * theta * (term1 + term2 + term3);
  333 + #endif
309 334  
310   - // Set value
311   - value = m_norm * std::exp(-exponent);
  335 + // Set value if the exponent is within the truncation region
  336 + if (exponent <= c_max_exponent) {
  337 + value = m_norm * std::exp(-exponent);
  338 + }
312 339  
313 340 // Compile option: Check for NaN/Inf
314 341 #if defined(G_NAN_CHECK)
... ... @@ -341,7 +368,7 @@ double GModelSpatialEllipticalGauss::eval(const double&amp; theta,
341 368 * @return Model value.
342 369 *
343 370 * Evaluates the function value. No gradient computation is implemented as
344   - * Elliptical models will be convolved with the instrument response and thus
  371 + * elliptical models will be convolved with the instrument response and thus
345 372 * require the numerical computation of the derivatives.
346 373 *
347 374 * See the eval() method for more information.
... ... @@ -364,7 +391,12 @@ double GModelSpatialEllipticalGauss::eval_gradients(const double&amp; theta,
364 391 * @param[in,out] ran Random number generator.
365 392 * @return Sky direction.
366 393 *
367   - * Draws an arbitrary sky position from the 2D gauss distribution.
  394 + * Draws an arbitrary sky direction from the elliptical Gaussian model.
  395 + *
  396 + * @warning
  397 + * For numerical reasons the elliptical Gaussian will be truncated for
  398 + * \f$\theta\f$ angles that correspond to 3.0 times the effective ellipse
  399 + * radius.
368 400 ***************************************************************************/
369 401 GSkyDir GModelSpatialEllipticalGauss::mc(const GEnergy& energy,
370 402 const GTime& time,
... ... @@ -379,10 +411,18 @@ GSkyDir GModelSpatialEllipticalGauss::mc(const GEnergy&amp; energy,
379 411 photon.time(time);
380 412  
381 413 // Draw gaussian offset from each axis
382   - double theta1 = semimajor() * ran.normal();
383   - double theta2 = semiminor() * ran.normal();
384   -
385   - // Compute total offset from model centre
  414 + double ran_major;
  415 + double ran_minor;
  416 + do {
  417 + ran_major = ran.normal();
  418 + } while (ran_major > c_theta_max);
  419 + do {
  420 + ran_minor = ran.normal();
  421 + } while (ran_minor > c_theta_max);
  422 + double theta1 = semimajor() * ran_major;
  423 + double theta2 = semiminor() * ran_minor;
  424 +
  425 + // Compute total offset from model centre in small angle approximation
386 426 double theta = std::sqrt(theta1 * theta1 + theta2 * theta2);
387 427  
388 428 // Compute rotation angle, taking into account given position angle
... ... @@ -401,7 +441,7 @@ GSkyDir GModelSpatialEllipticalGauss::mc(const GEnergy&amp; energy,
401 441  
402 442  
403 443 /***********************************************************************//**
404   - * @brief Checks where model contains specified sky direction
  444 + * @brief Checks whether model contains specified sky direction
405 445 *
406 446 * @param[in] dir Sky direction.
407 447 * @param[in] margin Margin to be added to sky direction (degrees)
... ... @@ -428,16 +468,17 @@ bool GModelSpatialEllipticalGauss::contains(const GSkyDir&amp; dir,
428 468 *
429 469 * @return Returns maximum model radius.
430 470 *
431   - * Returns \f$5 \sigma\f$ as approximate edge of the Gaussian. This limit
432   - * is of course arbitrary, but allows to limit the integration region for
433   - * response computation.
  471 + * Returns the maximum of 3.0 semimajor() and 3.0 semiminor() as
  472 + * approximate edge of the Gaussian. This limit is of course arbitrary, but
  473 + * allows to limit the integration region for response computation. The value
  474 + * of 3.0 has been determined by experiment (#1561).
434 475 ***************************************************************************/
435 476 double GModelSpatialEllipticalGauss::theta_max(void) const
436 477 {
437 478 // Set maximum model radius
438 479 double theta_max = (semimajor() > semiminor())
439   - ? semimajor() * gammalib::deg2rad * 5.0
440   - : semiminor() * gammalib::deg2rad * 5.0;
  480 + ? semimajor() * gammalib::deg2rad * c_theta_max
  481 + : semiminor() * gammalib::deg2rad * c_theta_max;
441 482  
442 483 // Return value
443 484 return theta_max;
... ... @@ -684,7 +725,7 @@ void GModelSpatialEllipticalGauss::init_members(void)
684 725 /***********************************************************************//**
685 726 * @brief Copy class members
686 727 *
687   - * @param[in] model Elliptical gauss model.
  728 + * @param[in] model Elliptical Gaussian model.
688 729 ***************************************************************************/
689 730 void GModelSpatialEllipticalGauss::copy_members(const GModelSpatialEllipticalGauss& model)
690 731 {
... ... @@ -724,10 +765,15 @@ void GModelSpatialEllipticalGauss::free_members(void)
724 765 *
725 766 * Computes the normalization
726 767 * \f[
727   - * {\tt m\_norm} = \frac{1}{2 \pi (1 - \cos a) (1 - \cos b)}
  768 + * {\tt m\_norm} = \frac{1}{2 \pi \times a \times b}
728 769 * \f]
  770 + * where
  771 + * \f$a\f$ is the semi-major axis and
  772 + * \f$b\f$ is the semi-minor axis of the ellipse.
729 773 *
730   - * @todo check this formula
  774 + * @warning
  775 + * The normalization of the elliptical Gaussian is only valid in the small
  776 + * angle approximation.
731 777 ***************************************************************************/
732 778 void GModelSpatialEllipticalGauss::update() const
733 779 {
... ... @@ -748,15 +794,20 @@ void GModelSpatialEllipticalGauss::update() const
748 794 m_minor_rad = m_last_minor * gammalib::deg2rad;
749 795 m_major_rad = m_last_major * gammalib::deg2rad;
750 796  
751   - // Perform precomputations
  797 + // Perform precomputations. Note that I verified the normalization
  798 + // by numerical integration of the resulting Gaussian. Note also
  799 + // also that the normalization is only correct in the small angle
  800 + // approximation.
752 801 m_minor2 = m_minor_rad * m_minor_rad;
753 802 m_major2 = m_major_rad * m_major_rad;
754   - double denom = gammalib::twopi * m_minor_rad * m_major_rad;
  803 + double denom = gammalib::twopi * m_minor_rad * m_major_rad *
  804 + c_fraction;
755 805 m_norm = (denom > 0.0) ? 1.0 / denom : 0.0;
756 806  
757 807 } // endif: update required
758 808  
759 809 // Update chache if position angle changed
  810 + #if !defined(G_SMALL_ANGLE_APPROXIMATION)
760 811 if (m_last_posangle != posangle()) {
761 812  
762 813 // Signal parameter changes
... ... @@ -788,6 +839,7 @@ void GModelSpatialEllipticalGauss::update() const
788 839 m_term3 = 0.5 * (m_sin2pos / m_major2 - m_sin2pos / m_minor2);
789 840  
790 841 } // endif: something has changed
  842 + #endif
791 843  
792 844 // Return
793 845 return;
... ...
src/numerics/GMath.cpp
... ... @@ -420,12 +420,12 @@ double gammalib::erfinv(const double&amp; arg)
420 420 double result;
421 421  
422 422 // Return NAN if out of range
423   - if (std::abs(arg > 1.0)) {
  423 + if (std::abs(arg) > 1.0) {
424 424 result = std::atof("NAN");
425 425 }
426 426  
427 427 // Return maximum double if at range limit
428   - else if (std::abs(arg == 1.0)) {
  428 + else if (std::abs(arg) == 1.0) {
429 429 result = copysign(1.0, arg) * DBL_MAX;
430 430 }
431 431  
... ...
src/sky/GSkyMap.cpp
... ... @@ -1252,7 +1252,24 @@ GSkyPixel GSkyMap::dir2pix(const GSkyDir&amp; dir) const
1252 1252 * @exception GException::invalid_value
1253 1253 * No valid sky projection found.
1254 1254 *
1255   - * Returns the flux in the pixel with the specified @p index.
  1255 + * Returns the flux in the pixel with the specified @p index. The flux is
  1256 + * computed by integrating the intensity over the solid angle subtended by
  1257 + * the pixel.
  1258 + * Integration is done by dividing the pixel into wedges, computing the
  1259 + * intensitites at the cornes of each wedge, averaging these intensities,
  1260 + * and multiplying it with the solid angle of each wedge. This provides an
  1261 + * approximation of the true pixel flux which is accurate to better than
  1262 + * about 5%.
  1263 + *
  1264 + * For a HealPix pixelisation, the pixel is divided into 12 wedges. For a
  1265 + * WCS pixelisation, the pixel is divided into 8 wedges.
  1266 + *
  1267 + * @warning
  1268 + * This method only returns correct values once the skymap is completely
  1269 + * setup with values. Do not use this method during a setup operation as
  1270 + * the method uses neighboring pixels for interpolation. If the map is not
  1271 + * completely setup the neighboring pixels may still be empty, hence the
  1272 + * flux interpolation will be wrong.
1256 1273 ***************************************************************************/
1257 1274 double GSkyMap::flux(const int& index, const int& map) const
1258 1275 {
... ... @@ -1290,6 +1307,13 @@ double GSkyMap::flux(const int&amp; index, const int&amp; map) const
1290 1307 *
1291 1308 * For a HealPix pixelisation, the pixel is divided into 12 wedges. For a
1292 1309 * WCS pixelisation, the pixel is divided into 8 wedges.
  1310 + *
  1311 + * @warning
  1312 + * This method only returns correct values once the skymap is completely
  1313 + * setup with values. Do not use this method during a setup operation as
  1314 + * the method uses neighboring pixels for interpolation. If the map is not
  1315 + * completely setup the neighboring pixels may still be empty, hence the
  1316 + * flux interpolation will be wrong.
1293 1317 ***************************************************************************/
1294 1318 double GSkyMap::flux(const GSkyPixel& pixel, const int& map) const
1295 1319 {
... ...
src/vo/GVOHub.cpp
... ... @@ -361,7 +361,7 @@ void GVOHub::start_hub(void)
361 361 while (1) {
362 362  
363 363 // Accept connection from the client
364   - socklen_t socket = accept(m_socket, (struct sockaddr *)&cli_addr, &clilen);
  364 + int socket = accept(m_socket, (struct sockaddr *)&cli_addr, &clilen);
365 365 if (socket < 0) {
366 366 std::string msg = "Client connection to socket not accepted.";
367 367 throw GException::runtime_error(G_START_HUB, msg);
... ...