diff --git a/ChangeLog b/ChangeLog index 706dd1d..09398c3 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ ctbkgcube now requires an input counts cube (#2763) CTA background rates are now per ontime (#2758) + Add exclusion_map() methods to ctskymap, csphagen, cslightcrv and + csphasecrv (#2725) Apply event bin weighting in ctmodel for stacked computation (#2721) Enable ctbin to produce counts cubes for a joint binned analysis (#2714) Add ctfindvar tool (#2713) diff --git a/NEWS b/NEWS index 55437be..d93b6e8 100755 --- a/NEWS +++ b/NEWS @@ -203,6 +203,8 @@ of the input observations (#2054). ctskymap - CTA sky mapping -------------------------- +Add exclusion_map() methods (#2725) + Add the "inmap", "iterations" and "threshold" parameters. The hidden "inmap" parameter allows specifying a sky map file containing a "COUNTS" and "ACCEPTANCE" extension which avoids looping over event lists in an @@ -281,6 +283,8 @@ None cslightcrv - Generate light curve --------------------------------- +Add exclusion_map() methods (#2725) + Add hidden "use_model_bkg" parameter for forwarding to csphagen. 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 csphagen - Generate On/Off observations --------------------------------------- +Add exclusion_map() methods (#2725) + A "outmodel" parameter was added and the script now produces an appropriate background model for maximum likelihood model fitting. The script now also sets the appropriate fit statistic depending on the "use_model_bkg" parameter @@ -367,6 +373,8 @@ tutorial was added to the user documentation (#2404). csphasecrv - Generate phase curve --------------------------------- +Add exclusion_map() methods (#2725) + Add hidden "nthreads" parameter and implement parallelisation of computations (#2421). diff --git a/cscripts/cslightcrv.py b/cscripts/cslightcrv.py index 9eb08e0..b43f870 100755 --- a/cscripts/cslightcrv.py +++ b/cscripts/cslightcrv.py @@ -79,7 +79,7 @@ class cslightcrv(ctools.csobservation): self._stacked = False self._fits = gammalib.GFits() self._nthreads = 0 - self._excl_reg_map = None # Exclusion region map for on/off analysis + self._excl_reg_map = None # Exclusion region map for on/off analysis # Return return @@ -736,26 +736,30 @@ class cslightcrv(ctools.csobservation): # Return return - def exclregmap(self, regmapobj=None): + def exclusion_map(self, object): """ - Access exclusion region map object + Set exclusion regions map Parameters ---------- - regmapobj : `~gammalib.GSkyRegionMap` - Excluded regions region map instance + object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename` + Exclusion regions object + """ + # Set exclusion region map + self._excl_reg_map = gammalib.GSkyRegionMap(object) + + # Return + return + + def exclusion_map(self): + """ + Get exclusion regions map Returns ------- - reg : `~gammalib.GSkyRegionMap` - Excluded regions region map instance + region : `~gammalib.GSkyRegionMap` + Exclusion regions map """ - # Check if exclusion map object was provided - if regmapobj is not None: - - # Set exclusion region map - self._excl_reg_map = gammalib.GSkyRegionMap(regmapobj) - # Return return self._excl_reg_map diff --git a/cscripts/csphagen.py b/cscripts/csphagen.py index eb97b0e..2e3742e 100755 --- a/cscripts/csphagen.py +++ b/cscripts/csphagen.py @@ -829,29 +829,30 @@ class csphagen(ctools.csobservation): # Return return - def exclregmap(self, regmapobj=None): + def exclusion_map(self, object): """ - Access exclusion region map object + Set exclusion regions map Parameters ---------- - regmapobj : `~gammalib.GSkyRegionMap` - Excluded regions region map instance - - Returns - ------- - reg : `~gammalib.GSkyRegionMap` - Excluded regions region map instance + object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename` + Exclusion regions object """ - # Check if exclusion map object was provided - if regmapobj is not None: + # Set exclusion region map + self._excl_reg = gammalib.GSkyRegionMap(object) - # Set exclusion region map - self._excl_reg = gammalib.GSkyRegionMap(regmapobj) + # Return + return - # Set has exclusion to yes - self._has_exclusion = True + def exclusion_map(self): + """ + Get exclusion regions map + Returns + ------- + region : `~gammalib.GSkyRegionMap` + Exclusion regions map + """ # Return return self._excl_reg diff --git a/cscripts/csphasecrv.py b/cscripts/csphasecrv.py index a9df906..06b6149 100755 --- a/cscripts/csphasecrv.py +++ b/cscripts/csphasecrv.py @@ -69,7 +69,7 @@ class csphasecrv(ctools.csobservation): self._fits = gammalib.GFits() self._fitmodels = {} self._nthreads = 0 - self._excl_reg_map = None # Exclusion region map for on/off analysis + self._excl_reg_map = None # Exclusion region map for on/off analysis # Return return @@ -548,26 +548,30 @@ class csphasecrv(ctools.csobservation): # Return return self._fitmodels - def exclregmap(self, regmapobj=None): + def exclusion_map(self, object): """ - Access exclusion region map object + Set exclusion regions map Parameters ---------- - regmapobj : `~gammalib.GSkyRegionMap` - Excluded regions region map instance + object : `~gammalib.GSkyRegion` or `~gammalib.GSkyMap` or `~gammalib.GFilename` + Exclusion regions object + """ + # Set exclusion region map + self._excl_reg_map = gammalib.GSkyRegionMap(object) + + # Return + return + + def exclusion_map(self): + """ + Get exclusion regions map Returns ------- - reg : `~gammalib.GSkyRegionMap` - Excluded regions region map instance + region : `~gammalib.GSkyRegionMap` + Exclusion regions map """ - # Check if exclusion map object was provided - if regmapobj is not None: - - # Set exclusion region map - self._excl_reg_map = gammalib.GSkyRegionMap(regmapobj) - # Return return self._excl_reg_map diff --git a/cscripts/obsutils.py b/cscripts/obsutils.py index ce4067d..e9ffc76 100755 --- a/cscripts/obsutils.py +++ b/cscripts/obsutils.py @@ -815,11 +815,11 @@ def get_onoff_obs(cls, obs, nthreads=0): phagen['debug'] = cls['debug'].boolean() phagen['nthreads'] = nthreads - # Pipe exclusion region map - if hasattr(cls, 'exclregmap'): - excl_reg_map = cls.exclregmap() - if excl_reg_map is not None: - phagen.exclregmap(excl_reg_map) + # Pipe exclusion map + if hasattr(cls, 'exclusion_map'): + exclusion_map = cls.exclusion_map() + if exclusion_map is not None: + phagen.exclusion_map(exclusion_map) # Run csphagen phagen.run() diff --git a/doc/source/admin/release_history/1.6.rst b/doc/source/admin/release_history/1.6.rst index a75b110..255e253 100644 --- a/doc/source/admin/release_history/1.6.rst +++ b/doc/source/admin/release_history/1.6.rst @@ -46,6 +46,9 @@ Improvements * [`2763 `_] - :ref:`ctbkgcube` now requires an input counts cube +* [`2725 `_] - + Add exclusion_map() methods to :ref:`ctskymap`, :ref:`csphagen`, + :ref:`cslightcrv` and :ref:`csphasecrv` * [`2714 `_] - Enable :ref:`ctbin` to produce counts cubes for a joint binned analysis. Rename ``outcube`` to ``outobs`` parameter. diff --git a/pyext/ctskymap.i b/pyext/ctskymap.i index b62bf11..158f03e 100755 --- a/pyext/ctskymap.i +++ b/pyext/ctskymap.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctskymap - Sky mapping tool * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2016 by Juergen Knoedlseder * + * copyright (C) 2012-2018 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -48,10 +48,9 @@ public: void run(void); void save(void); void publish(const std::string& name = ""); - - void exclmap(const GSkyMap& exclusionmap); - const GSkyMap& exclmap(void) const; const GSkyMap& skymap(void) const; + void exclusion_map(const GSkyRegionMap& exclusion_map); + GSkyRegionMap exclusion_map(void) const; }; diff --git a/src/ctskymap/ctskymap.cpp b/src/ctskymap/ctskymap.cpp index 1ba2ed6..b05238c 100755 --- a/src/ctskymap/ctskymap.cpp +++ b/src/ctskymap/ctskymap.cpp @@ -337,21 +337,6 @@ void ctskymap::publish(const std::string& name) } -/***********************************************************************//** - * @brief Set the exclusion map - * - * @param[in] exclmap Exclusion map object. - ***************************************************************************/ -void ctskymap::exclmap(const GSkyMap& exclusionmap) -{ - // Assign exclusion map - m_exclmap = exclusionmap; - - // Return - return; -} - - /*========================================================================== = = = Private methods = diff --git a/src/ctskymap/ctskymap.hpp b/src/ctskymap/ctskymap.hpp index d5bdd48..e63ed43 100755 --- a/src/ctskymap/ctskymap.hpp +++ b/src/ctskymap/ctskymap.hpp @@ -60,10 +60,9 @@ public: void run(void); void save(void); void publish(const std::string& name = ""); - - void exclmap(const GSkyMap& exclusionmap); - const GSkyMap& exclmap(void) const; const GSkyMap& skymap(void) const; + void exclusion_map(const GSkyRegionMap& exclusion_map); + GSkyRegionMap exclusion_map(void) const; protected: // Protected methods @@ -135,26 +134,43 @@ protected: /***********************************************************************//** - * @brief Return exclusion map + * @brief Return observation container * - * @return Reference to exclusion map + * @return Reference to observation container ***************************************************************************/ inline -const GSkyMap& ctskymap::exclmap(void) const +const GSkyMap& ctskymap::skymap(void) const { - return m_exclmap; + return m_skymap; } /***********************************************************************//** - * @brief Return observation container + * @brief Set exclusion region map * - * @return Reference to observation container + * @param[in] exclusion_map Exclusion region map. ***************************************************************************/ inline -const GSkyMap& ctskymap::skymap(void) const +void ctskymap::exclusion_map(const GSkyRegionMap& exclusion_map) { - return m_skymap; + // Assign exclusion map + m_exclmap = exclusion_map.map(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Return exclusion region map + * + * @return Exclusion region map + ***************************************************************************/ +inline +GSkyRegionMap ctskymap::exclusion_map(void) const +{ + GSkyRegionMap exclusion_map(m_exclmap); + return exclusion_map; } #endif /* CTSKYMAP_HPP */