Commit 32ac1d96a7f31b15b1a9c1a3e2dcb98df39b1e75
1 parent
fe04f866
Add Off sky regions to GCTAObservation (#2284)
Showing
7 changed files
with
96 additions
and
10 deletions
ChangeLog
| 1 | -2018-01-09 | |
| 1 | +2018-01-12 | |
| 2 | 2 | |
| 3 | 3 | * Version 1.5.0 released |
| 4 | 4 | ========================= |
| 5 | 5 | |
| 6 | - Set reference time to CTA reference time in GCTAEventcube, GCTAEventList and GCTACubeExposure (#2295) | |
| 6 | + Set reference time to CTA reference time in GCTAEventcube, GCTAEventList and | |
| 7 | + GCTACubeExposure (#2295) | |
| 7 | 8 | Add GPha::counts_spectrum() and GPha::backscal_spectrum() methods (#2290) |
| 8 | 9 | Add GNdarray sign(), operator*= and operator/= (#2290) |
| 9 | 10 | Add GSkyMap::counts() and GSkyMap::flux() methods and clip() friend operator (#2290) |
| 10 | 11 | Add GSkyMap::array() method to Python interface (#2285) |
| 12 | + Add Off sky regions to GCTAObservation (#2284) | |
| 11 | 13 | CTA observations handle "statistic" attribute in XML file (#2238) |
| 12 | 14 | Use CSTAT and CHI2 instead of POISSON and GAUSSIAN for statistic (#2237) |
| 13 | 15 | Changed GObservation::statistics() to statistic() (#2238) | ... | ... |
NEWS
| 1 | 1 | New Features and Important Changes in GammaLib 1.5.0 |
| 2 | 2 | |
| 3 | -9 January 2018 | |
| 3 | +12 January 2018 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | 1. Introduction |
| ... | ... | @@ -83,6 +83,8 @@ The following methods have been added: |
| 83 | 83 | - operator*(GRmf&, double&) |
| 84 | 84 | - operator*(double&, double&) |
| 85 | 85 | - operator/(GRmf&, double&) |
| 86 | +- GCTAObservation::off_regions(GSkyRegions&) | |
| 87 | +- GCTAObservation::off_regions() | |
| 86 | 88 | - GCTAOnOffObservation(GObservations&) |
| 87 | 89 | - GCTAOnOffObservation(GPha&, GPha&, GArf&, GRmf&) |
| 88 | 90 | - GCOMInstDir(GSkyDir&, double&) |
| ... | ... | @@ -246,6 +248,11 @@ also position fitting is now possible for Fermi-LAT (#604, #2183). |
| 246 | 248 | Set the Good Time Interval time reference to the CTA time reference in |
| 247 | 249 | GCTAEventList, GCTAEventCube and GCTACubeExposure (#2295). |
| 248 | 250 | |
| 251 | +Add Off sky regions attribute to the GCTAObservation class. The Off sky regions | |
| 252 | +can be set and accessed using the GCTAObservation::off_regions() method. The | |
| 253 | +Off regions filename is also read from and written into the observation | |
| 254 | +definition XML file (#2284). | |
| 255 | + | |
| 249 | 256 | GCTAObservation and GCTAOnOffObservation handle statistic attribute in XML |
| 250 | 257 | file (#2238). |
| 251 | 258 | ... | ... |
doc/source/admin/release_history/1.5.rst
| ... | ... | @@ -39,6 +39,8 @@ Improvements |
| 39 | 39 | and ``GPha::counts_spectrum()`` and ``GPha::backscal_spectrum()`` methods |
| 40 | 40 | * [`2285 <https://cta-redmine.irap.omp.eu/issues/2285>`_] - |
| 41 | 41 | Add ``GSkyMap::array()`` method to Python interface |
| 42 | +* [`2284 <https://cta-redmine.irap.omp.eu/issues/2284>`_] - | |
| 43 | + Add Off sky regions to ``GCTAObservation`` | |
| 42 | 44 | * [`2238 <https://cta-redmine.irap.omp.eu/issues/2238>`_] - |
| 43 | 45 | ``GCTAObservation`` and ``GCTAOnOffObservation`` handle ``statistic`` attribute in XML file |
| 44 | 46 | * [`2231 <https://cta-redmine.irap.omp.eu/issues/2231>`_] - | ... | ... |
inst/cta/include/GCTAObservation.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCTAObservation.hpp - CTA Observation class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -31,6 +31,7 @@ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include "GFilename.hpp" |
| 33 | 33 | #include "GObservation.hpp" |
| 34 | +#include "GSkyRegions.hpp" | |
| 34 | 35 | #include "GCTAResponse.hpp" |
| 35 | 36 | #include "GCTAPointing.hpp" |
| 36 | 37 | #include "GCTAEventList.hpp" |
| ... | ... | @@ -126,6 +127,8 @@ public: |
| 126 | 127 | const GCTACubeBackground& bkgcube); |
| 127 | 128 | void pointing(const GCTAPointing& pointing); |
| 128 | 129 | const GCTAPointing& pointing(void) const; |
| 130 | + void off_regions(const GSkyRegions& off_regions); | |
| 131 | + const GSkyRegions& off_regions(void) const; | |
| 129 | 132 | GCTARoi roi(void) const; |
| 130 | 133 | GGti gti(void) const; |
| 131 | 134 | GEbounds ebounds(void) const; |
| ... | ... | @@ -162,6 +165,7 @@ protected: |
| 162 | 165 | GFilename m_eventfile; //!< Event filename |
| 163 | 166 | GCTAResponse* m_response; //!< Pointer to instrument response functions |
| 164 | 167 | GCTAPointing m_pointing; //!< Pointing direction |
| 168 | + GSkyRegions m_off_regions; //!< Off regions | |
| 165 | 169 | int m_obs_id; //!< Observation ID |
| 166 | 170 | double m_ontime; //!< Ontime (seconds) |
| 167 | 171 | double m_livetime; //!< Livetime (seconds) |
| ... | ... | @@ -297,6 +301,31 @@ void GCTAObservation::pointing(const GCTAPointing& pointing) |
| 297 | 301 | |
| 298 | 302 | |
| 299 | 303 | /***********************************************************************//** |
| 304 | + * @brief Return sky off regions | |
| 305 | + * | |
| 306 | + * @return Sky off regions | |
| 307 | + ***************************************************************************/ | |
| 308 | +inline | |
| 309 | +const GSkyRegions& GCTAObservation::off_regions(void) const | |
| 310 | +{ | |
| 311 | + return m_off_regions; | |
| 312 | +} | |
| 313 | + | |
| 314 | + | |
| 315 | +/***********************************************************************//** | |
| 316 | + * @brief Set sky off regions | |
| 317 | + * | |
| 318 | + * @param[in] off_regions Sky off regions. | |
| 319 | + ***************************************************************************/ | |
| 320 | +inline | |
| 321 | +void GCTAObservation::off_regions(const GSkyRegions& off_regions) | |
| 322 | +{ | |
| 323 | + m_off_regions = off_regions; | |
| 324 | + return; | |
| 325 | +} | |
| 326 | + | |
| 327 | + | |
| 328 | +/***********************************************************************//** | |
| 300 | 329 | * @brief Set CTA observation object name |
| 301 | 330 | * |
| 302 | 331 | * @param[in] object Object name. | ... | ... |
inst/cta/pyext/GCTAObservation.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCTAObservation.i - CTA Observation class interface * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -94,6 +94,8 @@ public: |
| 94 | 94 | const GCTACubeBackground& bkgcube); |
| 95 | 95 | void pointing(const GCTAPointing& pointing); |
| 96 | 96 | const GCTAPointing& pointing(void) const; |
| 97 | + void off_regions(const GSkyRegions& off_regions); | |
| 98 | + const GSkyRegions& off_regions(void) const; | |
| 97 | 99 | GCTARoi roi(void) const; |
| 98 | 100 | GGti gti(void) const; |
| 99 | 101 | GEbounds ebounds(void) const; | ... | ... |
inst/cta/src/GCTAObservation.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCTAObservation.cpp - CTA Observation class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -728,6 +728,18 @@ void GCTAObservation::read(const GXmlElement& xml) |
| 728 | 728 | |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | + // Read Off regions | |
| 732 | + else if (par->attribute("name") == "OffRegions") { | |
| 733 | + | |
| 734 | + // Read off regions file name | |
| 735 | + std::string filename = gammalib::xml_file_expand(xml, | |
| 736 | + par->attribute("file")); | |
| 737 | + | |
| 738 | + // Load off regions | |
| 739 | + m_off_regions = GSkyRegions(filename); | |
| 740 | + | |
| 741 | + } | |
| 742 | + | |
| 731 | 743 | } // endfor: looped over observation parameters |
| 732 | 744 | |
| 733 | 745 | // Analyse parameters |
| ... | ... | @@ -1016,6 +1028,13 @@ void GCTAObservation::write(GXmlElement& xml) const |
| 1016 | 1028 | m_response->write(xml); |
| 1017 | 1029 | } |
| 1018 | 1030 | |
| 1031 | + // Write Off regions filename | |
| 1032 | + if (!m_off_regions.filename().is_empty()) { | |
| 1033 | + GXmlElement* par = gammalib::xml_need_par(G_WRITE, xml, "OffRegions"); | |
| 1034 | + par->attribute("file", gammalib::xml_file_reduce(xml, | |
| 1035 | + m_off_regions.filename().url())); | |
| 1036 | + } | |
| 1037 | + | |
| 1019 | 1038 | // Return |
| 1020 | 1039 | return; |
| 1021 | 1040 | } |
| ... | ... | @@ -1509,6 +1528,7 @@ void GCTAObservation::init_members(void) |
| 1509 | 1528 | m_bgdfile.clear(); |
| 1510 | 1529 | m_response = NULL; |
| 1511 | 1530 | m_pointing.clear(); |
| 1531 | + m_off_regions.clear(); | |
| 1512 | 1532 | m_obs_id = 0; |
| 1513 | 1533 | m_ontime = 0.0; |
| 1514 | 1534 | m_livetime = 0.0; |
| ... | ... | @@ -1537,6 +1557,7 @@ void GCTAObservation::copy_members(const GCTAObservation& obs) |
| 1537 | 1557 | m_eventfile = obs.m_eventfile; |
| 1538 | 1558 | m_bgdfile = obs.m_bgdfile; |
| 1539 | 1559 | m_pointing = obs.m_pointing; |
| 1560 | + m_off_regions = obs.m_off_regions; | |
| 1540 | 1561 | m_obs_id = obs.m_obs_id; |
| 1541 | 1562 | m_ontime = obs.m_ontime; |
| 1542 | 1563 | m_livetime = obs.m_livetime; | ... | ... |
inst/cta/test/test_CTA.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * test_CTA.cpp - Test CTA classes * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -82,6 +82,7 @@ const std::string cta_stacked_bkgcube = datadir+"/stacked_bkgcube.fits"; |
| 82 | 82 | /* __ Test files for On/Off analysis _____________________________________ */ |
| 83 | 83 | const std::string cta_onoff_obs = datadir+"/onoff_obs.xml"; |
| 84 | 84 | const std::string cta_onoff_model = datadir+"/onoff_model.xml"; |
| 85 | +const std::string cta_onoff_onreg = datadir+"/onoff_region_on.reg"; | |
| 85 | 86 | |
| 86 | 87 | |
| 87 | 88 | /***********************************************************************//** |
| ... | ... | @@ -2000,18 +2001,40 @@ void TestGCTAObservation::test_stacked_obs(void) |
| 2000 | 2001 | |
| 2001 | 2002 | /***********************************************************************//** |
| 2002 | 2003 | * @brief Test On/Off observation handling |
| 2003 | - * | |
| 2004 | - * @todo Unit test to be implemented | |
| 2005 | 2004 | ***************************************************************************/ |
| 2006 | 2005 | void TestGCTAObservation::test_onoff_obs(void) |
| 2007 | 2006 | { |
| 2008 | 2007 | // Load On/Off observation into container |
| 2009 | 2008 | GObservations obs(cta_onoff_obs); |
| 2010 | - //std::cout << *(obs[0]) << std::endl; | |
| 2011 | 2009 | |
| 2012 | 2010 | // Save observation container into XML file |
| 2013 | 2011 | obs.save("test_cta_onoff_obs.xml"); |
| 2014 | 2012 | |
| 2013 | + // Load CTA observations | |
| 2014 | + obs.load(cta_unbin_xml); | |
| 2015 | + | |
| 2016 | + // Setup sky regions | |
| 2017 | + GSkyRegions regions(cta_onoff_onreg); | |
| 2018 | + | |
| 2019 | + // Set and check regions | |
| 2020 | + for (int i = 0; i < obs.size(); ++i) { | |
| 2021 | + static_cast<GCTAObservation*>(obs[i])->off_regions(regions); | |
| 2022 | + test_value(static_cast<const GCTAObservation*>(obs[i])->off_regions().size(), | |
| 2023 | + 1, "Check number of sky regions"); | |
| 2024 | + } | |
| 2025 | + | |
| 2026 | + // Save observation container into XML file | |
| 2027 | + obs.save("test_cta_onoff_obs_regions.xml"); | |
| 2028 | + | |
| 2029 | + // Re-load observation container and check regions | |
| 2030 | + obs.load("test_cta_onoff_obs_regions.xml"); | |
| 2031 | + | |
| 2032 | + // Check regions | |
| 2033 | + for (int i = 0; i < obs.size(); ++i) { | |
| 2034 | + test_value(static_cast<const GCTAObservation*>(obs[i])->off_regions().size(), | |
| 2035 | + 1, "Check number of sky regions"); | |
| 2036 | + } | |
| 2037 | + | |
| 2015 | 2038 | // Return |
| 2016 | 2039 | return; |
| 2017 | 2040 | } | ... | ... |