Commit eaa252c243bc355ad2b2acb3b4f313f9ee764c95
1 parent
3b6811f5
Correct ctskymap Python test
Showing
2 changed files
with
15 additions
and
9 deletions
src/ctskymap/ctskymap.cpp
| ... | ... | @@ -33,8 +33,8 @@ |
| 33 | 33 | |
| 34 | 34 | /* __ Method name definitions ____________________________________________ */ |
| 35 | 35 | #define G_INIT_MAP "ctskymap::init_map(GCTAObservation* obs)" |
| 36 | -#define G_BIN_EVENTS "ctskymap::bin_events(GCTAObservation*)" | |
| 37 | -#define G_BKG_SUBTRACT_IRF "ctskymap::bkg_subtract_irf(GCTAObservation*)" | |
| 36 | +#define G_MAP_EVENTS "ctskymap::map_events(GCTAObservation*)" | |
| 37 | +#define G_MAP_BACKGROUND_IRF "ctskymap::map_background_irf(GCTAObservation*)" | |
| 38 | 38 | |
| 39 | 39 | /* __ Debug definitions __________________________________________________ */ |
| 40 | 40 | |
| ... | ... | @@ -297,7 +297,9 @@ void ctskymap::save(void) |
| 297 | 297 | hdu = m_bkgmap.write(fits); |
| 298 | 298 | |
| 299 | 299 | // Set background map extension name |
| 300 | - hdu->extname("BACKGROUND"); | |
| 300 | + if (hdu != NULL) { | |
| 301 | + hdu->extname("BACKGROUND"); | |
| 302 | + } | |
| 301 | 303 | |
| 302 | 304 | // Write keywords into background extension |
| 303 | 305 | write_ogip_keywords(hdu); |
| ... | ... | @@ -307,7 +309,9 @@ void ctskymap::save(void) |
| 307 | 309 | hdu = m_sigmap.write(fits); |
| 308 | 310 | |
| 309 | 311 | // Set significance map extension name |
| 310 | - hdu->extname("SIGNIFICANCE"); | |
| 312 | + if (hdu != NULL) { | |
| 313 | + hdu->extname("SIGNIFICANCE"); | |
| 314 | + } | |
| 311 | 315 | |
| 312 | 316 | // Write keywords into significance extension |
| 313 | 317 | write_ogip_keywords(hdu); |
| ... | ... | @@ -489,7 +493,7 @@ void ctskymap::map_events(GCTAObservation* obs) |
| 489 | 493 | // Make sure that the observation holds a CTA event list. If this |
| 490 | 494 | // is not the case then throw an exception. |
| 491 | 495 | if (events == NULL) { |
| 492 | - throw GException::no_list(G_BIN_EVENTS); | |
| 496 | + throw GException::no_list(G_MAP_EVENTS); | |
| 493 | 497 | } |
| 494 | 498 | |
| 495 | 499 | // Setup energy range covered by data |
| ... | ... | @@ -609,7 +613,7 @@ void ctskymap::map_background_irf(GCTAObservation* obs) |
| 609 | 613 | get_obs_header(obs)+" to compute IRF background. " |
| 610 | 614 | "Please specify response information or use " |
| 611 | 615 | "another background subtraction method."; |
| 612 | - throw GException::invalid_value(G_BKG_SUBTRACT_IRF, msg); | |
| 616 | + throw GException::invalid_value(G_MAP_BACKGROUND_IRF, msg); | |
| 613 | 617 | } |
| 614 | 618 | |
| 615 | 619 | // Get IRF background template |
| ... | ... | @@ -621,7 +625,7 @@ void ctskymap::map_background_irf(GCTAObservation* obs) |
| 621 | 625 | "response function for "+ |
| 622 | 626 | get_obs_header(obs)+". Please specify an instrument " |
| 623 | 627 | "response function containing a background template."; |
| 624 | - throw GException::invalid_value(G_BKG_SUBTRACT_IRF, msg); | |
| 628 | + throw GException::invalid_value(G_MAP_BACKGROUND_IRF, msg); | |
| 625 | 629 | } |
| 626 | 630 | |
| 627 | 631 | // Compute natural logarithm of energy range in MeV | ... | ... |
test/test_ctskymap.py
| ... | ... | @@ -217,7 +217,7 @@ class Test(test): |
| 217 | 217 | skymap['proj'] = 'CAR' |
| 218 | 218 | skymap['xref'] = 184.5575 |
| 219 | 219 | skymap['yref'] = -5.7844 |
| 220 | - skymap['bkgsubtract'] = 'IRF' | |
| 220 | + skymap['bkgsubtract'] = 'IRF' | |
| 221 | 221 | skymap['caldb'] = self._caldb |
| 222 | 222 | skymap['irf'] = self._irf |
| 223 | 223 | skymap['outmap'] = 'ctskymap_py4.fits' |
| ... | ... | @@ -229,7 +229,9 @@ class Test(test): |
| 229 | 229 | skymap.execute() |
| 230 | 230 | |
| 231 | 231 | # Check result file |
| 232 | - self._check_result_file('ctskymap_py3.fits') | |
| 232 | + self._check_result_file('ctskymap_py4.fits') | |
| 233 | + self._check_result_file('ctskymap_py4.fits[BACKGROUND]') | |
| 234 | + self._check_result_file('ctskymap_py4.fits[SIGNIFICANCE]') | |
| 233 | 235 | |
| 234 | 236 | # Return |
| 235 | 237 | return | ... | ... |