ctools 2.1.0.dev
Loading...
Searching...
No Matches
ctskymap.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * ctskymap - Sky mapping tool *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-2022 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file ctskymap.hpp
23 * @brief Sky mapping tool definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef CTSKYMAP_HPP
28#define CTSKYMAP_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "ctobservation.hpp"
33
34/* __Definitions _________________________________________________________ */
35#define CTSKYMAP_NAME "ctskymap"
36
37
38/***********************************************************************//**
39 * @class ctskymap
40 *
41 * @brief Sky mapping tool
42 *
43 * This class creates a sky map from a CTA event list.
44 ***************************************************************************/
45class ctskymap : public ctobservation {
46
47public:
48 // Constructors and destructors
49 ctskymap(void);
50 explicit ctskymap(const GObservations& obs);
51 ctskymap(int argc, char *argv[]);
52 ctskymap(const ctskymap& app);
53 virtual ~ctskymap(void);
54
55 // Operators
56 ctskymap& operator=(const ctskymap& app);
57
58 // Methods
59 void clear(void);
60 void process(void);
61 void save(void);
62 void publish(const std::string& name = "");
63 const GSkyMap& skymap(void) const;
64 const GFits& fits(void) const;
65 void exclusion_map(const GSkyRegionMap& exclusion_map);
66 GSkyRegionMap exclusion_map(void) const;
67
68protected:
69 // Protected methods
70 void init_members(void);
71 void copy_members(const ctskymap& app);
72 void free_members(void);
73 void get_parameters(void);
74 void setup_maps(void);
75 void setup_exclusion_map(void);
76 void setup_exclusion_map_fits(const GFilename& filename);
77 void setup_exclusion_map_region(const GFilename& filename);
78 void adjust_exclusion_map(void);
79 void fill_maps(void);
80 void fill_maps_counts(GCTAObservation* obs);
81 void fill_maps_acceptance(GCTAObservation* obs);
82 void compute_maps(void);
83 void compute_maps_ring_fft(void);
84 void compute_maps_ring_direct(void);
85 void compute_ring_values(const int& ipixel,
86 const GSkyMap& counts,
87 const GSkyMap& background,
88 double& non,
89 double& noff,
90 double& alpha);
91 void construct_fits(void);
92 void ring_bounding_box(const int& ipixel, int& ix1, int& ix2,
93 int& iy1, int& iy2) const;
94 GSkyMap ring_convolve(const GSkyMap& map, const double& rmin,
95 const double& rmax) const;
96 GNdarray ring_kernel(const double& rmin, const double& rmax) const;
97 double sigma_li_ma(const double& n_on,
98 const double& n_off,
99 const double& alpha) const;
100 void write_map(GFits& fits,
101 const GSkyMap& map,
102 const std::string& extname) const;
103 void write_hdu_keywords(GFitsHDU* hdu) const;
104
105 // User parameters
106 GFilename m_outmap; //!< Output file name
107 GFilename m_inexclusion; //!< Exclusion map file name
108 double m_emin; //!< Minimum energy (TeV)
109 double m_emax; //!< Maximum energy (TeV)
110 std::string m_bkgsubtract; //!< Background subtraction method
111 double m_roiradius; //!< Region of interest radius for RING bkg.
112 double m_inradius; //!< Inner ring radius for RING background
113 double m_outradius; //!< Outer ring radius for RING background
114 int m_iterations; //!< Number of iterations for RING background
115 double m_threshold; //!< Threshold for RING background
116 bool m_usefft; //!< Use FFT for RING background
117 bool m_publish; //!< Publish sky map?
118 GChatter m_chatter; //!< Chattiness
119
120 // Protected members
121 bool m_has_inmap; //!< Has valid input map
122 GSkyMap m_skymap; //!< Sky map
123 GSkyMap m_bkgmap; //!< Background map
124 GSkyMap m_sigmap; //!< Significance map
125 GSkyMap m_counts; //!< Counts map
126 GSkyMap m_acceptance; //!< Acceptance map
127 GSkyMap m_exclmap; //!< Exclusion map for RING background
128 GFits m_fits; //!< Output GFits object
129
130 // Caching variables to prevent multiple computations of the same thing
131 std::vector<double> m_solidangle; //!< Cached pixel solid angles
132 std::vector<GSkyDir> m_dirs; //!< Cached pixel directions
133 double m_cos_roiradius; //!< Cosine of RoI radius
134 double m_cos_inradius; //!< Cosine of inner ring radius
135 double m_cos_outradius; //!< Cosine of outer ring radius
136};
137
138
139/***********************************************************************//**
140 * @brief Return observation container
141 *
142 * @return Reference to observation container
143 ***************************************************************************/
144inline
145const GSkyMap& ctskymap::skymap(void) const
146{
147 return m_skymap;
148}
149
150
151/***********************************************************************//**
152 * @brief Return fits container
153 *
154 * @return Reference to fits container
155 ***************************************************************************/
156inline
157const GFits& ctskymap::fits(void) const
158{
159 return m_fits;
160}
161
162
163/***********************************************************************//**
164 * @brief Set exclusion region map
165 *
166 * @param[in] exclusion_map Exclusion region map.
167 ***************************************************************************/
168inline
169void ctskymap::exclusion_map(const GSkyRegionMap& exclusion_map)
170{
171 // Assign exclusion map
172 m_exclmap = exclusion_map.map();
173
174 // Return
175 return;
176}
177
178
179/***********************************************************************//**
180 * @brief Return exclusion region map
181 *
182 * @return Exclusion region map
183 ***************************************************************************/
184inline
185GSkyRegionMap ctskymap::exclusion_map(void) const
186{
187 GSkyRegionMap exclusion_map(m_exclmap);
188 return exclusion_map;
189}
190
191#endif /* CTSKYMAP_HPP */
Base class for observation tools.
const GObservations & obs(void) const
Return observation container.
Sky mapping tool.
Definition ctskymap.hpp:45
double m_threshold
Threshold for RING background.
Definition ctskymap.hpp:115
void compute_maps(void)
Compute sky map, background map and significance map.
GSkyMap ring_convolve(const GSkyMap &map, const double &rmin, const double &rmax) const
Return FFT kernel for background ring.
void fill_maps_counts(GCTAObservation *obs)
Fill events into counts map.
Definition ctskymap.cpp:822
void write_map(GFits &fits, const GSkyMap &map, const std::string &extname) const
Write sky map into FITS file.
void publish(const std::string &name="")
Publish sky map.
Definition ctskymap.cpp:333
void fill_maps_acceptance(GCTAObservation *obs)
Compute background acceptance sky map based on IRF template.
Definition ctskymap.cpp:930
void clear(void)
Clear sky mapping tool.
Definition ctskymap.cpp:186
bool m_has_inmap
Has valid input map.
Definition ctskymap.hpp:121
double m_cos_inradius
Cosine of inner ring radius.
Definition ctskymap.hpp:134
void compute_maps_ring_fft(void)
Compute the maps for RING background using a FFT.
GSkyMap m_counts
Counts map.
Definition ctskymap.hpp:125
GSkyMap m_exclmap
Exclusion map for RING background.
Definition ctskymap.hpp:127
double m_roiradius
Region of interest radius for RING bkg.
Definition ctskymap.hpp:111
void write_hdu_keywords(GFitsHDU *hdu) const
Write keywords in FITS HDU.
void fill_maps(void)
Fill maps from observation container.
Definition ctskymap.cpp:759
GFilename m_outmap
Output file name.
Definition ctskymap.hpp:106
GSkyMap m_bkgmap
Background map.
Definition ctskymap.hpp:123
void copy_members(const ctskymap &app)
Copy class members.
Definition ctskymap.cpp:408
virtual ~ctskymap(void)
Destructor.
Definition ctskymap.cpp:129
std::string m_bkgsubtract
Background subtraction method.
Definition ctskymap.hpp:110
double m_inradius
Inner ring radius for RING background.
Definition ctskymap.hpp:112
void ring_bounding_box(const int &ipixel, int &ix1, int &ix2, int &iy1, int &iy2) const
Computes bounding box for RING background computation.
void save(void)
Save sky map.
Definition ctskymap.cpp:252
void adjust_exclusion_map(void)
Verifys that exclusion map points in fov of counts.
Definition ctskymap.cpp:721
GNdarray ring_kernel(const double &rmin, const double &rmax) const
Return FFT kernel for background ring.
void compute_maps_ring_direct(void)
Compute the pixel significance for RING background.
void setup_exclusion_map_region(const GFilename &filename)
Fills exclusions map from DS9 region file.
Definition ctskymap.cpp:691
double m_emin
Minimum energy (TeV)
Definition ctskymap.hpp:108
void setup_exclusion_map(void)
Generates map of pixel exclusions.
Definition ctskymap.cpp:633
int m_iterations
Number of iterations for RING background.
Definition ctskymap.hpp:114
std::vector< double > m_solidangle
Cached pixel solid angles.
Definition ctskymap.hpp:131
bool m_publish
Publish sky map?
Definition ctskymap.hpp:117
GSkyRegionMap exclusion_map(void) const
Return exclusion region map.
Definition ctskymap.hpp:185
void get_parameters(void)
Get application parameters.
Definition ctskymap.cpp:466
void free_members(void)
Delete class members.
Definition ctskymap.cpp:450
double m_cos_outradius
Cosine of outer ring radius.
Definition ctskymap.hpp:135
std::vector< GSkyDir > m_dirs
Cached pixel directions.
Definition ctskymap.hpp:132
ctskymap & operator=(const ctskymap &app)
Assignment operator.
Definition ctskymap.cpp:151
bool m_usefft
Use FFT for RING background.
Definition ctskymap.hpp:116
void compute_ring_values(const int &ipixel, const GSkyMap &counts, const GSkyMap &background, double &non, double &noff, double &alpha)
Computes Non, Noff and alpha for a counts map and sensitivity map.
void setup_maps(void)
Setup maps.
Definition ctskymap.cpp:586
GChatter m_chatter
Chattiness.
Definition ctskymap.hpp:118
double m_outradius
Outer ring radius for RING background.
Definition ctskymap.hpp:113
void process(void)
Process the sky mapping tool.
Definition ctskymap.cpp:216
void setup_exclusion_map_fits(const GFilename &filename)
Fills exclusions map from FITS image.
Definition ctskymap.cpp:670
void init_members(void)
Initialise class members.
Definition ctskymap.cpp:364
GFits m_fits
Output GFits object.
Definition ctskymap.hpp:128
double m_emax
Maximum energy (TeV)
Definition ctskymap.hpp:109
const GSkyMap & skymap(void) const
Return observation container.
Definition ctskymap.hpp:145
GFilename m_inexclusion
Exclusion map file name.
Definition ctskymap.hpp:107
void construct_fits(void)
Construct GFits object consisting of all maps.
Definition ctskymap.cpp:287
GSkyMap m_skymap
Sky map.
Definition ctskymap.hpp:122
GSkyMap m_sigmap
Significance map.
Definition ctskymap.hpp:124
double m_cos_roiradius
Cosine of RoI radius.
Definition ctskymap.hpp:133
GSkyMap m_acceptance
Acceptance map.
Definition ctskymap.hpp:126
double sigma_li_ma(const double &n_on, const double &n_off, const double &alpha) const
Compute significance following Li & Ma.
ctskymap(void)
Void constructor.
Definition ctskymap.cpp:59
const GFits & fits(void) const
Return fits container.
Definition ctskymap.hpp:157
Observation tool base class interface definition.