Commit 7b0018c41988b6c676992c56e8c1a0b183726ca0

Authored by Jürgen Knödlseder
1 parent 45c4368b

Add GModelSpatial::region() method (#1764)

The GModelSpatial::region() method returns a pointer to a sky region that fully encloses the spatial model component.
ChangeLog
1   -2016-10-17
  1 +2016-11-22
2 2  
3 3 * Version 1.2.0 released
4 4 =========================
5 5  
  6 + Add region() method to GModelSpatial (#1764)
6 7 Add composite spatial and spectral models (#1706)
7 8 Add GObservations::save_covmat() method (#1863)
8 9 Add GFft and GFftWavetable classes (#1731)
... ...
1 1 New Features and Important Changes in GammaLib 1.2.0
2 2  
3   -17 October 2016
  3 +22 November 2016
4 4  
5 5  
6 6 1. Introduction
... ... @@ -57,6 +57,7 @@ The following methods have been added:
57 57 - GFits::publish()
58 58 - gammalib::rstrip_chars()
59 59 - GObservations::save_covmat()
  60 +- GModelSpatial::region()
60 61  
61 62 The following methods have been removed:
62 63 - <all classes>::eval_gradients()
... ... @@ -162,6 +163,11 @@ The GModelSpectralComposite and GModelSpatialComposite classes have been
162 163 added that implement composite spectral and spatial models, which are sums
163 164 of models as a new model component (#1706).
164 165  
  166 +A region() method has been added to the GModelSpatial base class and all
  167 +derived classes that returns a pointer to a sky region that bounds the
  168 +spatial model. For the moment, only circular sky regions have been
  169 +implemented (#1764).
  170 +
165 171  
166 172 9. Numerics module
167 173 ------------------
... ...
include/GModelSpatial.hpp
... ... @@ -39,6 +39,9 @@
39 39 #include "GXmlElement.hpp"
40 40 #include "GRan.hpp"
41 41  
  42 +/* __ Forward declarations _______________________________________________ */
  43 +class GSkyRegion;
  44 +
42 45  
43 46 /***********************************************************************//**
44 47 * @class GModelSpatial
... ... @@ -97,6 +100,7 @@ public:
97 100 const double& margin = 0.0) const = 0;
98 101 virtual void read(const GXmlElement& xml) = 0;
99 102 virtual void write(GXmlElement& xml) const = 0;
  103 + virtual GSkyRegion* region(void) const = 0;
100 104 virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
101 105  
102 106 // Methods
... ... @@ -113,7 +117,7 @@ protected:
113 117 void free_members(void);
114 118  
115 119 // Proteced members
116   - std::vector<GModelPar*> m_pars; //!< Parameter pointers
  120 + std::vector<GModelPar*> m_pars; //!< Parameter pointers
117 121 };
118 122  
119 123  
... ...
include/GModelSpatialComposite.hpp
... ... @@ -32,6 +32,7 @@
32 32 #include "GModelSpatial.hpp"
33 33 #include "GModelPar.hpp"
34 34 #include "GSkyDir.hpp"
  35 +#include "GSkyRegionCircle.hpp"
35 36 #include "GXmlElement.hpp"
36 37  
37 38  
... ... @@ -71,6 +72,7 @@ public:
71 72 const double& radius) const;
72 73 virtual bool contains(const GSkyDir& dir,
73 74 const double& margin = 0.0) const;
  75 + virtual GSkyRegion* region(void) const;
74 76 virtual void read(const GXmlElement& xml);
75 77 virtual void write(GXmlElement& xml) const;
76 78 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -88,15 +90,17 @@ public:
88 90  
89 91 protected:
90 92 // Protected methods
91   - void init_members(void);
92   - void copy_members(const GModelSpatialComposite& model);
93   - void free_members(void);
  93 + void init_members(void);
  94 + void copy_members(const GModelSpatialComposite& model);
  95 + void free_members(void);
  96 + void set_region(void) const;
94 97  
95 98 // Protected members
96 99 std::string m_type; //!< Model type
97 100 std::vector<GModelSpatial*> m_components; //!< Components
98 101 std::vector<std::string> m_names; //!< Component names
99 102 std::vector<double> m_scales; //!< Component scales
  103 + mutable GSkyRegionCircle m_region; //!< Bounding circle
100 104 };
101 105  
102 106  
... ... @@ -169,4 +173,19 @@ int GModelSpatialComposite::components(void) const
169 173 return m_components.size();
170 174 }
171 175  
  176 +
  177 +/***********************************************************************//**
  178 + * @brief Return boundary sky region
  179 + *
  180 + * @return Boundary sky region.
  181 + *
  182 + * Returns a sky region that fully encloses the point source.
  183 + ***************************************************************************/
  184 +inline
  185 +GSkyRegion* GModelSpatialComposite::region(void) const
  186 +{
  187 + set_region();
  188 + return (&m_region);
  189 +}
  190 +
172 191 #endif /* GMODELSPATIALCOMPOSITE_HPP */
... ...
include/GModelSpatialDiffuse.hpp
... ... @@ -37,6 +37,9 @@
37 37 #include "GXmlElement.hpp"
38 38 #include "GRan.hpp"
39 39  
  40 +/* __ Forward declarations _______________________________________________ */
  41 +class GSkyRegion;
  42 +
40 43  
41 44 /***********************************************************************//**
42 45 * @class GModelSpatialDiffuse
... ... @@ -70,6 +73,7 @@ public:
70 73 const double& radius) const = 0;
71 74 virtual bool contains(const GSkyDir& dir,
72 75 const double& margin = 0.0) const = 0;
  76 + virtual GSkyRegion* region(void) const = 0;
73 77 virtual void read(const GXmlElement& xml) = 0;
74 78 virtual void write(GXmlElement& xml) const = 0;
75 79 virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
... ...
include/GModelSpatialDiffuseConst.hpp
... ... @@ -32,6 +32,7 @@
32 32 #include "GModelSpatialDiffuse.hpp"
33 33 #include "GModelPar.hpp"
34 34 #include "GSkyDir.hpp"
  35 +#include "GSkyRegionCircle.hpp"
35 36 #include "GXmlElement.hpp"
36 37  
37 38  
... ... @@ -72,6 +73,7 @@ public:
72 73 const double& radius) const;
73 74 virtual bool contains(const GSkyDir& dir,
74 75 const double& margin = 0.0) const;
  76 + virtual GSkyRegion* region(void) const;
75 77 virtual void read(const GXmlElement& xml);
76 78 virtual void write(GXmlElement& xml) const;
77 79 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -85,12 +87,14 @@ protected:
85 87 void init_members(void);
86 88 void copy_members(const GModelSpatialDiffuseConst& model);
87 89 void free_members(void);
  90 + void set_region(void) const;
88 91  
89 92 // Protected members
90   - std::string m_type; //!< Model type
91   - GModelPar m_value; //!< Value
92   - mutable GSkyDir m_mc_centre; //!< Simulation cone centre
93   - mutable double m_mc_cos_radius; //!< Cosine of simulation cone radius
  93 + std::string m_type; //!< Model type
  94 + GModelPar m_value; //!< Value
  95 + mutable GSkyRegionCircle m_region; //!< Bounding circle
  96 + mutable GSkyDir m_mc_centre; //!< Simulation cone centre
  97 + mutable double m_mc_cos_radius; //!< Cosine of sim. cone radius
94 98 };
95 99  
96 100  
... ... @@ -167,4 +171,19 @@ bool GModelSpatialDiffuseConst::contains(const GSkyDir&amp; dir,
167 171 return (true);
168 172 }
169 173  
  174 +
  175 +/***********************************************************************//**
  176 + * @brief Return boundary sky region
  177 + *
  178 + * @return Boundary sky region.
  179 + *
  180 + * Returns a sky region that fully encloses the point source.
  181 + ***************************************************************************/
  182 +inline
  183 +GSkyRegion* GModelSpatialDiffuseConst::region(void) const
  184 +{
  185 + set_region();
  186 + return (&m_region);
  187 +}
  188 +
170 189 #endif /* GMODELSPATIALDIFFUSECONST_HPP */
... ...
include/GModelSpatialDiffuseCube.hpp
... ... @@ -35,6 +35,7 @@
35 35 #include "GModelPar.hpp"
36 36 #include "GSkyDir.hpp"
37 37 #include "GSkyMap.hpp"
  38 +#include "GSkyRegionCircle.hpp"
38 39 #include "GNodeArray.hpp"
39 40 #include "GEbounds.hpp"
40 41 #include "GFilename.hpp"
... ... @@ -87,6 +88,7 @@ public:
87 88 const double& radius) const;
88 89 virtual bool contains(const GSkyDir& dir,
89 90 const double& margin = 0.0) const;
  91 + virtual GSkyRegion* region(void) const;
90 92 virtual void read(const GXmlElement& xml);
91 93 virtual void write(GXmlElement& xml) const;
92 94 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -120,15 +122,17 @@ protected:
120 122 void set_energy_boundaries(void);
121 123 void update_mc_cache(void);
122 124 double cube_intensity(const GPhoton& photon) const;
  125 + void set_region(void) const;
123 126  
124 127 // Protected members
125   - std::string m_type; //!< Model type
126   - GModelPar m_value; //!< Value
127   - GFilename m_filename; //!< Name of map cube
128   - bool m_loaded; //!< Signals if map cube has been loaded
129   - GSkyMap m_cube; //!< Map cube
130   - GNodeArray m_logE; //!< Log10(energy) values of the maps
131   - GEbounds m_ebounds; //!< Energy bounds of the maps
  128 + std::string m_type; //!< Model type
  129 + GModelPar m_value; //!< Value
  130 + GFilename m_filename; //!< Name of map cube
  131 + bool m_loaded; //!< Signals if map cube has been loaded
  132 + GSkyMap m_cube; //!< Map cube
  133 + GNodeArray m_logE; //!< Log10(energy) values of the maps
  134 + GEbounds m_ebounds; //!< Energy bounds of the maps
  135 + mutable GSkyRegionCircle m_region; //!< Bounding circle
132 136  
133 137 // Monte Carlo cache
134 138 mutable GSkyDir m_mc_centre; //!< Centre of MC cone
... ... @@ -296,4 +300,19 @@ double GModelSpatialDiffuseCube::mc_norm(const GSkyDir&amp; dir,
296 300 return (value());
297 301 }
298 302  
  303 +
  304 +/***********************************************************************//**
  305 + * @brief Return boundary sky region
  306 + *
  307 + * @return Boundary sky region.
  308 + *
  309 + * Returns a sky region that fully encloses the point source.
  310 + ***************************************************************************/
  311 +inline
  312 +GSkyRegion* GModelSpatialDiffuseCube::region(void) const
  313 +{
  314 + set_region();
  315 + return (&m_region);
  316 +}
  317 +
299 318 #endif /* GMODELSPATIALDIFFUSECUBE_HPP */
... ...
include/GModelSpatialDiffuseMap.hpp
... ... @@ -34,6 +34,7 @@
34 34 #include "GModelPar.hpp"
35 35 #include "GSkyDir.hpp"
36 36 #include "GSkyMap.hpp"
  37 +#include "GSkyRegionCircle.hpp"
37 38 #include "GXmlElement.hpp"
38 39 #include "GFilename.hpp"
39 40  
... ... @@ -79,6 +80,7 @@ public:
79 80 const double& radius) const;
80 81 virtual bool contains(const GSkyDir& dir,
81 82 const double& margin = 0.0) const;
  83 + virtual GSkyRegion* region(void) const;
82 84 virtual void read(const GXmlElement& xml);
83 85 virtual void write(GXmlElement& xml) const;
84 86 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -100,16 +102,18 @@ protected:
100 102 void copy_members(const GModelSpatialDiffuseMap& model);
101 103 void free_members(void);
102 104 void prepare_map(void);
  105 + void set_region(void) const;
103 106  
104 107 // Protected members
105   - std::string m_type; //!< Model type
106   - GModelPar m_value; //!< Value
107   - GSkyMap m_map; //!< Skymap
108   - GFilename m_filename; //!< Name of skymap
109   - GSkyDir m_centre; //!< Centre of bounding circle
110   - double m_radius; //!< Radius of bounding circle
111   - bool m_normalize; //!< Normalize map (default: true)
112   - bool m_has_normalize; //!< XML has normalize attribute
  108 + std::string m_type; //!< Model type
  109 + GModelPar m_value; //!< Value
  110 + GSkyMap m_map; //!< Skymap
  111 + GFilename m_filename; //!< Name of skymap
  112 + GSkyDir m_centre; //!< Centre of bounding circle
  113 + double m_radius; //!< Radius of bounding circle
  114 + bool m_normalize; //!< Normalize map (default: true)
  115 + bool m_has_normalize; //!< XML has normalize attribute
  116 + mutable GSkyRegionCircle m_region; //!< Bounding circle
113 117  
114 118 // MC simulation cache
115 119 mutable GSkyDir m_mc_centre; //!< Centre of MC cone
... ... @@ -232,4 +236,19 @@ bool GModelSpatialDiffuseMap::normalize(void) const
232 236 return (m_normalize);
233 237 }
234 238  
  239 +
  240 +/***********************************************************************//**
  241 + * @brief Return boundary sky region
  242 + *
  243 + * @return Boundary sky region.
  244 + *
  245 + * Returns a sky region that fully encloses the point source.
  246 + ***************************************************************************/
  247 +inline
  248 +GSkyRegion* GModelSpatialDiffuseMap::region(void) const
  249 +{
  250 + set_region();
  251 + return (&m_region);
  252 +}
  253 +
235 254 #endif /* GMODELSPATIALDIFFUSEMAP_HPP */
... ...
include/GModelSpatialElliptical.hpp
... ... @@ -77,6 +77,7 @@ public:
77 77 virtual bool contains(const GSkyDir& dir,
78 78 const double& margin = 0.0) const = 0;
79 79 virtual double theta_max(void) const = 0;
  80 + virtual GSkyRegion* region(void) const = 0;
80 81 virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
81 82  
82 83 // Implemented virtual base class methods
... ... @@ -107,7 +108,7 @@ protected:
107 108 void copy_members(const GModelSpatialElliptical& model);
108 109 void free_members(void);
109 110  
110   - // Proteced members
  111 + // Protected members
111 112 GModelPar m_ra; //!< Right Ascension (deg)
112 113 GModelPar m_dec; //!< Declination (deg)
113 114 GModelPar m_posangle; //!< Position angle from North, counterclockwise (deg)
... ...
include/GModelSpatialEllipticalDisk.hpp
... ... @@ -32,6 +32,7 @@
32 32 #include "GModelSpatialElliptical.hpp"
33 33 #include "GModelPar.hpp"
34 34 #include "GSkyDir.hpp"
  35 +#include "GSkyRegionCircle.hpp"
35 36 #include "GXmlElement.hpp"
36 37  
37 38  
... ... @@ -76,6 +77,7 @@ public:
76 77 virtual bool contains(const GSkyDir& dir,
77 78 const double& margin = 0.0) const;
78 79 virtual double theta_max(void) const;
  80 + virtual GSkyRegion* region(void) const;
79 81 virtual void read(const GXmlElement& xml);
80 82 virtual void write(GXmlElement& xml) const;
81 83 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -87,6 +89,10 @@ protected:
87 89 void copy_members(const GModelSpatialEllipticalDisk& model);
88 90 void free_members(void);
89 91 void update(void) const;
  92 + void set_region(void) const;
  93 +
  94 + // Protected members
  95 + mutable GSkyRegionCircle m_region; //!< Bounding circle
90 96  
91 97 // Cached members used for pre-computations
92 98 mutable double m_last_semiminor; //!< Last semi-minor axis
... ... @@ -122,4 +128,19 @@ std::string GModelSpatialEllipticalDisk::type(void) const
122 128 return "EllipticalDisk";
123 129 }
124 130  
  131 +
  132 +/***********************************************************************//**
  133 + * @brief Return boundary sky region
  134 + *
  135 + * @return Boundary sky region.
  136 + *
  137 + * Returns a sky region that fully encloses the spatial model component.
  138 + ***************************************************************************/
  139 +inline
  140 +GSkyRegion* GModelSpatialEllipticalDisk::region(void) const
  141 +{
  142 + set_region();
  143 + return (&m_region);
  144 +}
  145 +
125 146 #endif /* GMODELSPATIALELLIPTICALDISK_HPP */
... ...
include/GModelSpatialEllipticalGauss.hpp
... ... @@ -32,6 +32,7 @@
32 32 #include "GModelSpatialElliptical.hpp"
33 33 #include "GModelPar.hpp"
34 34 #include "GSkyDir.hpp"
  35 +#include "GSkyRegionCircle.hpp"
35 36 #include "GXmlElement.hpp"
36 37  
37 38  
... ... @@ -77,6 +78,7 @@ public:
77 78 virtual bool contains(const GSkyDir& dir,
78 79 const double& margin = 0.0) const;
79 80 virtual double theta_max(void) const;
  81 + virtual GSkyRegion* region(void) const;
80 82 virtual void read(const GXmlElement& xml);
81 83 virtual void write(GXmlElement& xml) const;
82 84 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -88,9 +90,11 @@ protected:
88 90 void copy_members(const GModelSpatialEllipticalGauss& model);
89 91 void free_members(void);
90 92 void update(void) const;
  93 + void set_region(void) const;
91 94  
92 95 // Protected members
93   - std::string m_type; //!< Model type
  96 + std::string m_type; //!< Model type
  97 + mutable GSkyRegionCircle m_region; //!< Bounding circle
94 98  
95 99 // Cached members used for pre-computations
96 100 mutable double m_last_minor; //!< Last semi-minor axis
... ... @@ -136,4 +140,19 @@ std::string GModelSpatialEllipticalGauss::type(void) const
136 140 return (m_type);
137 141 }
138 142  
  143 +
  144 +/***********************************************************************//**
  145 + * @brief Return boundary sky region
  146 + *
  147 + * @return Boundary sky region.
  148 + *
  149 + * Returns a sky region that fully encloses the spatial model component.
  150 + ***************************************************************************/
  151 +inline
  152 +GSkyRegion* GModelSpatialEllipticalGauss::region(void) const
  153 +{
  154 + set_region();
  155 + return (&m_region);
  156 +}
  157 +
139 158 #endif /* GMODELSPATIALELLIPTICALGAUSS_HPP */
... ...
include/GModelSpatialPointSource.hpp
... ... @@ -32,6 +32,7 @@
32 32 #include "GModelSpatial.hpp"
33 33 #include "GModelPar.hpp"
34 34 #include "GSkyDir.hpp"
  35 +#include "GSkyRegionCircle.hpp"
35 36 #include "GXmlElement.hpp"
36 37  
37 38  
... ... @@ -74,6 +75,7 @@ public:
74 75 const double& radius) const;
75 76 virtual bool contains(const GSkyDir& dir,
76 77 const double& margin = 0.0) const;
  78 + virtual GSkyRegion* region(void) const;
77 79 virtual void read(const GXmlElement& xml);
78 80 virtual void write(GXmlElement& xml) const;
79 81 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -91,11 +93,13 @@ protected:
91 93 void init_members(void);
92 94 void copy_members(const GModelSpatialPointSource& model);
93 95 void free_members(void);
  96 + void set_region(void) const;
94 97  
95 98 // Protected members
96   - std::string m_type; //!< Model type
97   - GModelPar m_ra; //!< Right Ascension (deg)
98   - GModelPar m_dec; //!< Declination (deg)
  99 + std::string m_type; //!< Model type
  100 + GModelPar m_ra; //!< Right Ascension (deg)
  101 + GModelPar m_dec; //!< Declination (deg)
  102 + mutable GSkyRegionCircle m_region; //!< Bounding circle
99 103 };
100 104  
101 105  
... ... @@ -216,4 +220,19 @@ double GModelSpatialPointSource::mc_norm(const GSkyDir&amp; dir,
216 220 return (norm);
217 221 }
218 222  
  223 +
  224 +/***********************************************************************//**
  225 + * @brief Return boundary sky region
  226 + *
  227 + * @return Boundary sky region.
  228 + *
  229 + * Returns a sky region that fully encloses the point source.
  230 + ***************************************************************************/
  231 +inline
  232 +GSkyRegion* GModelSpatialPointSource::region(void) const
  233 +{
  234 + set_region();
  235 + return (&m_region);
  236 +}
  237 +
219 238 #endif /* GMODELSPATIALPOINTSOURCE_HPP */
... ...
include/GModelSpatialRadial.hpp
... ... @@ -76,6 +76,7 @@ public:
76 76 virtual bool contains(const GSkyDir& dir,
77 77 const double& margin = 0.0) const = 0;
78 78 virtual double theta_max(void) const = 0;
  79 + virtual GSkyRegion* region(void) const = 0;
79 80 virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
80 81  
81 82 // Implemented pure virtual base class methods
... ...
include/GModelSpatialRadialDisk.hpp
... ... @@ -32,6 +32,7 @@
32 32 #include "GModelSpatialRadial.hpp"
33 33 #include "GModelPar.hpp"
34 34 #include "GSkyDir.hpp"
  35 +#include "GSkyRegionCircle.hpp"
35 36 #include "GXmlElement.hpp"
36 37  
37 38  
... ... @@ -73,6 +74,7 @@ public:
73 74 virtual bool contains(const GSkyDir& dir,
74 75 const double& margin = 0.0) const;
75 76 virtual double theta_max(void) const;
  77 + virtual GSkyRegion* region(void) const;
76 78 virtual void read(const GXmlElement& xml);
77 79 virtual void write(GXmlElement& xml) const;
78 80 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -87,10 +89,12 @@ protected:
87 89 void copy_members(const GModelSpatialRadialDisk& model);
88 90 void free_members(void);
89 91 void update(void) const;
  92 + void set_region(void) const;
90 93  
91 94 // Protected members
92   - std::string m_type; //!< Model type
93   - GModelPar m_radius; //!< Disk radius (degrees)
  95 + std::string m_type; //!< Model type
  96 + GModelPar m_radius; //!< Disk radius (degrees)
  97 + mutable GSkyRegionCircle m_region; //!< Bounding circle
94 98  
95 99 // Cached members used for pre-computations
96 100 mutable double m_last_radius; //!< Last disk radius
... ... @@ -153,4 +157,19 @@ void GModelSpatialRadialDisk::radius(const double&amp; radius)
153 157 return;
154 158 }
155 159  
  160 +
  161 +/***********************************************************************//**
  162 + * @brief Return boundary sky region
  163 + *
  164 + * @return Boundary sky region.
  165 + *
  166 + * Returns a sky region that fully encloses the spatial model component.
  167 + ***************************************************************************/
  168 +inline
  169 +GSkyRegion* GModelSpatialRadialDisk::region(void) const
  170 +{
  171 + set_region();
  172 + return (&m_region);
  173 +}
  174 +
156 175 #endif /* GMODELSPATIALRADIALDISK_HPP */
... ...
include/GModelSpatialRadialGauss.hpp
... ... @@ -32,6 +32,7 @@
32 32 #include "GModelSpatialRadial.hpp"
33 33 #include "GModelPar.hpp"
34 34 #include "GSkyDir.hpp"
  35 +#include "GSkyRegionCircle.hpp"
35 36 #include "GEnergy.hpp"
36 37 #include "GTime.hpp"
37 38 #include "GXmlElement.hpp"
... ... @@ -74,6 +75,7 @@ public:
74 75 virtual bool contains(const GSkyDir& dir,
75 76 const double& margin = 0.0) const;
76 77 virtual double theta_max(void) const;
  78 + virtual GSkyRegion* region(void) const;
77 79 virtual void read(const GXmlElement& xml);
78 80 virtual void write(GXmlElement& xml) const;
79 81 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -87,10 +89,12 @@ protected:
87 89 void init_members(void);
88 90 void copy_members(const GModelSpatialRadialGauss& model);
89 91 void free_members(void);
  92 + void set_region(void) const;
90 93  
91 94 // Protected members
92   - std::string m_type; //!< Model type
93   - GModelPar m_sigma; //!< Gaussian width (deg)
  95 + std::string m_type; //!< Model type
  96 + GModelPar m_sigma; //!< Gaussian width (deg)
  97 + mutable GSkyRegionCircle m_region; //!< Bounding circle
94 98 };
95 99  
96 100  
... ... @@ -148,4 +152,19 @@ void GModelSpatialRadialGauss::sigma(const double&amp; sigma)
148 152 return;
149 153 }
150 154  
  155 +
  156 +/***********************************************************************//**
  157 + * @brief Return boundary sky region
  158 + *
  159 + * @return Boundary sky region.
  160 + *
  161 + * Returns a sky region that fully encloses the spatial model component.
  162 + ***************************************************************************/
  163 +inline
  164 +GSkyRegion* GModelSpatialRadialGauss::region(void) const
  165 +{
  166 + set_region();
  167 + return (&m_region);
  168 +}
  169 +
151 170 #endif /* GMODELSPATIALRADIALGAUSS_HPP */
... ...
include/GModelSpatialRadialShell.hpp
... ... @@ -32,6 +32,7 @@
32 32 #include "GModelSpatialRadial.hpp"
33 33 #include "GModelPar.hpp"
34 34 #include "GSkyDir.hpp"
  35 +#include "GSkyRegionCircle.hpp"
35 36 #include "GXmlElement.hpp"
36 37  
37 38  
... ... @@ -85,6 +86,7 @@ public:
85 86 virtual bool contains(const GSkyDir& dir,
86 87 const double& margin = 0.0) const;
87 88 virtual double theta_max(void) const;
  89 + virtual GSkyRegion* region(void) const;
88 90 virtual void read(const GXmlElement& xml);
89 91 virtual void write(GXmlElement& xml) const;
90 92 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ... @@ -103,11 +105,13 @@ protected:
103 105 void update(void) const;
104 106 static double f1(double x);
105 107 static double f2(double x);
  108 + void set_region(void) const;
106 109  
107 110 // Protected members
108   - std::string m_type; //!< Model type
109   - GModelPar m_radius; //!< Inner shell radius (deg)
110   - GModelPar m_width; //!< Shell thickness (deg)
  111 + std::string m_type; //!< Model type
  112 + GModelPar m_radius; //!< Inner shell radius (deg)
  113 + GModelPar m_width; //!< Shell thickness (deg)
  114 + mutable GSkyRegionCircle m_region; //!< Bounding circle
111 115  
112 116 // Cached members used for pre-computations
113 117 mutable double m_last_radius; //!< Last shell radius (deg)
... ... @@ -203,4 +207,19 @@ void GModelSpatialRadialShell::width(const double&amp; width)
203 207 return;
204 208 }
205 209  
  210 +
  211 +/***********************************************************************//**
  212 + * @brief Return boundary sky region
  213 + *
  214 + * @return Boundary sky region.
  215 + *
  216 + * Returns a sky region that fully encloses the spatial model component.
  217 + ***************************************************************************/
  218 +inline
  219 +GSkyRegion* GModelSpatialRadialShell::region(void) const
  220 +{
  221 + set_region();
  222 + return (&m_region);
  223 +}
  224 +
206 225 #endif /* GMODELSPATIALRADIALSHELL_HPP */
... ...
pyext/GModelSpatial.i
... ... @@ -57,6 +57,7 @@ public:
57 57 const double& margin = 0.0) const = 0;
58 58 virtual void read(const GXmlElement& xml) = 0;
59 59 virtual void write(GXmlElement& xml) const = 0;
  60 + virtual GSkyRegion* region(void) const = 0;
60 61  
61 62 // Methods
62 63 GModelPar& at(const int& index);
... ...
pyext/GModelSpatialComposite.i
... ... @@ -57,6 +57,7 @@ public:
57 57 const double& radius) const;
58 58 virtual bool contains(const GSkyDir& dir,
59 59 const double& margin = 0.0) const;
  60 + virtual GSkyRegion* region(void) const;
60 61 virtual void read(const GXmlElement& xml);
61 62 virtual void write(GXmlElement& xml) const;
62 63  
... ...
pyext/GModelSpatialDiffuse.i
... ... @@ -54,6 +54,7 @@ public:
54 54 const double& radius) const = 0;
55 55 virtual bool contains(const GSkyDir& dir,
56 56 const double& margin = 0.0) const = 0;
  57 + virtual GSkyRegion* region(void) const = 0;
57 58 virtual void read(const GXmlElement& xml) = 0;
58 59 virtual void write(GXmlElement& xml) const = 0;
59 60 };
... ...
pyext/GModelSpatialDiffuseConst.i
... ... @@ -57,6 +57,7 @@ public:
57 57 const double& radius) const;
58 58 virtual bool contains(const GSkyDir& dir,
59 59 const double& margin = 0.0) const;
  60 + virtual GSkyRegion* region(void) const;
60 61 virtual void read(const GXmlElement& xml);
61 62 virtual void write(GXmlElement& xml) const;
62 63  
... ...
pyext/GModelSpatialDiffuseCube.i
... ... @@ -62,6 +62,7 @@ public:
62 62 const double& radius) const;
63 63 virtual bool contains(const GSkyDir& dir,
64 64 const double& margin = 0.0) const;
  65 + virtual GSkyRegion* region(void) const;
65 66 virtual void read(const GXmlElement& xml);
66 67 virtual void write(GXmlElement& xml) const;
67 68  
... ...
pyext/GModelSpatialDiffuseMap.i
... ... @@ -62,6 +62,7 @@ public:
62 62 const double& radius) const;
63 63 virtual bool contains(const GSkyDir& dir,
64 64 const double& margin = 0.0) const;
  65 + virtual GSkyRegion* region(void) const;
65 66 virtual void read(const GXmlElement& xml);
66 67 virtual void write(GXmlElement& xml) const;
67 68  
... ...
pyext/GModelSpatialElliptical.i
... ... @@ -58,6 +58,7 @@ public:
58 58 const GTime& time,
59 59 GRan& ran) const = 0;
60 60 virtual double theta_max(void) const = 0;
  61 + virtual GSkyRegion* region(void) const = 0;
61 62  
62 63 // Implemented virtual methods
63 64 virtual double eval(const GPhoton& photon,
... ...
pyext/GModelSpatialEllipticalDisk.i
... ... @@ -63,6 +63,7 @@ public:
63 63 virtual bool contains(const GSkyDir& dir,
64 64 const double& margin = 0.0) const;
65 65 virtual double theta_max(void) const;
  66 + virtual GSkyRegion* region(void) const;
66 67 virtual void read(const GXmlElement& xml);
67 68 virtual void write(GXmlElement& xml) const;
68 69 };
... ...
pyext/GModelSpatialEllipticalGauss.i
... ... @@ -63,6 +63,7 @@ public:
63 63 virtual bool contains(const GSkyDir& dir,
64 64 const double& margin = 0.0) const;
65 65 virtual double theta_max(void) const;
  66 + virtual GSkyRegion* region(void) const;
66 67 virtual void read(const GXmlElement& xml);
67 68 virtual void write(GXmlElement& xml) const;
68 69 };
... ...
pyext/GModelSpatialPointSource.i
... ... @@ -61,6 +61,7 @@ public:
61 61 const double& margin = 0.0) const;
62 62 virtual void read(const GXmlElement& xml);
63 63 virtual void write(GXmlElement& xml) const;
  64 + virtual GSkyRegion* region(void) const;
64 65  
65 66 // Other methods
66 67 double ra(void) const;
... ...
pyext/GModelSpatialRadial.i
... ... @@ -58,6 +58,7 @@ public:
58 58 virtual bool contains(const GSkyDir& dir,
59 59 const double& margin = 0.0) const = 0;
60 60 virtual double theta_max(void) const = 0;
  61 + virtual GSkyRegion* region(void) const = 0;
61 62  
62 63 // Implemented virtual base class methods
63 64 virtual double eval(const GPhoton& photon,
... ...
pyext/GModelSpatialRadialDisk.i
... ... @@ -62,6 +62,7 @@ public:
62 62 virtual bool contains(const GSkyDir& dir,
63 63 const double& margin = 0.0) const;
64 64 virtual double theta_max(void) const;
  65 + virtual GSkyRegion* region(void) const;
65 66 virtual void read(const GXmlElement& xml);
66 67 virtual void write(GXmlElement& xml) const;
67 68  
... ...
pyext/GModelSpatialRadialGauss.i
... ... @@ -59,6 +59,7 @@ public:
59 59 virtual bool contains(const GSkyDir& dir,
60 60 const double& margin = 0.0) const;
61 61 virtual double theta_max(void) const;
  62 + virtual GSkyRegion* region(void) const;
62 63 virtual void read(const GXmlElement& xml);
63 64 virtual void write(GXmlElement& xml) const;
64 65  
... ...
pyext/GModelSpatialRadialShell.i
... ... @@ -60,6 +60,7 @@ public:
60 60 virtual bool contains(const GSkyDir& dir,
61 61 const double& margin = 0.0) const;
62 62 virtual double theta_max(void) const;
  63 + virtual GSkyRegion* region(void) const;
63 64 virtual void read(const GXmlElement& xml);
64 65 virtual void write(GXmlElement& xml) const;
65 66  
... ...
src/model/GModelSpatialComposite.cpp
... ... @@ -688,10 +688,11 @@ void GModelSpatialComposite::init_members(void)
688 688 // Initialise model type
689 689 m_type = "Composite";
690 690  
691   - // Initialise models vector
  691 + // Initialise other members
692 692 m_components.clear();
693 693 m_names.clear();
694 694 m_scales.clear();
  695 + m_region.clear();
695 696  
696 697 // Return
697 698 return;
... ... @@ -709,6 +710,7 @@ void GModelSpatialComposite::copy_members(const GModelSpatialComposite&amp; model)
709 710 m_type = model.m_type;
710 711 m_names = model.m_names;
711 712 m_scales = model.m_scales;
  713 + m_region = model.m_region;
712 714  
713 715 // Initialise components
714 716 m_components.clear();
... ... @@ -755,3 +757,21 @@ void GModelSpatialComposite::free_members(void)
755 757 // Return
756 758 return;
757 759 }
  760 +
  761 +
  762 +/***********************************************************************//**
  763 + * @brief Set boundary sky region
  764 + *
  765 + * @todo Implement computation of sky boundary region
  766 + ***************************************************************************/
  767 +void GModelSpatialComposite::set_region(void) const
  768 +{
  769 + // Set sky region centre to (0,0)
  770 + m_region.centre(0.0, 0.0);
  771 +
  772 + // Set sky region radius to 180 degrees (all points included)
  773 + m_region.radius(180.0);
  774 +
  775 + // Return
  776 + return;
  777 +}
... ...
src/model/GModelSpatialDiffuseConst.cpp
... ... @@ -535,6 +535,9 @@ void GModelSpatialDiffuseConst::init_members(void)
535 535 m_pars.clear();
536 536 m_pars.push_back(&m_value);
537 537  
  538 + // Initialise other members
  539 + m_region.clear();
  540 +
538 541 // Return
539 542 return;
540 543 }
... ... @@ -550,6 +553,7 @@ void GModelSpatialDiffuseConst::copy_members(const GModelSpatialDiffuseConst&amp; mo
550 553 // Copy members
551 554 m_type = model.m_type;
552 555 m_value = model.m_value;
  556 + m_region = model.m_region;
553 557 m_mc_centre = model.m_mc_centre;
554 558 m_mc_cos_radius = model.m_mc_cos_radius;
555 559  
... ... @@ -570,3 +574,19 @@ void GModelSpatialDiffuseConst::free_members(void)
570 574 // Return
571 575 return;
572 576 }
  577 +
  578 +
  579 +/***********************************************************************//**
  580 + * @brief Set boundary sky region
  581 + ***************************************************************************/
  582 +void GModelSpatialDiffuseConst::set_region(void) const
  583 +{
  584 + // Set sky region centre to (0,0)
  585 + m_region.centre(0.0, 0.0);
  586 +
  587 + // Set sky region radius to 180 degrees (all points included)
  588 + m_region.radius(180.0);
  589 +
  590 + // Return
  591 + return;
  592 +}
... ...
src/model/GModelSpatialDiffuseCube.cpp
... ... @@ -1047,6 +1047,7 @@ void GModelSpatialDiffuseCube::init_members(void)
1047 1047 m_logE.clear();
1048 1048 m_ebounds.clear();
1049 1049 m_loaded = false;
  1050 + m_region.clear();
1050 1051  
1051 1052 // Initialise MC cache
1052 1053 m_mc_centre.clear();
... ... @@ -1075,6 +1076,7 @@ void GModelSpatialDiffuseCube::copy_members(const GModelSpatialDiffuseCube&amp; mode
1075 1076 m_logE = model.m_logE;
1076 1077 m_ebounds = model.m_ebounds;
1077 1078 m_loaded = model.m_loaded;
  1079 + m_region = model.m_region;
1078 1080  
1079 1081 // Copy MC cache
1080 1082 m_mc_centre = model.m_mc_centre;
... ... @@ -1295,3 +1297,21 @@ double GModelSpatialDiffuseCube::cube_intensity(const GPhoton&amp; photon) const
1295 1297 // Return intensity
1296 1298 return intensity;
1297 1299 }
  1300 +
  1301 +
  1302 +/***********************************************************************//**
  1303 + * @brief Set boundary sky region
  1304 + *
  1305 + * @todo Implement determination of the cube boundary circle
  1306 + ***************************************************************************/
  1307 +void GModelSpatialDiffuseCube::set_region(void) const
  1308 +{
  1309 + // Set sky region centre to (0,0)
  1310 + m_region.centre(0.0, 0.0);
  1311 +
  1312 + // Set sky region radius to 180 degrees (all points included)
  1313 + m_region.radius(180.0);
  1314 +
  1315 + // Return
  1316 + return;
  1317 +}
... ...
src/model/GModelSpatialDiffuseMap.cpp
... ... @@ -853,6 +853,7 @@ void GModelSpatialDiffuseMap::init_members(void)
853 853 m_has_normalize = false;
854 854 m_centre.clear();
855 855 m_radius = 0.0;
  856 + m_region.clear();
856 857  
857 858 // Initialise MC cache
858 859 m_mc_centre.clear();
... ... @@ -882,6 +883,7 @@ void GModelSpatialDiffuseMap::copy_members(const GModelSpatialDiffuseMap&amp; model)
882 883 m_has_normalize = model.m_has_normalize;
883 884 m_centre = model.m_centre;
884 885 m_radius = model.m_radius;
  886 + m_region = model.m_region;
885 887  
886 888 // Copy MC cache
887 889 m_mc_centre = model.m_mc_centre;
... ... @@ -988,3 +990,19 @@ void GModelSpatialDiffuseMap::prepare_map(void)
988 990 // Return
989 991 return;
990 992 }
  993 +
  994 +
  995 +/***********************************************************************//**
  996 + * @brief Set boundary sky region
  997 + ***************************************************************************/
  998 +void GModelSpatialDiffuseMap::set_region(void) const
  999 +{
  1000 + // Set sky region centre to bounding circle centre
  1001 + m_region.centre(m_centre);
  1002 +
  1003 + // Set sky region radius to bounding circle radius
  1004 + m_region.radius(m_radius);
  1005 +
  1006 + // Return
  1007 + return;
  1008 +}
... ...
src/model/GModelSpatialEllipticalDisk.cpp
... ... @@ -646,6 +646,9 @@ void GModelSpatialEllipticalDisk::init_members(void)
646 646 m_semimajor_rad = 0.0;
647 647 m_norm = 0.0;
648 648  
  649 + // Initialise other members
  650 + m_region.clear();
  651 +
649 652 // Return
650 653 return;
651 654 }
... ... @@ -662,6 +665,9 @@ void GModelSpatialEllipticalDisk::init_members(void)
662 665 ***************************************************************************/
663 666 void GModelSpatialEllipticalDisk::copy_members(const GModelSpatialEllipticalDisk& model)
664 667 {
  668 + // Copy members
  669 + m_region = model.m_region;
  670 +
665 671 // Copy precomputation cache
666 672 m_last_semiminor = model.m_last_semiminor;
667 673 m_last_semimajor = model.m_last_semimajor;
... ... @@ -718,3 +724,22 @@ void GModelSpatialEllipticalDisk::update() const
718 724 // Return
719 725 return;
720 726 }
  727 +
  728 +
  729 +/***********************************************************************//**
  730 + * @brief Set boundary sky region
  731 + ***************************************************************************/
  732 +void GModelSpatialEllipticalDisk::set_region(void) const
  733 +{
  734 + // Set sky region centre to disk centre
  735 + m_region.centre(m_ra.value(), m_dec.value());
  736 +
  737 + // Set maximum model radius
  738 + double max_radius = (semimajor() > semiminor()) ? semimajor() : semiminor();
  739 +
  740 + // Set sky region radius to maximum disk radius
  741 + m_region.radius(max_radius);
  742 +
  743 + // Return
  744 + return;
  745 +}
... ...
src/model/GModelSpatialEllipticalGauss.cpp
... ... @@ -728,6 +728,9 @@ void GModelSpatialEllipticalGauss::init_members(void)
728 728 m_term2 = 0.0;
729 729 m_term3 = 0.0;
730 730  
  731 + // Initialise other members
  732 + m_region.clear();
  733 +
731 734 // Return
732 735 return;
733 736 }
... ... @@ -741,7 +744,8 @@ void GModelSpatialEllipticalGauss::init_members(void)
741 744 void GModelSpatialEllipticalGauss::copy_members(const GModelSpatialEllipticalGauss& model)
742 745 {
743 746 // Copy members
744   - m_type = model.m_type;
  747 + m_type = model.m_type;
  748 + m_region = model.m_region;
745 749  
746 750 // Copy precomputation cache
747 751 m_last_minor = model.m_last_minor;
... ... @@ -858,3 +862,23 @@ void GModelSpatialEllipticalGauss::update() const
858 862 // Return
859 863 return;
860 864 }
  865 +
  866 +
  867 +/***********************************************************************//**
  868 + * @brief Set boundary sky region
  869 + ***************************************************************************/
  870 +void GModelSpatialEllipticalGauss::set_region(void) const
  871 +{
  872 + // Set sky region centre to Gaussian centre
  873 + m_region.centre(m_ra.value(), m_dec.value());
  874 +
  875 + // Set maximum model radius
  876 + double max_radius = (semimajor() > semiminor()) ? semimajor() : semiminor();
  877 +
  878 + // Set sky region radius to maximum Gaussian sigma times a scaling
  879 + // factor (actually 3)
  880 + m_region.radius(max_radius * c_theta_max);
  881 +
  882 + // Return
  883 + return;
  884 +}
... ...
src/model/GModelSpatialPointSource.cpp
... ... @@ -602,6 +602,9 @@ void GModelSpatialPointSource::init_members(void)
602 602 m_pars.push_back(&m_ra);
603 603 m_pars.push_back(&m_dec);
604 604  
  605 + // Initialise other members
  606 + m_region.clear();
  607 +
605 608 // Return
606 609 return;
607 610 }
... ... @@ -615,9 +618,10 @@ void GModelSpatialPointSource::init_members(void)
615 618 void GModelSpatialPointSource::copy_members(const GModelSpatialPointSource& model)
616 619 {
617 620 // Copy members
618   - m_type = model.m_type;
619   - m_ra = model.m_ra;
620   - m_dec = model.m_dec;
  621 + m_type = model.m_type;
  622 + m_ra = model.m_ra;
  623 + m_dec = model.m_dec;
  624 + m_region = model.m_region;
621 625  
622 626 // Set parameter pointer(s)
623 627 m_pars.clear();
... ... @@ -637,3 +641,19 @@ void GModelSpatialPointSource::free_members(void)
637 641 // Return
638 642 return;
639 643 }
  644 +
  645 +
  646 +/***********************************************************************//**
  647 + * @brief Set boundary sky region
  648 + ***************************************************************************/
  649 +void GModelSpatialPointSource::set_region(void) const
  650 +{
  651 + // Set sky region centre
  652 + m_region.centre(m_ra.value(), m_dec.value());
  653 +
  654 + // Set sky region radius to zero
  655 + m_region.radius(0.0);
  656 +
  657 + // Return
  658 + return;
  659 +}
... ...
src/model/GModelSpatialRadialDisk.cpp
... ... @@ -584,6 +584,9 @@ void GModelSpatialRadialDisk::init_members(void)
584 584 m_radius_rad = 0.0;
585 585 m_norm = 0.0;
586 586  
  587 + // Initialise other members
  588 + m_region.clear();
  589 +
587 590 // Return
588 591 return;
589 592 }
... ... @@ -603,6 +606,7 @@ void GModelSpatialRadialDisk::copy_members(const GModelSpatialRadialDisk&amp; model)
603 606 // Copy members
604 607 m_type = model.m_type;
605 608 m_radius = model.m_radius;
  609 + m_region = model.m_region;
606 610  
607 611 // Copy precomputation cache
608 612 m_last_radius = model.m_last_radius;
... ... @@ -657,3 +661,19 @@ void GModelSpatialRadialDisk::update() const
657 661 // Return
658 662 return;
659 663 }
  664 +
  665 +
  666 +/***********************************************************************//**
  667 + * @brief Set boundary sky region
  668 + ***************************************************************************/
  669 +void GModelSpatialRadialDisk::set_region(void) const
  670 +{
  671 + // Set sky region centre to disk centre
  672 + m_region.centre(m_ra.value(), m_dec.value());
  673 +
  674 + // Set sky region radius to disk radius
  675 + m_region.radius(m_radius.value());
  676 +
  677 + // Return
  678 + return;
  679 +}
... ...
src/model/GModelSpatialRadialGauss.cpp
... ... @@ -580,6 +580,9 @@ void GModelSpatialRadialGauss::init_members(void)
580 580 // Set parameter pointer(s)
581 581 m_pars.push_back(&m_sigma);
582 582  
  583 + // Initialise other members
  584 + m_region.clear();
  585 +
583 586 // Return
584 587 return;
585 588 }
... ... @@ -597,8 +600,9 @@ void GModelSpatialRadialGauss::init_members(void)
597 600 void GModelSpatialRadialGauss::copy_members(const GModelSpatialRadialGauss& model)
598 601 {
599 602 // Copy members
600   - m_type = model.m_type;
601   - m_sigma = model.m_sigma;
  603 + m_type = model.m_type;
  604 + m_sigma = model.m_sigma;
  605 + m_region = model.m_region;
602 606  
603 607 // Return
604 608 return;
... ... @@ -613,3 +617,19 @@ void GModelSpatialRadialGauss::free_members(void)
613 617 // Return
614 618 return;
615 619 }
  620 +
  621 +
  622 +/***********************************************************************//**
  623 + * @brief Set boundary sky region
  624 + ***************************************************************************/
  625 +void GModelSpatialRadialGauss::set_region(void) const
  626 +{
  627 + // Set sky region centre to Gaussian centre
  628 + m_region.centre(m_ra.value(), m_dec.value());
  629 +
  630 + // Set sky region radius to 5 times the Gaussian sigma
  631 + m_region.radius(m_sigma.value() * 5.0);
  632 +
  633 + // Return
  634 + return;
  635 +}
... ...
src/model/GModelSpatialRadialShell.cpp
... ... @@ -660,6 +660,9 @@ void GModelSpatialRadialShell::init_members(void)
660 660 m_pars.push_back(&m_radius);
661 661 m_pars.push_back(&m_width);
662 662  
  663 + // Initialise other members
  664 + m_region.clear();
  665 +
663 666 // Initialise precomputation cache. Note that zero values flag
664 667 // uninitialised as a zero radius and width shell is not meaningful
665 668 m_last_radius = 0.0;
... ... @@ -687,9 +690,10 @@ void GModelSpatialRadialShell::init_members(void)
687 690 void GModelSpatialRadialShell::copy_members(const GModelSpatialRadialShell& model)
688 691 {
689 692 // Copy members
690   - m_type = model.m_type;
691   - m_radius = model.m_radius;
692   - m_width = model.m_width;
  693 + m_type = model.m_type;
  694 + m_radius = model.m_radius;
  695 + m_width = model.m_width;
  696 + m_region = model.m_region;
693 697  
694 698 // Copy precomputation cache
695 699 m_last_radius = model.m_last_radius;
... ... @@ -822,3 +826,19 @@ double GModelSpatialRadialShell::f2(double x)
822 826 // Return value
823 827 return f2;
824 828 }
  829 +
  830 +
  831 +/***********************************************************************//**
  832 + * @brief Set boundary sky region
  833 + ***************************************************************************/
  834 +void GModelSpatialRadialShell::set_region(void) const
  835 +{
  836 + // Set sky region centre to Gaussian centre
  837 + m_region.centre(m_ra.value(), m_dec.value());
  838 +
  839 + // Set sky region radius to sum of shell radius and width
  840 + m_region.radius(m_radius.value() + m_width.value());
  841 +
  842 + // Return
  843 + return;
  844 +}
... ...
test/test_GModel.cpp
... ... @@ -589,80 +589,55 @@ void TestGModel::test_sky_model(void)
589 589 void TestGModel::test_point_source(void)
590 590 {
591 591 // Test void constructor
592   - test_try("Test void constructor");
593   - try {
594   - GModelSpatialPointSource model;
595   - test_assert(model.type() == "PointSource",
596   - "Model type \"PointSource\" expected.");
597   - test_try_success();
598   - }
599   - catch (std::exception &e) {
600   - test_try_failure(e);
601   - }
  592 + GModelSpatialPointSource model1;
  593 + test_value(model1.type(), "PointSource");
602 594  
603 595 // Test sky direction constructor
604   - test_try("Test sky direction constructor");
605   - try {
606   - GSkyDir dir;
607   - dir.radec_deg(83.6331, +22.0145);
608   - GModelSpatialPointSource model(dir);
609   - test_value(model.ra(), 83.6331);
610   - test_value(model.dec(), +22.0145);
611   - test_try_success();
612   - }
613   - catch (std::exception &e) {
614   - test_try_failure(e);
615   - }
  596 + GSkyDir dir1;
  597 + dir1.radec_deg(83.6331, +22.0145);
  598 + GModelSpatialPointSource model2(dir1);
  599 + test_value(model2.ra(), 83.6331);
  600 + test_value(model2.dec(), +22.0145);
616 601  
617 602 // Test value constructor
618   - test_try("Test value constructor");
619   - try {
620   - GModelSpatialPointSource model(83.6331, +22.0145);
621   - test_value(model.ra(), 83.6331);
622   - test_value(model.dec(), +22.0145);
623   - test_try_success();
624   - }
625   - catch (std::exception &e) {
626   - test_try_failure(e);
627   - }
  603 + GModelSpatialPointSource model3(83.6331, +22.0145);
  604 + test_value(model3.ra(), 83.6331);
  605 + test_value(model3.dec(), +22.0145);
628 606  
629   - // Test XML constructor and value
630   - test_try("Test XML constructor, value and gradients");
631   - try {
632   - // Test XML constructor
633   - GXml xml(m_xml_model_point_plaw);
634   - GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
635   - GModelSpatialPointSource model(*element);
636   - test_value(model.size(), 2);
637   - test_assert(model.type() == "PointSource", "Expected \"PointSource\"");
638   - test_value(model.ra(), 83.6331);
639   - test_value(model.dec(), +22.0145);
640   -
641   - // Test ra method
642   - model.ra(3.9);
643   - test_value(model.ra(), 3.9);
644   -
645   - // Test dec method
646   - model.dec(3.9);
647   - test_value(model.dec(), 3.9);
648   -
649   - // Test operator access
650   - const char* strarray[] = {"RA", "DEC"};
651   - for (int i = 0; i < 2; ++i) {
652   - std::string keyname(strarray[i]);
653   - model[keyname].value(2.1);
654   - model[keyname].error(1.9);
655   - model[keyname].gradient(0.8);
656   - test_value(model[keyname].value(), 2.1);
657   - test_value(model[keyname].error(), 1.9);
658   - test_value(model[keyname].gradient(), 0.8);
659   - }
  607 + // Test XML constructor
  608 + GXml xml(m_xml_model_point_plaw);
  609 + GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
  610 + GModelSpatialPointSource model4(*element);
  611 + test_value(model4.size(), 2);
  612 + test_value(model4.type(), "PointSource");
  613 + test_value(model4.ra(), 83.6331);
  614 + test_value(model4.dec(), +22.0145);
  615 +
  616 + // Test ra method
  617 + model4.ra(3.9);
  618 + test_value(model4.ra(), 3.9);
  619 +
  620 + // Test dec method
  621 + model4.dec(3.9);
  622 + test_value(model4.dec(), 3.9);
  623 +
  624 + // Test region method
  625 + GSkyDir dir2;
  626 + dir2.radec_deg(3.9, 3.9);
  627 + test_assert(model4.region()->contains(dir2), "Test region() method (inside)");
  628 + dir2.radec_deg(4.9, 3.9);
  629 + test_assert(!model4.region()->contains(dir2), "Test region() method (outside)");
660 630  
661   - // Success if we reached this point
662   - test_try_success();
663   - }
664   - catch (std::exception &e) {
665   - test_try_failure(e);
  631 + // Test operator access
  632 + const char* strarray[] = {"RA", "DEC"};
  633 + for (int i = 0; i < 2; ++i) {
  634 + std::string keyname(strarray[i]);
  635 + model4[keyname].value(2.1);
  636 + model4[keyname].error(1.9);
  637 + model4[keyname].gradient(0.8);
  638 + test_value(model4[keyname].value(), 2.1);
  639 + test_value(model4[keyname].error(), 1.9);
  640 + test_value(model4[keyname].gradient(), 0.8);
666 641 }
667 642  
668 643 // Exit test
... ... @@ -676,61 +651,40 @@ void TestGModel::test_point_source(void)
676 651 void TestGModel::test_diffuse_const(void)
677 652 {
678 653 // Test void constructor
679   - test_try("Test void constructor");
680   - try {
681   - GModelSpatialDiffuseConst model;
682   - test_assert(model.type() == "DiffuseIsotropic",
683   - "Model type \"DiffuseIsotropic\" expected.");
684   - test_try_success();
685   - }
686   - catch (std::exception &e) {
687   - test_try_failure(e);
688   - }
  654 + GModelSpatialDiffuseConst model1;
  655 + test_value(model1.type(), "DiffuseIsotropic");
689 656  
690 657 // Test value constructor
691   - test_try("Test value constructor");
692   - try {
693   - GModelSpatialDiffuseConst model(3.0);
694   - test_value(model.value(), 3.0);
695   - test_try_success();
696   - }
697   - catch (std::exception &e) {
698   - test_try_failure(e);
699   - }
  658 + GModelSpatialDiffuseConst model2(3.0);
  659 + test_value(model2.value(), 3.0);
700 660  
701   - // Test XML constructor and value
702   - test_try("Test XML constructor, value and gradients");
703   - try {
704   - // Test XML constructor
705   - GXml xml(m_xml_model_diffuse_const);
706   - GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
707   - GModelSpatialDiffuseConst model(*element);
708   - test_value(model.size(), 1);
709   - test_assert(model.type() == "DiffuseIsotropic",
710   - "Expected \"DiffuseIsotropic\"");
711   - test_value(model.value(), 1.0);
712   -
713   - // Test value method
714   - model.value(3.9);
715   - test_value(model.value(), 3.9);
716   -
717   - // Test operator access
718   - test_value(model["Value"].value(), 3.9);
719   - test_value(model["Value"].error(), 0.0);
720   - test_value(model["Value"].gradient(), 0.0);
721   - model["Value"].value(2.1);
722   - model["Value"].error(1.9);
723   - model["Value"].gradient(0.8);
724   - test_value(model["Value"].value(), 2.1);
725   - test_value(model["Value"].error(), 1.9);
726   - test_value(model["Value"].gradient(), 0.8);
727   -
728   - // Success if we reached this point
729   - test_try_success();
730   - }
731   - catch (std::exception &e) {
732   - test_try_failure(e);
733   - }
  661 + // Test XML constructor
  662 + GXml xml(m_xml_model_diffuse_const);
  663 + GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
  664 + GModelSpatialDiffuseConst model3(*element);
  665 + test_value(model3.size(), 1);
  666 + test_value(model3.type(), "DiffuseIsotropic");
  667 + test_value(model3.value(), 1.0);
  668 +
  669 + // Test value method
  670 + model3.value(3.9);
  671 + test_value(model3.value(), 3.9);
  672 +
  673 + // Test region method
  674 + GSkyDir dir1;
  675 + dir1.radec_deg(3.9, 3.9);
  676 + test_assert(model3.region()->contains(dir1), "Test region() method (inside)");
  677 +
  678 + // Test operator access
  679 + test_value(model3["Value"].value(), 3.9);
  680 + test_value(model3["Value"].error(), 0.0);
  681 + test_value(model3["Value"].gradient(), 0.0);
  682 + model3["Value"].value(2.1);
  683 + model3["Value"].error(1.9);
  684 + model3["Value"].gradient(0.8);
  685 + test_value(model3["Value"].value(), 2.1);
  686 + test_value(model3["Value"].error(), 1.9);
  687 + test_value(model3["Value"].gradient(), 0.8);
734 688  
735 689 // Exit test
736 690 return;
... ... @@ -742,94 +696,62 @@ void TestGModel::test_diffuse_const(void)
742 696 ***************************************************************************/
743 697 void TestGModel::test_diffuse_cube(void)
744 698 {
745   - // Test void constructor
746   - test_try("Test void constructor");
747   - try {
748   - GModelSpatialDiffuseCube model;
749   - test_assert(model.type() == "DiffuseMapCube",
750   - "Model type \"DiffuseMapCube\" expected.");
751   - test_assert(model.filename().url() == "", "Model filename \"\" expected.");
752   - test_try_success();
753   - }
754   - catch (std::exception &e) {
755   - test_try_failure(e);
756   - }
  699 + GModelSpatialDiffuseCube model1;
  700 + test_value(model1.type(), "DiffuseMapCube");
  701 + test_value(model1.filename().url(), "");
757 702  
758 703 // Test filename value constructor
759   - test_try("Test filename value constructor");
760   - try {
761   - GModelSpatialDiffuseCube model(m_cube_file, 3.0);
762   - test_value(model.value(), 3.0);
763   - test_assert(model.filename().url() == m_cube_file,
764   - "Expected \""+m_cube_file+"\"");
765   - test_try_success();
766   - }
767   - catch (std::exception &e) {
768   - test_try_failure(e);
769   - }
  704 + GModelSpatialDiffuseCube model2(m_cube_file, 3.0);
  705 + test_value(model2.value(), 3.0);
  706 + test_value(model2.filename().url(), m_cube_file);
770 707  
771 708 // Test skymap value constructor
772   - test_try("Test skymap value constructor");
773   - try {
774   - GSkyMap map("GAL", 16, "RING", 10);
775   - GEnergies energies;
776   - for (int i = 0; i < 10; ++i) {
777   - energies.append(GEnergy(double(i+1.0), "MeV"));
778   - }
779   - GModelSpatialDiffuseCube model(map, energies, 3.0);
780   - test_value(model.value(), 3.0);
781   - test_assert(model.filename().url() == "", "Expected \"\"");
782   - //test_assert(model.cube() == map, "Map cube is not the expected one");
783   - test_try_success();
784   - }
785   - catch (std::exception &e) {
786   - test_try_failure(e);
787   - }
  709 + GSkyMap map("GAL", 16, "RING", 10);
  710 + GEnergies energies;
  711 + for (int i = 0; i < 10; ++i) {
  712 + energies.append(GEnergy(double(i+1.0), "MeV"));
  713 + }
  714 + GModelSpatialDiffuseCube model3(map, energies, 3.0);
  715 + test_value(model3.value(), 3.0);
  716 + test_value(model3.filename().url(), "");
  717 + //test_assert(model.cube() == map, "Map cube is not the expected one");
788 718  
789   - // Test XML constructor and attribute methods
790   - test_try("Test XML constructor, value and gradients");
791   - try {
792   - // Test XML constructor
793   - GXml xml(m_xml_model_diffuse_cube);
794   - GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
795   - GModelSpatialDiffuseCube model(*element);
796   - test_value(model.size(), 1);
797   - test_assert(model.type() == "DiffuseMapCube",
798   - "Expected \"DiffuseMapCube\"");
799   - test_value(model.value(), 1.0);
800   - test_assert(model.filename().url() == m_cube_file,
801   - "Model filename \""+m_cube_file+"\" expected.");
802   -
803   - // Test value method
804   - model.value(3.9);
805   - test_value(model.value(), 3.9);
806   -
807   - // Test filename method
808   - model.filename("Help me!");
809   - test_assert(model.filename().url() == "Help me!",
810   - "Model filename \"Help me!\" expected.");
811   -
812   - // Test cube method
813   - model.cube(GSkyMap("GAL", 16, "RING", 10));
814   - test_value(model.cube().npix(), 3072);
815   -
816   - // Test operator access
817   - test_value(model["Normalization"].value(), 3.9);
818   - test_value(model["Normalization"].error(), 0.0);
819   - test_value(model["Normalization"].gradient(), 0.0);
820   - model["Normalization"].value(2.1);
821   - model["Normalization"].error(1.9);
822   - model["Normalization"].gradient(0.8);
823   - test_value(model["Normalization"].value(), 2.1);
824   - test_value(model["Normalization"].error(), 1.9);
825   - test_value(model["Normalization"].gradient(), 0.8);
826   -
827   - // Success if we reached this point
828   - test_try_success();
829   - }
830   - catch (std::exception &e) {
831   - test_try_failure(e);
832   - }
  719 + // Test XML constructor
  720 + GXml xml(m_xml_model_diffuse_cube);
  721 + GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
  722 + GModelSpatialDiffuseCube model4(*element);
  723 + test_value(model4.size(), 1);
  724 + test_value(model4.type(), "DiffuseMapCube");
  725 + test_value(model4.value(), 1.0);
  726 + test_value(model4.filename().url(), m_cube_file);
  727 +
  728 + // Test value method
  729 + model4.value(3.9);
  730 + test_value(model4.value(), 3.9);
  731 +
  732 + // Test region method
  733 + GSkyDir dir1;
  734 + dir1.radec_deg(3.9, 3.9);
  735 + test_assert(model4.region()->contains(dir1), "Test region() method (inside)");
  736 +
  737 + // Test filename method
  738 + model4.filename("Help me!");
  739 + test_value(model4.filename().url(), "Help me!");
  740 +
  741 + // Test cube method
  742 + model4.cube(GSkyMap("GAL", 16, "RING", 10));
  743 + test_value(model4.cube().npix(), 3072);
  744 +
  745 + // Test operator access
  746 + test_value(model4["Normalization"].value(), 3.9);
  747 + test_value(model4["Normalization"].error(), 0.0);
  748 + test_value(model4["Normalization"].gradient(), 0.0);
  749 + model4["Normalization"].value(2.1);
  750 + model4["Normalization"].error(1.9);
  751 + model4["Normalization"].gradient(0.8);
  752 + test_value(model4["Normalization"].value(), 2.1);
  753 + test_value(model4["Normalization"].error(), 1.9);
  754 + test_value(model4["Normalization"].gradient(), 0.8);
833 755  
834 756 // Exit test
835 757 return;
... ... @@ -843,51 +765,43 @@ void TestGModel::test_diffuse_map(void)
843 765 {
844 766 // Test void constructor
845 767 GModelSpatialDiffuseMap model1;
846   - test_assert(model1.type() == "DiffuseMap",
847   - "Check that model is of type \"DiffuseMap\".");
848   - test_assert(model1.filename().url() == "",
849   - "Check that model has empty filename.");
  768 + test_value(model1.type(), "DiffuseMap");
  769 + test_value(model1.filename().url(), "");
850 770  
851 771 // Test filename value constructor
852 772 GModelSpatialDiffuseMap model2(m_map_file, 3.0);
853   - test_value(model2.value(), 3.0,
854   - "Check the value after loading from XML file.");
855   - test_assert(model2.filename().url() == m_map_file,
856   - "Check the filename after loading from XML file.");
  773 + test_value(model2.value(), 3.0);
  774 + test_value(model2.filename().url(), m_map_file);
857 775  
858 776 // Test skymap value constructor
859 777 GSkyMap map("GAL", 16, "RING", 10);
860 778 GModelSpatialDiffuseMap model3(map, 3.0);
861   - test_value(model3.value(), 3.0,
862   - "Check the value after creating model from sky map.");
863   - test_assert(model3.filename().url() == "",
864   - "Check that filename is empty after creating model from sky map.");
  779 + test_value(model3.value(), 3.0);
  780 + test_value(model3.filename().url(), "");
865 781  
866 782 // Test XML constructor and attribute methods
867 783 GXml xml(m_xml_model_diffuse_map);
868 784 GXmlElement* elementp = xml.element(0)->element(0)->element("spatialModel", 0);
869 785 GModelSpatialDiffuseMap model(*elementp);
870   - test_value(model.size(), 1,
871   - "Check that model build from an XML element has one parameter.");
872   - test_assert(model.type() == "DiffuseMap",
873   - "Check that model build from an XML element is of type "
874   - "\"DiffuseMap\".");
875   - test_value(model.value(), 1.0,
876   - "Check that normalisation of model build from an XML element is "
877   - "unity.");
878   - test_assert(model.filename().url() == m_map_file,
879   - "Check that filename of model build from an XML elements is "
880   - "\""+m_map_file+"\".");
  786 + test_value(model.size(), 1);
  787 + test_value(model.type(), "DiffuseMap");
  788 + test_value(model.value(), 1.0);
  789 + test_value(model.filename().url(), m_map_file);
881 790  
882 791 // Test value method
883 792 model.value(3.9);
884 793 test_value(model.value(), 3.9);
885 794  
  795 + // Test region method
  796 + GSkyDir dir1;
  797 + dir1.radec_deg(201.365, -43.019);
  798 + test_assert(model.region()->contains(dir1), "Test region() method (inside)");
  799 + dir1.radec_deg(180.0, -43.019);
  800 + test_assert(!model.region()->contains(dir1), "Test region() method (outside)");
  801 +
886 802 // Test load method
887 803 model.load(m_map_file);
888   - test_assert(model.filename().url() == m_map_file,
889   - "Check that filename of model loaded from a file is "
890   - "\""+m_map_file+"\".");
  804 + test_value(model.filename().url(), m_map_file);
891 805  
892 806 // Test map method
893 807 model.map(GSkyMap("GAL", 16, "RING", 10));
... ... @@ -948,80 +862,62 @@ void TestGModel::test_diffuse_map(void)
948 862 void TestGModel::test_radial_disk(void)
949 863 {
950 864 // Test void constructor
951   - test_try("Test void constructor");
952   - try {
953   - GModelSpatialRadialDisk model;
954   - test_assert(model.type() == "RadialDisk",
955   - "Model type \"RadialDisk\" expected.");
956   - test_try_success();
957   - }
958   - catch (std::exception &e) {
959   - test_try_failure(e);
960   - }
  865 + GModelSpatialRadialDisk model1;
  866 + test_value(model1.type(), "RadialDisk");
961 867  
962 868 // Test value constructor
963   - test_try("Test value constructor");
964   - try {
965   - GSkyDir dir;
966   - dir.radec_deg(83.6331, +22.0145);
967   - GModelSpatialRadialDisk model(dir, 3.0);
968   - test_value(model.ra(), 83.6331);
969   - test_value(model.dec(), 22.0145);
970   - test_value(model.radius(), 3.0);
971   - test_try_success();
972   - }
973   - catch (std::exception &e) {
974   - test_try_failure(e);
975   - }
  869 + GSkyDir dir1;
  870 + dir1.radec_deg(83.6331, +22.0145);
  871 + GModelSpatialRadialDisk model2(dir1, 3.0);
  872 + test_value(model2.ra(), 83.6331);
  873 + test_value(model2.dec(), 22.0145);
  874 + test_value(model2.radius(), 3.0);
976 875  
977   - // Test XML constructor and attribute methods
978   - test_try("Test XML constructor, value and gradients");
979   - try {
980   - // Test XML constructor
981   - GXml xml(m_xml_model_radial_disk);
982   - GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
983   - GModelSpatialRadialDisk model(*element);
984   - test_value(model.size(), 3);
985   - test_assert(model.type() == "RadialDisk", "Expected \"RadialDisk\"");
986   - test_value(model.ra(), 83.6331);
987   - test_value(model.dec(), 22.0145);
988   - test_value(model.radius(), 0.45);
989   -
990   - // Test ra method
991   - model.ra(100.0);
992   - test_value(model.ra(), 100.0);
993   -
994   - // Test dec method
995   - model.dec(10.0);
996   - test_value(model.dec(), 10.0);
997   -
998   - // Test dir method
999   - GSkyDir dir;
1000   - dir.radec_deg(83.6331, +22.0145);
1001   - model.dir(dir);
1002   - test_assert(model.dir() == dir, "Test sky direction");
1003   -
1004   - // Test radius method
1005   - model.radius(3.9);
1006   - test_value(model.radius(), 3.9);
1007   -
1008   - // Test operator access
1009   - const char* strarray[] = {"RA", "DEC", "Radius"};
1010   - for (int i = 0; i < 3; ++i) {
1011   - std::string keyname(strarray[i]);
1012   - model[keyname].value(2.1);
1013   - model[keyname].error(1.9);
1014   - model[keyname].gradient(0.8);
1015   - test_value(model[keyname].value(), 2.1);
1016   - test_value(model[keyname].error(), 1.9);
1017   - test_value(model[keyname].gradient(), 0.8);
1018   - }
  876 + // Test XML constructor
  877 + GXml xml(m_xml_model_radial_disk);
  878 + GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
  879 + GModelSpatialRadialDisk model3(*element);
  880 + test_value(model3.size(), 3);
  881 + test_value(model3.type(), "RadialDisk");
  882 + test_value(model3.ra(), 83.6331);
  883 + test_value(model3.dec(), 22.0145);
  884 + test_value(model3.radius(), 0.45);
  885 +
  886 + // Test ra method
  887 + model3.ra(100.0);
  888 + test_value(model3.ra(), 100.0);
  889 +
  890 + // Test dec method
  891 + model3.dec(10.0);
  892 + test_value(model3.dec(), 10.0);
  893 +
  894 + // Test dir method
  895 + GSkyDir dir2;
  896 + dir2.radec_deg(83.6331, +22.0145);
  897 + model3.dir(dir2);
  898 + test_assert(model3.dir() == dir2, "Test sky direction");
  899 +
  900 + // Test radius method
  901 + model3.radius(3.9);
  902 + test_value(model3.radius(), 3.9);
  903 +
  904 + // Test region method
  905 + GSkyDir dir3;
  906 + dir3.radec_deg(83.6331, +22.0145);
  907 + test_assert(model3.region()->contains(dir3), "Test region() method (inside)");
  908 + dir3.radec_deg(83.6331, +26.0);
  909 + test_assert(!model3.region()->contains(dir3), "Test region() method (outside)");
1019 910  
1020   - // Success if we reached this point
1021   - test_try_success();
1022   - }
1023   - catch (std::exception &e) {
1024   - test_try_failure(e);
  911 + // Test operator access
  912 + const char* strarray[] = {"RA", "DEC", "Radius"};
  913 + for (int i = 0; i < 3; ++i) {
  914 + std::string keyname(strarray[i]);
  915 + model3[keyname].value(2.1);
  916 + model3[keyname].error(1.9);
  917 + model3[keyname].gradient(0.8);
  918 + test_value(model3[keyname].value(), 2.1);
  919 + test_value(model3[keyname].error(), 1.9);
  920 + test_value(model3[keyname].gradient(), 0.8);
1025 921 }
1026 922  
1027 923 // Exit test
... ... @@ -1035,81 +931,62 @@ void TestGModel::test_radial_disk(void)
1035 931 void TestGModel::test_radial_gauss(void)
1036 932 {
1037 933 // Test void constructor
1038   - test_try("Test void constructor");
1039   - try {
1040   - GModelSpatialRadialGauss model;
1041   - test_assert(model.type() == "RadialGaussian",
1042   - "Model type \"RadialGaussian\" expected.");
1043   - test_try_success();
1044   - }
1045   - catch (std::exception &e) {
1046   - test_try_failure(e);
1047   - }
  934 + GModelSpatialRadialGauss model1;
  935 + test_value(model1.type(), "RadialGaussian");
1048 936  
1049 937 // Test value constructor
1050   - test_try("Test value constructor");
1051   - try {
1052   - GSkyDir dir;
1053   - dir.radec_deg(83.6331, +22.0145);
1054   - GModelSpatialRadialGauss model(dir, 3.0);
1055   - test_value(model.ra(), 83.6331);
1056   - test_value(model.dec(), 22.0145);
1057   - test_value(model.sigma(), 3.0);
1058   - test_try_success();
1059   - }
1060   - catch (std::exception &e) {
1061   - test_try_failure(e);
1062   - }
  938 + GSkyDir dir1;
  939 + dir1.radec_deg(83.6331, +22.0145);
  940 + GModelSpatialRadialGauss model2(dir1, 3.0);
  941 + test_value(model2.ra(), 83.6331);
  942 + test_value(model2.dec(), 22.0145);
  943 + test_value(model2.sigma(), 3.0);
1063 944  
1064   - // Test XML constructor and attribute methods
1065   - test_try("Test XML constructor, value and gradients");
1066   - try {
1067   - // Test XML constructor
1068   - GXml xml(m_xml_model_radial_gauss);
1069   - GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
1070   - GModelSpatialRadialGauss model(*element);
1071   - test_value(model.size(), 3);
1072   - test_assert(model.type() == "RadialGaussian",
1073   - "Expected \"RadialGaussian\"");
1074   - test_value(model.ra(), 83.6331);
1075   - test_value(model.dec(), 22.0145);
1076   - test_value(model.sigma(), 0.20);
1077   -
1078   - // Test ra method
1079   - model.ra(100.0);
1080   - test_value(model.ra(), 100.0);
1081   -
1082   - // Test dec method
1083   - model.dec(10.0);
1084   - test_value(model.dec(), 10.0);
1085   -
1086   - // Test dir method
1087   - GSkyDir dir;
1088   - dir.radec_deg(83.6331, +22.0145);
1089   - model.dir(dir);
1090   - test_assert(model.dir() == dir, "Test sky direction");
1091   -
1092   - // Test sigma method
1093   - model.sigma(3.9);
1094   - test_value(model.sigma(), 3.9);
1095   -
1096   - // Test operator access
1097   - const char* strarray[] = {"RA", "DEC", "Sigma"};
1098   - for (int i = 0; i < 3; ++i) {
1099   - std::string keyname(strarray[i]);
1100   - model[keyname].value(2.1);
1101   - model[keyname].error(1.9);
1102   - model[keyname].gradient(0.8);
1103   - test_value(model[keyname].value(), 2.1);
1104   - test_value(model[keyname].error(), 1.9);
1105   - test_value(model[keyname].gradient(), 0.8);
1106   - }
  945 + // Test XML constructor
  946 + GXml xml(m_xml_model_radial_gauss);
  947 + GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
  948 + GModelSpatialRadialGauss model3(*element);
  949 + test_value(model3.size(), 3);
  950 + test_value(model3.type(), "RadialGaussian");
  951 + test_value(model3.ra(), 83.6331);
  952 + test_value(model3.dec(), 22.0145);
  953 + test_value(model3.sigma(), 0.20);
1107 954  
1108   - // Success if we reached this point
1109   - test_try_success();
1110   - }
1111   - catch (std::exception &e) {
1112   - test_try_failure(e);
  955 + // Test ra method
  956 + model3.ra(100.0);
  957 + test_value(model3.ra(), 100.0);
  958 +
  959 + // Test dec method
  960 + model3.dec(10.0);
  961 + test_value(model3.dec(), 10.0);
  962 +
  963 + // Test dir method
  964 + GSkyDir dir2;
  965 + dir2.radec_deg(83.6331, +22.0145);
  966 + model3.dir(dir2);
  967 + test_assert(model3.dir() == dir2, "Test sky direction");
  968 +
  969 + // Test sigma method
  970 + model3.sigma(3.9);
  971 + test_value(model3.sigma(), 3.9);
  972 +
  973 + // Test region method
  974 + GSkyDir dir3;
  975 + dir3.radec_deg(83.6331, +22.0145);
  976 + test_assert(model3.region()->contains(dir3), "Test region() method (inside)");
  977 + dir3.radec_deg(83.6331, -70.0);
  978 + test_assert(!model3.region()->contains(dir3), "Test region() method (outside)");
  979 +
  980 + // Test operator access
  981 + const char* strarray[] = {"RA", "DEC", "Sigma"};
  982 + for (int i = 0; i < 3; ++i) {
  983 + std::string keyname(strarray[i]);
  984 + model3[keyname].value(2.1);
  985 + model3[keyname].error(1.9);
  986 + model3[keyname].gradient(0.8);
  987 + test_value(model3[keyname].value(), 2.1);
  988 + test_value(model3[keyname].error(), 1.9);
  989 + test_value(model3[keyname].gradient(), 0.8);
1113 990 }
1114 991  
1115 992 // Exit test
... ... @@ -1123,86 +1000,68 @@ void TestGModel::test_radial_gauss(void)
1123 1000 void TestGModel::test_radial_shell(void)
1124 1001 {
1125 1002 // Test void constructor
1126   - test_try("Test void constructor");
1127   - try {
1128   - GModelSpatialRadialShell model;
1129   - test_assert(model.type() == "RadialShell",
1130   - "Model type \"RadialShell\" expected.");
1131   - test_try_success();
1132   - }
1133   - catch (std::exception &e) {
1134   - test_try_failure(e);
1135   - }
  1003 + GModelSpatialRadialShell model1;
  1004 + test_value(model1.type(), "RadialShell");
1136 1005  
1137 1006 // Test value constructor
1138   - test_try("Test value constructor");
1139   - try {
1140   - GSkyDir dir;
1141   - dir.radec_deg(83.6331, +22.0145);
1142   - GModelSpatialRadialShell model(dir, 3.0, 1.0);
1143   - test_value(model.ra(), 83.6331);
1144   - test_value(model.dec(), 22.0145);
1145   - test_value(model.radius(), 3.0);
1146   - test_value(model.width(), 1.0);
1147   - test_try_success();
1148   - }
1149   - catch (std::exception &e) {
1150   - test_try_failure(e);
1151   - }
  1007 + GSkyDir dir1;
  1008 + dir1.radec_deg(83.6331, +22.0145);
  1009 + GModelSpatialRadialShell model2(dir1, 3.0, 1.0);
  1010 + test_value(model2.ra(), 83.6331);
  1011 + test_value(model2.dec(), 22.0145);
  1012 + test_value(model2.radius(), 3.0);
  1013 + test_value(model2.width(), 1.0);
1152 1014  
1153   - // Test XML constructor and attribute methods
1154   - test_try("Test XML constructor, value and gradients");
1155   - try {
1156   - // Test XML constructor
1157   - GXml xml(m_xml_model_radial_shell);
1158   - GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
1159   - GModelSpatialRadialShell model(*element);
1160   - test_value(model.size(), 4);
1161   - test_assert(model.type() == "RadialShell", "Expected \"RadialShell\"");
1162   - test_value(model.ra(), 83.6331);
1163   - test_value(model.dec(), 22.0145);
1164   - test_value(model.radius(), 0.30);
1165   - test_value(model.width(), 0.10);
1166   -
1167   - // Test ra method
1168   - model.ra(100.0);
1169   - test_value(model.ra(), 100.0);
1170   -
1171   - // Test dec method
1172   - model.dec(10.0);
1173   - test_value(model.dec(), 10.0);
1174   -
1175   - // Test dir method
1176   - GSkyDir dir;
1177   - dir.radec_deg(83.6331, +22.0145);
1178   - model.dir(dir);
1179   - test_assert(model.dir() == dir, "Test sky direction");
1180   -
1181   - // Test radius method
1182   - model.radius(3.9);
1183   - test_value(model.radius(), 3.9);
1184   -
1185   - // Test width method
1186   - model.width(3.9);
1187   - test_value(model.width(), 3.9);
1188   -
1189   - // Test operator access
1190   - const char* strarray[] = {"RA", "DEC", "Radius", "Width"};
1191   - for (int i = 0; i < 4; ++i) {
1192   - std::string keyname(strarray[i]);
1193   - model[keyname].value(2.1);
1194   - model[keyname].error(1.9);
1195   - model[keyname].gradient(0.8);
1196   - test_value(model[keyname].value(), 2.1);
1197   - test_value(model[keyname].error(), 1.9);
1198   - test_value(model[keyname].gradient(), 0.8);
1199   - }
  1015 + // Test XML constructor
  1016 + GXml xml(m_xml_model_radial_shell);
  1017 + GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
  1018 + GModelSpatialRadialShell model3(*element);
  1019 + test_value(model3.size(), 4);
  1020 + test_value(model3.type(), "RadialShell");
  1021 + test_value(model3.ra(), 83.6331);
  1022 + test_value(model3.dec(), 22.0145);
  1023 + test_value(model3.radius(), 0.30);
  1024 + test_value(model3.width(), 0.10);
  1025 +
  1026 + // Test ra method
  1027 + model3.ra(100.0);
  1028 + test_value(model3.ra(), 100.0);
  1029 +
  1030 + // Test dec method
  1031 + model3.dec(10.0);
  1032 + test_value(model3.dec(), 10.0);
  1033 +
  1034 + // Test dir method
  1035 + GSkyDir dir2;
  1036 + dir2.radec_deg(83.6331, +22.0145);
  1037 + model3.dir(dir2);
  1038 + test_assert(model3.dir() == dir2, "Test sky direction");
  1039 +
  1040 + // Test radius method
  1041 + model3.radius(3.9);
  1042 + test_value(model3.radius(), 3.9);
  1043 +
  1044 + // Test width method
  1045 + model3.width(3.9);
  1046 + test_value(model3.width(), 3.9);
  1047 +
  1048 + // Test region method
  1049 + GSkyDir dir3;
  1050 + dir3.radec_deg(83.6331, +22.0145);
  1051 + test_assert(model3.region()->contains(dir3), "Test region() method (inside)");
  1052 + dir3.radec_deg(83.6331, +29.815);
  1053 + test_assert(!model3.region()->contains(dir3), "Test region() method (outside)");
1200 1054  
1201   - // Success if we reached this point
1202   - test_try_success();
1203   - }
1204   - catch (std::exception &e) {
1205   - test_try_failure(e);
  1055 + // Test operator access
  1056 + const char* strarray[] = {"RA", "DEC", "Radius", "Width"};
  1057 + for (int i = 0; i < 4; ++i) {
  1058 + std::string keyname(strarray[i]);
  1059 + model3[keyname].value(2.1);
  1060 + model3[keyname].error(1.9);
  1061 + model3[keyname].gradient(0.8);
  1062 + test_value(model3[keyname].value(), 2.1);
  1063 + test_value(model3[keyname].error(), 1.9);
  1064 + test_value(model3[keyname].gradient(), 0.8);
1206 1065 }
1207 1066  
1208 1067 // Exit test
... ... @@ -1216,92 +1075,74 @@ void TestGModel::test_radial_shell(void)
1216 1075 void TestGModel::test_elliptical_disk(void)
1217 1076 {
1218 1077 // Test void constructor
1219   - test_try("Test void constructor");
1220   - try {
1221   - GModelSpatialEllipticalDisk model;
1222   - test_assert(model.type() == "EllipticalDisk",
1223   - "Model type \"EllipticalDisk\" expected.");
1224   - test_try_success();
1225   - }
1226   - catch (std::exception &e) {
1227   - test_try_failure(e);
1228   - }
  1078 + GModelSpatialEllipticalDisk model1;
  1079 + test_value(model1.type(), "EllipticalDisk");
1229 1080  
1230 1081 // Test value constructor
1231   - test_try("Test value constructor");
1232   - try {
1233   - GSkyDir dir;
1234   - dir.radec_deg(83.6331, +22.0145);
1235   - GModelSpatialEllipticalDisk model(dir, 3.0, 2.0, 45.0);
1236   - test_value(model.ra(), 83.6331);
1237   - test_value(model.dec(), 22.0145);
1238   - test_value(model.posangle(), 45.0);
1239   - test_value(model.semimajor(), 3.0);
1240   - test_value(model.semiminor(), 2.0);
1241   - test_try_success();
1242   - }
1243   - catch (std::exception &e) {
1244   - test_try_failure(e);
1245   - }
  1082 + GSkyDir dir1;
  1083 + dir1.radec_deg(83.6331, +22.0145);
  1084 + GModelSpatialEllipticalDisk model2(dir1, 3.0, 2.0, 45.0);
  1085 + test_value(model2.ra(), 83.6331);
  1086 + test_value(model2.dec(), 22.0145);
  1087 + test_value(model2.posangle(), 45.0);
  1088 + test_value(model2.semimajor(), 3.0);
  1089 + test_value(model2.semiminor(), 2.0);
1246 1090  
1247   - // Test XML constructor and attribute methods
1248   - test_try("Test XML constructor, value and gradients");
1249   - try {
1250   - // Test XML constructor
1251   - GXml xml(m_xml_model_elliptical_disk);
1252   - GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
1253   - GModelSpatialEllipticalDisk model(*element);
1254   - test_value(model.size(), 5);
1255   - test_assert(model.type() == "EllipticalDisk", "Expected \"EllipticalDisk\"");
1256   - test_value(model.ra(), 83.6331);
1257   - test_value(model.dec(), 22.0145);
1258   - test_value(model.posangle(), 45.0);
1259   - test_value(model.semimajor(), 2.0);
1260   - test_value(model.semiminor(), 0.5);
1261   -
1262   - // Test ra method
1263   - model.ra(100.0);
1264   - test_value(model.ra(), 100.0);
1265   -
1266   - // Test dec method
1267   - model.dec(10.0);
1268   - test_value(model.dec(), 10.0);
1269   -
1270   - // Test dir method
1271   - GSkyDir dir;
1272   - dir.radec_deg(83.6331, +22.0145);
1273   - model.dir(dir);
1274   - test_assert(model.dir() == dir, "Test sky direction");
1275   -
1276   - // Test posangle method
1277   - model.posangle(3.9);
1278   - test_value(model.posangle(), 3.9);
1279   -
1280   - // Test semimajor method
1281   - model.semimajor(3.9);
1282   - test_value(model.semimajor(), 3.9);
1283   -
1284   - // Test semiminor method
1285   - model.semiminor(3.9);
1286   - test_value(model.semiminor(), 3.9);
1287   -
1288   - // Test operator access
1289   - const char* strarray[] = {"RA", "DEC", "PA", "MinorRadius", "MajorRadius"};
1290   - for (int i = 0; i < 5; ++i) {
1291   - std::string keyname(strarray[i]);
1292   - model[keyname].value(2.1);
1293   - model[keyname].error(1.9);
1294   - model[keyname].gradient(0.8);
1295   - test_value(model[keyname].value(), 2.1);
1296   - test_value(model[keyname].error(), 1.9);
1297   - test_value(model[keyname].gradient(), 0.8);
1298   - }
  1091 + // Test XML constructor
  1092 + GXml xml(m_xml_model_elliptical_disk);
  1093 + GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
  1094 + GModelSpatialEllipticalDisk model3(*element);
  1095 + test_value(model3.size(), 5);
  1096 + test_value(model3.type(), "EllipticalDisk");
  1097 + test_value(model3.ra(), 83.6331);
  1098 + test_value(model3.dec(), 22.0145);
  1099 + test_value(model3.posangle(), 45.0);
  1100 + test_value(model3.semimajor(), 2.0);
  1101 + test_value(model3.semiminor(), 0.5);
  1102 +
  1103 + // Test ra method
  1104 + model3.ra(100.0);
  1105 + test_value(model3.ra(), 100.0);
  1106 +
  1107 + // Test dec method
  1108 + model3.dec(10.0);
  1109 + test_value(model3.dec(), 10.0);
  1110 +
  1111 + // Test dir method
  1112 + GSkyDir dir2;
  1113 + dir2.radec_deg(83.6331, +22.0145);
  1114 + model3.dir(dir2);
  1115 + test_assert(model3.dir() == dir2, "Test sky direction");
  1116 +
  1117 + // Test posangle method
  1118 + model3.posangle(3.9);
  1119 + test_value(model3.posangle(), 3.9);
  1120 +
  1121 + // Test semimajor method
  1122 + model3.semimajor(3.9);
  1123 + test_value(model3.semimajor(), 3.9);
  1124 +
  1125 + // Test semiminor method
  1126 + model3.semiminor(3.9);
  1127 + test_value(model3.semiminor(), 3.9);
  1128 +
  1129 + // Test region method
  1130 + GSkyDir dir3;
  1131 + dir3.radec_deg(83.6331, +22.0145);
  1132 + test_assert(model3.region()->contains(dir3), "Test region() method (inside)");
  1133 + dir3.radec_deg(83.6331, +25.915);
  1134 + test_assert(!model3.region()->contains(dir3), "Test region() method (outside)");
1299 1135  
1300   - // Success if we reached this point
1301   - test_try_success();
1302   - }
1303   - catch (std::exception &e) {
1304   - test_try_failure(e);
  1136 + // Test operator access
  1137 + const char* strarray[] = {"RA", "DEC", "PA", "MinorRadius", "MajorRadius"};
  1138 + for (int i = 0; i < 5; ++i) {
  1139 + std::string keyname(strarray[i]);
  1140 + model3[keyname].value(2.1);
  1141 + model3[keyname].error(1.9);
  1142 + model3[keyname].gradient(0.8);
  1143 + test_value(model3[keyname].value(), 2.1);
  1144 + test_value(model3[keyname].error(), 1.9);
  1145 + test_value(model3[keyname].gradient(), 0.8);
1305 1146 }
1306 1147  
1307 1148 // Exit test
... ... @@ -1314,93 +1155,74 @@ void TestGModel::test_elliptical_disk(void)
1314 1155 void TestGModel::test_elliptical_gauss(void)
1315 1156 {
1316 1157 // Test void constructor
1317   - test_try("Test void constructor");
1318   - try {
1319   - GModelSpatialEllipticalGauss model;
1320   - test_assert(model.type() == "EllipticalGaussian",
1321   - "Model type \"EllipticalGaussian\" expected.");
1322   - test_try_success();
1323   - }
1324   - catch (std::exception &e) {
1325   - test_try_failure(e);
1326   - }
  1158 + GModelSpatialEllipticalGauss model1;
  1159 + test_value(model1.type(), "EllipticalGaussian");
1327 1160  
1328 1161 // Test value constructor
1329   - test_try("Test value constructor");
1330   - try {
1331   - GSkyDir dir;
1332   - dir.radec_deg(83.6331, +22.0145);
1333   - GModelSpatialEllipticalGauss model(dir, 3.0, 2.0, 45.0);
1334   - test_value(model.ra(), 83.6331);
1335   - test_value(model.dec(), 22.0145);
1336   - test_value(model.posangle(), 45.0);
1337   - test_value(model.semimajor(), 3.0);
1338   - test_value(model.semiminor(), 2.0);
1339   - test_try_success();
1340   - }
1341   - catch (std::exception &e) {
1342   - test_try_failure(e);
1343   - }
  1162 + GSkyDir dir1;
  1163 + dir1.radec_deg(83.6331, +22.0145);
  1164 + GModelSpatialEllipticalGauss model2(dir1, 3.0, 2.0, 45.0);
  1165 + test_value(model2.ra(), 83.6331);
  1166 + test_value(model2.dec(), 22.0145);
  1167 + test_value(model2.posangle(), 45.0);
  1168 + test_value(model2.semimajor(), 3.0);
  1169 + test_value(model2.semiminor(), 2.0);
1344 1170  
1345   - // Test XML constructor and attribute methods
1346   - test_try("Test XML constructor, value and gradients");
1347   - try {
1348   - // Test XML constructor
1349   - GXml xml(m_xml_model_elliptical_gauss);
1350   - GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
1351   - GModelSpatialEllipticalGauss model(*element);
1352   - test_value(model.size(), 5);
1353   - test_assert(model.type() == "EllipticalGaussian",
1354   - "Expected \"EllipticalGaussian\"");
1355   - test_value(model.ra(), 83.6331);
1356   - test_value(model.dec(), 22.0145);
1357   - test_value(model.posangle(), 45.0);
1358   - test_value(model.semimajor(), 0.3);
1359   - test_value(model.semiminor(), 0.1);
1360   -
1361   - // Test ra method
1362   - model.ra(100.0);
1363   - test_value(model.ra(), 100.0);
1364   -
1365   - // Test dec method
1366   - model.dec(10.0);
1367   - test_value(model.dec(), 10.0);
1368   -
1369   - // Test dir method
1370   - GSkyDir dir;
1371   - dir.radec_deg(83.6331, +22.0145);
1372   - model.dir(dir);
1373   - test_assert(model.dir() == dir, "Test sky direction");
1374   -
1375   - // Test posangle method
1376   - model.posangle(3.9);
1377   - test_value(model.posangle(), 3.9);
1378   -
1379   - // Test semimajor method
1380   - model.semimajor(3.9);
1381   - test_value(model.semimajor(), 3.9);
1382   -
1383   - // Test semiminor method
1384   - model.semiminor(3.9);
1385   - test_value(model.semiminor(), 3.9);
1386   -
1387   - // Test operator access
1388   - const char* strarray[] = {"RA", "DEC", "PA", "MinorRadius", "MajorRadius"};
1389   - for (int i = 0; i < 5; ++i) {
1390   - std::string keyname(strarray[i]);
1391   - model[keyname].value(2.1);
1392   - model[keyname].error(1.9);
1393   - model[keyname].gradient(0.8);
1394   - test_value(model[keyname].value(), 2.1);
1395   - test_value(model[keyname].error(), 1.9);
1396   - test_value(model[keyname].gradient(), 0.8);
1397   - }
  1171 + // Test XML constructor
  1172 + GXml xml(m_xml_model_elliptical_gauss);
  1173 + GXmlElement* element = xml.element(0)->element(0)->element("spatialModel", 0);
  1174 + GModelSpatialEllipticalGauss model3(*element);
  1175 + test_value(model3.size(), 5);
  1176 + test_value(model3.type(), "EllipticalGaussian");
  1177 + test_value(model3.ra(), 83.6331);
  1178 + test_value(model3.dec(), 22.0145);
  1179 + test_value(model3.posangle(), 45.0);
  1180 + test_value(model3.semimajor(), 0.3);
  1181 + test_value(model3.semiminor(), 0.1);
  1182 +
  1183 + // Test ra method
  1184 + model3.ra(100.0);
  1185 + test_value(model3.ra(), 100.0);
  1186 +
  1187 + // Test dec method
  1188 + model3.dec(10.0);
  1189 + test_value(model3.dec(), 10.0);
  1190 +
  1191 + // Test dir method
  1192 + GSkyDir dir2;
  1193 + dir2.radec_deg(83.6331, +22.0145);
  1194 + model3.dir(dir2);
  1195 + test_assert(model3.dir() == dir2, "Test sky direction");
  1196 +
  1197 + // Test posangle method
  1198 + model3.posangle(3.9);
  1199 + test_value(model3.posangle(), 3.9);
  1200 +
  1201 + // Test semimajor method
  1202 + model3.semimajor(3.9);
  1203 + test_value(model3.semimajor(), 3.9);
  1204 +
  1205 + // Test semiminor method
  1206 + model3.semiminor(3.9);
  1207 + test_value(model3.semiminor(), 3.9);
  1208 +
  1209 + // Test region method
  1210 + GSkyDir dir3;
  1211 + dir3.radec_deg(83.6331, +22.0145);
  1212 + test_assert(model3.region()->contains(dir3), "Test region() method (inside)");
  1213 + dir3.radec_deg(83.6331, +41.5);
  1214 + test_assert(!model3.region()->contains(dir3), "Test region() method (outside)");
1398 1215  
1399   - // Success if we reached this point
1400   - test_try_success();
1401   - }
1402   - catch (std::exception &e) {
1403   - test_try_failure(e);
  1216 + // Test operator access
  1217 + const char* strarray[] = {"RA", "DEC", "PA", "MinorRadius", "MajorRadius"};
  1218 + for (int i = 0; i < 5; ++i) {
  1219 + std::string keyname(strarray[i]);
  1220 + model3[keyname].value(2.1);
  1221 + model3[keyname].error(1.9);
  1222 + model3[keyname].gradient(0.8);
  1223 + test_value(model3[keyname].value(), 2.1);
  1224 + test_value(model3[keyname].error(), 1.9);
  1225 + test_value(model3[keyname].gradient(), 0.8);
1404 1226 }
1405 1227  
1406 1228 // Exit test
... ... @@ -1418,12 +1240,12 @@ void TestGModel::test_spatial_composite(void)
1418 1240 test_value(model1.type(), "Composite", "Check void model type");
1419 1241  
1420 1242 // Set sky direction
1421   - GSkyDir dir = GSkyDir();
1422   - dir.radec_deg(83.6331, 22.01);
  1243 + GSkyDir dir1 = GSkyDir();
  1244 + dir1.radec_deg(83.6331, 22.01);
1423 1245  
1424 1246 // Test append method
1425   - model1.append(GModelSpatialPointSource(dir));
1426   - model1.append(GModelSpatialRadialGauss(dir, 0.2), "", 1.5);
  1247 + model1.append(GModelSpatialPointSource(dir1));
  1248 + model1.append(GModelSpatialRadialGauss(dir1, 0.2), "", 1.5);
1427 1249 test_value(model1.components(), 2);
1428 1250 test_value(model1.size(), 5);
1429 1251  
... ... @@ -1436,7 +1258,12 @@ void TestGModel::test_spatial_composite(void)
1436 1258 test_value(model2.scale(0), 1.0);
1437 1259 test_value(model2.scale(1), 3.0);
1438 1260 test_value(model2.sum_of_scales(), 4.0);
1439   -
  1261 +
  1262 + // Test region method
  1263 + GSkyDir dir2;
  1264 + dir2.radec_deg(83.6331, 22.01);
  1265 + test_assert(model2.region()->contains(dir2), "Test region() method (inside)");
  1266 +
1440 1267 // Test access of individual parameters
1441 1268 test_value(model2["2:RA"].value(), 83.6331);
1442 1269 test_value(model2["2:DEC"].value(), 22.0145);
... ...