From 148a99f98e6eca34d289036b63c433ddfb185602 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 25 Jul 2014 00:14:04 +0200 Subject: [PATCH] Clean-up public method interface. --- ChangeLog | 3 ++- NEWS | 8 +++++++- pyext/ctcubemask.i | 12 +++++------- pyext/ctexpcube.i | 11 +++++------ pyext/ctlike.i | 14 ++++++-------- pyext/ctmodel.i | 13 +++++-------- pyext/ctobssim.i | 18 +++++++----------- pyext/ctpsfcube.i | 16 +++++----------- pyext/ctselect.i | 14 ++++++-------- pyext/ctskymap.i | 6 +----- src/ctcubemask/ctcubemask.hpp | 26 +++++++++++++++++++------- src/ctexpcube/ctexpcube.hpp | 23 +++++------------------ src/ctlike/ctlike.hpp | 48 ++++++++++++++++++++++++++++++++++++------------ src/ctmodel/ctmodel.hpp | 28 ++++++++++++++++++++-------- src/ctobssim/ctobssim.hpp | 36 +++++++++++++++++++++++++++--------- src/ctpsfcube/ctpsfcube.hpp | 39 +++++++++++++-------------------------- src/ctselect/ctselect.hpp | 28 ++++++++++++++++++++-------- src/ctskymap/ctskymap.hpp | 24 +++++++++++++++++------- 18 files changed, 206 insertions(+), 161 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c58826..bea564e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2014-07-22 Juergen Knoedlseder +2014-07-24 Juergen Knoedlseder * Version 0.8.0 released ======================== + Clean-up public interface Adapt to GammaLib 0.9.0 interface ctbin now always merges event lists into a single counts cube Add ctexpcube tool (generates exposure cube) diff --git a/NEWS b/NEWS index 83ca9c1..394068e 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 00-08-00 Author(s) : Juergen Knoedlseder -22 July 2014 +24 July 2014 1. Introduction @@ -10,6 +10,12 @@ Author(s) : Juergen Knoedlseder This document briefly summarizes executable by executable the most important changes made since the last release of ctools. +For all ctools, the public method interface was cleaned up so that +only methods that are really useful for an outside client are +exposed. Low-level methods that are used by the application are now +protected, as improper usage of these methods may lead to +unpredictable results. + 2. Configuration ----------------- diff --git a/pyext/ctcubemask.i b/pyext/ctcubemask.i index 1ac086b..2d87e68 100644 --- a/pyext/ctcubemask.i +++ b/pyext/ctcubemask.i @@ -45,13 +45,11 @@ public: virtual ~ctcubemask(void); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void); - void get_parameters(void); - void apply_mask(GCTAObservation* obs); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; }; diff --git a/pyext/ctexpcube.i b/pyext/ctexpcube.i index 43841e6..927e15a 100644 --- a/pyext/ctexpcube.i +++ b/pyext/ctexpcube.i @@ -46,12 +46,11 @@ public: virtual ~ctexpcube(void); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - const GObservations& obs(void) const; - const GCTAExposure& expcube(void) const; + void clear(void); + void execute(void); + void run(void); + void save(void); + const GCTAExposure& expcube(void) const; }; diff --git a/pyext/ctlike.i b/pyext/ctlike.i index 791439b..8e2bcf7 100644 --- a/pyext/ctlike.i +++ b/pyext/ctlike.i @@ -46,14 +46,12 @@ public: virtual ~ctlike(void); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void); - GOptimizer* opt(void); - void get_parameters(void); - void optimize_lm(void); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; + const GOptimizer* opt(void) const; }; diff --git a/pyext/ctmodel.i b/pyext/ctmodel.i index 3c41ccc..c6c33b7 100644 --- a/pyext/ctmodel.i +++ b/pyext/ctmodel.i @@ -46,14 +46,11 @@ public: virtual ~ctmodel(void); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void) { return m_obs; } - void get_parameters(void); - void setup_obs(void); - void model_map(GCTAObservation* obs, const GModels& models); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; }; diff --git a/pyext/ctobssim.i b/pyext/ctobssim.i index 25f0843..fee00cc 100644 --- a/pyext/ctobssim.i +++ b/pyext/ctobssim.i @@ -1,7 +1,7 @@ /*************************************************************************** * ctobssim - CTA observation simulation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2014 by Jurgen Knodlseder * + * copyright (C) 2011-2014 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -21,7 +21,7 @@ /** * @file ctobssim.i * @brief CTA observation simulation tool Python interface definition - * @author J. Knodlseder + * @author Juergen Knoedlseder */ %{ /* Put headers and other declarations here that are needed for compilation */ @@ -45,15 +45,11 @@ public: virtual ~ctobssim(void); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void); - void get_parameters(void); - void set_list(GCTAObservation* obs); - void simulate_source(GCTAObservation* obs, const GModels& models, GRan& ran, GLog* wrklog=NULL); - void simulate_background(GCTAObservation* obs, const GModels& models, GRan& ran, GLog* wrklog=NULL); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; }; diff --git a/pyext/ctpsfcube.i b/pyext/ctpsfcube.i index a7a1bcb..a4729f4 100644 --- a/pyext/ctpsfcube.i +++ b/pyext/ctpsfcube.i @@ -46,17 +46,11 @@ public: virtual ~ctpsfcube(void); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - const GObservations& obs(void) const; - const GCTAMeanPsf& psfcube(void) const; - void get_parameters(void); - void get_obs(void); - void set_response(void); - void get_ebounds(void); - void set_from_cntmap(const std::string& filename); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GCTAMeanPsf& psfcube(void) const; }; /***********************************************************************//** diff --git a/pyext/ctselect.i b/pyext/ctselect.i index 0024bdf..51f7171 100644 --- a/pyext/ctselect.i +++ b/pyext/ctselect.i @@ -21,7 +21,7 @@ /** * @file ctselect.i * @brief CTA data selection tool Python interface definition - * @author J. Knodlseder + * @author Juergen Knoedlseder */ %{ /* Put headers and other declarations here that are needed for compilation */ @@ -45,13 +45,11 @@ public: virtual ~ctselect(void); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void) { return m_obs; } - void get_parameters(void); - void select_events(GCTAObservation* obs, const std::string& filename); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; }; diff --git a/pyext/ctskymap.i b/pyext/ctskymap.i index fd27f2b..0e75935 100644 --- a/pyext/ctskymap.i +++ b/pyext/ctskymap.i @@ -49,11 +49,7 @@ public: void execute(void); void run(void); void save(void); - GObservations& obs(void); - GSkymap& skymap(void); - void get_parameters(void); - void init_map(GCTAObservation* obs); - void map_events(GCTAObservation* obs); + const GSkymap& map(void) const; }; diff --git a/src/ctcubemask/ctcubemask.hpp b/src/ctcubemask/ctcubemask.hpp index 6847cb7..a6d725b 100644 --- a/src/ctcubemask/ctcubemask.hpp +++ b/src/ctcubemask/ctcubemask.hpp @@ -56,19 +56,19 @@ public: ctcubemask& operator=(const ctcubemask& app); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void) { return m_obs; } - void get_parameters(void); - void apply_mask(GCTAObservation* obs); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; protected: // Protected methods void init_members(void); void copy_members(const ctcubemask& app); void free_members(void); + void get_parameters(void); + void apply_mask(GCTAObservation* obs); std::string check_infile(const std::string& filename) const; std::string set_outfile_name(const std::string& filename) const; void save_fits(void); @@ -95,4 +95,16 @@ protected: bool m_read_ahead; //!< Read ahead parameters }; + +/***********************************************************************//** + * @brief Return observation container + * + * @return Reference to observation container + ***************************************************************************/ +inline +const GObservations& ctcubemask::obs(void) const +{ + return m_obs; +} + #endif /* CTCUBEMASK_HPP */ diff --git a/src/ctexpcube/ctexpcube.hpp b/src/ctexpcube/ctexpcube.hpp index 0432f79..9a074d3 100644 --- a/src/ctexpcube/ctexpcube.hpp +++ b/src/ctexpcube/ctexpcube.hpp @@ -55,12 +55,11 @@ public: ctexpcube& operator=(const ctexpcube& app); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - const GObservations& obs(void) const; - const GCTAExposure& expcube(void) const; + void clear(void); + void execute(void); + void run(void); + void save(void); + const GCTAExposure& expcube(void) const; protected: // Protected methods @@ -86,18 +85,6 @@ protected: /***********************************************************************//** - * @brief Return observation container - * - * @return Observation container - ***************************************************************************/ -inline -const GObservations& ctexpcube::obs(void) const -{ - return (m_obs); -} - - -/***********************************************************************//** * @brief Return exposure cube * * @return Exposure cube diff --git a/src/ctlike/ctlike.hpp b/src/ctlike/ctlike.hpp index 1642a8e..e3eb366 100644 --- a/src/ctlike/ctlike.hpp +++ b/src/ctlike/ctlike.hpp @@ -55,21 +55,21 @@ public: ctlike& operator= (const ctlike& app); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void) { return m_obs; } - GOptimizer* opt(void) { return m_opt; } - void get_parameters(void); - void optimize_lm(void); - double reoptimize_lm(void); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; + const GOptimizer* opt(void) const; protected: // Protected methods - void init_members(void); - void copy_members(const ctlike& app); - void free_members(void); + void init_members(void); + void copy_members(const ctlike& app); + void free_members(void); + void get_parameters(void); + void optimize_lm(void); + double reoptimize_lm(void); // User parameters std::string m_stat; //!< Optimisation statistics (poisson/gaussian) @@ -89,4 +89,28 @@ protected: bool m_read_ahead; //!< Read ahead parameters }; + +/***********************************************************************//** + * @brief Return observation container + * + * @return Reference to observation container + ***************************************************************************/ +inline +const GObservations& ctlike::obs(void) const +{ + return m_obs; +} + + +/***********************************************************************//** + * @brief Return optimizer + * + * @return Pointer to optimizer + ***************************************************************************/ +inline +const GOptimizer* ctlike::opt(void) const +{ + return m_opt; +} + #endif /* CTLIKE_HPP */ diff --git a/src/ctmodel/ctmodel.hpp b/src/ctmodel/ctmodel.hpp index e7d0cc3..88b2cea 100644 --- a/src/ctmodel/ctmodel.hpp +++ b/src/ctmodel/ctmodel.hpp @@ -64,20 +64,20 @@ public: ctmodel& operator=(const ctmodel& app); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void) { return m_obs; } - void get_parameters(void); - void setup_obs(void); - void model_map(GCTAObservation* obs, const GModels& models); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; protected: // Protected methods void init_members(void); void copy_members(const ctmodel& app); void free_members(void); + void get_parameters(void); + void setup_obs(void); + void model_map(GCTAObservation* obs, const GModels& models); std::string set_outfile_name(const std::string& filename) const; void save_fits(void); void save_xml(void); @@ -115,4 +115,16 @@ protected: bool m_read_ahead; //!< Read ahead parameters }; + +/***********************************************************************//** + * @brief Return observation container + * + * @return Reference to observation container + ***************************************************************************/ +inline +const GObservations& ctmodel::obs(void) const +{ + return m_obs; +} + #endif /* CTMODEL_HPP */ diff --git a/src/ctobssim/ctobssim.hpp b/src/ctobssim/ctobssim.hpp index 1dee2f7..9ff8210 100644 --- a/src/ctobssim/ctobssim.hpp +++ b/src/ctobssim/ctobssim.hpp @@ -60,21 +60,27 @@ public: ctobssim& operator=(const ctobssim& app); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void) { return m_obs; } - void get_parameters(void); - void set_list(GCTAObservation* obs); - void simulate_source(GCTAObservation* obs, const GModels& models,GRan& ran, GLog* wrklog=NULL); - void simulate_background(GCTAObservation* obs, const GModels& models,GRan& ran, GLog* wrklog=NULL); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; protected: // Protected methods void init_members(void); void copy_members(const ctobssim& app); void free_members(void); + void get_parameters(void); + void set_list(GCTAObservation* obs); + void simulate_source(GCTAObservation* obs, + const GModels& models, + GRan& ran, + GLog* wrklog = NULL); + void simulate_background(GCTAObservation* obs, + const GModels& models, + GRan& ran, + GLog* wrklog = NULL); void save_fits(void); void save_xml(void); @@ -106,4 +112,16 @@ protected: int m_event_id; //!< Event identifier }; + +/***********************************************************************//** + * @brief Return observation container + * + * @return Reference to observation container + ***************************************************************************/ +inline +const GObservations& ctobssim::obs(void) const +{ + return m_obs; +} + #endif /* CTOBSSIM_HPP */ diff --git a/src/ctpsfcube/ctpsfcube.hpp b/src/ctpsfcube/ctpsfcube.hpp index f51a3be..c1919f3 100644 --- a/src/ctpsfcube/ctpsfcube.hpp +++ b/src/ctpsfcube/ctpsfcube.hpp @@ -55,23 +55,22 @@ public: ctpsfcube& operator=(const ctpsfcube& app); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - const GObservations& obs(void) const; - const GCTAMeanPsf& psfcube(void) const; - void get_parameters(void); - void get_obs(void); - void set_response(void); - void get_ebounds(void); - void set_from_cntmap(const std::string& filename); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GCTAMeanPsf& psfcube(void) const; protected: // Protected methods - void init_members(void); - void copy_members(const ctpsfcube& app); - void free_members(void); + void init_members(void); + void copy_members(const ctpsfcube& app); + void free_members(void); + void get_parameters(void); + void get_obs(void); + void set_response(void); + void get_ebounds(void); + void set_from_cntmap(const std::string& filename); // User parameters std::string m_outfile; //!< Output PSF cube file @@ -86,18 +85,6 @@ protected: /***********************************************************************//** - * @brief Return observation container - * - * @return Observation container - ***************************************************************************/ -inline -const GObservations& ctpsfcube::obs(void) const -{ - return (m_obs); -} - - -/***********************************************************************//** * @brief Return PSF cube * * @return PSF cube diff --git a/src/ctselect/ctselect.hpp b/src/ctselect/ctselect.hpp index 800b2e2..172bf25 100644 --- a/src/ctselect/ctselect.hpp +++ b/src/ctselect/ctselect.hpp @@ -53,22 +53,22 @@ public: virtual ~ctselect(void); // Operators - ctselect& operator= (const ctselect& app); + ctselect& operator=(const ctselect& app); // Methods - void clear(void); - void execute(void); - void run(void); - void save(void); - GObservations& obs(void) { return m_obs; } - void get_parameters(void); - void select_events(GCTAObservation* obs, const std::string& filename); + void clear(void); + void execute(void); + void run(void); + void save(void); + const GObservations& obs(void) const; protected: // Protected methods void init_members(void); void copy_members(const ctselect& app); void free_members(void); + void get_parameters(void); + void select_events(GCTAObservation* obs, const std::string& filename); std::string check_infile(const std::string& filename) const; std::string set_outfile_name(const std::string& filename) const; void save_fits(void); @@ -101,4 +101,16 @@ protected: GTimeReference m_cta_ref; //!< CTA time reference }; + +/***********************************************************************//** + * @brief Return observation container + * + * @return Reference to observation container + ***************************************************************************/ +inline +const GObservations& ctselect::obs(void) const +{ + return m_obs; +} + #endif /* CTSELECT_HPP */ diff --git a/src/ctskymap/ctskymap.hpp b/src/ctskymap/ctskymap.hpp index 198672c..f5c0a2d 100644 --- a/src/ctskymap/ctskymap.hpp +++ b/src/ctskymap/ctskymap.hpp @@ -53,25 +53,23 @@ public: virtual ~ctskymap(void); // Operators - ctskymap& operator= (const ctskymap& app); + ctskymap& operator=(const ctskymap& app); // Methods void clear(void); void execute(void); void run(void); void save(void); - GObservations& obs(void) { return m_obs; } - GSkymap& skymap(void) { return m_skymap; } - void get_parameters(void); - void init_map(GCTAObservation* obs); - void map_events(GCTAObservation* obs); - + const GSkymap& map(void) const; protected: // Protected methods void init_members(void); void copy_members(const ctskymap& app); void free_members(void); + void get_parameters(void); + void init_map(GCTAObservation* obs); + void map_events(GCTAObservation* obs); // User parameters std::string m_evfile; //!< Input event list @@ -91,4 +89,16 @@ protected: GSkymap m_skymap; //!< Sky map }; + +/***********************************************************************//** + * @brief Return observation container + * + * @return Reference to observation container + ***************************************************************************/ +inline +const GSkymap& ctskymap::map(void) const +{ + return m_skymap; +} + #endif /* CTSKYMAP_HPP */ -- libgit2 0.21.4