Commit 9968f648f0b2dbbc39d83e0ea0271b1392ed6148

Authored by Jürgen Knödlseder
Committed by Luigi Tibaldo
1 parent 597dbdd3

Add exclusion_map() methods to ctskymap, csphagen, cslightcrv and csphasecrv (#2725)

ChangeLog
@@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
5 5
6 ctbkgcube now requires an input counts cube (#2763) 6 ctbkgcube now requires an input counts cube (#2763)
7 CTA background rates are now per ontime (#2758) 7 CTA background rates are now per ontime (#2758)
  8 + Add exclusion_map() methods to ctskymap, csphagen, cslightcrv and
  9 + csphasecrv (#2725)
8 Apply event bin weighting in ctmodel for stacked computation (#2721) 10 Apply event bin weighting in ctmodel for stacked computation (#2721)
9 Enable ctbin to produce counts cubes for a joint binned analysis (#2714) 11 Enable ctbin to produce counts cubes for a joint binned analysis (#2714)
10 Add ctfindvar tool (#2713) 12 Add ctfindvar tool (#2713)
@@ -203,6 +203,8 @@ of the input observations (#2054). @@ -203,6 +203,8 @@ of the input observations (#2054).
203 203
204 ctskymap - CTA sky mapping 204 ctskymap - CTA sky mapping
205 -------------------------- 205 --------------------------
  206 +Add exclusion_map() methods (#2725)
  207 +
206 Add the "inmap", "iterations" and "threshold" parameters. The hidden 208 Add the "inmap", "iterations" and "threshold" parameters. The hidden
207 "inmap" parameter allows specifying a sky map file containing a "COUNTS" 209 "inmap" parameter allows specifying a sky map file containing a "COUNTS"
208 and "ACCEPTANCE" extension which avoids looping over event lists in an 210 and "ACCEPTANCE" extension which avoids looping over event lists in an
@@ -281,6 +283,8 @@ None @@ -281,6 +283,8 @@ None
281 283
282 cslightcrv - Generate light curve 284 cslightcrv - Generate light curve
283 --------------------------------- 285 ---------------------------------
  286 +Add exclusion_map() methods (#2725)
  287 +
284 Add hidden "use_model_bkg" parameter for forwarding to csphagen. 288 Add hidden "use_model_bkg" parameter for forwarding to csphagen.
285 289
286 Add hidden "nthreads" parameter and implement parallelisation of light 290 Add hidden "nthreads" parameter and implement parallelisation of light
@@ -334,6 +338,8 @@ Use time reference of input observations if time selection is given in MET @@ -334,6 +338,8 @@ Use time reference of input observations if time selection is given in MET
334 338
335 csphagen - Generate On/Off observations 339 csphagen - Generate On/Off observations
336 --------------------------------------- 340 ---------------------------------------
  341 +Add exclusion_map() methods (#2725)
  342 +
337 A "outmodel" parameter was added and the script now produces an appropriate 343 A "outmodel" parameter was added and the script now produces an appropriate
338 background model for maximum likelihood model fitting. The script now also 344 background model for maximum likelihood model fitting. The script now also
339 sets the appropriate fit statistic depending on the "use_model_bkg" parameter 345 sets the appropriate fit statistic depending on the "use_model_bkg" parameter
@@ -367,6 +373,8 @@ tutorial was added to the user documentation (#2404). @@ -367,6 +373,8 @@ tutorial was added to the user documentation (#2404).
367 373
368 csphasecrv - Generate phase curve 374 csphasecrv - Generate phase curve
369 --------------------------------- 375 ---------------------------------
  376 +Add exclusion_map() methods (#2725)
  377 +
370 Add hidden "nthreads" parameter and implement parallelisation of computations 378 Add hidden "nthreads" parameter and implement parallelisation of computations
371 (#2421). 379 (#2421).
372 380
cscripts/cslightcrv.py
@@ -79,7 +79,7 @@ class cslightcrv(ctools.csobservation): @@ -79,7 +79,7 @@ class cslightcrv(ctools.csobservation):
79 self._stacked = False 79 self._stacked = False
80 self._fits = gammalib.GFits() 80 self._fits = gammalib.GFits()
81 self._nthreads = 0 81 self._nthreads = 0
82 - self._excl_reg_map = None # Exclusion region map for on/off analysis 82 + self._excl_reg_map = None # Exclusion region map for on/off analysis
83 83
84 # Return 84 # Return
85 return 85 return
@@ -736,26 +736,30 @@ class cslightcrv(ctools.csobservation): @@ -736,26 +736,30 @@ class cslightcrv(ctools.csobservation):
736 # Return 736 # Return
737 return 737 return
738 738
739 - def exclregmap(self, regmapobj=None): 739 + def exclusion_map(self, object):
740 """ 740 """
741 - Access exclusion region map object 741 + Set exclusion regions map
742 742
743 Parameters 743 Parameters
744 ---------- 744 ----------
745 - regmapobj : `~gammalib.GSkyRegionMap`  
746 - Excluded regions region map instance 745 + object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename`
  746 + Exclusion regions object
  747 + """
  748 + # Set exclusion region map
  749 + self._excl_reg_map = gammalib.GSkyRegionMap(object)
  750 +
  751 + # Return
  752 + return
  753 +
  754 + def exclusion_map(self):
  755 + """
  756 + Get exclusion regions map
747 757
748 Returns 758 Returns
749 ------- 759 -------
750 - reg : `~gammalib.GSkyRegionMap`  
751 - Excluded regions region map instance 760 + region : `~gammalib.GSkyRegionMap`
  761 + Exclusion regions map
752 """ 762 """
753 - # Check if exclusion map object was provided  
754 - if regmapobj is not None:  
755 -  
756 - # Set exclusion region map  
757 - self._excl_reg_map = gammalib.GSkyRegionMap(regmapobj)  
758 -  
759 # Return 763 # Return
760 return self._excl_reg_map 764 return self._excl_reg_map
761 765
cscripts/csphagen.py
@@ -829,29 +829,30 @@ class csphagen(ctools.csobservation): @@ -829,29 +829,30 @@ class csphagen(ctools.csobservation):
829 # Return 829 # Return
830 return 830 return
831 831
832 - def exclregmap(self, regmapobj=None): 832 + def exclusion_map(self, object):
833 """ 833 """
834 - Access exclusion region map object 834 + Set exclusion regions map
835 835
836 Parameters 836 Parameters
837 ---------- 837 ----------
838 - regmapobj : `~gammalib.GSkyRegionMap`  
839 - Excluded regions region map instance  
840 -  
841 - Returns  
842 - -------  
843 - reg : `~gammalib.GSkyRegionMap`  
844 - Excluded regions region map instance 838 + object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename`
  839 + Exclusion regions object
845 """ 840 """
846 - # Check if exclusion map object was provided  
847 - if regmapobj is not None: 841 + # Set exclusion region map
  842 + self._excl_reg = gammalib.GSkyRegionMap(object)
848 843
849 - # Set exclusion region map  
850 - self._excl_reg = gammalib.GSkyRegionMap(regmapobj) 844 + # Return
  845 + return
851 846
852 - # Set has exclusion to yes  
853 - self._has_exclusion = True 847 + def exclusion_map(self):
  848 + """
  849 + Get exclusion regions map
854 850
  851 + Returns
  852 + -------
  853 + region : `~gammalib.GSkyRegionMap`
  854 + Exclusion regions map
  855 + """
855 # Return 856 # Return
856 return self._excl_reg 857 return self._excl_reg
857 858
cscripts/csphasecrv.py
@@ -69,7 +69,7 @@ class csphasecrv(ctools.csobservation): @@ -69,7 +69,7 @@ class csphasecrv(ctools.csobservation):
69 self._fits = gammalib.GFits() 69 self._fits = gammalib.GFits()
70 self._fitmodels = {} 70 self._fitmodels = {}
71 self._nthreads = 0 71 self._nthreads = 0
72 - self._excl_reg_map = None # Exclusion region map for on/off analysis 72 + self._excl_reg_map = None # Exclusion region map for on/off analysis
73 73
74 # Return 74 # Return
75 return 75 return
@@ -548,26 +548,30 @@ class csphasecrv(ctools.csobservation): @@ -548,26 +548,30 @@ class csphasecrv(ctools.csobservation):
548 # Return 548 # Return
549 return self._fitmodels 549 return self._fitmodels
550 550
551 - def exclregmap(self, regmapobj=None): 551 + def exclusion_map(self, object):
552 """ 552 """
553 - Access exclusion region map object 553 + Set exclusion regions map
554 554
555 Parameters 555 Parameters
556 ---------- 556 ----------
557 - regmapobj : `~gammalib.GSkyRegionMap`  
558 - Excluded regions region map instance 557 + object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename`
  558 + Exclusion regions object
  559 + """
  560 + # Set exclusion region map
  561 + self._excl_reg_map = gammalib.GSkyRegionMap(object)
  562 +
  563 + # Return
  564 + return
  565 +
  566 + def exclusion_map(self):
  567 + """
  568 + Get exclusion regions map
559 569
560 Returns 570 Returns
561 ------- 571 -------
562 - reg : `~gammalib.GSkyRegionMap`  
563 - Excluded regions region map instance 572 + region : `~gammalib.GSkyRegionMap`
  573 + Exclusion regions map
564 """ 574 """
565 - # Check if exclusion map object was provided  
566 - if regmapobj is not None:  
567 -  
568 - # Set exclusion region map  
569 - self._excl_reg_map = gammalib.GSkyRegionMap(regmapobj)  
570 -  
571 # Return 575 # Return
572 return self._excl_reg_map 576 return self._excl_reg_map
573 577
cscripts/obsutils.py
@@ -815,11 +815,11 @@ def get_onoff_obs(cls, obs, nthreads=0): @@ -815,11 +815,11 @@ def get_onoff_obs(cls, obs, nthreads=0):
815 phagen['debug'] = cls['debug'].boolean() 815 phagen['debug'] = cls['debug'].boolean()
816 phagen['nthreads'] = nthreads 816 phagen['nthreads'] = nthreads
817 817
818 - # Pipe exclusion region map  
819 - if hasattr(cls, 'exclregmap'):  
820 - excl_reg_map = cls.exclregmap()  
821 - if excl_reg_map is not None:  
822 - phagen.exclregmap(excl_reg_map) 818 + # Pipe exclusion map
  819 + if hasattr(cls, 'exclusion_map'):
  820 + exclusion_map = cls.exclusion_map()
  821 + if exclusion_map is not None:
  822 + phagen.exclusion_map(exclusion_map)
823 823
824 # Run csphagen 824 # Run csphagen
825 phagen.run() 825 phagen.run()
doc/source/admin/release_history/1.6.rst
@@ -46,6 +46,9 @@ Improvements @@ -46,6 +46,9 @@ Improvements
46 46
47 * [`2763 <https://cta-redmine.irap.omp.eu/issues/2763>`_] - 47 * [`2763 <https://cta-redmine.irap.omp.eu/issues/2763>`_] -
48 :ref:`ctbkgcube` now requires an input counts cube 48 :ref:`ctbkgcube` now requires an input counts cube
  49 +* [`2725 <https://cta-redmine.irap.omp.eu/issues/2725>`_] -
  50 + Add exclusion_map() methods to :ref:`ctskymap`, :ref:`csphagen`,
  51 + :ref:`cslightcrv` and :ref:`csphasecrv`
49 * [`2714 <https://cta-redmine.irap.omp.eu/issues/2714>`_] - 52 * [`2714 <https://cta-redmine.irap.omp.eu/issues/2714>`_] -
50 Enable :ref:`ctbin` to produce counts cubes for a joint binned analysis. 53 Enable :ref:`ctbin` to produce counts cubes for a joint binned analysis.
51 Rename ``outcube`` to ``outobs`` parameter. 54 Rename ``outcube`` to ``outobs`` parameter.
pyext/ctskymap.i
1 /*************************************************************************** 1 /***************************************************************************
2 * ctskymap - Sky mapping tool * 2 * ctskymap - Sky mapping tool *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2012-2016 by Juergen Knoedlseder * 4 + * copyright (C) 2012-2018 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -48,10 +48,9 @@ public: @@ -48,10 +48,9 @@ public:
48 void run(void); 48 void run(void);
49 void save(void); 49 void save(void);
50 void publish(const std::string& name = ""); 50 void publish(const std::string& name = "");
51 -  
52 - void exclmap(const GSkyMap& exclusionmap);  
53 - const GSkyMap& exclmap(void) const;  
54 const GSkyMap& skymap(void) const; 51 const GSkyMap& skymap(void) const;
  52 + void exclusion_map(const GSkyRegionMap& exclusion_map);
  53 + GSkyRegionMap exclusion_map(void) const;
55 }; 54 };
56 55
57 56
src/ctskymap/ctskymap.cpp
@@ -337,21 +337,6 @@ void ctskymap::publish(const std::string&amp; name) @@ -337,21 +337,6 @@ void ctskymap::publish(const std::string&amp; name)
337 } 337 }
338 338
339 339
340 -/***********************************************************************//**  
341 - * @brief Set the exclusion map  
342 - *  
343 - * @param[in] exclmap Exclusion map object.  
344 - ***************************************************************************/  
345 -void ctskymap::exclmap(const GSkyMap& exclusionmap)  
346 -{  
347 - // Assign exclusion map  
348 - m_exclmap = exclusionmap;  
349 -  
350 - // Return  
351 - return;  
352 -}  
353 -  
354 -  
355 /*========================================================================== 340 /*==========================================================================
356 = = 341 = =
357 = Private methods = 342 = Private methods =
src/ctskymap/ctskymap.hpp
@@ -60,10 +60,9 @@ public: @@ -60,10 +60,9 @@ public:
60 void run(void); 60 void run(void);
61 void save(void); 61 void save(void);
62 void publish(const std::string& name = ""); 62 void publish(const std::string& name = "");
63 -  
64 - void exclmap(const GSkyMap& exclusionmap);  
65 - const GSkyMap& exclmap(void) const;  
66 const GSkyMap& skymap(void) const; 63 const GSkyMap& skymap(void) const;
  64 + void exclusion_map(const GSkyRegionMap& exclusion_map);
  65 + GSkyRegionMap exclusion_map(void) const;
67 66
68 protected: 67 protected:
69 // Protected methods 68 // Protected methods
@@ -135,26 +134,43 @@ protected: @@ -135,26 +134,43 @@ protected:
135 134
136 135
137 /***********************************************************************//** 136 /***********************************************************************//**
138 - * @brief Return exclusion map 137 + * @brief Return observation container
139 * 138 *
140 - * @return Reference to exclusion map 139 + * @return Reference to observation container
141 ***************************************************************************/ 140 ***************************************************************************/
142 inline 141 inline
143 -const GSkyMap& ctskymap::exclmap(void) const 142 +const GSkyMap& ctskymap::skymap(void) const
144 { 143 {
145 - return m_exclmap; 144 + return m_skymap;
146 } 145 }
147 146
148 147
149 /***********************************************************************//** 148 /***********************************************************************//**
150 - * @brief Return observation container 149 + * @brief Set exclusion region map
151 * 150 *
152 - * @return Reference to observation container 151 + * @param[in] exclusion_map Exclusion region map.
153 ***************************************************************************/ 152 ***************************************************************************/
154 inline 153 inline
155 -const GSkyMap& ctskymap::skymap(void) const 154 +void ctskymap::exclusion_map(const GSkyRegionMap& exclusion_map)
156 { 155 {
157 - return m_skymap; 156 + // Assign exclusion map
  157 + m_exclmap = exclusion_map.map();
  158 +
  159 + // Return
  160 + return;
  161 +}
  162 +
  163 +
  164 +/***********************************************************************//**
  165 + * @brief Return exclusion region map
  166 + *
  167 + * @return Exclusion region map
  168 + ***************************************************************************/
  169 +inline
  170 +GSkyRegionMap ctskymap::exclusion_map(void) const
  171 +{
  172 + GSkyRegionMap exclusion_map(m_exclmap);
  173 + return exclusion_map;
158 } 174 }
159 175
160 #endif /* CTSKYMAP_HPP */ 176 #endif /* CTSKYMAP_HPP */