Commit 44348b19c411764accd1a01c7d17af35e6719f72

Authored by Jürgen Knödlseder
1 parent 691026ec

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

ChangeLog
... ... @@ -5,6 +5,8 @@
5 5  
6 6 ctbkgcube now requires an input counts cube (#2763)
7 7 CTA background rates are now per ontime (#2758)
  8 + Add exclusion_map() methods to ctskymap, csphagen, cslightcrv and
  9 + csphasecrv (#2725)
8 10 Apply event bin weighting in ctmodel for stacked computation (#2721)
9 11 Enable ctbin to produce counts cubes for a joint binned analysis (#2714)
10 12 Add ctfindvar tool (#2713)
... ...
... ... @@ -203,6 +203,8 @@ of the input observations (#2054).
203 203  
204 204 ctskymap - CTA sky mapping
205 205 --------------------------
  206 +Add exclusion_map() methods (#2725)
  207 +
206 208 Add the "inmap", "iterations" and "threshold" parameters. The hidden
207 209 "inmap" parameter allows specifying a sky map file containing a "COUNTS"
208 210 and "ACCEPTANCE" extension which avoids looping over event lists in an
... ... @@ -281,6 +283,8 @@ None
281 283  
282 284 cslightcrv - Generate light curve
283 285 ---------------------------------
  286 +Add exclusion_map() methods (#2725)
  287 +
284 288 Add hidden "use_model_bkg" parameter for forwarding to csphagen.
285 289  
286 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 338  
335 339 csphagen - Generate On/Off observations
336 340 ---------------------------------------
  341 +Add exclusion_map() methods (#2725)
  342 +
337 343 A "outmodel" parameter was added and the script now produces an appropriate
338 344 background model for maximum likelihood model fitting. The script now also
339 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 373  
368 374 csphasecrv - Generate phase curve
369 375 ---------------------------------
  376 +Add exclusion_map() methods (#2725)
  377 +
370 378 Add hidden "nthreads" parameter and implement parallelisation of computations
371 379 (#2421).
372 380  
... ...
cscripts/cslightcrv.py
... ... @@ -79,7 +79,7 @@ class cslightcrv(ctools.csobservation):
79 79 self._stacked = False
80 80 self._fits = gammalib.GFits()
81 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 84 # Return
85 85 return
... ... @@ -736,26 +736,30 @@ class cslightcrv(ctools.csobservation):
736 736 # Return
737 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 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 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 763 # Return
760 764 return self._excl_reg_map
761 765  
... ...
cscripts/csphagen.py
... ... @@ -828,29 +828,30 @@ class csphagen(ctools.csobservation):
828 828 # Return
829 829 return
830 830  
831   - def exclregmap(self, regmapobj=None):
  831 + def exclusion_map(self, object):
832 832 """
833   - Access exclusion region map object
  833 + Set exclusion regions map
834 834  
835 835 Parameters
836 836 ----------
837   - regmapobj : `~gammalib.GSkyRegionMap`
838   - Excluded regions region map instance
839   -
840   - Returns
841   - -------
842   - reg : `~gammalib.GSkyRegionMap`
843   - Excluded regions region map instance
  837 + object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename`
  838 + Exclusion regions object
844 839 """
845   - # Check if exclusion map object was provided
846   - if regmapobj is not None:
  840 + # Set exclusion region map
  841 + self._excl_reg = gammalib.GSkyRegionMap(object)
847 842  
848   - # Set exclusion region map
849   - self._excl_reg = gammalib.GSkyRegionMap(regmapobj)
  843 + # Return
  844 + return
850 845  
851   - # Set has exclusion to yes
852   - self._has_exclusion = True
  846 + def exclusion_map(self):
  847 + """
  848 + Get exclusion regions map
853 849  
  850 + Returns
  851 + -------
  852 + region : `~gammalib.GSkyRegionMap`
  853 + Exclusion regions map
  854 + """
854 855 # Return
855 856 return self._excl_reg
856 857  
... ...
cscripts/csphasecrv.py
... ... @@ -69,7 +69,7 @@ class csphasecrv(ctools.csobservation):
69 69 self._fits = gammalib.GFits()
70 70 self._fitmodels = {}
71 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 74 # Return
75 75 return
... ... @@ -548,26 +548,30 @@ class csphasecrv(ctools.csobservation):
548 548 # Return
549 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 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 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 575 # Return
572 576 return self._excl_reg_map
573 577  
... ...
cscripts/obsutils.py
... ... @@ -815,11 +815,11 @@ def get_onoff_obs(cls, obs, nthreads=0):
815 815 phagen['debug'] = cls['debug'].boolean()
816 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 824 # Run csphagen
825 825 phagen.run()
... ...
doc/source/admin/release_history/1.6.rst
... ... @@ -46,6 +46,9 @@ Improvements
46 46  
47 47 * [`2763 <https://cta-redmine.irap.omp.eu/issues/2763>`_] -
48 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 52 * [`2714 <https://cta-redmine.irap.omp.eu/issues/2714>`_] -
50 53 Enable :ref:`ctbin` to produce counts cubes for a joint binned analysis.
51 54 Rename ``outcube`` to ``outobs`` parameter.
... ...
pyext/ctskymap.i
1 1 /***************************************************************************
2 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 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -48,10 +48,9 @@ public:
48 48 void run(void);
49 49 void save(void);
50 50 void publish(const std::string& name = "");
51   -
52   - void exclmap(const GSkyMap& exclusionmap);
53   - const GSkyMap& exclmap(void) const;
54 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 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 342 = Private methods =
... ...
src/ctskymap/ctskymap.hpp
... ... @@ -60,10 +60,9 @@ public:
60 60 void run(void);
61 61 void save(void);
62 62 void publish(const std::string& name = "");
63   -
64   - void exclmap(const GSkyMap& exclusionmap);
65   - const GSkyMap& exclmap(void) const;
66 63 const GSkyMap& skymap(void) const;
  64 + void exclusion_map(const GSkyRegionMap& exclusion_map);
  65 + GSkyRegionMap exclusion_map(void) const;
67 66  
68 67 protected:
69 68 // Protected methods
... ... @@ -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 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 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 176 #endif /* CTSKYMAP_HPP */
... ...