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,8 +33,8 @@ | ||
| 33 | 33 | ||
| 34 | /* __ Method name definitions ____________________________________________ */ | 34 | /* __ Method name definitions ____________________________________________ */ |
| 35 | #define G_INIT_MAP "ctskymap::init_map(GCTAObservation* obs)" | 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 | /* __ Debug definitions __________________________________________________ */ | 39 | /* __ Debug definitions __________________________________________________ */ |
| 40 | 40 | ||
| @@ -297,7 +297,9 @@ void ctskymap::save(void) | @@ -297,7 +297,9 @@ void ctskymap::save(void) | ||
| 297 | hdu = m_bkgmap.write(fits); | 297 | hdu = m_bkgmap.write(fits); |
| 298 | 298 | ||
| 299 | // Set background map extension name | 299 | // Set background map extension name |
| 300 | - hdu->extname("BACKGROUND"); | 300 | + if (hdu != NULL) { |
| 301 | + hdu->extname("BACKGROUND"); | ||
| 302 | + } | ||
| 301 | 303 | ||
| 302 | // Write keywords into background extension | 304 | // Write keywords into background extension |
| 303 | write_ogip_keywords(hdu); | 305 | write_ogip_keywords(hdu); |
| @@ -307,7 +309,9 @@ void ctskymap::save(void) | @@ -307,7 +309,9 @@ void ctskymap::save(void) | ||
| 307 | hdu = m_sigmap.write(fits); | 309 | hdu = m_sigmap.write(fits); |
| 308 | 310 | ||
| 309 | // Set significance map extension name | 311 | // Set significance map extension name |
| 310 | - hdu->extname("SIGNIFICANCE"); | 312 | + if (hdu != NULL) { |
| 313 | + hdu->extname("SIGNIFICANCE"); | ||
| 314 | + } | ||
| 311 | 315 | ||
| 312 | // Write keywords into significance extension | 316 | // Write keywords into significance extension |
| 313 | write_ogip_keywords(hdu); | 317 | write_ogip_keywords(hdu); |
| @@ -489,7 +493,7 @@ void ctskymap::map_events(GCTAObservation* obs) | @@ -489,7 +493,7 @@ void ctskymap::map_events(GCTAObservation* obs) | ||
| 489 | // Make sure that the observation holds a CTA event list. If this | 493 | // Make sure that the observation holds a CTA event list. If this |
| 490 | // is not the case then throw an exception. | 494 | // is not the case then throw an exception. |
| 491 | if (events == NULL) { | 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 | // Setup energy range covered by data | 499 | // Setup energy range covered by data |
| @@ -609,7 +613,7 @@ void ctskymap::map_background_irf(GCTAObservation* obs) | @@ -609,7 +613,7 @@ void ctskymap::map_background_irf(GCTAObservation* obs) | ||
| 609 | get_obs_header(obs)+" to compute IRF background. " | 613 | get_obs_header(obs)+" to compute IRF background. " |
| 610 | "Please specify response information or use " | 614 | "Please specify response information or use " |
| 611 | "another background subtraction method."; | 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 | // Get IRF background template | 619 | // Get IRF background template |
| @@ -621,7 +625,7 @@ void ctskymap::map_background_irf(GCTAObservation* obs) | @@ -621,7 +625,7 @@ void ctskymap::map_background_irf(GCTAObservation* obs) | ||
| 621 | "response function for "+ | 625 | "response function for "+ |
| 622 | get_obs_header(obs)+". Please specify an instrument " | 626 | get_obs_header(obs)+". Please specify an instrument " |
| 623 | "response function containing a background template."; | 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 | // Compute natural logarithm of energy range in MeV | 631 | // Compute natural logarithm of energy range in MeV |
test/test_ctskymap.py
| @@ -217,7 +217,7 @@ class Test(test): | @@ -217,7 +217,7 @@ class Test(test): | ||
| 217 | skymap['proj'] = 'CAR' | 217 | skymap['proj'] = 'CAR' |
| 218 | skymap['xref'] = 184.5575 | 218 | skymap['xref'] = 184.5575 |
| 219 | skymap['yref'] = -5.7844 | 219 | skymap['yref'] = -5.7844 |
| 220 | - skymap['bkgsubtract'] = 'IRF' | 220 | + skymap['bkgsubtract'] = 'IRF' |
| 221 | skymap['caldb'] = self._caldb | 221 | skymap['caldb'] = self._caldb |
| 222 | skymap['irf'] = self._irf | 222 | skymap['irf'] = self._irf |
| 223 | skymap['outmap'] = 'ctskymap_py4.fits' | 223 | skymap['outmap'] = 'ctskymap_py4.fits' |
| @@ -229,7 +229,9 @@ class Test(test): | @@ -229,7 +229,9 @@ class Test(test): | ||
| 229 | skymap.execute() | 229 | skymap.execute() |
| 230 | 230 | ||
| 231 | # Check result file | 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 | # Return | 236 | # Return |
| 235 | return | 237 | return |