Commit 50757195622edc2d7ab7ce95b89c7f4b914f291e

Authored by Jürgen Knödlseder
1 parent d56bdc8e

Make Python classes pickable (#1398)

Showing 139 changed files with 2551 additions and 947 deletions

Too many changes.

To preserve performance only 100 of 139 files are displayed.

1 1 New Features and Important Changes in GammaLib 1.6.0
2 2  
3   -25 June 2018
  3 +28 June 2018
4 4  
5 5  
6 6 1. Introduction
... ... @@ -24,12 +24,16 @@ The following methods have been added:
24 24 - gammalib::atan2()
25 25 - gammalib::plaw_integral()
26 26 - gammalib::gauss_integral()
27   -- GSkyDir::cos_dist()
  27 +- GApplication(std::string&, std::string&, std::vector<std::string>&)
  28 +- GApplicationPar::pickle()
28 29 - GApplicationPar::query()
29 30 - GApplicationPar::was_queried()
  31 +- GApplicationPars::pickle()
30 32 - GApplicationPars::syspfiles()
31 33 - operator==(GSkyPixel&, GSkyPixel&)
32 34 - operator!=(GSkyPixel&, GSkyPixel&)
  35 +- GArf::read(GFits&)
  36 +- GPha::read(GFits&)
33 37 - GPha::operator(int&, int&)
34 38 - GPha::operator[](std::string&)
35 39 - GPha::columns()
... ... @@ -47,20 +51,27 @@ The following methods have been added:
47 51 - GPha::respfile()
48 52 - GPha::ancrfile(std::string&)
49 53 - GPha::ancrfile()
  54 +- GRmf::read(GFits&)
50 55 - GFitsHDU::header(GFitsHeader&)
51 56 - GFitsHDU::card(std::string&, bool&, std::string&)
52   -- GFitsHeaderCard general card constructor
53   -- GFitsHeaderCard boolean constructor
  57 +- GFitsHeaderCard(std::string&, std::string&, std::string&, std::string&)
  58 +- GFitsHeaderCard(std::string&, bool&, std::string&)
54 59 - GObservation::has_events()
55 60 - GModelSpatialPointSource::type(std::string&)
56 61 - GModelSpectralPlaw::type(std::string&)
57 62 - GModelSpatialRadialProfileGauss(GSkyDir&, double&)
58 63 - GModelSpatialRadialProfileGauss::sigma()
  64 +- GSkyDir::cos_dist()
  65 +- GSkyRegions::filename(GFilename&)
59 66 - GXml::GXml(GXmlDocument&)
60 67 - GXml::root()
61 68 - GXmlElement::attributes()
62 69 - GXmlElement::attribute(int&)
63 70 - GXmlDocument::GXmlDocument(GFilename&, std::string&, std::string&, std::string&)
  71 +- GCTAObservation::instrument(std::string&)
  72 +- GCTAObservation::lo_user_thres(double&)
  73 +- GCTAObservation::hi_user_thres(double&)
  74 +- GCTAOnOffObservation::has_response()
64 75 - GCTAInstDir::theta()
65 76 - GCTAInstDir::phi()
66 77 - GCTAEventAtom(GCTAInstDir&, GEnergy&, GTime&)
... ... @@ -72,6 +83,9 @@ The following methods have been added:
72 83 - GCTAEdispPerfTable::prob_erecobin()
73 84 - GCTAEdispRmf::prob_erecobin()
74 85 - GCTAEdisp2D::prob_erecobin()
  86 +- GCTAModelAeffBackground(GModelSpectral&, GModelTemporal&)
  87 +- GCTAModelCubeBackground(GModelSpectral&, GModelTemporal&)
  88 +- GCTAModelRadialAcceptance(GCTAModelRadial&, GModelSpectral&, GModelTemporal&)
75 89 - GCTAModelRadialAcceptance::radial(GCTAModelRadial*)
76 90 - GCTAModelRadialAcceptance::spectral(GModelSpectral*)
77 91 - GCTAModelRadialAcceptance::temporal(GModelTemporal*)
... ... @@ -79,13 +93,13 @@ The following methods have been added:
79 93 - GCTAModelIrfBackground::temporal(GModelTemporal*)
80 94  
81 95 The following methods have been removed:
82   -- none
  96 +- GSkyRegionMap::filename()
83 97  
84 98 The following methods have been renamed:
85 99 - GPhoton::mc_id() from GPhoton::mcid()
86 100  
87 101 The arguments for the following methods have been changed:
88   -- GCTAOnOffObservation CTA observation constructor now takes a spatial model component
  102 +- GCTAOnOffObservation(GCTAObservation&, GModelSpatial&, GEbounds&, GEbounds&, GSkyRegions&, GSkyRegions&)
89 103  
90 104 The return value of the following methods has been changed:
91 105 - none
... ...
include/GApplication.hpp
... ... @@ -53,6 +53,8 @@ public:
53 53 GApplication(void);
54 54 GApplication(const std::string& name, const std::string& version);
55 55 GApplication(const std::string& name, const std::string& version,
  56 + const std::vector<std::string>& args);
  57 + GApplication(const std::string& name, const std::string& version,
56 58 int argc, char* argv[]);
57 59 GApplication(const GApplication& app);
58 60 ~GApplication(void);
... ... @@ -65,49 +67,50 @@ public:
65 67 const GApplicationPar& operator[](const std::string& name) const;
66 68  
67 69 // Methods
68   - void clear(void);
69   - GApplication* clone(void) const;
70   - std::string classname(void) const;
71   - const std::string& name(void) const;
72   - const std::string& version(void) const;
73   - double telapse(void) const;
74   - double celapse(void) const;
75   - void logFileOpen(const bool& clobber = true);
76   - void logFileClose(void);
77   - bool logTerse(void) const;
78   - bool logNormal(void) const;
79   - bool logExplicit(void) const;
80   - bool logVerbose(void) const;
81   - bool logDebug(void) const;
82   - bool clobber(void) const;
83   - bool has_par(const std::string& name) const;
84   - const std::string& par_filename(void) const;
85   - const std::string& log_filename(void) const;
86   - void log_header(void);
87   - void log_trailer(void);
88   - void log_string(const GChatter& chatter,
89   - const std::string& string,
90   - const bool& linefeed = true);
91   - void log_value(const GChatter& chatter,
92   - const std::string& name,
93   - const std::string& value);
94   - void log_value(const GChatter& chatter,
95   - const std::string& name,
96   - const int& value);
97   - void log_value(const GChatter& chatter,
98   - const std::string& name,
99   - const double& value);
100   - void log_header1(const GChatter& chatter,
101   - const std::string& header);
102   - void log_header2(const GChatter& chatter,
103   - const std::string& header);
104   - void log_header3(const GChatter& chatter,
105   - const std::string& header);
106   - void log_parameters(const GChatter& chatter);
107   - const bool& need_help(void) const;
108   - const GApplicationPars& pars(void) const;
109   - void pars(const GApplicationPars& pars);
110   - std::string print(const GChatter& chatter = NORMAL) const;
  70 + void clear(void);
  71 + GApplication* clone(void) const;
  72 + std::string classname(void) const;
  73 + const std::string& name(void) const;
  74 + const std::string& version(void) const;
  75 + double telapse(void) const;
  76 + double celapse(void) const;
  77 + void logFileOpen(const bool& clobber = true);
  78 + void logFileClose(void);
  79 + bool logTerse(void) const;
  80 + bool logNormal(void) const;
  81 + bool logExplicit(void) const;
  82 + bool logVerbose(void) const;
  83 + bool logDebug(void) const;
  84 + bool clobber(void) const;
  85 + bool has_par(const std::string& name) const;
  86 + const std::string& par_filename(void) const;
  87 + const std::string& log_filename(void) const;
  88 + void log_header(void);
  89 + void log_trailer(void);
  90 + void log_string(const GChatter& chatter,
  91 + const std::string& string,
  92 + const bool& linefeed = true);
  93 + void log_value(const GChatter& chatter,
  94 + const std::string& name,
  95 + const std::string& value);
  96 + void log_value(const GChatter& chatter,
  97 + const std::string& name,
  98 + const int& value);
  99 + void log_value(const GChatter& chatter,
  100 + const std::string& name,
  101 + const double& value);
  102 + void log_header1(const GChatter& chatter,
  103 + const std::string& header);
  104 + void log_header2(const GChatter& chatter,
  105 + const std::string& header);
  106 + void log_header3(const GChatter& chatter,
  107 + const std::string& header);
  108 + void log_parameters(const GChatter& chatter);
  109 + const bool& need_help(void) const;
  110 + const GApplicationPars& pars(void) const;
  111 + void pars(const GApplicationPars& pars);
  112 + const std::vector<std::string>& args(void) const;
  113 + std::string print(const GChatter& chatter = NORMAL) const;
111 114  
112 115 // Public members
113 116 GLog log; //!< Application logger
... ... @@ -117,6 +120,9 @@ protected:
117 120 void init_members(void);
118 121 void copy_members(const GApplication& app);
119 122 void free_members(void);
  123 + void set_members(const std::string& name,
  124 + const std::string& version,
  125 + const std::vector<std::string>& args);
120 126 void set_log_chatter(void);
121 127 void set_log_filename(void);
122 128  
... ... @@ -312,4 +318,16 @@ void GApplication::pars(const GApplicationPars&amp; pars)
312 318 return;
313 319 }
314 320  
  321 +
  322 +/***********************************************************************//**
  323 + * @brief Return command line arguments
  324 + *
  325 + * @return Command line arguments.
  326 + ***************************************************************************/
  327 +inline
  328 +const std::vector<std::string>& GApplication::args(void) const
  329 +{
  330 + return m_args;
  331 +}
  332 +
315 333 #endif /* GAPPLICATION_HPP */
... ...
include/GApplicationPar.hpp
... ... @@ -29,6 +29,7 @@
29 29  
30 30 /* __ Includes ___________________________________________________________ */
31 31 #include <string>
  32 +#include <vector>
32 33 #include "GBase.hpp"
33 34 #include "GTime.hpp"
34 35  
... ... @@ -62,42 +63,44 @@ public:
62 63 GApplicationPar& operator=(const GApplicationPar& par);
63 64  
64 65 // Methods
65   - void clear(void);
66   - GApplicationPar* clone(void) const;
67   - std::string classname(void) const;
68   - void type(const std::string& type);
69   - void mode(const std::string& mode);
70   - void value(const std::string& value);
71   - void string(const std::string& value);
72   - void filename(const GFilename& value);
73   - void time(const GTime& value);
74   - void boolean(const bool& value);
75   - void integer(const int& value);
76   - void real(const double& value);
77   - const std::string& name(void) const;
78   - const std::string& type(void) const;
79   - const std::string& mode(void) const;
80   - void query(void);
81   - std::string value(void);
82   - std::string string(void);
83   - GFilename filename(void);
84   - GTime time(void);
85   - GTime time(const GTimeReference& ref);
86   - bool boolean(void);
87   - int integer(void);
88   - double real(void);
89   - const std::string& current_value(void) const;
90   - const std::string& min(void) const;
91   - const std::string& max(void) const;
92   - const std::string& prompt(void) const;
93   - bool is_learn(void) const;
94   - bool is_query(void) const;
95   - bool is_filename(void) const;
96   - bool is_valid(void);
97   - bool is_undefined(void);
98   - bool is_notanumber(void);
99   - bool was_queried(void) const;
100   - std::string print(const GChatter& chatter = NORMAL) const;
  66 + void clear(void);
  67 + GApplicationPar* clone(void) const;
  68 + std::string classname(void) const;
  69 + void type(const std::string& type);
  70 + void mode(const std::string& mode);
  71 + void value(const std::string& value);
  72 + void string(const std::string& value);
  73 + void filename(const GFilename& value);
  74 + void time(const GTime& value);
  75 + void boolean(const bool& value);
  76 + void integer(const int& value);
  77 + void real(const double& value);
  78 + const std::string& name(void) const;
  79 + const std::string& type(void) const;
  80 + const std::string& mode(void) const;
  81 + void query(void);
  82 + std::string value(void);
  83 + std::string string(void);
  84 + GFilename filename(void);
  85 + GTime time(void);
  86 + GTime time(const GTimeReference& ref);
  87 + bool boolean(void);
  88 + int integer(void);
  89 + double real(void);
  90 + const std::string& current_value(void) const;
  91 + const std::string& min(void) const;
  92 + const std::string& max(void) const;
  93 + const std::string& prompt(void) const;
  94 + bool is_learn(void) const;
  95 + bool is_query(void) const;
  96 + bool is_filename(void) const;
  97 + bool is_valid(void);
  98 + bool is_undefined(void);
  99 + bool is_notanumber(void);
  100 + bool was_queried(void) const;
  101 + void pickle(const std::vector<std::string>& string);
  102 + std::vector<std::string> pickle(void) const;
  103 + std::string print(const GChatter& chatter = NORMAL) const;
101 104  
102 105 protected:
103 106 // Protected enumerators
... ...
include/GApplicationPars.hpp
... ... @@ -66,30 +66,32 @@ public:
66 66 const GApplicationPar& operator[](const std::string& name) const;
67 67  
68 68 // Methods
69   - void clear(void);
70   - GApplicationPars* clone(void) const;
71   - std::string classname(void) const;
72   - GApplicationPar& at(const int& index);
73   - const GApplicationPar& at(const int& index) const;
74   - int size(void) const;
75   - bool is_empty(void) const;
76   - GApplicationPar& append(const GApplicationPar& par);
77   - void append_standard(void);
78   - GApplicationPar& insert(const int& index, const GApplicationPar& par);
79   - GApplicationPar& insert(const std::string& name,
80   - const GApplicationPar& par);
81   - void remove(const int& index);
82   - void remove(const std::string& name);
83   - void reserve(const int& num);
84   - void extend(const GApplicationPars& pars);
85   - bool contains(const std::string& name) const;
86   - void syspfiles(const std::string& syspfiles);
87   - const std::string& syspfiles(void) const;
88   - void load(const GFilename& filename);
89   - void load(const GFilename& filename,
90   - const std::vector<std::string>& args);
91   - void save(const GFilename& filename);
92   - std::string print(const GChatter& chatter = NORMAL) const;
  69 + void clear(void);
  70 + GApplicationPars* clone(void) const;
  71 + std::string classname(void) const;
  72 + GApplicationPar& at(const int& index);
  73 + const GApplicationPar& at(const int& index) const;
  74 + int size(void) const;
  75 + bool is_empty(void) const;
  76 + GApplicationPar& append(const GApplicationPar& par);
  77 + void append_standard(void);
  78 + GApplicationPar& insert(const int& index, const GApplicationPar& par);
  79 + GApplicationPar& insert(const std::string& name,
  80 + const GApplicationPar& par);
  81 + void remove(const int& index);
  82 + void remove(const std::string& name);
  83 + void reserve(const int& num);
  84 + void extend(const GApplicationPars& pars);
  85 + bool contains(const std::string& name) const;
  86 + void syspfiles(const std::string& syspfiles);
  87 + const std::string& syspfiles(void) const;
  88 + void load(const GFilename& filename);
  89 + void load(const GFilename& filename,
  90 + const std::vector<std::string>& args);
  91 + void save(const GFilename& filename);
  92 + void pickle(const std::vector<std::string>& string);
  93 + std::vector<std::string> pickle(void) const;
  94 + std::string print(const GChatter& chatter = NORMAL) const;
93 95  
94 96 protected:
95 97 // Protected methods
... ...
include/GArf.hpp
1 1 /***************************************************************************
2 2 * GArf.hpp - XSPEC Auxiliary Response File class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2017 by Juergen Knoedlseder *
  4 + * copyright (C) 2013-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -100,6 +100,7 @@ public:
100 100 void load(const GFilename& filename);
101 101 void save(const GFilename& filename,
102 102 const bool& clobber = false) const;
  103 + void read(const GFits& fits);
103 104 void read(const GFitsTable& table);
104 105 void write(GFits& fits) const;
105 106 const GFilename& filename(void) const;
... ...
include/GFitsAsciiTable.hpp
1 1 /***************************************************************************
2 2 * GFitsAsciiTable.hpp - FITS ASCII table class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2008-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -65,6 +65,7 @@ private:
65 65 void init_members(void);
66 66 void copy_members(const GFitsAsciiTable& table);
67 67 void free_members(void);
  68 + void init_table_header(void);
68 69 };
69 70  
70 71  
... ...
include/GFitsBinTable.hpp
1 1 /***************************************************************************
2 2 * GFitsBinTable.hpp - FITS binary table class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2015 by Juergen Knoedlseder *
  4 + * copyright (C) 2008-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -59,6 +59,7 @@ private:
59 59 void init_members(void);
60 60 void copy_members(const GFitsBinTable& table);
61 61 void free_members(void);
  62 + void init_table_header(void);
62 63 };
63 64  
64 65  
... ...
include/GModelSpatialDiffuseCube.hpp
1 1 /***************************************************************************
2 2 * GModelSpatialDiffuseCube.hpp - Spatial map cube model class *
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 *
... ... @@ -110,7 +110,8 @@ public:
110 110 void load(const GFilename& filename);
111 111 void save(const GFilename& filename,
112 112 const bool& clobber = false) const;
113   - void write(GFits& file) const;
  113 + void read(const GFits& fits);
  114 + void write(GFits& fits) const;
114 115  
115 116 protected:
116 117 // Protected methods
... ...
include/GPha.hpp
... ... @@ -134,6 +134,7 @@ public:
134 134 void load(const GFilename& filename);
135 135 void save(const GFilename& filename,
136 136 const bool& clobber = false) const;
  137 + void read(const GFits& fits);
137 138 void read(const GFitsTable& table);
138 139 void write(GFits& fits) const;
139 140 const GFilename& filename(void) const;
... ...
include/GRmf.hpp
1 1 /***************************************************************************
2 2 * GRmf.hpp - XSPEC Redistribution Matrix File class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2017 by Juergen Knoedlseder *
  4 + * copyright (C) 2013-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -97,6 +97,7 @@ public:
97 97 void save(const GFilename& filename,
98 98 const bool& clobber = false,
99 99 const std::string& unit = "keV") const;
  100 + void read(const GFits& fits);
100 101 void read(const GFitsTable& table);
101 102 void write(GFits& fits,
102 103 const std::string& unit = "keV") const;
... ...
include/GSkyRegionMap.hpp
1 1 /***************************************************************************
2 2 * GSkyRegionMap.hpp - Sky region map class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2017 by Pierrick Martin *
  4 + * copyright (C) 2017-2018 by Pierrick Martin *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -45,17 +45,17 @@ class GSkyRegionMap;
45 45 * @brief Interface for a sky region map
46 46 *
47 47 * This class provides an implementation for a sky region defined by a
48   - * sky map. The map is provided as a FITS file filled with 0 and non-zero
49   - * values.
  48 + * sky map. The map is provided as a FITS file. Pixels with non-zero values
  49 + * are within the region, pixels with zero values outside the region.
50 50 ***************************************************************************/
51 51 class GSkyRegionMap : public GSkyRegion {
52 52  
53 53 public:
54 54 // Constructors and destructors
55 55 GSkyRegionMap(void);
56   - GSkyRegionMap(const GFilename& filename);
57   - GSkyRegionMap(const GSkyMap& map);
58   - GSkyRegionMap(const GSkyRegion* region);
  56 + explicit GSkyRegionMap(const GFilename& filename);
  57 + explicit GSkyRegionMap(const GSkyMap& map);
  58 + explicit GSkyRegionMap(const GSkyRegion* region);
59 59 GSkyRegionMap(const GSkyRegionMap& region);
60 60 virtual ~GSkyRegionMap(void);
61 61  
... ... @@ -77,7 +77,6 @@ public:
77 77 void load(const GFilename& filename);
78 78 void map(const GSkyMap& map);
79 79 const GSkyMap& map(void) const;
80   - const GFilename& filename(void) const;
81 80 const std::vector<int>& nonzero_indices(void) const;
82 81  
83 82 protected:
... ... @@ -92,7 +91,6 @@ protected:
92 91 // Protected members
93 92 GSkyMap m_map; //!< The region map
94 93 std::vector<int> m_nonzero_indices; //!< Vector of non-zero pixel indices
95   - mutable GFilename m_filename; //!< Filename of origin (if any)
96 94 };
97 95  
98 96  
... ... @@ -142,10 +140,12 @@ const std::vector&lt;int&gt;&amp; GSkyRegionMap::nonzero_indices(void) const
142 140 * which the region was saved. The returned string will be empty if
143 141 * no load() or save() method has been called before.
144 142 ***************************************************************************/
  143 +/*
145 144 inline
146 145 const GFilename& GSkyRegionMap::filename(void) const
147 146 {
148 147 return (m_filename);
149 148 }
  149 +*/
150 150  
151 151 #endif /* GSKYREGIONMAP_HPP */
... ...
include/GSkyRegions.hpp
... ... @@ -87,6 +87,7 @@ public:
87 87 void load(const GFilename& filename);
88 88 void save(const GFilename& filename) const;
89 89 const GFilename& filename(void) const;
  90 + void filename(const GFilename& filename);
90 91 std::string print(const GChatter& chatter = NORMAL) const;
91 92  
92 93 protected:
... ... @@ -185,14 +186,14 @@ void GSkyRegions::reserve(const int&amp; num)
185 186  
186 187  
187 188 /***********************************************************************//**
188   - * @brief Return file name
  189 + * @brief Return regions file name
189 190 *
190 191 * @return File name from which the regions have been loaded or into which
191 192 * the regions have been saved.
192 193 *
193 194 * Returns the file name from which the regions have been loaded or into
194   - * which the regions have been saved. The returned string will be empty if
195   - * no load() or save() method has been called before.
  195 + * which the regions have been saved. The returned string will be set if
  196 + * the load(), save() or filename() setter methods were called.
196 197 ***************************************************************************/
197 198 inline
198 199 const GFilename& GSkyRegions::filename(void) const
... ... @@ -200,4 +201,19 @@ const GFilename&amp; GSkyRegions::filename(void) const
200 201 return (m_filename);
201 202 }
202 203  
  204 +
  205 +/***********************************************************************//**
  206 + * @brief Set regions file name
  207 + *
  208 + * @param[in] filename Regions file name.
  209 + *
  210 + * Set the regions file name.
  211 + ***************************************************************************/
  212 +inline
  213 +void GSkyRegions::filename(const GFilename& filename)
  214 +{
  215 + m_filename = filename;
  216 + return;
  217 +}
  218 +
203 219 #endif /* GSKYREGIONS_HPP */
... ...
inst/cta/include/GCTAModelAeffBackground.hpp
1 1 /***************************************************************************
2 2 * GCTAModelAeffBackground.hpp - CTA Aeff background model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2015-2016 by Michael Mayer *
  4 + * copyright (C) 2015-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -51,6 +51,8 @@ public:
51 51 GCTAModelAeffBackground(void);
52 52 explicit GCTAModelAeffBackground(const GXmlElement& xml);
53 53 explicit GCTAModelAeffBackground(const GModelSpectral& spectral);
  54 + GCTAModelAeffBackground(const GModelSpectral& spectral,
  55 + const GModelTemporal& temporal);
54 56 GCTAModelAeffBackground(const GCTAModelAeffBackground& bgd);
55 57 virtual ~GCTAModelAeffBackground(void);
56 58  
... ...
inst/cta/include/GCTAModelCubeBackground.hpp
1 1 /***************************************************************************
2 2 * GCTAModelCubeBackground.hpp - CTA cube background model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2016 by Michael Mayer *
  4 + * copyright (C) 2013-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -56,6 +56,8 @@ public:
56 56 GCTAModelCubeBackground(void);
57 57 explicit GCTAModelCubeBackground(const GXmlElement& xml);
58 58 explicit GCTAModelCubeBackground(const GModelSpectral& spectral);
  59 + GCTAModelCubeBackground(const GModelSpectral& spectral,
  60 + const GModelTemporal& temporal);
59 61 GCTAModelCubeBackground(const GCTAModelCubeBackground& bgd);
60 62 virtual ~GCTAModelCubeBackground(void);
61 63  
... ...
inst/cta/include/GCTAModelRadial.hpp
1 1 /***************************************************************************
2 2 * GCTAModelRadial.hpp - Radial model abstract base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -21,7 +21,7 @@
21 21 /**
22 22 * @file GCTAModelRadial.hpp
23 23 * @brief Abstract radial acceptance model class interface definition
24   - * @author J. Knodlseder
  24 + * @author Juergen Knoedlseder
25 25 */
26 26  
27 27 #ifndef GCTAMODELRADIAL_HPP
... ... @@ -73,7 +73,7 @@ public:
73 73 virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
74 74  
75 75 // Methods
76   - int size(void) const { return (int)m_pars.size(); }
  76 + int size(void) const;
77 77  
78 78 protected:
79 79 // Protected methods
... ... @@ -85,4 +85,16 @@ protected:
85 85 std::vector<GModelPar*> m_pars; //!< Parameter pointers
86 86 };
87 87  
  88 +
  89 +/***********************************************************************//**
  90 + * @brief Return number of model parameters
  91 + *
  92 + * @return Number of model parameters.
  93 + ***************************************************************************/
  94 +inline
  95 +int GCTAModelRadial::size(void) const
  96 +{
  97 + return ((int)m_pars.size());
  98 +}
  99 +
88 100 #endif /* GCTAMODELRADIAL_HPP */
... ...
inst/cta/include/GCTAModelRadialAcceptance.hpp
... ... @@ -55,8 +55,11 @@ public:
55 55 // Constructors and destructors
56 56 GCTAModelRadialAcceptance(void);
57 57 explicit GCTAModelRadialAcceptance(const GXmlElement& xml);
58   - explicit GCTAModelRadialAcceptance(const GCTAModelRadial& radial,
59   - const GModelSpectral& spectral);
  58 + GCTAModelRadialAcceptance(const GCTAModelRadial& radial,
  59 + const GModelSpectral& spectral);
  60 + GCTAModelRadialAcceptance(const GCTAModelRadial& radial,
  61 + const GModelSpectral& spectral,
  62 + const GModelTemporal& temporal);
60 63 GCTAModelRadialAcceptance(const GCTAModelRadialAcceptance& model);
61 64 virtual ~GCTAModelRadialAcceptance(void);
62 65  
... ...
inst/cta/include/GCTAModelRadialPolynom.hpp
... ... @@ -63,7 +63,7 @@ public:
63 63 virtual ~GCTAModelRadialPolynom(void);
64 64  
65 65 // Operators
66   - virtual GCTAModelRadialPolynom& operator= (const GCTAModelRadialPolynom& model);
  66 + virtual GCTAModelRadialPolynom& operator=(const GCTAModelRadialPolynom& model);
67 67  
68 68 // Implemented pure virtual methods
69 69 virtual void clear(void);
... ... @@ -79,7 +79,6 @@ public:
79 79 virtual std::string print(const GChatter& chatter = NORMAL) const;
80 80  
81 81 // Other methods
82   - int size(void) const;
83 82 //double coeff(void) const;
84 83 //void coeff(const double& value);
85 84  
... ... @@ -130,16 +129,4 @@ std::string GCTAModelRadialPolynom::type(void) const
130 129 return ("Polynom");
131 130 }
132 131  
133   -
134   -/***********************************************************************//**
135   - * @brief Return number of coefficients in polynomial
136   - *
137   - * @return Number of coefficients in polynomial.
138   - ***************************************************************************/
139   -inline
140   -int GCTAModelRadialPolynom::size(void) const
141   -{
142   - return (int)m_coeffs.size();
143   -}
144   -
145 132 #endif /* GCTAMODELRADIALPOLYNOM_HPP */
... ...
inst/cta/include/GCTAObservation.hpp
... ... @@ -98,6 +98,7 @@ public:
98 98 virtual std::string print(const GChatter& chatter = NORMAL) const;
99 99  
100 100 // Other methods
  101 + void instrument(const std::string& instrument);
101 102 bool has_response(void) const;
102 103 bool has_events(void) const;
103 104 void read(const GFits& fits);
... ... @@ -145,7 +146,9 @@ public:
145 146 const GFilename& eventfile(void) const;
146 147 std::string eventtype(void) const;
147 148 void dispose_events(void);
  149 + void lo_user_thres(const double& lo_user_thres);
148 150 const double& lo_user_thres(void) const;
  151 + void hi_user_thres(const double& hi_user_thres);
149 152 const double& hi_user_thres(void) const;
150 153 void n_tels(const int& tels);
151 154 const int& n_tels(void) const;
... ... @@ -193,6 +196,19 @@ std::string GCTAObservation::classname(void) const
193 196  
194 197  
195 198 /***********************************************************************//**
  199 + * @brief Set instrument name
  200 + *
  201 + * @param[in] instrument Instrument name.
  202 + ***************************************************************************/
  203 +inline
  204 +void GCTAObservation::instrument(const std::string& instrument)
  205 +{
  206 + m_instrument = instrument;
  207 + return;
  208 +}
  209 +
  210 +
  211 +/***********************************************************************//**
196 212 * @brief Return instrument name
197 213 *
198 214 * @return Instrument name.
... ... @@ -462,6 +478,19 @@ const GFilename&amp; GCTAObservation::eventfile(void) const
462 478  
463 479  
464 480 /***********************************************************************//**
  481 + * @brief Set user low energy threshold
  482 + *
  483 + * @param[in] lo_user_thres User low energy threshold.
  484 + ***************************************************************************/
  485 +inline
  486 +void GCTAObservation::lo_user_thres(const double& lo_user_thres)
  487 +{
  488 + m_lo_user_thres = lo_user_thres;
  489 + return;
  490 +}
  491 +
  492 +
  493 +/***********************************************************************//**
465 494 * @brief Return user low energy threshold
466 495 *
467 496 * @return User low energy threshold.
... ... @@ -472,6 +501,20 @@ const double&amp; GCTAObservation::lo_user_thres(void) const
472 501 return m_lo_user_thres;
473 502 }
474 503  
  504 +
  505 +/***********************************************************************//**
  506 + * @brief Set user high energy threshold
  507 + *
  508 + * @param[in] hi_user_thres User high energy threshold.
  509 + ***************************************************************************/
  510 +inline
  511 +void GCTAObservation::hi_user_thres(const double& hi_user_thres)
  512 +{
  513 + m_hi_user_thres = hi_user_thres;
  514 + return;
  515 +}
  516 +
  517 +
475 518 /***********************************************************************//**
476 519 * @brief Return user high energy threshold
477 520 *
... ...
inst/cta/include/GCTAOnOffObservation.hpp
... ... @@ -109,6 +109,7 @@ public:
109 109  
110 110 // Other methods
111 111 void instrument(const std::string& instrument);
  112 + bool has_response(void) const;
112 113 const GPha& on_spec(void) const;
113 114 const GPha& off_spec(void) const;
114 115 const GArf& arf(void) const;
... ... @@ -243,6 +244,18 @@ double GCTAOnOffObservation::deadc(const GTime&amp; time) const
243 244  
244 245  
245 246 /***********************************************************************//**
  247 + * @brief Signal if observation contains response information
  248 + *
  249 + * @return True if observation contains response information.
  250 + ***************************************************************************/
  251 +inline
  252 +bool GCTAOnOffObservation::has_response(void) const
  253 +{
  254 + return (m_response != NULL);
  255 +}
  256 +
  257 +
  258 +/***********************************************************************//**
246 259 * @brief Set instrument
247 260 *
248 261 * @param[in] instrument Instrument.
... ...
inst/cta/pyext/GCTAAeff2D.i
1 1 /***************************************************************************
2 2 * GCTAAeff2D.i - CTA 2D effective area class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2017 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 *
... ... @@ -80,4 +80,21 @@ public:
80 80 GCTAAeff2D copy() {
81 81 return (*self);
82 82 }
  83 +%pythoncode {
  84 + def __getstate__(self):
  85 + if self.filename().is_empty():
  86 + hdu = gammalib.GFitsBinTable()
  87 + self.write(hdu)
  88 + state = (self.filename(), hdu)
  89 + else:
  90 + state = (self.filename(),)
  91 + return state
  92 + def __setstate__(self, state):
  93 + if state[0].is_empty():
  94 + self.__init__()
  95 + if state[1].nrows() > 0:
  96 + self.read(state[1])
  97 + else:
  98 + self.__init__(state[0])
  99 +}
83 100 };
... ...
inst/cta/pyext/GCTABackground3D.i
... ... @@ -80,4 +80,21 @@ public:
80 80 GCTABackground3D copy() {
81 81 return (*self);
82 82 }
  83 +%pythoncode {
  84 + def __getstate__(self):
  85 + if self.filename().is_empty():
  86 + hdu = gammalib.GFitsBinTable()
  87 + self.write(hdu)
  88 + state = (self.filename(), hdu)
  89 + else:
  90 + state = (self.filename(),)
  91 + return state
  92 + def __setstate__(self, state):
  93 + if state[0].is_empty():
  94 + self.__init__()
  95 + if state[1].nrows() > 0:
  96 + self.read(state[1])
  97 + else:
  98 + self.__init__(state[0])
  99 +}
83 100 };
... ...
inst/cta/pyext/GCTACubeBackground.i
1 1 /***************************************************************************
2 2 * GCTACubeBackground.i - CTA cube background class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2015-2016 by Michael Mayer *
  4 + * copyright (C) 2015-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -81,4 +81,20 @@ public:
81 81 GCTACubeBackground copy() {
82 82 return (*self);
83 83 }
  84 +%pythoncode {
  85 + def __getstate__(self):
  86 + if self.filename().is_empty():
  87 + fits = gammalib.GFits()
  88 + self.write(fits)
  89 + state = (self.filename(), fits)
  90 + else:
  91 + state = (self.filename(),)
  92 + return state
  93 + def __setstate__(self, state):
  94 + if state[0].is_empty():
  95 + self.__init__()
  96 + self.read(state[1])
  97 + else:
  98 + self.__init__(state[0])
  99 +}
84 100 };
... ...
inst/cta/pyext/GCTACubeEdisp.i
1 1 /***************************************************************************
2 2 * GCTACubeEdisp.i - CTA cube analysis energy dispersion class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2016 by Michael Mayer *
  4 + * copyright (C) 2016-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -96,4 +96,20 @@ public:
96 96 GCTACubeEdisp copy() {
97 97 return (*self);
98 98 }
  99 +%pythoncode {
  100 + def __getstate__(self):
  101 + if self.filename().is_empty():
  102 + fits = gammalib.GFits()
  103 + self.write(fits)
  104 + state = (self.filename(), fits)
  105 + else:
  106 + state = (self.filename(),)
  107 + return state
  108 + def __setstate__(self, state):
  109 + if state[0].is_empty():
  110 + self.__init__()
  111 + self.read(state[1])
  112 + else:
  113 + self.__init__(state[0])
  114 +}
99 115 };
... ...
inst/cta/pyext/GCTACubeExposure.i
1 1 /***************************************************************************
2 2 * GCTACubeExposure.i - CTA cube analysis exposure class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2016 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2018 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -87,4 +87,20 @@ public:
87 87 GCTACubeExposure copy() {
88 88 return (*self);
89 89 }
  90 +%pythoncode {
  91 + def __getstate__(self):
  92 + if self.filename().is_empty():
  93 + fits = gammalib.GFits()
  94 + self.write(fits)
  95 + state = (self.filename(), fits)
  96 + else:
  97 + state = (self.filename(),)
  98 + return state
  99 + def __setstate__(self, state):
  100 + if state[0].is_empty():
  101 + self.__init__()
  102 + self.read(state[1])
  103 + else:
  104 + self.__init__(state[0])
  105 +}
90 106 };
... ...
inst/cta/pyext/GCTACubePsf.i
1 1 /***************************************************************************
2 2 * GCTACubePsf.i - CTA cube analysis point spread function class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2016 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2018 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -95,4 +95,20 @@ public:
95 95 GCTACubePsf copy() {
96 96 return (*self);
97 97 }
  98 +%pythoncode {
  99 + def __getstate__(self):
  100 + if self.filename().is_empty():
  101 + fits = gammalib.GFits()
  102 + self.write(fits)
  103 + state = (self.filename(), fits)
  104 + else:
  105 + state = (self.filename(),)
  106 + return state
  107 + def __setstate__(self, state):
  108 + if state[0].is_empty():
  109 + self.__init__()
  110 + self.read(state[1])
  111 + else:
  112 + self.__init__(state[0])
  113 +}
98 114 };
... ...
inst/cta/pyext/GCTAEdisp2D.i
... ... @@ -96,4 +96,21 @@ public:
96 96 GCTAEdisp2D copy() {
97 97 return (*self);
98 98 }
  99 +%pythoncode {
  100 + def __getstate__(self):
  101 + if self.filename().is_empty():
  102 + hdu = gammalib.GFitsBinTable()
  103 + self.write(hdu)
  104 + state = (self.filename(), hdu)
  105 + else:
  106 + state = (self.filename(),)
  107 + return state
  108 + def __setstate__(self, state):
  109 + if state[0].is_empty():
  110 + self.__init__()
  111 + if state[1].nrows() > 0:
  112 + self.read(state[1])
  113 + else:
  114 + self.__init__(state[0])
  115 +}
99 116 };
... ...
inst/cta/pyext/GCTAEventBin.i
1 1 /***************************************************************************
2 2 * GCTAEventBin.i - CTA event bin class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2017 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -83,4 +83,22 @@ public:
83 83 GCTAEventBin copy() {
84 84 return (*self);
85 85 }
  86 +%pythoncode {
  87 + def __getstate__(self):
  88 + state = (self.ipix(), self.dir(), self.energy(), self.time(),
  89 + self.counts(), self.solidangle(), self.ewidth(),
  90 + self.ontime(), self.weight())
  91 + return state
  92 + def __setstate__(self, state):
  93 + self.__init__()
  94 + if state[0] == -1:
  95 + self.dir(state[1])
  96 + self.energy(state[2])
  97 + self.time(state[3])
  98 + self.counts(state[4])
  99 + self.solidangle(state[5])
  100 + self.ewidth(state[6])
  101 + self.ontime(state[7])
  102 + self.weight(state[8])
  103 +}
86 104 };
... ...
inst/cta/pyext/GCTAEventCube.i
... ... @@ -92,10 +92,13 @@ public:
92 92 }
93 93 %pythoncode {
94 94 def __getstate__(self):
95   - args = gammalib.GEventCube.__getstate__(self)
96   - return args
  95 + fits = gammalib.GFits()
  96 + self.write(fits)
  97 + state = (fits,)
  98 + return state
97 99 def __setstate__(self, state):
98 100 self.__init__()
99   - gammalib.GEventCube.__setstate__(self, state)
  101 + if state[0][0].has_card('NAXIS') and state[0][0].integer('NAXIS') >= 2:
  102 + self.read(state[0])
100 103 }
101 104 };
... ...
inst/cta/pyext/GCTAEventList.i
... ... @@ -152,10 +152,12 @@ public:
152 152 }
153 153 %pythoncode {
154 154 def __getstate__(self):
155   - args = gammalib.GEventList.__getstate__(self)
156   - return args
  155 + fits = gammalib.GFits()
  156 + self.write(fits)
  157 + state = (fits,)
  158 + return state
157 159 def __setstate__(self, state):
158 160 self.__init__()
159   - gammalib.GEventList.__setstate__(self, state)
  161 + self.read(state[0])
160 162 }
161 163 };
... ...
inst/cta/pyext/GCTAModelAeffBackground.i
1 1 /***************************************************************************
2 2 * GCTAModelAeffBackground.i - CTA Aeff background model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2015-2016 by Michael Mayer *
  4 + * copyright (C) 2015-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -40,6 +40,8 @@ public:
40 40 GCTAModelAeffBackground(void);
41 41 explicit GCTAModelAeffBackground(const GXmlElement& xml);
42 42 explicit GCTAModelAeffBackground(const GModelSpectral& spectral);
  43 + GCTAModelAeffBackground(const GModelSpectral& spectral,
  44 + const GModelTemporal& temporal);
43 45 GCTAModelAeffBackground(const GCTAModelAeffBackground& bgd);
44 46 virtual ~GCTAModelAeffBackground(void);
45 47  
... ... @@ -71,4 +73,18 @@ public:
71 73 GCTAModelAeffBackground copy() {
72 74 return (*self);
73 75 }
  76 +%pythoncode {
  77 + def __getstate__(self):
  78 + state = (self.spectral(), self.temporal(),
  79 + gammalib.GModelData.__getstate__(self))
  80 + return state
  81 + def __setstate__(self, state):
  82 + if state[0] == None and state[1] == None:
  83 + self.__init__()
  84 + elif state[1] == None:
  85 + self.__init__(state[0])
  86 + else:
  87 + self.__init__(state[0], state[1])
  88 + gammalib.GModelData.__setstate__(self, state[2])
  89 +}
74 90 };
... ...
inst/cta/pyext/GCTAModelCubeBackground.i
1 1 /***************************************************************************
2 2 * GCTAModelCubeBackground.i - CTA cube background model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2016 by Michael Mayer *
  4 + * copyright (C) 2013-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -41,6 +41,8 @@ public:
41 41 GCTAModelCubeBackground(void);
42 42 explicit GCTAModelCubeBackground(const GXmlElement& xml);
43 43 explicit GCTAModelCubeBackground(const GModelSpectral& spectral);
  44 + GCTAModelCubeBackground(const GModelSpectral& spectral,
  45 + const GModelTemporal& temporal);
44 46 GCTAModelCubeBackground(const GCTAModelCubeBackground& model);
45 47  
46 48 virtual ~GCTAModelCubeBackground(void);
... ... @@ -72,4 +74,18 @@ public:
72 74 GCTAModelCubeBackground copy() {
73 75 return (*self);
74 76 }
  77 +%pythoncode {
  78 + def __getstate__(self):
  79 + state = (self.spectral(), self.temporal(),
  80 + gammalib.GModelData.__getstate__(self))
  81 + return state
  82 + def __setstate__(self, state):
  83 + if state[0] == None and state[1] == None:
  84 + self.__init__()
  85 + elif state[1] == None:
  86 + self.__init__(state[0])
  87 + else:
  88 + self.__init__(state[0], state[1])
  89 + gammalib.GModelData.__setstate__(self, state[2])
  90 +}
75 91 };
... ...
inst/cta/pyext/GCTAModelRadial.i
1 1 /***************************************************************************
2 2 * GCTAModelRadial.i - Abstract radial model base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -26,7 +26,6 @@
26 26 %{
27 27 /* Put headers and other declarations here that are needed for compilation */
28 28 #include "GCTAModelRadial.hpp"
29   -#include "GTools.hpp"
30 29 %}
31 30  
32 31  
... ... @@ -56,7 +55,7 @@ public:
56 55 virtual void write(GXmlElement& xml) const = 0;
57 56  
58 57 // Methods
59   - int size(void) const { return m_pars.size(); }
  58 + int size(void) const;
60 59 };
61 60  
62 61  
... ...
inst/cta/pyext/GCTAModelRadialAcceptance.i
... ... @@ -26,7 +26,6 @@
26 26 %{
27 27 /* Put headers and other declarations here that are needed for compilation */
28 28 #include "GCTAModelRadialAcceptance.hpp"
29   -#include "GTools.hpp"
30 29 %}
31 30  
32 31  
... ... @@ -41,8 +40,11 @@ public:
41 40 // Constructors and destructors
42 41 GCTAModelRadialAcceptance(void);
43 42 explicit GCTAModelRadialAcceptance(const GXmlElement& xml);
44   - explicit GCTAModelRadialAcceptance(const GCTAModelRadial& radial,
45   - const GModelSpectral& spectral);
  43 + GCTAModelRadialAcceptance(const GCTAModelRadial& radial,
  44 + const GModelSpectral& spectral);
  45 + GCTAModelRadialAcceptance(const GCTAModelRadial& radial,
  46 + const GModelSpectral& spectral,
  47 + const GModelTemporal& temporal);
46 48 GCTAModelRadialAcceptance(const GCTAModelRadialAcceptance& model);
47 49 virtual ~GCTAModelRadialAcceptance(void);
48 50  
... ... @@ -72,7 +74,24 @@ public:
72 74  
73 75  
74 76 /***********************************************************************//**
75   - * @brief GCTAModelRadial class extension
  77 + * @brief GCTAModelRadialAcceptance class extension
76 78 ***************************************************************************/
77   -%extend GCTAModelRadial {
  79 +%extend GCTAModelRadialAcceptance {
  80 + GCTAModelRadialAcceptance copy() {
  81 + return (*self);
  82 + }
  83 +%pythoncode {
  84 + def __getstate__(self):
  85 + state = (self.radial(), self.spectral(), self.temporal(),
  86 + gammalib.GModelData.__getstate__(self))
  87 + return state
  88 + def __setstate__(self, state):
  89 + if state[0] != None and state[1] != None and state[2] != None:
  90 + self.__init__(state[0], state[1], state[2])
  91 + elif state[0] != None and state[1] != None:
  92 + self.__init__(state[0], state[1])
  93 + else:
  94 + self.__init__()
  95 + gammalib.GModelData.__setstate__(self, state[3])
  96 +}
78 97 };
... ...
inst/cta/pyext/GCTAModelRadialGauss.i
1 1 /***************************************************************************
2 2 * GCTAModelRadialGauss.i - Radial Gaussian model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -26,7 +26,6 @@
26 26 %{
27 27 /* Put headers and other declarations here that are needed for compilation */
28 28 #include "GCTAModelRadialGauss.hpp"
29   -#include "GTools.hpp"
30 29 %}
31 30  
32 31  
... ... @@ -66,4 +65,15 @@ public:
66 65 * @brief GCTAModelRadialGauss class extension
67 66 ***************************************************************************/
68 67 %extend GCTAModelRadialGauss {
  68 + GCTAModelRadialGauss copy() {
  69 + return (*self);
  70 + }
  71 +%pythoncode {
  72 + def __getstate__(self):
  73 + state = (self[0],)
  74 + return state
  75 + def __setstate__(self, state):
  76 + self.__init__()
  77 + self[0] = state[0]
  78 +}
69 79 };
... ...
inst/cta/pyext/GCTAModelRadialPolynom.i
1 1 /***************************************************************************
2 2 * GCTAModelRadialPolynom.i - Radial Polynom model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -26,7 +26,6 @@
26 26 %{
27 27 /* Put headers and other declarations here that are needed for compilation */
28 28 #include "GCTAModelRadialPolynom.hpp"
29   -#include "GTools.hpp"
30 29 %}
31 30  
32 31  
... ... @@ -57,7 +56,6 @@ public:
57 56 virtual void write(GXmlElement& xml) const;
58 57  
59 58 // Other methods
60   - int size(void) const { return m_coeffs.size(); }
61 59 //double coeff(void) const;
62 60 //void coeff(const double& value);
63 61 };
... ... @@ -67,4 +65,19 @@ public:
67 65 * @brief GCTAModelRadialPolynom class extension
68 66 ***************************************************************************/
69 67 %extend GCTAModelRadialPolynom {
  68 + GCTAModelRadialPolynom copy() {
  69 + return (*self);
  70 + }
  71 +%pythoncode {
  72 + def __getstate__(self):
  73 + xml = gammalib.GXmlElement()
  74 + self.write(xml)
  75 + state = (xml,)
  76 + return state
  77 + def __setstate__(self, state):
  78 + if state[0].elements('parameter') == 0:
  79 + self.__init__()
  80 + else:
  81 + self.__init__(state[0])
  82 +}
70 83 };
... ...
inst/cta/pyext/GCTAModelRadialProfile.i
1 1 /***************************************************************************
2 2 * GCTAModelRadialProfile.i - Radial Profile model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -71,4 +71,17 @@ public:
71 71 * @brief GCTAModelRadialProfile class extension
72 72 ***************************************************************************/
73 73 %extend GCTAModelRadialProfile {
  74 + GCTAModelRadialProfile copy() {
  75 + return (*self);
  76 + }
  77 +%pythoncode {
  78 + def __getstate__(self):
  79 + state = (self[0], self[1], self[2])
  80 + return state
  81 + def __setstate__(self, state):
  82 + self.__init__()
  83 + self[0] = state[0]
  84 + self[1] = state[1]
  85 + self[2] = state[2]
  86 +}
74 87 };
... ...
inst/cta/pyext/GCTAObservation.i
... ... @@ -65,6 +65,7 @@ public:
65 65 virtual void write(GXmlElement& xml) const;
66 66  
67 67 // Other methods
  68 + void instrument(const std::string& instrument);
68 69 bool has_response(void) const;
69 70 bool has_events(void) const;
70 71 void read(const GFits& fits);
... ... @@ -112,7 +113,9 @@ public:
112 113 const GFilename& eventfile(void) const;
113 114 std::string eventtype(void) const;
114 115 void dispose_events(void);
  116 + void lo_user_thres(const double& lo_user_thres);
115 117 const double& lo_user_thres(void) const;
  118 + void hi_user_thres(const double& hi_user_thres);
116 119 const double& hi_user_thres(void) const;
117 120 void n_tels(const int& tels);
118 121 const int& n_tels(void) const;
... ... @@ -128,10 +131,32 @@ public:
128 131 }
129 132 %pythoncode {
130 133 def __getstate__(self):
131   - args = gammalib.GObservation.__getstate__(self) + ()
132   - return args
  134 + if self.has_response():
  135 + response = self.response()
  136 + else:
  137 + response = None
  138 + state = (gammalib.GObservation.__getstate__(self),
  139 + self.instrument(), self.eventfile(), response,
  140 + self.pointing(), self.off_regions(), self.ontime(),
  141 + self.livetime(), self.deadc(), self.ra_obj(), self.dec_obj(),
  142 + self.lo_user_thres(), self.hi_user_thres(), self.n_tels())
  143 + return state
133 144 def __setstate__(self, state):
134 145 self.__init__()
135   - gammalib.GObservation.__setstate__(self, state)
  146 + gammalib.GObservation.__setstate__(self, state[0])
  147 + self.instrument(state[1])
  148 + self.eventfile(state[2])
  149 + if state[3] != None:
  150 + self.response(state[3])
  151 + self.pointing(state[4])
  152 + self.off_regions(state[5])
  153 + self.ontime(state[6])
  154 + self.livetime(state[7])
  155 + self.deadc(state[8])
  156 + self.ra_obj(state[9])
  157 + self.dec_obj(state[10])
  158 + self.lo_user_thres(state[11])
  159 + self.hi_user_thres(state[12])
  160 + self.n_tels(state[13])
136 161 }
137 162 };
... ...
inst/cta/pyext/GCTAOnOffObservation.i
... ... @@ -112,6 +112,7 @@ public:
112 112  
113 113 // Other methods
114 114 void instrument(const std::string& instrument);
  115 + bool has_response(void) const;
115 116 const GPha& on_spec(void) const;
116 117 const GPha& off_spec(void) const;
117 118 const GArf& arf(void) const;
... ... @@ -128,4 +129,21 @@ public:
128 129 GCTAOnOffObservation copy() {
129 130 return (*self);
130 131 }
  132 +%pythoncode {
  133 + def __getstate__(self):
  134 + if self.has_response():
  135 + response = self.response()
  136 + else:
  137 + response = None
  138 + state = (gammalib.GObservation.__getstate__(self),
  139 + self.instrument(), response, self.on_spec(), self.off_spec(),
  140 + self.arf(), self.rmf())
  141 + return state
  142 + def __setstate__(self, state):
  143 + self.__init__(state[3], state[4], state[5], state[6])
  144 + gammalib.GObservation.__setstate__(self, state[0])
  145 + self.instrument(state[1])
  146 + if state[2] != None:
  147 + self.response(state[2])
  148 +}
131 149 }
... ...
inst/cta/pyext/GCTAPointing.i
1 1 /***************************************************************************
2 2 * GCTAPointing.i - CTA pointing class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2016 by Jurgen Knodlseder *
  4 + * copyright (C) 2010-2018 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -73,4 +73,13 @@ public:
73 73 GCTAPointing copy() {
74 74 return (*self);
75 75 }
  76 +%pythoncode {
  77 + def __getstate__(self):
  78 + state = (self.dir(), self.zenith(), self.azimuth())
  79 + return state
  80 + def __setstate__(self, state):
  81 + self.__init__(state[0])
  82 + self.zenith(state[1])
  83 + self.azimuth(state[2])
  84 +}
76 85 };
... ...
inst/cta/pyext/GCTAPsf2D.i
1 1 /***************************************************************************
2 2 * GCTAPsf2D.i - CTA 2D point spread function class *
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 *
... ... @@ -96,4 +96,21 @@ public:
96 96 GCTAPsf2D copy() {
97 97 return (*self);
98 98 }
  99 +%pythoncode {
  100 + def __getstate__(self):
  101 + if self.filename().is_empty():
  102 + hdu = gammalib.GFitsBinTable()
  103 + self.write(hdu)
  104 + state = (self.filename(), hdu)
  105 + else:
  106 + state = (self.filename(),)
  107 + return state
  108 + def __setstate__(self, state):
  109 + if state[0].is_empty():
  110 + self.__init__()
  111 + if state[1].nrows() > 0:
  112 + self.read(state[1])
  113 + else:
  114 + self.__init__(state[0])
  115 +}
99 116 };
... ...
inst/cta/pyext/GCTAPsfKing.i
1 1 /***************************************************************************
2 2 * GCTAPsfKing.i - King profile CTA point spread function class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2016 by Michael Mayer *
  4 + * copyright (C) 2013-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -98,4 +98,21 @@ public:
98 98 GCTAPsfKing copy() {
99 99 return (*self);
100 100 }
  101 +%pythoncode {
  102 + def __getstate__(self):
  103 + if self.filename().is_empty():
  104 + hdu = gammalib.GFitsBinTable()
  105 + self.write(hdu)
  106 + state = (self.filename(), hdu)
  107 + else:
  108 + state = (self.filename(),)
  109 + return state
  110 + def __setstate__(self, state):
  111 + if state[0].is_empty():
  112 + self.__init__()
  113 + if state[1].nrows() > 0:
  114 + self.read(state[1])
  115 + else:
  116 + self.__init__(state[0])
  117 +}
101 118 };
... ...
inst/cta/pyext/GCTAPsfTable.i
1 1 /***************************************************************************
2 2 * GCTAPsfTable.i - CTA point spread function table class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2016-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -95,4 +95,21 @@ public:
95 95 GCTAPsfTable copy() {
96 96 return (*self);
97 97 }
  98 +%pythoncode {
  99 + def __getstate__(self):
  100 + if self.filename().is_empty():
  101 + hdu = gammalib.GFitsBinTable()
  102 + self.write(hdu)
  103 + state = (self.filename(), hdu)
  104 + else:
  105 + state = (self.filename(),)
  106 + return state
  107 + def __setstate__(self, state):
  108 + if state[0].is_empty():
  109 + self.__init__()
  110 + if state[1].nrows() > 0:
  111 + self.read(state[1])
  112 + else:
  113 + self.__init__(state[0])
  114 +}
98 115 };
... ...
inst/cta/pyext/GCTAResponseCube.i
1 1 /***************************************************************************
2 2 * GCTAResponseCube.i - CTA cube analysis response function class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2014-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -90,4 +90,16 @@ public:
90 90 GCTAResponseCube copy() {
91 91 return (*self);
92 92 }
  93 +%pythoncode {
  94 + def __getstate__(self):
  95 + state = (self.exposure(), self.psf(), self.edisp(), self.background(),
  96 + self.apply_edisp())
  97 + return state
  98 + def __setstate__(self, state):
  99 + if state[2].energies().is_empty():
  100 + self.__init__(state[0], state[1], state[3])
  101 + else:
  102 + self.__init__(state[0], state[1], state[2], state[3])
  103 + self.apply_edisp(state[4])
  104 +}
93 105 };
... ...
inst/cta/pyext/GCTAResponseIrf.i
... ... @@ -129,4 +129,14 @@ public:
129 129 GCTAResponseIrf copy() {
130 130 return (*self);
131 131 }
  132 +%pythoncode {
  133 + def __getstate__(self):
  134 + state = (self.rspname(), self.caldb())
  135 + return state
  136 + def __setstate__(self, state):
  137 + if state[0]:
  138 + self.__init__(state[0], state[1])
  139 + else:
  140 + self.__init__()
  141 +}
132 142 };
... ...
inst/cta/pyext/GCTAResponseTable.i
1 1 /***************************************************************************
2 2 * GCTAResponseTable.i - CTA response table class *
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 *
... ... @@ -169,9 +169,6 @@ public:
169 169 * @brief GCTAResponse class extension
170 170 ***************************************************************************/
171 171 %extend GCTAResponseTable {
172   - GCTAResponseTable copy() {
173   - return (*self);
174   - }
175 172 double __getitem__(int GCTAResponseTableInx[]) {
176 173 if (GCTAResponseTableInx[0] == 1) {
177 174 return (*self)(GCTAResponseTableInx[1]);
... ... @@ -188,4 +185,17 @@ public:
188 185 (*self)(GCTAResponseTableInx[1], GCTAResponseTableInx[2]) = value;
189 186 }
190 187 }
  188 + GCTAResponseTable copy() {
  189 + return (*self);
  190 + }
  191 +%pythoncode {
  192 + def __getstate__(self):
  193 + hdu = gammalib.GFitsBinTable()
  194 + self.write(hdu)
  195 + state = (hdu,)
  196 + return state
  197 + def __setstate__(self, state):
  198 + self.__init__()
  199 + self.read(state[0])
  200 +}
191 201 };
... ...
inst/cta/pyext/GCTARoi.i
1 1 /***************************************************************************
2 2 * GCTARoi.i - CTA region of interest class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2017 by Jurgen Knodlseder *
  4 + * copyright (C) 2010-2018 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -69,4 +69,14 @@ public:
69 69 GCTARoi copy() {
70 70 return (*self);
71 71 }
  72 +%pythoncode {
  73 + def __getstate__(self):
  74 + state = (self.centre(), self.radius())
  75 + return state
  76 + def __setstate__(self, state):
  77 + if state[1] > 0.0:
  78 + self.__init__(state[0], state[1])
  79 + else:
  80 + self.__init__()
  81 +}
72 82 };
... ...
inst/cta/pyext/cta.i
1 1 /***************************************************************************
2 2 * cta.i - Cherenkov Telescope Array module *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2017 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -178,6 +178,28 @@
178 178 }
179 179 $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), myinfo, 0 | 0);
180 180 }
  181 +%typemap(out) GCTAModelRadial* {
  182 + if ($1 == NULL) {
  183 + $result = Py_None;
  184 + Py_INCREF(Py_None); // Py_None is a singleton so increment its reference
  185 + }
  186 + else {
  187 + char classname[80];
  188 + strcpy(classname, "_p_");
  189 + strcat(classname, result->classname().c_str());
  190 + swig_type_info *myinfo = SWIGTYPE_p_GCTAModelRadial;
  191 + swig_cast_info *mycast = 0;
  192 + mycast = myinfo->cast;
  193 + while (mycast != 0) {
  194 + if (strcmp(classname, mycast->type->name) == 0) {
  195 + myinfo = mycast->type;
  196 + break;
  197 + }
  198 + mycast = mycast->next;
  199 + }
  200 + $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), myinfo, 0 | 0);
  201 + }
  202 +}
181 203 %typemap(out) GModelSpectral* {
182 204 if ($1 == NULL) {
183 205 $result = Py_None;
... ...
inst/cta/src/GCTAAeff2D.cpp
... ... @@ -548,25 +548,33 @@ std::string GCTAAeff2D::print(const GChatter&amp; chatter) const
548 548 // Continue only if chatter is not silent
549 549 if (chatter != SILENT) {
550 550  
551   - // Compute energy boundaries in TeV
552   - double emin = m_aeff.axis_lo(m_inx_energy,0);
553   - double emax = m_aeff.axis_hi(m_inx_energy,
554   - m_aeff.axis_bins(m_inx_energy)-1);
555   -
556   - // Compute offset angle boundaries in deg
557   - double omin = m_aeff.axis_lo(m_inx_theta,0);
558   - double omax = m_aeff.axis_hi(m_inx_theta,
559   - m_aeff.axis_bins(m_inx_theta)-1);
560   -
561 551 // Append header
562 552 result.append("=== GCTAAeff2D ===");
  553 + result.append("\n"+gammalib::parformat("Filename")+m_filename);
  554 +
  555 + // Initialise information
  556 + int nebins = 0;
  557 + int nthetabins = 0;
  558 + double emin = 0.0;
  559 + double emax = 0.0;
  560 + double omin = 0.0;
  561 + double omax = 0.0;
  562 +
  563 + // Extract information if there are axes in the response table
  564 + if (m_aeff.axes() > 0) {
  565 + nebins = m_aeff.axis_bins(m_inx_energy);
  566 + nthetabins = m_aeff.axis_bins(m_inx_theta);
  567 + emin = m_aeff.axis_lo(m_inx_energy,0);
  568 + emax = m_aeff.axis_hi(m_inx_energy,nebins-1);
  569 + omin = m_aeff.axis_lo(m_inx_theta,0);
  570 + omax = m_aeff.axis_hi(m_inx_theta,nthetabins-1);
  571 + }
563 572  
564 573 // Append information
565   - result.append("\n"+gammalib::parformat("Filename")+m_filename);
566 574 result.append("\n"+gammalib::parformat("Number of energy bins") +
567   - gammalib::str(m_aeff.axis_bins(m_inx_energy)));
  575 + gammalib::str(nebins));
568 576 result.append("\n"+gammalib::parformat("Number of offset bins") +
569   - gammalib::str(m_aeff.axis_bins(m_inx_theta)));
  577 + gammalib::str(nthetabins));
570 578 result.append("\n"+gammalib::parformat("Log10(Energy) range"));
571 579 result.append(gammalib::str(emin)+" - "+gammalib::str(emax)+" TeV");
572 580 result.append("\n"+gammalib::parformat("Offset angle range"));
... ...
inst/cta/src/GCTACubeExposure.cpp
... ... @@ -420,8 +420,10 @@ void GCTACubeExposure::write(GFits&amp; fits) const
420 420 m_cube.write(fits);
421 421  
422 422 // Get last HDU and write attributes
423   - GFitsHDU& hdu = *fits[fits.size()-1];
424   - write_attributes(hdu);
  423 + if (fits.size() > 0) {
  424 + GFitsHDU& hdu = *fits[fits.size()-1];
  425 + write_attributes(hdu);
  426 + }
425 427  
426 428 // Write energies
427 429 m_energies.write(fits);
... ...
inst/cta/src/GCTAEdisp2D.cpp
... ... @@ -691,8 +691,6 @@ GEbounds GCTAEdisp2D::ebounds_src(const double&amp; logEobs,
691 691 * @exception GException::file_error
692 692 * File not found.
693 693 * Unable to load energy dispersion.
694   - * @exception GException::invalid_value
695   - * No file name has been specified.
696 694 *
697 695 * Fetches the energy dispersion by reading it from a FITS file. This method
698 696 * does nothing if the energy dispersion is already loaded, if there is
... ... @@ -763,13 +761,6 @@ void GCTAEdisp2D::fetch(void) const
763 761 }
764 762  
765 763 } // endif: filename was not empty
766   -
767   - // Throw an exception if the FITS file name is not known
768   - else {
769   - std::string msg = "Unable to fetch energy dispersion since no "
770   - "filename is specified.";
771   - throw GException::invalid_value(G_FETCH, msg);
772   - }
773 764  
774 765 } // endif: energy dispersion had not yet been fetched
775 766  
... ... @@ -932,35 +923,44 @@ std::string GCTAEdisp2D::print(const GChatter&amp; chatter) const
932 923 // Continue only if chatter is not silent
933 924 if (chatter != SILENT) {
934 925  
  926 + // Append header
  927 + result.append("=== GCTAEdisp2D ===");
  928 + result.append("\n"+gammalib::parformat("Filename")+m_filename);
  929 +
935 930 // Make sure that energy dispersion is online
936 931 fetch();
937 932  
938   - // Compute energy boundaries in TeV
939   - double emin = m_edisp.axis_lo(m_inx_etrue,0);
940   - double emax = m_edisp.axis_hi(m_inx_etrue,
941   - m_edisp.axis_bins(m_inx_etrue)-1);
942   -
943   - // Compute mingration
944   - double mmin = m_edisp.axis_lo(m_inx_migra,0);
945   - double mmax = m_edisp.axis_hi(m_inx_migra,
946   - m_edisp.axis_bins(m_inx_migra)-1);
947   -
948   - // Compute offset angle boundaries in deg
949   - double omin = m_edisp.axis_lo(m_inx_theta,0);
950   - double omax = m_edisp.axis_hi(m_inx_theta,
951   - m_edisp.axis_bins(m_inx_theta)-1);
952   -
953   - // Append header
954   - result.append("=== GCTAEdisp2D ===");
  933 + // Initialise information
  934 + int nebins = 0;
  935 + int nmigrabins = 0;
  936 + int nthetabins = 0;
  937 + double emin = 0.0;
  938 + double emax = 0.0;
  939 + double mmin = 0.0;
  940 + double mmax = 0.0;
  941 + double omin = 0.0;
  942 + double omax = 0.0;
  943 +
  944 + // Extract information if there are axes in the response table
  945 + if (m_edisp.axes() > 0) {
  946 + nebins = m_edisp.axis_bins(m_inx_etrue);
  947 + nmigrabins = m_edisp.axis_bins(m_inx_migra);
  948 + nthetabins = m_edisp.axis_bins(m_inx_theta);
  949 + emin = m_edisp.axis_lo(m_inx_etrue,0);
  950 + emax = m_edisp.axis_hi(m_inx_etrue,nebins-1);
  951 + mmin = m_edisp.axis_lo(m_inx_migra,0);
  952 + mmax = m_edisp.axis_hi(m_inx_migra,nmigrabins-1);
  953 + omin = m_edisp.axis_lo(m_inx_theta,0);
  954 + omax = m_edisp.axis_hi(m_inx_theta,nthetabins-1);
  955 + }
955 956  
956 957 // Append information
957   - result.append("\n"+gammalib::parformat("Filename")+m_filename);
958 958 result.append("\n"+gammalib::parformat("Number of energy bins") +
959   - gammalib::str(m_edisp.axis_bins(m_inx_etrue)));
  959 + gammalib::str(nebins));
960 960 result.append("\n"+gammalib::parformat("Number of migration bins") +
961   - gammalib::str(m_edisp.axis_bins(m_inx_migra)));
  961 + gammalib::str(nmigrabins));
962 962 result.append("\n"+gammalib::parformat("Number of offset bins") +
963   - gammalib::str(m_edisp.axis_bins(m_inx_theta)));
  963 + gammalib::str(nthetabins));
964 964 result.append("\n"+gammalib::parformat("Log10(Energy) range"));
965 965 result.append(gammalib::str(emin)+" - "+gammalib::str(emax)+" TeV");
966 966 result.append("\n"+gammalib::parformat("Migration range"));
... ...
inst/cta/src/GCTAEventList.cpp
... ... @@ -444,9 +444,10 @@ void GCTAEventList::read(const GFits&amp; fits)
444 444 // Read phase intervals from data sub-space keyword
445 445 m_phases = gammalib::read_ds_phase(events);
446 446  
447   - // If the file name contains an expression then load the events now.
448   - // We do this at the end to make sure that the GTI has been set before.
449   - if (m_filename.has_expression()) {
  447 + // If the file name contains an expression or the filename is empty then
  448 + // load the events now. We do this at the end to make sure that the GTI
  449 + // has been set before.
  450 + if (m_filename.has_expression() || m_filename.is_empty()) {
450 451 read_events(events);
451 452 }
452 453  
... ...
inst/cta/src/GCTAModelAeffBackground.cpp
1 1 /***************************************************************************
2 2 * GCTAModelAeffBackground.cpp - CTA Aeff background model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2015-2017 by Michael Mayer *
  4 + * copyright (C) 2015-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -85,7 +85,7 @@ GCTAModelAeffBackground::GCTAModelAeffBackground(void) : GModelData()
85 85  
86 86  
87 87 /***********************************************************************//**
88   - * @brief Constructor
  88 + * @brief XML constructor
89 89 *
90 90 * @param[in] xml XML element.
91 91 *
... ... @@ -135,10 +135,8 @@ GCTAModelAeffBackground::GCTAModelAeffBackground(const GXmlElement&amp; xml) :
135 135 *
136 136 * @param[in] spectral Spectral model component.
137 137 *
138   - * Constructs a CTA effective area background model from a spectral
  138 + * Constructs a CTA effective area background model from a @p spectral
139 139 * model component. The temporal component is assumed to be constant.
140   - * Please refer to the class GModelSpectral to learn more about the
141   - * definition of the spectral components.
142 140 ***************************************************************************/
143 141 GCTAModelAeffBackground::GCTAModelAeffBackground(const GModelSpectral& spectral) :
144 142 GModelData()
... ... @@ -162,6 +160,34 @@ GCTAModelAeffBackground::GCTAModelAeffBackground(const GModelSpectral&amp; spectral)
162 160  
163 161  
164 162 /***********************************************************************//**
  163 + * @brief Construct from model components
  164 + *
  165 + * @param[in] spectral Spectral model component.
  166 + * @param[in] temporal Temporal model component.
  167 + *
  168 + * Constructs a CTA effective area background model from a @p spectral and a
  169 + * @p temporal component.
  170 + ***************************************************************************/
  171 +GCTAModelAeffBackground::GCTAModelAeffBackground(const GModelSpectral& spectral,
  172 + const GModelTemporal& temporal) :
  173 + GModelData()
  174 +{
  175 + // Initialise members
  176 + init_members();
  177 +
  178 + // Clone model components
  179 + m_spectral = spectral.clone();
  180 + m_temporal = temporal.clone();
  181 +
  182 + // Set parameter pointers
  183 + set_pointers();
  184 +
  185 + // Return
  186 + return;
  187 +}
  188 +
  189 +
  190 +/***********************************************************************//**
165 191 * @brief Copy constructor
166 192 *
167 193 * @param[in] aeff CTA instrument background model.
... ...
inst/cta/src/GCTAModelCubeBackground.cpp
1 1 /***************************************************************************
2 2 * GCTAModelCubeBackground.cpp - CTA cube background model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2016 by Michael Mayer *
  4 + * copyright (C) 2013-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -112,10 +112,8 @@ GCTAModelCubeBackground::GCTAModelCubeBackground(const GXmlElement&amp; xml) :
112 112 *
113 113 * @param[in] spectral Spectral model component.
114 114 *
115   - * Constructs a CTA cube background model from a spectral model component.
116   - * The temporal component is assumed to be constant. Please refer to the
117   - * class GModelSpectral to learn more about the definition of the spectral
118   - * components.
  115 + * Constructs a CTA cube background model from a @p spectral model component.
  116 + * The temporal component is assumed to be constant.
119 117 ***************************************************************************/
120 118 GCTAModelCubeBackground::GCTAModelCubeBackground(const GModelSpectral& spectral) :
121 119 GModelData()
... ... @@ -139,6 +137,34 @@ GCTAModelCubeBackground::GCTAModelCubeBackground(const GModelSpectral&amp; spectral)
139 137  
140 138  
141 139 /***********************************************************************//**
  140 + * @brief Construct from model components
  141 + *
  142 + * @param[in] spectral Spectral model component.
  143 + * @param[in] temporal Temporal model component.
  144 + *
  145 + * Constructs a CTA cube background model from a @p spectral and a
  146 + * @p temporal component.
  147 + ***************************************************************************/
  148 +GCTAModelCubeBackground::GCTAModelCubeBackground(const GModelSpectral& spectral,
  149 + const GModelTemporal& temporal) :
  150 + GModelData()
  151 +{
  152 + // Initialise members
  153 + init_members();
  154 +
  155 + // Clone model components
  156 + m_spectral = spectral.clone();
  157 + m_temporal = temporal.clone();
  158 +
  159 + // Set parameter pointers
  160 + set_pointers();
  161 +
  162 + // Return
  163 + return;
  164 +}
  165 +
  166 +
  167 +/***********************************************************************//**
142 168 * @brief Copy constructor
143 169 *
144 170 * @param[in] bgd CTA cube background model.
... ...
inst/cta/src/GCTAModelRadialAcceptance.cpp
... ... @@ -92,14 +92,13 @@ GCTAModelRadialAcceptance::GCTAModelRadialAcceptance(void) : GModelData()
92 92  
93 93  
94 94 /***********************************************************************//**
95   - * @brief Constructor
  95 + * @brief XML constructor
96 96 *
97 97 * @param[in] xml XML element.
98 98 *
99 99 * Constructs a CTA radial acceptance model from the information that is
100   - * found in a XML element. Please refer to the method
101   - * GCTAModelRadialAcceptance::read
102   - * to learn more about the information that is expected in the XML element.
  100 + * found in a XML element. Please refer to the read() method to learn about
  101 + * the expected structure of the XML element.
103 102 ***************************************************************************/
104 103 GCTAModelRadialAcceptance::GCTAModelRadialAcceptance(const GXmlElement& xml) :
105 104 GModelData(xml)
... ... @@ -124,10 +123,9 @@ GCTAModelRadialAcceptance::GCTAModelRadialAcceptance(const GXmlElement&amp; xml) :
124 123 * @param[in] radial Radial CTA model component.
125 124 * @param[in] spectral Spectral model component.
126 125 *
127   - * Constructs a CTA radial acceptance model from a radial and a spectral
128   - * model component. The temporal component is assumed to be constant.
129   - * Please refer to the classes GCTAModelRadial and GModelSpectral to learn
130   - * more about the definition of the radial and spectral components.
  126 + * Constructs a CTA radial acceptance model from a @p radial and a
  127 + * @p spectral model component. The temporal component is assumed to be
  128 + * constant.
131 129 ***************************************************************************/
132 130 GCTAModelRadialAcceptance::GCTAModelRadialAcceptance(const GCTAModelRadial& radial,
133 131 const GModelSpectral& spectral) :
... ... @@ -153,6 +151,37 @@ GCTAModelRadialAcceptance::GCTAModelRadialAcceptance(const GCTAModelRadial&amp; radi
153 151  
154 152  
155 153 /***********************************************************************//**
  154 + * @brief Construct from model components
  155 + *
  156 + * @param[in] radial Radial CTA model component.
  157 + * @param[in] spectral Spectral model component.
  158 + * @param[in] temporal Temporal model component.
  159 + *
  160 + * Constructs a CTA radial acceptance model from a @p radial, a @p spectral
  161 + * and a @p temporal model component.
  162 + ***************************************************************************/
  163 +GCTAModelRadialAcceptance::GCTAModelRadialAcceptance(const GCTAModelRadial& radial,
  164 + const GModelSpectral& spectral,
  165 + const GModelTemporal& temporal) :
  166 + GModelData()
  167 +{
  168 + // Initialise members
  169 + init_members();
  170 +
  171 + // Clone model components
  172 + m_radial = radial.clone();
  173 + m_spectral = spectral.clone();
  174 + m_temporal = temporal.clone();
  175 +
  176 + // Set parameter pointers
  177 + set_pointers();
  178 +
  179 + // Return
  180 + return;
  181 +}
  182 +
  183 +
  184 +/***********************************************************************//**
156 185 * @brief Copy constructor
157 186 *
158 187 * @param[in] model Radial acceptance model.
... ...
inst/cta/src/GCTAModelRadialPolynom.cpp
... ... @@ -79,8 +79,8 @@ GCTAModelRadialPolynom::GCTAModelRadialPolynom(void) : GCTAModelRadial()
79 79 *
80 80 * @param[in] coeffs Vector of polynomial coefficients.
81 81 ***************************************************************************/
82   -GCTAModelRadialPolynom::GCTAModelRadialPolynom(const std::vector<double>& coeffs)
83   - : GCTAModelRadial()
  82 +GCTAModelRadialPolynom::GCTAModelRadialPolynom(const std::vector<double>& coeffs) :
  83 + GCTAModelRadial()
84 84 {
85 85 // Initialise members
86 86 init_members();
... ... @@ -95,7 +95,7 @@ GCTAModelRadialPolynom::GCTAModelRadialPolynom(const std::vector&lt;double&gt;&amp; coeffs
95 95 par.value(coeffs[i]);
96 96  
97 97 // Set other attributes
98   - std::string name = "coeff" + gammalib::str(i);
  98 + std::string name = "Coeff" + gammalib::str(i);
99 99 par.name(name);
100 100 par.unit("");
101 101 par.free();
... ...
inst/cta/src/GCTAPsf2D.cpp
1 1 /***************************************************************************
2 2 * GCTAPsf2D.cpp - CTA 2D point spread function class *
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 *
... ... @@ -364,10 +364,12 @@ void GCTAPsf2D::write(GFitsBinTable&amp; table) const
364 364 // Create a copy of the response table
365 365 GCTAResponseTable psf(m_psf);
366 366  
367   - // Convert sigma parameters back to degrees
368   - psf.scale(m_inx_sigma1, gammalib::rad2deg);
369   - psf.scale(m_inx_sigma2, gammalib::rad2deg);
370   - psf.scale(m_inx_sigma3, gammalib::rad2deg);
  367 + // Convert sigma parameters back to degrees (only if there are tables)
  368 + if (psf.tables() > 0) {
  369 + psf.scale(m_inx_sigma1, gammalib::rad2deg);
  370 + psf.scale(m_inx_sigma2, gammalib::rad2deg);
  371 + psf.scale(m_inx_sigma3, gammalib::rad2deg);
  372 + }
371 373  
372 374 // Write response table
373 375 psf.write(table);
... ... @@ -670,7 +672,7 @@ double GCTAPsf2D::containment_radius(const double&amp; fraction,
670 672 /***********************************************************************//**
671 673 * @brief Print point spread function information
672 674 *
673   - * @param[in] chatter Chattiness (defaults to NORMAL).
  675 + * @param[in] chatter Chattiness.
674 676 * @return String containing point spread function information.
675 677 ***************************************************************************/
676 678 std::string GCTAPsf2D::print(const GChatter& chatter) const
... ... @@ -681,25 +683,33 @@ std::string GCTAPsf2D::print(const GChatter&amp; chatter) const
681 683 // Continue only if chatter is not silent
682 684 if (chatter != SILENT) {
683 685  
684   - // Compute energy boundaries in TeV
685   - double emin = m_psf.axis_lo(m_inx_energy,0);
686   - double emax = m_psf.axis_hi(m_inx_energy,
687   - m_psf.axis_bins(m_inx_energy)-1);
688   -
689   - // Compute offset angle boundaries in deg
690   - double omin = m_psf.axis_lo(m_inx_theta,0);
691   - double omax = m_psf.axis_hi(m_inx_theta,
692   - m_psf.axis_bins(m_inx_theta)-1);
693   -
694 686 // Append header
695 687 result.append("=== GCTAPsf2D ===");
  688 + result.append("\n"+gammalib::parformat("Filename")+m_filename);
  689 +
  690 + // Initialise information
  691 + int nebins = 0;
  692 + int nthetabins = 0;
  693 + double emin = 0.0;
  694 + double emax = 0.0;
  695 + double omin = 0.0;
  696 + double omax = 0.0;
  697 +
  698 + // Extract information if there are axes in the response table
  699 + if (m_psf.axes() > 0) {
  700 + nebins = m_psf.axis_bins(m_inx_energy);
  701 + nthetabins = m_psf.axis_bins(m_inx_theta);
  702 + emin = m_psf.axis_lo(m_inx_energy,0);
  703 + emax = m_psf.axis_hi(m_inx_energy,nebins-1);
  704 + omin = m_psf.axis_lo(m_inx_theta,0);
  705 + omax = m_psf.axis_hi(m_inx_theta,nthetabins-1);
  706 + }
696 707  
697 708 // Append information
698   - result.append("\n"+gammalib::parformat("Filename")+m_filename);
699 709 result.append("\n"+gammalib::parformat("Number of energy bins") +
700   - gammalib::str(m_psf.axis_bins(m_inx_energy)));
  710 + gammalib::str(nebins));
701 711 result.append("\n"+gammalib::parformat("Number of offset bins") +
702   - gammalib::str(m_psf.axis_bins(m_inx_theta)));
  712 + gammalib::str(nthetabins));
703 713 result.append("\n"+gammalib::parformat("Log10(Energy) range"));
704 714 result.append(gammalib::str(emin)+" - "+gammalib::str(emax)+" TeV");
705 715 result.append("\n"+gammalib::parformat("Offset angle range"));
... ...
inst/cta/src/GCTAPsfKing.cpp
... ... @@ -341,8 +341,10 @@ void GCTAPsfKing::write(GFitsBinTable&amp; table) const
341 341 // Create a copy of the response table
342 342 GCTAResponseTable psf(m_psf);
343 343  
344   - // Convert sigma parameters back to degrees
345   - psf.scale(m_inx_sigma, gammalib::rad2deg);
  344 + // Convert sigma parameters back to degrees (only if there are tables)
  345 + if (psf.tables() > 0) {
  346 + psf.scale(m_inx_sigma, gammalib::rad2deg);
  347 + }
346 348  
347 349 // Write response table
348 350 psf.write(table);
... ... @@ -583,7 +585,7 @@ double GCTAPsfKing::containment_radius(const double&amp; fraction,
583 585 /***********************************************************************//**
584 586 * @brief Print point spread function information
585 587 *
586   - * @return Content of point spread function instance.
  588 + * @param[in] chatter Chattiness.
587 589 * @return String containing point spread function information.
588 590 ***************************************************************************/
589 591 std::string GCTAPsfKing::print(const GChatter& chatter) const
... ... @@ -594,25 +596,33 @@ std::string GCTAPsfKing::print(const GChatter&amp; chatter) const
594 596 // Continue only if chatter is not silent
595 597 if (chatter != SILENT) {
596 598  
597   - // Compute energy boundaries in TeV
598   - double emin = m_psf.axis_lo(m_inx_energy,0);
599   - double emax = m_psf.axis_hi(m_inx_energy,
600   - m_psf.axis_bins(m_inx_energy)-1);
601   -
602   - // Compute offset angle boundaries in deg
603   - double omin = m_psf.axis_lo(m_inx_theta,0);
604   - double omax = m_psf.axis_hi(m_inx_theta,
605   - m_psf.axis_bins(m_inx_theta)-1);
606   -
607 599 // Append header
608 600 result.append("=== GCTAPsfKing ===");
  601 + result.append("\n"+gammalib::parformat("Filename")+m_filename);
  602 +
  603 + // Initialise information
  604 + int nebins = 0;
  605 + int nthetabins = 0;
  606 + double emin = 0.0;
  607 + double emax = 0.0;
  608 + double omin = 0.0;
  609 + double omax = 0.0;
  610 +
  611 + // Extract information if there are axes in the response table
  612 + if (m_psf.axes() > 0) {
  613 + nebins = m_psf.axis_bins(m_inx_energy);
  614 + nthetabins = m_psf.axis_bins(m_inx_theta);
  615 + emin = m_psf.axis_lo(m_inx_energy,0);
  616 + emax = m_psf.axis_hi(m_inx_energy,nebins-1);
  617 + omin = m_psf.axis_lo(m_inx_theta,0);
  618 + omax = m_psf.axis_hi(m_inx_theta,nthetabins-1);
  619 + }
609 620  
610 621 // Append information
611   - result.append("\n"+gammalib::parformat("Filename")+m_filename);
612 622 result.append("\n"+gammalib::parformat("Number of energy bins") +
613   - gammalib::str(m_psf.axis_bins(m_inx_energy)));
  623 + gammalib::str(nebins));
614 624 result.append("\n"+gammalib::parformat("Number of offset bins") +
615   - gammalib::str(m_psf.axis_bins(m_inx_theta)));
  625 + gammalib::str(nthetabins));
616 626 result.append("\n"+gammalib::parformat("Log10(Energy) range"));
617 627 result.append(gammalib::str(emin)+" - "+gammalib::str(emax)+" TeV");
618 628 result.append("\n"+gammalib::parformat("Offset angle range"));
... ...
inst/cta/src/GCTAPsfTable.cpp
... ... @@ -583,7 +583,7 @@ double GCTAPsfTable::containment_radius(const double&amp; fraction,
583 583 /***********************************************************************//**
584 584 * @brief Print point spread function information
585 585 *
586   - * @return Content of point spread function instance.
  586 + * @param[in] chatter Chattiness.
587 587 * @return String containing point spread function information.
588 588 ***************************************************************************/
589 589 std::string GCTAPsfTable::print(const GChatter& chatter) const
... ... @@ -594,32 +594,42 @@ std::string GCTAPsfTable::print(const GChatter&amp; chatter) const
594 594 // Continue only if chatter is not silent
595 595 if (chatter != SILENT) {
596 596  
597   - // Compute energy boundaries in TeV
598   - double emin = m_psf.axis_lo(m_inx_energy,0);
599   - double emax = m_psf.axis_hi(m_inx_energy,
600   - m_psf.axis_bins(m_inx_energy)-1);
601   -
602   - // Compute offset angle boundaries in deg
603   - double omin = m_psf.axis_lo(m_inx_theta,0);
604   - double omax = m_psf.axis_hi(m_inx_theta,
605   - m_psf.axis_bins(m_inx_theta)-1);
606   -
607   - // Compute delta angle boundaries in deg
608   - double dmin = m_psf.axis_lo(m_inx_delta,0);
609   - double dmax = m_psf.axis_hi(m_inx_delta,
610   - m_psf.axis_bins(m_inx_delta)-1);
611   -
612 597 // Append header
613 598 result.append("=== GCTAPsfTable ===");
  599 + result.append("\n"+gammalib::parformat("Filename")+m_filename);
  600 +
  601 + // Initialise information
  602 + int nebins = 0;
  603 + int nthetabins = 0;
  604 + int ndeltabins = 0;
  605 + double emin = 0.0;
  606 + double emax = 0.0;
  607 + double omin = 0.0;
  608 + double omax = 0.0;
  609 + double dmin = 0.0;
  610 + double dmax = 0.0;
  611 +
  612 + // Extract information if there are axes in the response table
  613 + if (m_psf.axes() > 0) {
  614 + nebins = m_psf.axis_bins(m_inx_energy);
  615 + nthetabins = m_psf.axis_bins(m_inx_theta);
  616 + ndeltabins = m_psf.axis_bins(m_inx_delta);
  617 + emin = m_psf.axis_lo(m_inx_energy,0);
  618 + emax = m_psf.axis_hi(m_inx_energy,nebins-1);
  619 + omin = m_psf.axis_lo(m_inx_theta,0);
  620 + omax = m_psf.axis_hi(m_inx_theta,nthetabins-1);
  621 + dmin = m_psf.axis_lo(m_inx_delta,0);
  622 + dmax = m_psf.axis_hi(m_inx_delta,ndeltabins-1);
  623 + }
  624 +
614 625  
615 626 // Append information
616   - result.append("\n"+gammalib::parformat("Filename")+m_filename);
617 627 result.append("\n"+gammalib::parformat("Number of energy bins") +
618   - gammalib::str(m_psf.axis_bins(m_inx_energy)));
  628 + gammalib::str(nebins));
619 629 result.append("\n"+gammalib::parformat("Number of offset bins") +
620   - gammalib::str(m_psf.axis_bins(m_inx_theta)));
  630 + gammalib::str(nthetabins));
621 631 result.append("\n"+gammalib::parformat("Number of delta bins") +
622   - gammalib::str(m_psf.axis_bins(m_inx_delta)));
  632 + gammalib::str(ndeltabins));
623 633 result.append("\n"+gammalib::parformat("Log10(Energy) range"));
624 634 result.append(gammalib::str(emin)+" - "+gammalib::str(emax)+" TeV");
625 635 result.append("\n"+gammalib::parformat("Offset angle range"));
... ...
inst/cta/src/GCTAResponseTable.cpp
... ... @@ -1836,7 +1836,7 @@ void GCTAResponseTable::read_tables(const GFitsTable&amp; hdu)
1836 1836 m_tables.clear();
1837 1837  
1838 1838 // Compute expected cube size
1839   - m_nelements = axis_bins(0);
  1839 + m_nelements = (axes() > 0) ? axis_bins(0) : 0;
1840 1840 for (int i = 1; i < axes(); ++i) {
1841 1841 m_nelements *= axis_bins(i);
1842 1842 }
... ...
inst/cta/test/test_CTA.py
... ... @@ -65,6 +65,31 @@ class Test(gammalib.GPythonTestSuite):
65 65 # Return event list container
66 66 return list
67 67  
  68 + # Setup GCTAEventCube
  69 + def _setup_eventcube(self):
  70 + """
  71 + Setup GCTAEventCube
  72 +
  73 + Returns
  74 + -------
  75 + cube : `~gammalib.GCTAEventCube`
  76 + GCTAEventCube
  77 + """
  78 + # Setup event cube
  79 + map = gammalib.GSkyMap('CAR','CEL',0.0,0.0,1.0,1.0,5,5,2)
  80 + ebds = gammalib.GEbounds(2, gammalib.GEnergy(1.0, 'TeV'),
  81 + gammalib.GEnergy(10.0, 'TeV'))
  82 + gti = gammalib.GGti(gammalib.GTime(0.0,'sec'),
  83 + gammalib.GTime(1.0,'sec'))
  84 + cube = gammalib.GCTAEventCube(map, ebds, gti)
  85 + counts = 0.0
  86 + for bin in cube:
  87 + counts += 1.0
  88 + bin.counts(1.0)
  89 +
  90 + # Return event cube
  91 + return cube
  92 +
68 93 # Test GCTAEventList class access operators
69 94 def _test_eventlist_access(self):
70 95 """
... ... @@ -347,48 +372,52 @@ class Test(gammalib.GPythonTestSuite):
347 372 """
348 373 Test class pickeling
349 374 """
  375 + # Set CALDB
  376 + os.environ['CALDB'] = os.environ['TEST_DATA']+'/caldb'
  377 +
350 378 # Perform pickeling tests of empty classes
351   - #test_support._pickeling(self, gammalib.GCTAAeff2D())
  379 + test_support._pickeling(self, gammalib.GCTAAeff2D())
352 380 #test_support._pickeling(self, gammalib.GCTAAeffArf())
353 381 #test_support._pickeling(self, gammalib.GCTAAeffPerfTable())
354   - #test_support._pickeling(self, gammalib.GCTABackground3D())
  382 + test_support._pickeling(self, gammalib.GCTABackground3D())
355 383 #test_support._pickeling(self, gammalib.GCTABackgroundPerfTable())
356   - #test_support._pickeling(self, gammalib.GCTACubeBackground())
357   - #test_support._pickeling(self, gammalib.GCTACubeEdisp())
358   - #test_support._pickeling(self, gammalib.GCTACubeExposure())
359   - #test_support._pickeling(self, gammalib.GCTACubePsf())
  384 + test_support._pickeling(self, gammalib.GCTACubeBackground())
  385 + test_support._pickeling(self, gammalib.GCTACubeEdisp())
  386 + test_support._pickeling(self, gammalib.GCTACubeExposure())
  387 + test_support._pickeling(self, gammalib.GCTACubePsf())
360 388 #test_support._pickeling(self, gammalib.GCTACubeSourceDiffuse())
361 389 #test_support._pickeling(self, gammalib.GCTACubeSourcePoint())
362   - #test_support._pickeling(self, gammalib.GCTAEdisp2D())
  390 + test_support._pickeling(self, gammalib.GCTAEdisp2D())
363 391 #test_support._pickeling(self, gammalib.GCTAEdispPerfTable())
364 392 #test_support._pickeling(self, gammalib.GCTAEdispRmf())
365 393 test_support._pickeling(self, gammalib.GCTAEventAtom())
366   - #test_support._pickeling(self, gammalib.GCTAEventBin())
367   - #test_support._pickeling(self, gammalib.GCTAEventCube())
368   - #test_support._pickeling(self, gammalib.GCTAEventList())
  394 + test_support._pickeling(self, gammalib.GCTAEventBin())
  395 + test_support._pickeling(self, gammalib.GCTAEventCube())
  396 + test_support._pickeling(self, gammalib.GCTAEventList())
369 397 test_support._pickeling(self, gammalib.GCTAInstDir())
370   - #test_support._pickeling(self, gammalib.GCTAModelAeffBackground())
371   - #test_support._pickeling(self, gammalib.GCTAModelCubeBackground())
  398 + test_support._pickeling(self, gammalib.GCTAModelAeffBackground())
  399 + test_support._pickeling(self, gammalib.GCTAModelCubeBackground())
372 400 test_support._pickeling(self, gammalib.GCTAModelIrfBackground())
373   - #test_support._pickeling(self, gammalib.GCTAModelRadialAcceptance())
374   - #test_support._pickeling(self, gammalib.GCTAModelRadialGauss())
375   - #test_support._pickeling(self, gammalib.GCTAModelRadialPolynom())
376   - #test_support._pickeling(self, gammalib.GCTAModelRadialProfile())
377   - #test_support._pickeling(self, gammalib.GCTAObservation())
378   - #test_support._pickeling(self, gammalib.GCTAOnOffObservation())
379   - #test_support._pickeling(self, gammalib.GCTAPointing())
380   - #test_support._pickeling(self, gammalib.GCTAPsf2D())
381   - #test_support._pickeling(self, gammalib.GCTAPsfKing())
  401 + test_support._pickeling(self, gammalib.GCTAModelRadialAcceptance())
  402 + test_support._pickeling(self, gammalib.GCTAModelRadialGauss())
  403 + test_support._pickeling(self, gammalib.GCTAModelRadialPolynom())
  404 + test_support._pickeling(self, gammalib.GCTAModelRadialProfile())
  405 + test_support._pickeling(self, gammalib.GCTAObservation())
  406 + test_support._pickeling(self, gammalib.GCTAOnOffObservation())
  407 + test_support._pickeling(self, gammalib.GCTAPointing())
  408 + test_support._pickeling(self, gammalib.GCTAPsf2D())
  409 + test_support._pickeling(self, gammalib.GCTAPsfKing())
382 410 #test_support._pickeling(self, gammalib.GCTAPsfPerfTable())
383   - #test_support._pickeling(self, gammalib.GCTAPsfTable())
  411 + test_support._pickeling(self, gammalib.GCTAPsfTable())
384 412 #test_support._pickeling(self, gammalib.GCTAPsfVector())
385   - #test_support._pickeling(self, gammalib.GCTAResponseCube())
386   - #test_support._pickeling(self, gammalib.GCTAResponseIrf())
387   - #test_support._pickeling(self, gammalib.GCTAResponseTable())
388   - #test_support._pickeling(self, gammalib.GCTARoi())
  413 + test_support._pickeling(self, gammalib.GCTAResponseCube())
  414 + test_support._pickeling(self, gammalib.GCTAResponseIrf())
  415 + test_support._pickeling(self, gammalib.GCTAResponseTable())
  416 + test_support._pickeling(self, gammalib.GCTARoi())
389 417  
390 418 # Setup test
391 419 list = self._setup_eventlist()
  420 + cube = self._setup_eventcube()
392 421 atom = list[0]
393 422 dir = gammalib.GSkyDir()
394 423 instdir = gammalib.GCTAInstDir(dir)
... ... @@ -396,46 +425,92 @@ class Test(gammalib.GPythonTestSuite):
396 425 plaw = gammalib.GModelSpectralPlaw(1.0,-2.0,pivot)
397 426 instdir.detx(2.0)
398 427 instdir.dety(-3.0)
  428 + irfname = os.environ['TEST_DATA']+'/caldb/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz'
  429 + bin = gammalib.GCTAEventBin()
  430 + bin.dir(instdir)
  431 + bin.energy(pivot)
  432 + bin.time(gammalib.GTime(1.0,'sec'))
  433 + bin.counts(1.0)
  434 + bin.solidangle(0.1)
  435 + bin.ewidth(pivot)
  436 + bin.ontime(100.0)
  437 + bin.weight(1.0)
  438 + emin = gammalib.GEnergy(1.0,'TeV')
  439 + emax = gammalib.GEnergy(10.0,'TeV')
  440 + engs = gammalib.GEnergies(10,emin,emax)
  441 + ebds = gammalib.GEbounds(2,emin,emax)
  442 + region = gammalib.GSkyRegionCircle(dir, 0.2)
  443 + regs = gammalib.GSkyRegions()
  444 + regs.append(region)
  445 + ptsrc = gammalib.GModelSpatialPointSource()
  446 + expcube = gammalib.GCTACubeExposure('CAR','CEL',0.,0.,0.1,0.1,10,10,engs)
  447 + psfcube = gammalib.GCTACubePsf('CAR','CEL',0.,0.,0.1,0.1,10,10,engs,1.0,10)
  448 + bgdcube = gammalib.GCTACubeBackground('CAR','CEL',0.,0.,0.1,0.1,10,10,engs)
  449 + edispcube = gammalib.GCTACubeEdisp('CAR','CEL',0.,0.,0.1,0.1,10,10,engs,1.0,10)
  450 + caldb = gammalib.GCaldb('cta','prod2')
  451 + rspirf = gammalib.GCTAResponseIrf('North_0.5h', caldb)
  452 + rspcube1 = gammalib.GCTAResponseCube(expcube, psfcube, bgdcube)
  453 + rspcube2 = gammalib.GCTAResponseCube(expcube, psfcube, edispcube, bgdcube)
  454 + obs1 = gammalib.GCTAObservation()
  455 + obs1.events(list)
  456 + obs1.response(rspirf)
  457 + obs2 = gammalib.GCTAObservation()
  458 + obs2.events(cube)
  459 + obs2.response(rspirf)
  460 + obs3 = gammalib.GCTAObservation()
  461 + obs3.events(cube)
  462 + obs3.response(rspcube1)
  463 + obs4 = gammalib.GCTAObservation()
  464 + obs4.events(cube)
  465 + obs4.response(rspcube2)
  466 + obs5 = gammalib.GCTAOnOffObservation(obs1, ptsrc, ebds, ebds, regs, regs)
  467 + radgauss = gammalib.GCTAModelRadialGauss(1.0)
  468 + radacc = gammalib.GCTAModelRadialAcceptance(radgauss, plaw)
  469 + kingname = self._caldb + '/prod1_king.fits'
399 470  
400 471 # Perform pickeling tests of filled classes
401   - #test_support._pickeling(self, gammalib.GCTAAeff2D())
  472 + test_support._pickeling(self, gammalib.GCTAAeff2D(irfname))
402 473 #test_support._pickeling(self, gammalib.GCTAAeffArf())
403 474 #test_support._pickeling(self, gammalib.GCTAAeffPerfTable())
404   - #test_support._pickeling(self, gammalib.GCTABackground3D())
  475 + test_support._pickeling(self, gammalib.GCTABackground3D(irfname))
405 476 #test_support._pickeling(self, gammalib.GCTABackgroundPerfTable())
406   - #test_support._pickeling(self, gammalib.GCTACubeBackground())
407   - #test_support._pickeling(self, gammalib.GCTACubeEdisp())
408   - #test_support._pickeling(self, gammalib.GCTACubeExposure())
409   - #test_support._pickeling(self, gammalib.GCTACubePsf())
  477 + test_support._pickeling(self, gammalib.GCTACubeBackground(bgdcube))
  478 + test_support._pickeling(self, gammalib.GCTACubeEdisp(edispcube))
  479 + test_support._pickeling(self, gammalib.GCTACubeExposure(expcube))
  480 + test_support._pickeling(self, gammalib.GCTACubePsf(psfcube))
410 481 #test_support._pickeling(self, gammalib.GCTACubeSourceDiffuse())
411 482 #test_support._pickeling(self, gammalib.GCTACubeSourcePoint())
412   - #test_support._pickeling(self, gammalib.GCTAEdisp2D())
  483 + test_support._pickeling(self, gammalib.GCTAEdisp2D(irfname))
413 484 #test_support._pickeling(self, gammalib.GCTAEdispPerfTable())
414 485 #test_support._pickeling(self, gammalib.GCTAEdispRmf())
415 486 test_support._pickeling(self, gammalib.GCTAEventAtom(atom))
416   - #test_support._pickeling(self, gammalib.GCTAEventBin())
417   - #test_support._pickeling(self, gammalib.GCTAEventCube())
418   - #test_support._pickeling(self, gammalib.GCTAEventList())
  487 + test_support._pickeling(self, gammalib.GCTAEventBin(bin))
  488 + test_support._pickeling(self, gammalib.GCTAEventCube(cube))
  489 + test_support._pickeling(self, gammalib.GCTAEventList(list))
419 490 test_support._pickeling(self, gammalib.GCTAInstDir(instdir))
420   - #test_support._pickeling(self, gammalib.GCTAModelAeffBackground())
421   - #test_support._pickeling(self, gammalib.GCTAModelCubeBackground())
  491 + test_support._pickeling(self, gammalib.GCTAModelAeffBackground(plaw))
  492 + test_support._pickeling(self, gammalib.GCTAModelCubeBackground(plaw))
422 493 test_support._pickeling(self, gammalib.GCTAModelIrfBackground(plaw))
423   - #test_support._pickeling(self, gammalib.GCTAModelRadialAcceptance())
424   - #test_support._pickeling(self, gammalib.GCTAModelRadialGauss())
425   - #test_support._pickeling(self, gammalib.GCTAModelRadialPolynom())
426   - #test_support._pickeling(self, gammalib.GCTAModelRadialProfile())
427   - #test_support._pickeling(self, gammalib.GCTAObservation())
428   - #test_support._pickeling(self, gammalib.GCTAOnOffObservation())
429   - #test_support._pickeling(self, gammalib.GCTAPointing())
430   - #test_support._pickeling(self, gammalib.GCTAPsf2D())
431   - #test_support._pickeling(self, gammalib.GCTAPsfKing())
  494 + test_support._pickeling(self, gammalib.GCTAModelRadialAcceptance(radacc))
  495 + test_support._pickeling(self, gammalib.GCTAModelRadialGauss(1.0))
  496 + test_support._pickeling(self, gammalib.GCTAModelRadialPolynom([1.0,2.0]))
  497 + test_support._pickeling(self, gammalib.GCTAModelRadialProfile(1.0,2.0,3.0))
  498 + test_support._pickeling(self, gammalib.GCTAObservation(obs1))
  499 + test_support._pickeling(self, gammalib.GCTAObservation(obs2))
  500 + test_support._pickeling(self, gammalib.GCTAObservation(obs3))
  501 + test_support._pickeling(self, gammalib.GCTAObservation(obs4))
  502 + test_support._pickeling(self, gammalib.GCTAOnOffObservation(obs5))
  503 + test_support._pickeling(self, gammalib.GCTAPointing(dir))
  504 + test_support._pickeling(self, gammalib.GCTAPsf2D(irfname))
  505 + test_support._pickeling(self, gammalib.GCTAPsfKing(kingname))
432 506 #test_support._pickeling(self, gammalib.GCTAPsfPerfTable())
433   - #test_support._pickeling(self, gammalib.GCTAPsfTable())
  507 + #test_support._pickeling(self, gammalib.GCTAPsfTable()) # No test data
434 508 #test_support._pickeling(self, gammalib.GCTAPsfVector())
435   - #test_support._pickeling(self, gammalib.GCTAResponseCube())
436   - #test_support._pickeling(self, gammalib.GCTAResponseIrf())
437   - #test_support._pickeling(self, gammalib.GCTAResponseTable())
438   - #test_support._pickeling(self, gammalib.GCTARoi())
  509 + test_support._pickeling(self, gammalib.GCTAResponseCube(rspcube1))
  510 + test_support._pickeling(self, gammalib.GCTAResponseCube(rspcube2))
  511 + test_support._pickeling(self, gammalib.GCTAResponseIrf(rspirf))
  512 + #test_support._pickeling(self, gammalib.GCTAResponseTable()) # No constructor
  513 + test_support._pickeling(self, gammalib.GCTARoi(instdir,2.0))
439 514  
440 515 # Return
441 516 return
... ... @@ -456,7 +531,7 @@ class Test(gammalib.GPythonTestSuite):
456 531 self.append(self._test_edisp, 'Test CTA energy dispersion classes')
457 532 self.append(self._test_response, 'Test CTA response classes')
458 533 self.append(self._test_onoff, 'Test CTA On/Off analysis')
459   - self.append(self._test_pickeling, 'Test pickeling of "cta" classes')
  534 + self.append(self._test_pickeling, 'Test CTA class pickeling')
460 535  
461 536 # Return
462 537 return
... ...
pyext/GApplication.i
1 1 /***************************************************************************
2 2 * GApplication.i - GammaLib application base 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 *
... ... @@ -48,6 +48,8 @@ public:
48 48 GApplication(void);
49 49 GApplication(const std::string& name, const std::string& version);
50 50 GApplication(const std::string& name, const std::string& version,
  51 + const std::vector<std::string>& args);
  52 + GApplication(const std::string& name, const std::string& version,
51 53 int ARGC, char **ARGV);
52 54 GApplication(const GApplication& app);
53 55 ~GApplication(void);
... ... @@ -76,28 +78,34 @@ public:
76 78 %rename(_log_header) log_header;
77 79 %rename(_log_trailer) log_trailer;
78 80 %rename(_need_help) need_help;
  81 + %rename(_args) args;
79 82 %rename(_log) log;
80 83  
81 84 // Methods
82   - void clear(void);
83   - GApplication* clone(void) const;
84   - std::string classname(void) const;
85   - const std::string& name(void) const;
86   - const std::string& version(void) const;
87   - bool logTerse(void) const;
88   - bool logNormal(void) const;
89   - bool logExplicit(void) const;
90   - bool logVerbose(void) const;
91   - bool logDebug(void) const;
92   - bool clobber(void) const;
93   - bool has_par(const std::string& name) const;
94   - const std::string& par_filename(void) const;
95   - const std::string& log_filename(void) const;
96   - void log_header(void);
97   - void log_trailer(void);
98   - const bool& need_help(void) const;
99   - const GApplicationPars& pars(void) const;
100   - void pars(const GApplicationPars& pars);
  85 + void clear(void);
  86 + GApplication* clone(void) const;
  87 + std::string classname(void) const;
  88 + const std::string& name(void) const;
  89 + const std::string& version(void) const;
  90 + double telapse(void) const;
  91 + double celapse(void) const;
  92 + void logFileOpen(const bool& clobber = true);
  93 + void logFileClose(void);
  94 + bool logTerse(void) const;
  95 + bool logNormal(void) const;
  96 + bool logExplicit(void) const;
  97 + bool logVerbose(void) const;
  98 + bool logDebug(void) const;
  99 + bool clobber(void) const;
  100 + bool has_par(const std::string& name) const;
  101 + const std::string& par_filename(void) const;
  102 + const std::string& log_filename(void) const;
  103 + void log_header(void);
  104 + void log_trailer(void);
  105 + const bool& need_help(void) const;
  106 + const GApplicationPars& pars(void) const;
  107 + void pars(const GApplicationPars& pars);
  108 + const std::vector<std::string>& args(void) const;
101 109  
102 110 // Public members
103 111 GLog log; //!< Application logger
... ... @@ -276,4 +284,15 @@ GApplication._log_value = _log_value
276 284 GApplication copy() {
277 285 return (*self);
278 286 }
  287 +%pythoncode {
  288 + def __getstate__(self):
  289 + state = (self._name(), self._version(), self._args(), self.pars())
  290 + return state
  291 + def __setstate__(self, state):
  292 + if state[0] and state[1]:
  293 + self.__init__(state[0], state[1], state[2])
  294 + else:
  295 + self.__init__()
  296 + self.pars(state[3])
  297 +}
279 298 };
... ...
pyext/GApplicationPar.i
... ... @@ -46,41 +46,43 @@ public:
46 46 virtual ~GApplicationPar(void);
47 47  
48 48 // Methods
49   - void clear(void);
50   - GApplicationPar* clone(void) const;
51   - std::string classname(void) const;
52   - void type(const std::string& type);
53   - void mode(const std::string& mode);
54   - void value(const std::string& value);
55   - void string(const std::string& value);
56   - void filename(const GFilename& value);
57   - void time(const GTime& value);
58   - void boolean(const bool& value);
59   - void integer(const int& value);
60   - void real(const double& value);
61   - const std::string& name(void) const;
62   - const std::string& type(void) const;
63   - const std::string& mode(void) const;
64   - void query(void);
65   - std::string value(void);
66   - std::string string(void);
67   - GFilename filename(void);
68   - GTime time(void);
69   - GTime time(const GTimeReference& ref);
70   - bool boolean(void);
71   - int integer(void);
72   - double real(void);
73   - const std::string& current_value(void) const;
74   - const std::string& min(void) const;
75   - const std::string& max(void) const;
76   - const std::string& prompt(void) const;
77   - bool is_learn(void) const;
78   - bool is_query(void) const;
79   - bool is_filename(void) const;
80   - bool is_valid(void);
81   - bool is_undefined(void);
82   - bool is_notanumber(void);
83   - bool was_queried(void) const;
  49 + void clear(void);
  50 + GApplicationPar* clone(void) const;
  51 + std::string classname(void) const;
  52 + void type(const std::string& type);
  53 + void mode(const std::string& mode);
  54 + void value(const std::string& value);
  55 + void string(const std::string& value);
  56 + void filename(const GFilename& value);
  57 + void time(const GTime& value);
  58 + void boolean(const bool& value);
  59 + void integer(const int& value);
  60 + void real(const double& value);
  61 + const std::string& name(void) const;
  62 + const std::string& type(void) const;
  63 + const std::string& mode(void) const;
  64 + void query(void);
  65 + std::string value(void);
  66 + std::string string(void);
  67 + GFilename filename(void);
  68 + GTime time(void);
  69 + GTime time(const GTimeReference& ref);
  70 + bool boolean(void);
  71 + int integer(void);
  72 + double real(void);
  73 + const std::string& current_value(void) const;
  74 + const std::string& min(void) const;
  75 + const std::string& max(void) const;
  76 + const std::string& prompt(void) const;
  77 + bool is_learn(void) const;
  78 + bool is_query(void) const;
  79 + bool is_filename(void) const;
  80 + bool is_valid(void);
  81 + bool is_undefined(void);
  82 + bool is_notanumber(void);
  83 + bool was_queried(void) const;
  84 + void pickle(const std::vector<std::string>& string);
  85 + std::vector<std::string> pickle(void) const;
84 86 };
85 87  
86 88  
... ... @@ -91,4 +93,12 @@ public:
91 93 GApplicationPar copy() {
92 94 return (*self);
93 95 }
  96 +%pythoncode {
  97 + def __getstate__(self):
  98 + state = (self.pickle(),)
  99 + return state
  100 + def __setstate__(self, state):
  101 + self.__init__()
  102 + self.pickle(state[0])
  103 +}
94 104 }
... ...
pyext/GApplicationPars.i
... ... @@ -26,7 +26,6 @@
26 26 %{
27 27 /* Put headers and other declarations here that are needed for compilation */
28 28 #include "GApplicationPars.hpp"
29   -#include "GException.hpp"
30 29 #include "GFilename.hpp"
31 30 %}
32 31  
... ... @@ -48,27 +47,29 @@ public:
48 47 virtual ~GApplicationPars(void);
49 48  
50 49 // Methods
51   - void clear(void);
52   - GApplicationPars* clone(void) const;
53   - std::string classname(void) const;
54   - int size(void) const;
55   - bool is_empty(void) const;
56   - GApplicationPar& append(const GApplicationPar& par);
57   - void append_standard(void);
58   - GApplicationPar& insert(const int& index, const GApplicationPar& par);
59   - GApplicationPar& insert(const std::string& name,
60   - const GApplicationPar& par);
61   - void remove(const int& index);
62   - void remove(const std::string& name);
63   - void reserve(const int& num);
64   - void extend(const GApplicationPars& pars);
65   - bool contains(const std::string& name) const;
66   - void syspfiles(const std::string& syspfiles);
67   - const std::string& syspfiles(void) const;
68   - void load(const GFilename& filename);
69   - void load(const GFilename& filename,
70   - const std::vector<std::string>& args);
71   - void save(const GFilename& filename);
  50 + void clear(void);
  51 + GApplicationPars* clone(void) const;
  52 + std::string classname(void) const;
  53 + int size(void) const;
  54 + bool is_empty(void) const;
  55 + GApplicationPar& append(const GApplicationPar& par);
  56 + void append_standard(void);
  57 + GApplicationPar& insert(const int& index, const GApplicationPar& par);
  58 + GApplicationPar& insert(const std::string& name,
  59 + const GApplicationPar& par);
  60 + void remove(const int& index);
  61 + void remove(const std::string& name);
  62 + void reserve(const int& num);
  63 + void extend(const GApplicationPars& pars);
  64 + bool contains(const std::string& name) const;
  65 + void syspfiles(const std::string& syspfiles);
  66 + const std::string& syspfiles(void) const;
  67 + void load(const GFilename& filename);
  68 + void load(const GFilename& filename,
  69 + const std::vector<std::string>& args);
  70 + void save(const GFilename& filename);
  71 + void pickle(const std::vector<std::string>& string);
  72 + std::vector<std::string> pickle(void) const;
72 73 };
73 74  
74 75  
... ... @@ -142,4 +143,12 @@ public:
142 143 GApplicationPars copy() {
143 144 return (*self);
144 145 }
  146 +%pythoncode {
  147 + def __getstate__(self):
  148 + state = (self.pickle(),)
  149 + return state
  150 + def __setstate__(self, state):
  151 + self.__init__()
  152 + self.pickle(state[0])
145 153 }
  154 +};
... ...
pyext/GArf.i
... ... @@ -29,6 +29,11 @@
29 29 #include "GTools.hpp"
30 30 %}
31 31  
  32 +/* __ Constants __________________________________________________________ */
  33 +namespace gammalib {
  34 + const std::string extname_arf = "SPECRESP";
  35 +}
  36 +
32 37  
33 38 /***********************************************************************//**
34 39 * @class GArf
... ... @@ -64,6 +69,7 @@ public:
64 69 void load(const GFilename& filename);
65 70 void save(const GFilename& filename,
66 71 const bool& clobber = false) const;
  72 + void read(const GFits& fits);
67 73 void read(const GFitsTable& table);
68 74 void write(GFits& fits) const;
69 75 const GFilename& filename(void) const;
... ... @@ -125,4 +131,15 @@ public:
125 131 GArf copy() {
126 132 return (*self);
127 133 }
  134 +%pythoncode {
  135 + def __getstate__(self):
  136 + fits = gammalib.GFits()
  137 + self.write(fits)
  138 + state = (fits,)
  139 + return state
  140 + def __setstate__(self, state):
  141 + self.__init__()
  142 + if not state[0].is_empty():
  143 + self.read(state[0])
  144 +}
128 145 };
... ...
pyext/GCaldb.i
... ... @@ -80,6 +80,9 @@ public:
80 80 state = (self.mission(), self.instrument())
81 81 return state
82 82 def __setstate__(self, state):
83   - self.__init__(state[0], state[1])
  83 + if state[0] and state[1]:
  84 + self.__init__(state[0], state[1])
  85 + else:
  86 + self.__init__()
84 87 }
85 88 };
... ...
pyext/GEbounds.i
... ... @@ -29,6 +29,11 @@
29 29 #include "GTools.hpp"
30 30 %}
31 31  
  32 +/* __ Constants __________________________________________________________ */
  33 +namespace gammalib {
  34 + const std::string extname_ebounds = "EBOUNDS";
  35 +}
  36 +
32 37  
33 38 /***********************************************************************//**
34 39 * @class GEbounds
... ...
pyext/GFitsTable.i
... ... @@ -154,11 +154,12 @@ public:
154 154 }
155 155 %pythoncode {
156 156 def __getstate__(self):
157   - state = (tuple([self[i] for i in range(self.ncols())]),)
  157 + state = (gammalib.GFitsHDU.__getstate__(self), tuple([self[i] for i in range(self.ncols())]))
158 158 return state
159 159 def __setstate__(self, state):
160 160 self.__init__()
161   - for x in state[0]:
  161 + gammalib.GFitsHDU.__setstate__(self, state[0])
  162 + for x in state[1]:
162 163 self.append(x)
163 164 }
164 165 };
... ...
pyext/GFitsTableBitCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GFitsTableBoolCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GFitsTableByteCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GFitsTableDoubleCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GFitsTableFloatCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GFitsTableLongCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GFitsTableLongLongCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GFitsTableShortCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GFitsTableStringCol.i
... ... @@ -136,13 +136,14 @@ public:
136 136 }
137 137 %pythoncode {
138 138 def __getstate__(self):
139   - state = (self.name(), self.nrows(), self.width(), self.number(),
  139 + state = (self.name(), self.nrows(), self.width(), self.number(), self.unit(),
140 140 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
141 141 return state
142 142 def __setstate__(self, state):
143 143 self.__init__(state[0], state[1], state[2], state[3])
144   - for row in range(len(state[4])):
145   - for inx in range(len(state[4][row])):
146   - self[row,inx] = state[4][row][inx]
  144 + self.unit(state[4])
  145 + for row in range(len(state[5])):
  146 + for inx in range(len(state[5][row])):
  147 + self[row,inx] = state[5][row][inx]
147 148 }
148 149 };
... ...
pyext/GFitsTableULongCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GFitsTableUShortCol.i
... ... @@ -115,13 +115,14 @@ public:
115 115 }
116 116 %pythoncode {
117 117 def __getstate__(self):
118   - state = (self.name(), self.nrows(), self.number(),
  118 + state = (self.name(), self.nrows(), self.number(), self.unit(),
119 119 [[self[row,inx] for inx in range(self.elements(row))] for row in range(self.nrows())])
120 120 return state
121 121 def __setstate__(self, state):
122 122 self.__init__(state[0], state[1], state[2])
123   - for row in range(len(state[3])):
124   - for inx in range(len(state[3][row])):
125   - self[row,inx] = state[3][row][inx]
  123 + self.unit(state[3])
  124 + for row in range(len(state[4])):
  125 + for inx in range(len(state[4][row])):
  126 + self[row,inx] = state[4][row][inx]
126 127 }
127 128 };
... ...
pyext/GHealpix.i
1 1 /***************************************************************************
2 2 * GHealpix.i - Healpix projection class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2016 by Jurgen Knodlseder *
  4 + * copyright (C) 2010-2018 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -77,4 +77,14 @@ public:
77 77 GHealpix copy() {
78 78 return (*self);
79 79 }
  80 +%pythoncode {
  81 + def __getstate__(self):
  82 + hdu = gammalib.GFitsBinTable()
  83 + self.write(hdu)
  84 + state = (hdu,)
  85 + return state
  86 + def __setstate__(self, state):
  87 + self.__init__()
  88 + self.read(state[0])
  89 +}
80 90 };
... ...
pyext/GHorizDir.i
1 1 /***************************************************************************
2 2 * GHorizDir.i - Horizontal direction class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014-2015 by Karl Kosack *
  4 + * copyright (C) 2014-2018 by Karl Kosack *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -74,4 +74,12 @@ public:
74 74 GHorizDir copy() {
75 75 return (*self);
76 76 }
  77 +%pythoncode {
  78 + def __getstate__(self):
  79 + state = (self.alt(), self.az())
  80 + return state
  81 + def __setstate__(self, state):
  82 + self.__init__()
  83 + self.altaz(state[0], state[1])
  84 +}
77 85 };
... ...
pyext/GModel.i
... ... @@ -110,8 +110,8 @@ public:
110 110 }
111 111 %pythoncode {
112 112 def __getstate__(self):
113   - state = self.name(), self.instruments(), self.ids(), self.tscalc(), \
114   - self.has_ts(), self.ts()
  113 + state = (self.name(), self.instruments(), self.ids(), self.tscalc(),
  114 + self.has_ts(), self.ts())
115 115 return state
116 116 def __setstate__(self, state):
117 117 self.__init__()
... ...
pyext/GModelData.i
... ... @@ -66,9 +66,9 @@ public:
66 66 %extend GModelData {
67 67 %pythoncode {
68 68 def __getstate__(self):
69   - state = gammalib.GModel.__getstate__(self)
  69 + state = (gammalib.GModel.__getstate__(self),)
70 70 return state
71 71 def __setstate__(self, state):
72   - gammalib.GModel.__setstate__(self, state)
  72 + gammalib.GModel.__setstate__(self, state[0])
73 73 }
74 74 };
... ...
pyext/GModelSpatialDiffuseCube.i
... ... @@ -83,7 +83,8 @@ public:
83 83 void load(const GFilename& filename);
84 84 void save(const GFilename& filename,
85 85 const bool& clobber = false) const;
86   - void write(GFits& file) const;
  86 + void read(const GFits& fits);
  87 + void write(GFits& fits) const;
87 88 };
88 89  
89 90  
... ... @@ -94,4 +95,16 @@ public:
94 95 GModelSpatialDiffuseCube copy() {
95 96 return (*self);
96 97 }
  98 +%pythoncode {
  99 + def __getstate__(self):
  100 + fits = gammalib.GFits()
  101 + self.write(fits)
  102 + state = (fits, self.filename(), self[0])
  103 + return state
  104 + def __setstate__(self, state):
  105 + self.__init__()
  106 + self.read(state[0])
  107 + self.filename(state[1])
  108 + self[0] = state[2]
  109 +}
97 110 };
... ...
pyext/GModelSpatialDiffuseMap.i
1 1 /***************************************************************************
2 2 * GModelSpatialDiffuseMap.i - Spatial map model class *
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 *
... ... @@ -86,4 +86,13 @@ public:
86 86 GModelSpatialDiffuseMap copy() {
87 87 return (*self);
88 88 }
  89 +%pythoncode {
  90 + def __getstate__(self):
  91 + xml = gammalib.GXmlElement()
  92 + self.write(xml)
  93 + state = (xml,)
  94 + return state
  95 + def __setstate__(self, state):
  96 + self.__init__(state[0])
  97 +}
89 98 };
... ...
pyext/GModelSpatialEllipticalDisk.i
1 1 /***************************************************************************
2 2 * GModelSpatialEllipticalDisk.i - Elliptical disk source model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2016 by Michael Mayer *
  4 + * copyright (C) 2013-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -79,4 +79,13 @@ public:
79 79 double eval(const GPhoton& photon, const bool& gradients) const {
80 80 return self->GModelSpatialElliptical::eval(photon, gradients);
81 81 }
  82 +%pythoncode {
  83 + def __getstate__(self):
  84 + xml = gammalib.GXmlElement()
  85 + self.write(xml)
  86 + state = (xml,)
  87 + return state
  88 + def __setstate__(self, state):
  89 + self.__init__(state[0])
  90 +}
82 91 };
... ...
pyext/GModelSpatialEllipticalGauss.i
1 1 /***************************************************************************
2 2 * GModelSpatialEllipticalGauss.i - Elliptical gauss source model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2015-2016 by Michael Mayer *
  4 + * copyright (C) 2015-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -79,4 +79,13 @@ public:
79 79 double eval(const GPhoton& photon, const bool& gradients) const {
80 80 return self->GModelSpatialElliptical::eval(photon, gradients);
81 81 }
  82 +%pythoncode {
  83 + def __getstate__(self):
  84 + xml = gammalib.GXmlElement()
  85 + self.write(xml)
  86 + state = (xml,)
  87 + return state
  88 + def __setstate__(self, state):
  89 + self.__init__(state[0])
  90 +}
82 91 };
... ...
pyext/GModelSpatialRadialDisk.i
1 1 /***************************************************************************
2 2 * GModelSpatialRadialDisk.i - Radial disk source model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2016 by Christoph Deil *
  4 + * copyright (C) 2011-2018 by Christoph Deil *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -88,4 +88,13 @@ public:
88 88 double eval(const GPhoton& photon, const bool& gradients) const {
89 89 return self->GModelSpatialRadial::eval(photon, gradients);
90 90 }
  91 +%pythoncode {
  92 + def __getstate__(self):
  93 + xml = gammalib.GXmlElement()
  94 + self.write(xml)
  95 + state = (xml,)
  96 + return state
  97 + def __setstate__(self, state):
  98 + self.__init__(state[0])
  99 +}
91 100 };
... ...
pyext/GModelSpatialRadialGauss.i
1 1 /***************************************************************************
2 2 * GModelSpatialRadialGauss.i - Radial Gaussian source model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2018 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -85,4 +85,13 @@ public:
85 85 double eval(const GPhoton& photon, const bool& gradients) const {
86 86 return self->GModelSpatialRadial::eval(photon, gradients);
87 87 }
  88 +%pythoncode {
  89 + def __getstate__(self):
  90 + xml = gammalib.GXmlElement()
  91 + self.write(xml)
  92 + state = (xml,)
  93 + return state
  94 + def __setstate__(self, state):
  95 + self.__init__(state[0])
  96 +}
88 97 };
... ...
pyext/GModelSpatialRadialProfileDMBurkert.i
1 1 /***************************************************************************
2 2 * GModelSpatialRadialProfileDMBurkert.i - Burkert radial profile class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2016 by Nathan Kelley-Hoskins *
  4 + * copyright (C) 2016-2018 by Nathan Kelley-Hoskins *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -75,4 +75,13 @@ public:
75 75 GModelSpatialRadialProfileDMBurkert copy() {
76 76 return (*self);
77 77 }
  78 +%pythoncode {
  79 + def __getstate__(self):
  80 + xml = gammalib.GXmlElement()
  81 + self.write(xml)
  82 + state = (xml,)
  83 + return state
  84 + def __setstate__(self, state):
  85 + self.__init__(state[0])
  86 +}
78 87 };
... ...
pyext/GModelSpatialRadialProfileDMEinasto.i
1 1 /***************************************************************************
2 2 * GModelSpatialRadialProfileDMEinasto.i - Einasto radial profile class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2016 by Nathan Kelley-Hoskins *
  4 + * copyright (C) 2016-2018 by Nathan Kelley-Hoskins *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -77,4 +77,13 @@ public:
77 77 GModelSpatialRadialProfileDMEinasto copy() {
78 78 return (*self);
79 79 }
  80 +%pythoncode {
  81 + def __getstate__(self):
  82 + xml = gammalib.GXmlElement()
  83 + self.write(xml)
  84 + state = (xml,)
  85 + return state
  86 + def __setstate__(self, state):
  87 + self.__init__(state[0])
  88 +}
80 89 };
... ...
pyext/GModelSpatialRadialProfileDMZhao.i
1 1 /***************************************************************************
2 2 * GModelSpatialRadialProfileDMZhao.i - Zhao radial profile class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2016 by Nathan Kelley-Hoskins *
  4 + * copyright (C) 2016-2018 by Nathan Kelley-Hoskins *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -81,4 +81,13 @@ public:
81 81 GModelSpatialRadialProfileDMZhao copy() {
82 82 return (*self);
83 83 }
  84 +%pythoncode {
  85 + def __getstate__(self):
  86 + xml = gammalib.GXmlElement()
  87 + self.write(xml)
  88 + state = (xml,)
  89 + return state
  90 + def __setstate__(self, state):
  91 + self.__init__(state[0])
  92 +}
84 93 };
... ...
pyext/GModelSpatialRadialProfileGauss.i
... ... @@ -70,4 +70,13 @@ public:
70 70 GModelSpatialRadialProfileGauss copy() {
71 71 return (*self);
72 72 }
  73 +%pythoncode {
  74 + def __getstate__(self):
  75 + xml = gammalib.GXmlElement()
  76 + self.write(xml)
  77 + state = (xml,)
  78 + return state
  79 + def __setstate__(self, state):
  80 + self.__init__(state[0])
  81 +}
73 82 };
... ...
pyext/GModelSpatialRadialShell.i
1 1 /***************************************************************************
2 2 * GModelSpatialRadialShell.i - Radial spatial shell source model class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2016 by Christoph Deil *
  4 + * copyright (C) 2011-2018 by Christoph Deil *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -88,4 +88,13 @@ public:
88 88 double eval(const GPhoton& photon, const bool& gradients) const {
89 89 return self->GModelSpatialRadial::eval(photon, gradients);
90 90 }
  91 +%pythoncode {
  92 + def __getstate__(self):
  93 + xml = gammalib.GXmlElement()
  94 + self.write(xml)
  95 + state = (xml,)
  96 + return state
  97 + def __setstate__(self, state):
  98 + self.__init__(state[0])
  99 +}
91 100 };
... ...
pyext/GPha.i
... ... @@ -28,6 +28,11 @@
28 28 #include "GPha.hpp"
29 29 %}
30 30  
  31 +/* __ Constants __________________________________________________________ */
  32 +namespace gammalib {
  33 + const std::string extname_pha = "SPECTRUM";
  34 +}
  35 +
31 36  
32 37 /***********************************************************************//**
33 38 * @class GPha
... ... @@ -87,6 +92,7 @@ public:
87 92 void load(const GFilename& filename);
88 93 void save(const GFilename& filename,
89 94 const bool& clobber = false) const;
  95 + void read(const GFits& fits);
90 96 void read(const GFitsTable& table);
91 97 void write(GFits& fits) const;
92 98 const GFilename& filename(void) const;
... ... @@ -148,4 +154,15 @@ public:
148 154 GPha copy() {
149 155 return (*self);
150 156 }
  157 +%pythoncode {
  158 + def __getstate__(self):
  159 + fits = gammalib.GFits()
  160 + self.write(fits)
  161 + state = (fits,)
  162 + return state
  163 + def __setstate__(self, state):
  164 + self.__init__()
  165 + if not state[0].is_empty():
  166 + self.read(state[0])
  167 +}
151 168 };
... ...
pyext/GRmf.i
... ... @@ -31,6 +31,11 @@
31 31 /* __ Includes ___________________________________________________________ */
32 32 %include "GTypemaps.i"
33 33  
  34 +/* __ Constants __________________________________________________________ */
  35 +namespace gammalib {
  36 + const std::string extname_rmf = "MATRIX";
  37 +}
  38 +
34 39  
35 40 /***********************************************************************//**
36 41 * @class GRmf
... ... @@ -67,6 +72,7 @@ public:
67 72 void save(const GFilename& filename,
68 73 const bool& clobber = false,
69 74 const std::string& unit = "keV") const;
  75 + void read(const GFits& fits);
70 76 void read(const GFitsTable& table);
71 77 void write(GFits& fits,
72 78 const std::string& unit = "keV") const;
... ... @@ -115,4 +121,15 @@ public:
115 121 GRmf copy() {
116 122 return (*self);
117 123 }
  124 +%pythoncode {
  125 + def __getstate__(self):
  126 + fits = gammalib.GFits()
  127 + self.write(fits)
  128 + state = (fits,)
  129 + return state
  130 + def __setstate__(self, state):
  131 + self.__init__()
  132 + if not state[0].is_empty():
  133 + self.read(state[0])
  134 +}
118 135 };
... ...
pyext/GSkyMap.i
... ... @@ -312,4 +312,23 @@ public:
312 312 }
313 313 return array;
314 314 }
  315 +// Pickeling
  316 +%pythoncode {
  317 + def __getstate__(self):
  318 + fits = gammalib.GFits()
  319 + self.write(fits)
  320 + state = (fits,)
  321 + return state
  322 + def __setstate__(self, state):
  323 + self.__init__()
  324 + for hdu in state[0]:
  325 + if ((hdu.exttype() == 0 and
  326 + hdu.has_card('NAXIS') and
  327 + hdu.integer('NAXIS') >= 2) or
  328 + (hdu.exttype() == 0 and
  329 + hdu.has_card('PIXTYPE') and
  330 + hdu.string('PIXTYPE') == 'HEALPIX')):
  331 + self.read(hdu)
  332 + break
  333 +}
315 334 };
... ...
pyext/GSkyPixel.i
... ... @@ -76,4 +76,16 @@ public:
76 76 GSkyPixel copy() {
77 77 return (*self);
78 78 }
  79 +%pythoncode {
  80 + def __getstate__(self):
  81 + state = (self.is_1D(), self.is_2D(), self.x(), self.y(), self.index())
  82 + return state
  83 + def __setstate__(self, state):
  84 + if state[0]:
  85 + self.__init__(state[4])
  86 + elif state[1]:
  87 + self.__init__(state[2], state[3])
  88 + else:
  89 + self.__init__()
  90 +}
79 91 };
... ...
pyext/GSkyRegionCircle.i
1 1 /***************************************************************************
2 2 * GSkyRegionCircle.i - Sky region class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2015 by Michael Mayer *
  4 + * copyright (C) 2013-2018 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -70,4 +70,11 @@ public:
70 70 GSkyRegionCircle copy() {
71 71 return (*self);
72 72 }
  73 +%pythoncode {
  74 + def __getstate__(self):
  75 + state = (self.centre(), self.radius())
  76 + return state
  77 + def __setstate__(self, state):
  78 + self.__init__(state[0], state[1])
  79 +}
73 80 };
... ...
pyext/GSkyRegionMap.i
1 1 /***************************************************************************
2 2 * GSkyRegionMap.i - Sky region map class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2017 by Pierrick Martin *
  4 + * copyright (C) 2017-2018 by Pierrick Martin *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -38,9 +38,9 @@ class GSkyRegionMap : public GSkyRegion {
38 38 public:
39 39 // Constructors and destructors
40 40 GSkyRegionMap(void);
41   - GSkyRegionMap(const GFilename& filename);
42   - GSkyRegionMap(const GSkyMap& map);
43   - GSkyRegionMap(const GSkyRegion* region);
  41 + explicit GSkyRegionMap(const GFilename& filename);
  42 + explicit GSkyRegionMap(const GSkyMap& map);
  43 + explicit GSkyRegionMap(const GSkyRegion* region);
44 44 GSkyRegionMap(const GSkyRegionMap& region);
45 45 virtual ~GSkyRegionMap(void);
46 46  
... ... @@ -58,7 +58,6 @@ public:
58 58 void load(const GFilename& filename);
59 59 void map(const GSkyMap& map);
60 60 const GSkyMap& map(void) const;
61   - const GFilename& filename(void) const;
62 61 const std::vector<int>& nonzero_indices(void) const;
63 62 };
64 63  
... ... @@ -70,4 +69,11 @@ public:
70 69 GSkyRegionMap copy() {
71 70 return (*self);
72 71 }
  72 +%pythoncode {
  73 + def __getstate__(self):
  74 + state = (self.map(),)
  75 + return state
  76 + def __setstate__(self, state):
  77 + self.__init__(state[0])
  78 +}
73 79 };
... ...
pyext/GSkyRegions.i
... ... @@ -60,6 +60,7 @@ public:
60 60 void load(const GFilename& filename);
61 61 void save(const GFilename& filename) const;
62 62 const GFilename& filename(void) const;
  63 + void filename(const GFilename& filename);
63 64 };
64 65  
65 66 /***********************************************************************//**
... ... @@ -124,4 +125,16 @@ public:
124 125 GSkyRegions copy() {
125 126 return (*self);
126 127 }
  128 +%pythoncode {
  129 + def __getstate__(self):
  130 + state = (tuple([x for x in self]), self.filename())
  131 + return state
  132 + def __setstate__(self, state):
  133 + self.__init__()
  134 + size = len(state[0])
  135 + self.reserve(size)
  136 + for x in state[0]:
  137 + self.append(x)
  138 + self.filename(state[1])
  139 +}
127 140 };
... ...