diff --git a/src/ctskymap/ctskymap.cpp b/src/ctskymap/ctskymap.cpp index d2b0093..fd0a134 100644 --- a/src/ctskymap/ctskymap.cpp +++ b/src/ctskymap/ctskymap.cpp @@ -442,7 +442,7 @@ void ctskymap::get_parameters(void) // If IRF background subtraction is requested then make sure that the // CTA observations in the observation container have response information - if (m_bkgsubtract == "IRF") { + if (m_bkgsubtract != "NONE") { set_response(m_obs); } @@ -746,7 +746,7 @@ void ctskymap::map_background_ring(GCTAObservation* obs) get_obs_header(obs)+" to compute IRF background. " "Please specify response information or use " "another background subtraction method."; - throw GException::invalid_value(G_BKG_SUBTRACT_IRF, msg); + throw GException::invalid_value(G_BKG_SUBTRACT_RING, msg); } // Get IRF background template @@ -758,7 +758,7 @@ void ctskymap::map_background_ring(GCTAObservation* obs) "response function for "+ get_obs_header(obs)+". Please specify an instrument " "response function containing a background template."; - throw GException::invalid_value(G_BKG_SUBTRACT_IRF, msg); + throw GException::invalid_value(G_BKG_SUBTRACT_RING, msg); } // Compute natural logarithm of energy range in MeV @@ -836,9 +836,7 @@ void ctskymap::map_background_ring(GCTAObservation* obs) else { // Compute the on, off and alpha parameters - double n_on(0); - double n_off(0); - double alpha(0); + double n_on(0.0), n_off(0.0), alpha(0.0); compute_ring_values(m_skymap, sens, m_dirs[ibin], n_on, n_off, alpha); @@ -886,6 +884,12 @@ void ctskymap::map_significance(void) // Loop through each bin in the on-counts map for (int i = 0; i < m_onmap.npix(); ++i) { + // Since this can take a long time, keep the user updated on + // the progress when another 10% of pixels is processed + if (i%(m_onmap.npix()/10)==0) { + log_value(NORMAL, "Pixels remaining", m_onmap.npix()-i); + } + // Get bin coordinate GSkyDir& skydir = m_dirs[i]; diff --git a/test/test_ctskymap.py b/test/test_ctskymap.py index 54be18c..80e5ca9 100755 --- a/test/test_ctskymap.py +++ b/test/test_ctskymap.py @@ -206,6 +206,10 @@ class Test(test): # Publish with name skymap.publish('My sky map') + # ================================ + # TEST IRF BACKGROUND SUBTRACTION + # ================================ + # Allocate ctskymap tool from observation container skymap = ctools.ctskymap(obs) skymap['emin'] = 0.1 @@ -229,7 +233,41 @@ class Test(test): skymap.execute() # Check result file - self._check_result_file('ctskymap_py3.fits') + self._check_result_file('ctskymap_py4.fits') + + # ================================ + # TEST RING BACKGROUND SUBTRACTION + # ================================ + + # Allocate ctskymap tool from observation container + skymap = ctools.ctskymap(obs) + skymap['emin'] = 0.1 + skymap['emax'] = 100 + skymap['nxpix'] = 100 # Make region smaller since the 'RING' + skymap['nypix'] = 100 # method takes longer to run than 'IRF' + skymap['binsz'] = 0.02 + skymap['coordsys'] = 'CEL' + skymap['proj'] = 'CAR' + skymap['xref'] = 83.63 + skymap['yref'] = 22.01 + skymap['bkgsubtract'] = 'RING' + skymap['caldb'] = self._caldb + skymap['irf'] = self._irf + skymap['outmap'] = 'ctskymap_py5.fits' + skymap['logfile'] = 'ctskymap_py5.log' + skymap['chatter'] = 4 + skymap['roiradius'] = 0.1 + skymap['inradius'] = 0.6 + skymap['outradius'] = 0.8 + skymap['regfile'] = 'NONE' + skymap['runavgalpha'] = True + + # Execute tool + skymap.logFileOpen() # Needed to get a new log file + skymap.execute() + + # Check result file + self._check_result_file('ctskymap_py5.fits', 100, 100) # Return return