From d8b4579bcf469d70a2cd23eecee88d9cbfbf32fa Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Mon, 22 Jan 2018 15:01:44 +0100 Subject: [PATCH] Remove GCTAObservation::obs_id() methods (#1836) --- ChangeLog | 1 + NEWS | 6 +++++- doc/source/admin/release_history/1.5.rst | 2 ++ inst/cta/include/GCTAObservation.hpp | 28 ---------------------------- inst/cta/pyext/GCTAObservation.i | 2 -- inst/cta/src/GCTAObservation.cpp | 25 +++++++++++++------------ inst/cta/test/test_CTA.cpp | 6 +++--- 7 files changed, 24 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index baf2356..738b2df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,7 @@ Add GSkyMap division operator for Python 3.x (#2122) Add time parameter to GApplicationPar class (#1864) Add time string constructor and set method to GTime class (#1864) + Remove GCTAObservation::obs_id() methods (#1836) Use GNdarray to store GSkyMap pixels and add smooth() method (#1729) Use XML support functions in all model classes (#1430) Add GSkyRegionMap class (#1121) diff --git a/NEWS b/NEWS index dc940ae..76b5fe6 100644 --- a/NEWS +++ b/NEWS @@ -90,7 +90,7 @@ The following methods have been added: - GCOMInstDir(GSkyDir&, double&) The following methods have been removed: -- n.a. +- GCTAObservation::obs_id() The following methods have been renamed: - GObservation::statistic() was GObservation::statistics() @@ -288,6 +288,10 @@ Redistribution Matrix File (#2210). The WSTAT statistics was added to GCTAOnOffObservation for maximum likelihood fitting (#2209). +The GCTAObservation::obs_id() methods have been removed since the generic +observation identified string, accessed via the GObservation::id() methods, +will now be used (#1836). + 21. COMPTEL interface --------------------- diff --git a/doc/source/admin/release_history/1.5.rst b/doc/source/admin/release_history/1.5.rst index cde4fb5..f63f962 100644 --- a/doc/source/admin/release_history/1.5.rst +++ b/doc/source/admin/release_history/1.5.rst @@ -98,3 +98,5 @@ Clean up Changed ``GObservation::statistics()`` to ``GObservation::statistic()`` * [`2237 `_] - Use ``CSTAT`` and ``CHI2`` instead of ``POISSON`` and ``GAUSSIAN`` for statistic +* [`1836 `_] - + Remove ``GCTAObservation::obs_id()`` methods diff --git a/inst/cta/include/GCTAObservation.hpp b/inst/cta/include/GCTAObservation.hpp index 8bfcb80..4d1214b 100644 --- a/inst/cta/include/GCTAObservation.hpp +++ b/inst/cta/include/GCTAObservation.hpp @@ -134,8 +134,6 @@ public: GEbounds ebounds(void) const; void object(const std::string& object); const std::string& object(void) const; - void obs_id(const int& id); - const int& obs_id(void) const; void ra_obj(const double& ra); const double& ra_obj(void) const; void dec_obj(const double& dec); @@ -166,7 +164,6 @@ protected: GCTAResponse* m_response; //!< Pointer to instrument response functions GCTAPointing m_pointing; //!< Pointing direction GSkyRegions m_off_regions; //!< Off regions - int m_obs_id; //!< Observation ID double m_ontime; //!< Ontime (seconds) double m_livetime; //!< Livetime (seconds) double m_deadc; //!< Deadtime correction (livetime/ontime) @@ -351,31 +348,6 @@ const std::string& GCTAObservation::object(void) const /***********************************************************************//** - * @brief Set CTA observation identifier - * - * @param[in] id Observation identifier. - ***************************************************************************/ -inline -void GCTAObservation::obs_id(const int& id) -{ - m_obs_id = id; - return; -} - - -/***********************************************************************//** - * @brief Return CTA observation identifier - * - * @return Observation identifier. - ***************************************************************************/ -inline -const int& GCTAObservation::obs_id(void) const -{ - return m_obs_id; -} - - -/***********************************************************************//** * @brief Set CTA object Right Ascension * * @param[in] ra Object Right Ascension. diff --git a/inst/cta/pyext/GCTAObservation.i b/inst/cta/pyext/GCTAObservation.i index 2183416..b808eea 100644 --- a/inst/cta/pyext/GCTAObservation.i +++ b/inst/cta/pyext/GCTAObservation.i @@ -101,8 +101,6 @@ public: GEbounds ebounds(void) const; void object(const std::string& object); const std::string& object(void) const; - void obs_id(const int& id); - const int& obs_id(void) const; void ra_obj(const double& ra); const double& ra_obj(void) const; void dec_obj(const double& dec); diff --git a/inst/cta/src/GCTAObservation.cpp b/inst/cta/src/GCTAObservation.cpp index bc4b5c6..f2f8de6 100644 --- a/inst/cta/src/GCTAObservation.cpp +++ b/inst/cta/src/GCTAObservation.cpp @@ -1532,7 +1532,6 @@ void GCTAObservation::init_members(void) m_response = NULL; m_pointing.clear(); m_off_regions.clear(); - m_obs_id = 0; m_ontime = 0.0; m_livetime = 0.0; m_deadc = 1.0; @@ -1561,7 +1560,6 @@ void GCTAObservation::copy_members(const GCTAObservation& obs) m_bgdfile = obs.m_bgdfile; m_pointing = obs.m_pointing; m_off_regions = obs.m_off_regions; - m_obs_id = obs.m_obs_id; m_ontime = obs.m_ontime; m_livetime = obs.m_livetime; m_deadc = obs.m_deadc; @@ -1635,15 +1633,18 @@ void GCTAObservation::read_attributes(const GFitsHDU& hdu) m_livetime = (hdu.has_card("LIVETIME")) ? hdu.real("LIVETIME") : 0.0; // Read optional attributes - m_object = (hdu.has_card("OBJECT")) ? hdu.string("OBJECT") : "unknown"; - m_deadc = (hdu.has_card("DEADC")) ? hdu.real("DEADC") : 0.0; - m_ra_obj = (hdu.has_card("RA_OBJ")) ? hdu.real("RA_OBJ") : 0.0; - m_dec_obj = (hdu.has_card("DEC_OBJ")) ? hdu.real("DEC_OBJ") : 0.0; - m_obs_id = (hdu.has_card("OBS_ID")) ? hdu.integer("OBS_ID") : 0; - double alt = (hdu.has_card("ALT_PNT")) ? hdu.real("ALT_PNT") : 0.0; - double az = (hdu.has_card("AZ_PNT")) ? hdu.real("AZ_PNT") : 0.0; - m_instrument = (hdu.has_card("TELESCOP")) ? hdu.string("TELESCOP") : "CTA"; - m_n_tels = (hdu.has_card("N_TELS")) ? hdu.integer("N_TELS") : 0; + m_object = (hdu.has_card("OBJECT")) ? hdu.string("OBJECT") : "unknown"; + m_deadc = (hdu.has_card("DEADC")) ? hdu.real("DEADC") : 0.0; + m_ra_obj = (hdu.has_card("RA_OBJ")) ? hdu.real("RA_OBJ") : 0.0; + m_dec_obj = (hdu.has_card("DEC_OBJ")) ? hdu.real("DEC_OBJ") : 0.0; + std::string id = (hdu.has_card("OBS_ID")) ? hdu.string("OBS_ID") : ""; + double alt = (hdu.has_card("ALT_PNT")) ? hdu.real("ALT_PNT") : 0.0; + double az = (hdu.has_card("AZ_PNT")) ? hdu.real("AZ_PNT") : 0.0; + m_instrument = (hdu.has_card("TELESCOP")) ? hdu.string("TELESCOP") : "CTA"; + m_n_tels = (hdu.has_card("N_TELS")) ? hdu.integer("N_TELS") : 0; + + // Set attributes + this->id(id); // Kluge: compute DEADC from livetime and ontime instead of using the // keyword value as the original event lists had this values badly @@ -1698,7 +1699,7 @@ void GCTAObservation::write_attributes(GFitsHDU& hdu) const // Set observation information hdu.card("CREATOR", "GammaLib", "Program which created the file"); hdu.card("TELESCOP", instrument(), "Telescope"); - hdu.card("OBS_ID", obs_id(), "Observation identifier"); + hdu.card("OBS_ID", id(), "Observation identifier"); hdu.card("DATE-OBS", date_obs, "Observation start date"); hdu.card("TIME-OBS", time_obs, "Observation start time"); hdu.card("DATE-END", date_end, "Observation end date"); diff --git a/inst/cta/test/test_CTA.cpp b/inst/cta/test/test_CTA.cpp index ceb1247..628fc79 100644 --- a/inst/cta/test/test_CTA.cpp +++ b/inst/cta/test/test_CTA.cpp @@ -1778,7 +1778,7 @@ void TestGCTAObservation::test_unbinned_obs(void) test_value(run.deadc(), 0.95); test_value(run.ra_obj(), 0.0); test_value(run.dec_obj(), 0.0); - test_value(run.obs_id(), 0); + test_value(run.id(), "0"); test_value(run.pointing().dir().ra_deg(), 83.63); test_value(run.pointing().dir().dec_deg(), 22.01); test_try_success(); @@ -1804,7 +1804,7 @@ void TestGCTAObservation::test_unbinned_obs(void) test_value(run.deadc(), 0.95); test_value(run.ra_obj(), 0.0); test_value(run.dec_obj(), 0.0); - test_value(run.obs_id(), 0); + test_value(run.id(), "0"); test_value(run.pointing().dir().ra_deg(), 83.63); test_value(run.pointing().dir().dec_deg(), 22.01); test_try_success(); @@ -1852,7 +1852,7 @@ void TestGCTAObservation::test_unbinned_obs(void) test_value(run->deadc(), 0.95); test_value(run->ra_obj(), 0.0); test_value(run->dec_obj(), 0.0); - test_value(run->obs_id(), 0); + test_value(run->id(), "00001"); test_value(run->pointing().dir().ra_deg(), 83.63); test_value(run->pointing().dir().dec_deg(), 22.01); test_try_success(); -- libgit2 0.21.4