Commit ee693cad2e0b932e34e2519520febc8283dcad9f

Authored by Jürgen Knödlseder
1 parent 9dc8a8dd

Implement SPI unit tests

inst/spi/include/GSPIEventBin.hpp
@@ -102,20 +102,20 @@ protected: @@ -102,20 +102,20 @@ protected:
102 void free_members(void); 102 void free_members(void);
103 103
104 // Protected members 104 // Protected members
105 - bool m_alloc; //!< Signals proper memory allocation  
106 - int m_index; //!< Dataspace index  
107 - int m_ipt; //!< Pointing index  
108 - int m_idir; //!< Direction index  
109 - int m_iebin; //!< Energy bin index  
110 - int m_num_models; //!< Number of models in bin  
111 - GSPIInstDir* m_dir; //!< Pointer to direction of bin  
112 - GTime* m_time; //!< Pointer to time of bin  
113 - GEnergy* m_energy; //!< Pointer to energy of bin  
114 - double* m_counts; //!< Pointer to number of counts  
115 - double* m_ontime; //!< Pointer to ontime of bin  
116 - double* m_livetime; //!< Pointer to livetime of bin  
117 - double* m_size; //!< Pointer to size of bin  
118 - double* m_models; //!< Pointer to models of bin 105 + bool m_alloc; //!< Signals proper memory allocation
  106 + int m_index; //!< Dataspace index
  107 + int m_ipt; //!< Pointing index
  108 + int m_idir; //!< Direction index
  109 + int m_iebin; //!< Energy bin index
  110 + int m_num_models; //!< Number of models in bin
  111 + GSPIInstDir* m_dir; //!< Pointer to direction of bin
  112 + GTime* m_time; //!< Pointer to time of bin
  113 + GEnergy* m_energy; //!< Pointer to energy of bin
  114 + double* m_counts; //!< Pointer to number of counts
  115 + double* m_ontime; //!< Pointer to ontime of bin
  116 + double* m_livetime; //!< Pointer to livetime of bin
  117 + double* m_size; //!< Pointer to size of bin
  118 + double* m_models; //!< Pointer to models of bin
119 }; 119 };
120 120
121 121
inst/spi/include/GSPILib.hpp
@@ -31,11 +31,12 @@ @@ -31,11 +31,12 @@
31 #include "GammaLib.hpp" 31 #include "GammaLib.hpp"
32 32
33 /* __ INTEGRAL/SPI specific headers ___________________________________________ */ 33 /* __ INTEGRAL/SPI specific headers ___________________________________________ */
34 -#include "GSPITools.hpp"  
35 -#include "GSPIObservation.hpp"  
36 #include "GSPIEventBin.hpp" 34 #include "GSPIEventBin.hpp"
37 #include "GSPIEventCube.hpp" 35 #include "GSPIEventCube.hpp"
38 #include "GSPIInstDir.hpp" 36 #include "GSPIInstDir.hpp"
  37 +#include "GSPIModelDataSpace.hpp"
  38 +#include "GSPIObservation.hpp"
39 #include "GSPIResponse.hpp" 39 #include "GSPIResponse.hpp"
  40 +#include "GSPITools.hpp"
40 41
41 #endif /* GSPILIB_HPP */ 42 #endif /* GSPILIB_HPP */
inst/spi/include/GSPIModelDataSpace.hpp
@@ -32,7 +32,6 @@ @@ -32,7 +32,6 @@
32 #include <vector> 32 #include <vector>
33 #include "GModelData.hpp" 33 #include "GModelData.hpp"
34 #include "GModelPar.hpp" 34 #include "GModelPar.hpp"
35 -//#include "GSPIObservation.hpp"  
36 #include "GSPIEventCube.hpp" 35 #include "GSPIEventCube.hpp"
37 36
38 /* __ Forward declarations _______________________________________________ */ 37 /* __ Forward declarations _______________________________________________ */
@@ -61,9 +60,9 @@ public: @@ -61,9 +60,9 @@ public:
61 // Constructors and destructors 60 // Constructors and destructors
62 GSPIModelDataSpace(void); 61 GSPIModelDataSpace(void);
63 GSPIModelDataSpace(const GSPIObservation& obs, 62 GSPIModelDataSpace(const GSPIObservation& obs,
64 - const std::string& name,  
65 - const std::string& method,  
66 - const int& index); 63 + const std::string& name,
  64 + const std::string& method,
  65 + const int& index);
67 explicit GSPIModelDataSpace(const GXmlElement& xml); 66 explicit GSPIModelDataSpace(const GXmlElement& xml);
68 GSPIModelDataSpace(const GSPIModelDataSpace& model); 67 GSPIModelDataSpace(const GSPIModelDataSpace& model);
69 virtual ~GSPIModelDataSpace(void); 68 virtual ~GSPIModelDataSpace(void);
inst/spi/pyext/GSPIModelDataSpace.i
@@ -43,9 +43,9 @@ public: @@ -43,9 +43,9 @@ public:
43 // Constructors and destructors 43 // Constructors and destructors
44 GSPIModelDataSpace(void); 44 GSPIModelDataSpace(void);
45 GSPIModelDataSpace(const GSPIObservation& obs, 45 GSPIModelDataSpace(const GSPIObservation& obs,
46 - const std::string& name,  
47 - const std::string& method,  
48 - const int& index); 46 + const std::string& name,
  47 + const std::string& method,
  48 + const int& index);
49 explicit GSPIModelDataSpace(const GXmlElement& xml); 49 explicit GSPIModelDataSpace(const GXmlElement& xml);
50 GSPIModelDataSpace(const GSPIModelDataSpace& model); 50 GSPIModelDataSpace(const GSPIModelDataSpace& model);
51 virtual ~GSPIModelDataSpace(void); 51 virtual ~GSPIModelDataSpace(void);
@@ -80,9 +80,14 @@ public: @@ -80,9 +80,14 @@ public:
80 } 80 }
81 %pythoncode { 81 %pythoncode {
82 def __getstate__(self): 82 def __getstate__(self):
83 - state = (self.classname()) # TODO: Replace by appropriate class members 83 + xml = gammalib.GXmlElement()
  84 + self.write(xml)
  85 + state = (xml,)
84 return state 86 return state
85 def __setstate__(self, state): 87 def __setstate__(self, state):
86 - self.__init__() 88 + if state[0][0].elements('parameter') == 0:
  89 + self.__init__()
  90 + else:
  91 + self.__init__(state[0][0])
87 } 92 }
88 }; 93 };
inst/spi/pyext/GSPIObservation.i
@@ -77,9 +77,13 @@ public: @@ -77,9 +77,13 @@ public:
77 } 77 }
78 %pythoncode { 78 %pythoncode {
79 def __getstate__(self): 79 def __getstate__(self):
80 - state = (self.classname()) # TODO: Replace by appropriate class members 80 + xml = gammalib.GXmlElement()
  81 + self.write(xml)
  82 + state = (xml,)
81 return state 83 return state
82 def __setstate__(self, state): 84 def __setstate__(self, state):
83 self.__init__() 85 self.__init__()
  86 + if gammalib.xml_get_attr('GSPIObservation.__setstate__', state[0], 'ObservationGroup', 'file') != '':
  87 + self.read(state[0])
84 } 88 }
85 }; 89 };
inst/spi/src/GSPIEventBin.cpp
@@ -280,9 +280,10 @@ void GSPIEventBin::init_members(void) @@ -280,9 +280,10 @@ void GSPIEventBin::init_members(void)
280 m_dir->clear(); 280 m_dir->clear();
281 m_time->clear(); 281 m_time->clear();
282 m_energy->clear(); 282 m_energy->clear();
283 - *m_counts = 0.0;  
284 - *m_ontime = 0.0;  
285 - *m_size = 0.0; 283 + *m_counts = 0.0;
  284 + *m_ontime = 0.0;
  285 + *m_livetime = 0.0;
  286 + *m_size = 0.0;
286 287
287 // Return 288 // Return
288 return; 289 return;
inst/spi/src/GSPIModelDataSpace.cpp
@@ -571,7 +571,7 @@ void GSPIModelDataSpace::write(GXmlElement&amp; xml) const @@ -571,7 +571,7 @@ void GSPIModelDataSpace::write(GXmlElement&amp; xml) const
571 write_attributes(*src); 571 write_attributes(*src);
572 572
573 // Write method 573 // Write method
574 - xml.attribute("method", m_method); 574 + src->attribute("method", m_method);
575 575
576 // Return 576 // Return
577 return; 577 return;
inst/spi/src/GSPIObservation.cpp
@@ -310,9 +310,9 @@ void GSPIObservation::write(GXmlElement&amp; xml) const @@ -310,9 +310,9 @@ void GSPIObservation::write(GXmlElement&amp; xml) const
310 // Allocate XML element pointer 310 // Allocate XML element pointer
311 GXmlElement* par; 311 GXmlElement* par;
312 312
313 - // TODO: Write out all parameters. An example is shown below. 313 + // Set ObservationGroup parameter
314 par = gammalib::xml_need_par(G_WRITE, xml, "ObservationGroup"); 314 par = gammalib::xml_need_par(G_WRITE, xml, "ObservationGroup");
315 - par->attribute("ObservationGroup", gammalib::xml_file_reduce(xml, m_filename)); 315 + par->attribute("file", gammalib::xml_file_reduce(xml, m_filename));
316 316
317 // Return 317 // Return
318 return; 318 return;
inst/spi/test/test_SPI.cpp
@@ -51,10 +51,20 @@ void TestGSPI::set(void) @@ -51,10 +51,20 @@ void TestGSPI::set(void)
51 name("GSPI"); 51 name("GSPI");
52 52
53 // Append tests to test suite 53 // Append tests to test suite
  54 + append(static_cast<pfunction>(&TestGSPI::test_instdir),
  55 + "Test GSPIInstDir");
  56 + append(static_cast<pfunction>(&TestGSPI::test_eventbin),
  57 + "Test GSPIEventBin");
  58 + append(static_cast<pfunction>(&TestGSPI::test_eventcube),
  59 + "Test GSPIEventCube");
  60 + append(static_cast<pfunction>(&TestGSPI::test_modeldataspace),
  61 + "Test GSPIModelDataSpace");
54 append(static_cast<pfunction>(&TestGSPI::test_obs), 62 append(static_cast<pfunction>(&TestGSPI::test_obs),
55 "Test GSPIObservation"); 63 "Test GSPIObservation");
56 append(static_cast<pfunction>(&TestGSPI::test_response), 64 append(static_cast<pfunction>(&TestGSPI::test_response),
57 "Test GSPIResponse"); 65 "Test GSPIResponse");
  66 + append(static_cast<pfunction>(&TestGSPI::test_tools),
  67 + "Test GSPITools");
58 68
59 // Return 69 // Return
60 return; 70 return;
@@ -74,15 +84,215 @@ TestGSPI* TestGSPI::clone(void) const @@ -74,15 +84,215 @@ TestGSPI* TestGSPI::clone(void) const
74 84
75 85
76 /***********************************************************************//** 86 /***********************************************************************//**
  87 + * @brief Test GSPIInstDir class
  88 + ***************************************************************************/
  89 +void TestGSPI::test_instdir(void)
  90 +{
  91 + // Test content of void class
  92 + GSPIInstDir dir1;
  93 + test_value(dir1.classname(), "GSPIInstDir", "Void instance classname");
  94 + test_value(dir1.dir().ra_deg(), 0.0, "Void instance Right Ascension");
  95 + test_value(dir1.dir().dec_deg(), 0.0, "Void instance Declination");
  96 + test_value(dir1.detid(), 0, "Void instance detector identifier");
  97 +
  98 + // Test content of filled class
  99 + GSkyDir dir;
  100 + dir.radec_deg(83.6331, 22.0145);
  101 + GSPIInstDir dir2(dir, 13);
  102 + test_value(dir2.dir().ra_deg(), 83.6331, "Filled instance Right Ascension");
  103 + test_value(dir2.dir().dec_deg(), 22.0145, "Filled instance Declination");
  104 + test_value(dir2.detid(), 13, "Filled instance detector identifier");
  105 +
  106 + // Test content of copied class
  107 + GSPIInstDir dir3 = dir2;
  108 + test_value(dir3.dir().ra_deg(), 83.6331, "Copied instance Right Ascension");
  109 + test_value(dir3.dir().dec_deg(), 22.0145, "Copied instance Declination");
  110 + test_value(dir3.detid(), 13, "Copied instance detector identifier");
  111 +
  112 + // Test content of copy-constructed class
  113 + GSPIInstDir dir4(dir3);
  114 + test_value(dir4.dir().ra_deg(), 83.6331, "Copied instance Right Ascension");
  115 + test_value(dir4.dir().dec_deg(), 22.0145, "Copied instance Declination");
  116 + test_value(dir4.detid(), 13, "Copied instance detector identifier");
  117 +
  118 + // Test setters and getters
  119 + dir.radec_deg(299.5903, 35.2016);
  120 + dir4.dir(dir);
  121 + dir4.detid(1);
  122 + test_value(dir4.dir().ra_deg(), 299.5903, "Get Right Ascension");
  123 + test_value(dir4.dir().dec_deg(), 35.2016, "Get Declination");
  124 + test_value(dir4.detid(), 1, "Get detector identifier");
  125 +
  126 + // Return
  127 + return;
  128 +}
  129 +
  130 +
  131 +/***********************************************************************//**
  132 + * @brief Test GSPIEventBin class
  133 + ***************************************************************************/
  134 +void TestGSPI::test_eventbin(void)
  135 +{
  136 + // Test content of void bin
  137 + GSPIEventBin bin1;
  138 + test_value(bin1.classname(), "GSPIEventBin", "Void instance classname");
  139 + test_value(bin1.dir().dir().ra_deg(), 0.0, "Void instance Right Ascension");
  140 + test_value(bin1.dir().dir().dec_deg(), 0.0, "Void instance Declination");
  141 + test_value(bin1.dir().detid(), 0, "Void instance detector identifier");
  142 + test_value(bin1.energy().keV(), 0.0, "Void instance energy");
  143 + test_value(bin1.time().secs(), 0.0, "Void instance time");
  144 + test_value(bin1.counts(), 0.0, "Void instance counts");
  145 + test_value(bin1.error(), 0.0, "Void instance error");
  146 + test_value(bin1.ontime(), 0.0, "Void instance ontime");
  147 + test_value(bin1.livetime(), 0.0, "Void instance livetime");
  148 + test_value(bin1.index(), -1, "Void instance index");
  149 + test_value(bin1.ipt(), -1, "Void instance pointing index");
  150 + test_value(bin1.idir(), -1, "Void instance direction index");
  151 + test_value(bin1.iebin(), -1, "Void instance energy bin index");
  152 +
  153 + // Test counts setter and getter
  154 + bin1.counts(41.0);
  155 + test_value(bin1.counts(), 41.0, "Counts getter");
  156 +
  157 + // Return
  158 + return;
  159 +}
  160 +
  161 +
  162 +/***********************************************************************//**
  163 + * @brief Test GSPIEventCube class
  164 + ***************************************************************************/
  165 +void TestGSPI::test_eventcube(void)
  166 +{
  167 + // Test content of void cube
  168 + GSPIEventCube cube1;
  169 + test_value(cube1.classname(), "GSPIEventCube", "Void instance classname");
  170 + test_value(cube1.size(), 0, "Void instance size");
  171 + test_value(cube1.dim(), 3, "Void instance dimensions");
  172 + test_value(cube1.naxis(0), 0, "Void instance pointings");
  173 + test_value(cube1.naxis(1), 0, "Void instance detectors");
  174 + test_value(cube1.naxis(2), 0, "Void instance energy bins");
  175 + test_value(cube1.number(), 0, "Void instance number of events");
  176 + test_value(cube1.ontime(), 0.0, "Void instance ontime");
  177 + test_value(cube1.livetime(), 0.0, "Void instance livetime");
  178 + test_value(cube1.models(), 0, "Void instance models");
  179 +
  180 + // Test loading of Observation Group
  181 + cube1.load(og_dol);
  182 + test_value(cube1.size(), 16720, "Loaded instance size");
  183 + test_value(cube1.dim(), 3, "Loaded instance dimensions");
  184 + test_value(cube1.naxis(0), 88, "Loaded instance pointings");
  185 + test_value(cube1.naxis(1), 19, "Loaded instance detectors");
  186 + test_value(cube1.naxis(2), 10, "Loaded instance energy bins");
  187 + test_value(cube1.number(), 101269457, "Loaded instance number of events");
  188 + test_value(cube1.ontime(), 193966.8178673, "Loaded instance ontime");
  189 + test_value(cube1.livetime(), 170657.5371606, "Loaded instance livetime");
  190 + test_value(cube1.models(), 1, "Loaded instance models");
  191 + test_value(cube1.model_counts(0), 101269456.964783, "Loaded instance model counts");
  192 + test_value(cube1.ptid(7), "00440010.000000", "Loaded instance ptid(7)");
  193 + test_value(cube1.dir(11,9).dir().ra_deg(), 83.77876, "Loaded instance RA");
  194 + test_value(cube1.dir(11,9).dir().dec_deg(), 22.03696, "Loaded instance RA");
  195 + test_value(cube1.spi_x(11).ra_deg(), 83.77876, "Loaded instance RA_X");
  196 + test_value(cube1.spi_x(11).dec_deg(), 22.03696, "Loaded instance DEC_X");
  197 + test_value(cube1.spi_z(11).ra_deg(), 354.8671, "Loaded instance RA_Z");
  198 + test_value(cube1.spi_z(11).dec_deg(), -2.686594, "Loaded instance DEC_Z");
  199 +
  200 + // Test one event bin
  201 + const GSPIEventBin* bin1 = cube1[45];
  202 + test_value(bin1->dir().dir().ra_deg(), 87.98045, "Bin[45] RA");
  203 + test_value(bin1->dir().dir().dec_deg(), 17.98266, "Bin[45] DEC");
  204 + test_value(bin1->dir().detid(), 4, "Bin[45] detector identifier");
  205 + test_value(bin1->energy().keV(), 262.5, "Bin[45] energy");
  206 + test_value(bin1->time().secs(), -216415756.731, "Bin[45] time");
  207 + test_value(bin1->counts(), 4766.0, "Bin[45] counts");
  208 + test_value(bin1->error(), 69.03622, "Bin[45] error");
  209 + test_value(bin1->ontime(), 2928.9207878, "Bin[45] ontime");
  210 + test_value(bin1->livetime(), 2578.60894906, "Bin[45] livetime");
  211 + test_value(bin1->index(), 45, "Bin[45] index");
  212 + test_value(bin1->ipt(), 0, "Bin[45] pointing index");
  213 + test_value(bin1->idir(), 4, "Bin[45] direction index");
  214 + test_value(bin1->iebin(), 5, "Bin[45] energy bin index");
  215 +
  216 + // Return
  217 + return;
  218 +}
  219 +
  220 +
  221 +/***********************************************************************//**
  222 + * @brief Test GSPIModelDataSpace class
  223 + ***************************************************************************/
  224 +void TestGSPI::test_modeldataspace(void)
  225 +{
  226 + // Test content of void model
  227 + GSPIModelDataSpace model1;
  228 + test_value(model1.classname(), "GSPIModelDataSpace", "Void instance classname");
  229 + test_value(model1.type(), "DataSpace", "Void instance type");
  230 + test_value(model1.size(), 0, "Void instance size");
  231 + test_value(model1.instruments(), "SPI", "Void instance instruments");
  232 + test_assert(model1.is_constant(), "Void instance is_constant");
  233 + GXmlElement xml;
  234 + model1.write(xml);
  235 + model1.read(*xml.element(0));
  236 + test_value(model1.type(), "DataSpace", "Void instance type");
  237 + test_value(model1.size(), 0, "Void instance size");
  238 + test_value(model1.instruments(), "SPI", "Void instance instruments");
  239 + test_assert(model1.is_constant(), "Void instance is_constant");
  240 +
  241 + // Construct "orbit" model from OG
  242 + GSPIObservation obs(og_dol);
  243 + GSPIModelDataSpace model2(obs, "GEDSAT", "orbit", 0);
  244 + test_value(model2.type(), "DataSpace", "ORBIT instance type");
  245 + test_value(model2.size(), 1, "ORBIT instance size");
  246 + test_value(model2.instruments(), "SPI", "ORBIT instance instruments");
  247 + test_value(model2.name(), "GEDSAT", "ORBIT instance name");
  248 + test_value(model2[0].name(), "GEDSAT Rev0044", "ORBIT instance parameter");
  249 + xml.clear();
  250 + model2.write(xml);
  251 +
  252 + // Construct "orbit" model from XML
  253 + GSPIModelDataSpace model3(*xml.element(0));
  254 + test_value(model3.type(), "DataSpace", "XML constructed instance type");
  255 + test_value(model3.size(), 1, "XML constructed ORBIT instance size");
  256 + test_value(model3.instruments(), "SPI", "XML constructed ORBIT instance instruments");
  257 + test_value(model3.name(), "GEDSAT", "ORBIT instance name");
  258 + test_value(model3[0].name(), "GEDSAT Rev0044", "XML constructed ORBIT instance parameter");
  259 +
  260 + // Construct "orbit,dete" model from OG
  261 + GSPIModelDataSpace model4(obs, "GEDSAT", "orbit,dete", 0);
  262 + test_value(model4.type(), "DataSpace", "ORBIT,DETE instance type");
  263 + test_value(model4.size(), 19, "ORBIT,DETE instance size");
  264 + test_value(model4[1].name(), "GEDSAT D001 Rev0044", "ORBIT,DETE instance parameter");
  265 +
  266 + // Construct "orbit,dete,ebin" model from OG
  267 + GSPIModelDataSpace model5(obs, "GEDSAT", "orbit,dete,ebin", 0);
  268 + test_value(model5.type(), "DataSpace", "ORBIT,DETE,EBIN instance type");
  269 + test_value(model5.size(), 190, "ORBIT,DETE,EBIN instance size");
  270 + test_value(model5[35].name(), "GEDSAT E005 D003 Rev0044", "ORBIT,DETE,EBIN instance parameter");
  271 +
  272 + // Return
  273 + return;
  274 +}
  275 +
  276 +
  277 +/***********************************************************************//**
77 * @brief Test GSPIObservation class 278 * @brief Test GSPIObservation class
78 ***************************************************************************/ 279 ***************************************************************************/
79 void TestGSPI::test_obs(void) 280 void TestGSPI::test_obs(void)
80 { 281 {
81 - // Test empty GSPIObservation instance 282 + // Test content of void observation
82 GSPIObservation obs1; 283 GSPIObservation obs1;
  284 + test_value(obs1.classname(), "GSPIObservation", "Void instance classname");
  285 + test_value(obs1.instrument(), "SPI", "Void instance instrument");
  286 + test_value(obs1.ontime(), 0.0, "Void instance ontime");
  287 + test_value(obs1.livetime(), 0.0, "Void instance livetime");
  288 + test_value(obs1.deadc(), 0.0, "Void instance deadc");
83 289
84 - // Construct GSPIObservation instance from Observation group 290 + // Test content of OG
85 GSPIObservation obs2(og_dol); 291 GSPIObservation obs2(og_dol);
  292 + test_value(obs2.instrument(), "SPI", "Void instance instrument");
  293 + test_value(obs2.ontime(), 193966.8178673, "Void instance ontime");
  294 + test_value(obs2.livetime(), 170657.5371606, "Void instance livetime");
  295 + test_value(obs2.deadc(), 0.87982851416, "Void instance deadc");
86 296
87 // Return 297 // Return
88 return; 298 return;
@@ -94,6 +304,30 @@ void TestGSPI::test_obs(void) @@ -94,6 +304,30 @@ void TestGSPI::test_obs(void)
94 ***************************************************************************/ 304 ***************************************************************************/
95 void TestGSPI::test_response(void) 305 void TestGSPI::test_response(void)
96 { 306 {
  307 + // Set energy
  308 + GEnergy obsEnergy;
  309 +
  310 + // Test content of void response
  311 + GSPIResponse rsp1;
  312 + test_value(rsp1.classname(), "GSPIResponse", "Void instance classname");
  313 + test_assert(!rsp1.use_edisp(), "Void instance use_edisp");
  314 + test_assert(!rsp1.use_tdisp(), "Void instance use_edisp");
  315 + test_assert(!rsp1.is_precomputed(), "Void instance is_precomputed");
  316 +
  317 + // Return
  318 + return;
  319 +}
  320 +
  321 +
  322 +/***********************************************************************//**
  323 + * @brief Test GSPITools module
  324 + ***************************************************************************/
  325 +void TestGSPI::test_tools(void)
  326 +{
  327 + // Test methods
  328 + test_value(gammalib::spi_ijd2time(1500.0).utc(), "2004-02-08T23:58:56",
  329 + "spi_ijd2time");
  330 +
97 // Return 331 // Return
98 return; 332 return;
99 } 333 }
inst/spi/test/test_SPI.hpp
@@ -49,8 +49,13 @@ public: @@ -49,8 +49,13 @@ public:
49 virtual void set(void); 49 virtual void set(void);
50 virtual TestGSPI* clone(void) const; 50 virtual TestGSPI* clone(void) const;
51 virtual std::string classname(void) const { return "TestGSPI"; } 51 virtual std::string classname(void) const { return "TestGSPI"; }
  52 + void test_instdir(void);
  53 + void test_eventbin(void);
  54 + void test_eventcube(void);
  55 + void test_modeldataspace(void);
52 void test_obs(void); 56 void test_obs(void);
53 void test_response(void); 57 void test_response(void);
  58 + void test_tools(void);
54 }; 59 };
55 60
56 #endif /* TEST_SPI_HPP */ 61 #endif /* TEST_SPI_HPP */
inst/spi/test/test_SPI.py
@@ -38,8 +38,9 @@ class Test(gammalib.GPythonTestSuite): @@ -38,8 +38,9 @@ class Test(gammalib.GPythonTestSuite):
38 gammalib.GPythonTestSuite.__init__(self) 38 gammalib.GPythonTestSuite.__init__(self)
39 39
40 # Set test directories 40 # Set test directories
41 - self._data = os.environ['TEST_SPI_DATA']  
42 - self._caldb = self._data + '/../caldb' 41 + self._data = os.environ['TEST_SPI_DATA']
  42 + self._caldb = self._data + '/../caldb'
  43 + self._og_dol = self._data + '/obs/og_spi.fits'
43 44
44 # Return 45 # Return
45 return 46 return
@@ -78,11 +79,8 @@ class Test(gammalib.GPythonTestSuite): @@ -78,11 +79,8 @@ class Test(gammalib.GPythonTestSuite):
78 """ 79 """
79 Test GSPIObservation class 80 Test GSPIObservation class
80 """ 81 """
81 - # Set Observation Group file name  
82 - og_dol = self._data + '/obs/og_spi.fits'  
83 -  
84 # Load event cube 82 # Load event cube
85 - obs = gammalib.GSPIObservation(og_dol) 83 + obs = gammalib.GSPIObservation(self._og_dol)
86 self.test_value(obs.ontime(), 193966.8178673, 1.0e-6, 'Check ontime') 84 self.test_value(obs.ontime(), 193966.8178673, 1.0e-6, 'Check ontime')
87 self.test_value(obs.livetime(), 170657.5371606, 1.0e-6, 'Check livetime') 85 self.test_value(obs.livetime(), 170657.5371606, 1.0e-6, 'Check livetime')
88 self.test_value(obs.deadc(), 0.8798285, 1.0e-6, 'Check deadtime correction') 86 self.test_value(obs.deadc(), 0.8798285, 1.0e-6, 'Check deadtime correction')
@@ -111,20 +109,26 @@ class Test(gammalib.GPythonTestSuite): @@ -111,20 +109,26 @@ class Test(gammalib.GPythonTestSuite):
111 test_support.pickeling(self, gammalib.GSPIEventBin()) 109 test_support.pickeling(self, gammalib.GSPIEventBin())
112 test_support.pickeling(self, gammalib.GSPIEventCube()) 110 test_support.pickeling(self, gammalib.GSPIEventCube())
113 test_support.pickeling(self, gammalib.GSPIInstDir()) 111 test_support.pickeling(self, gammalib.GSPIInstDir())
  112 + test_support.pickeling(self, gammalib.GSPIModelDataSpace())
114 test_support.pickeling(self, gammalib.GSPIObservation()) 113 test_support.pickeling(self, gammalib.GSPIObservation())
115 test_support.pickeling(self, gammalib.GSPIResponse()) 114 test_support.pickeling(self, gammalib.GSPIResponse())
116 115
117 - # Setup test (TODO: to be filled with meaningful values)  
118 - bin = gammalib.GSPIEventBin()  
119 - cube = gammalib.GSPIEventCube()  
120 - dir = gammalib.GSPIInstDir()  
121 - obs = gammalib.GSPIObservation()  
122 - rsp = gammalib.GSPIResponse() 116 + # Setup test
  117 + dir = gammalib.GSkyDir()
  118 + dir.radec_deg(83.6331, 22.0145)
  119 + instdir = gammalib.GSPIInstDir(dir, 13)
  120 + obs = gammalib.GSPIObservation(self._og_dol)
  121 + model = gammalib.GSPIModelDataSpace(obs, 'GEDSAT', 'orbit', 0)
  122 + #
  123 + bin = gammalib.GSPIEventBin() # pickeling not yet implemented
  124 + cube = gammalib.GSPIEventCube() # pickeling not yet implemented
  125 + rsp = gammalib.GSPIResponse() # pickeling not yet implemented
123 126
124 # Perform pickeling tests of filled classes 127 # Perform pickeling tests of filled classes
125 test_support.pickeling(self, gammalib.GSPIEventBin(bin)) 128 test_support.pickeling(self, gammalib.GSPIEventBin(bin))
126 test_support.pickeling(self, gammalib.GSPIEventCube(cube)) 129 test_support.pickeling(self, gammalib.GSPIEventCube(cube))
127 - test_support.pickeling(self, gammalib.GSPIInstDir(dir)) 130 + test_support.pickeling(self, gammalib.GSPIInstDir(instdir))
  131 + test_support.pickeling(self, gammalib.GSPIModelDataSpace(model))
128 test_support.pickeling(self, gammalib.GSPIObservation(obs)) 132 test_support.pickeling(self, gammalib.GSPIObservation(obs))
129 test_support.pickeling(self, gammalib.GSPIResponse(rsp)) 133 test_support.pickeling(self, gammalib.GSPIResponse(rsp))
130 134