From 523cbd4b23340d659cb19768780e56941f32ffe4 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Thu, 20 Apr 2017 15:29:25 +0200 Subject: [PATCH] Catch events in ctbin that have an invalid WCS transformation --- src/ctbin/ctbin.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ctbin/ctbin.cpp b/src/ctbin/ctbin.cpp index 585c614..80f901c 100644 --- a/src/ctbin/ctbin.cpp +++ b/src/ctbin/ctbin.cpp @@ -491,6 +491,7 @@ void ctbin::fill_cube(GCTAObservation* obs) // Initialise binning statistics int num_outside_roi = 0; + int num_invalid_wcs = 0; int num_outside_map = 0; int num_outside_ebds = 0; int num_in_map = 0; @@ -501,17 +502,26 @@ void ctbin::fill_cube(GCTAObservation* obs) // Get event const GCTAEventAtom* event = (*events)[i]; - // Determine sky pixel + // Determine event sky direction GCTAInstDir* inst = (GCTAInstDir*)&(event->dir()); GSkyDir dir = inst->dir(); - GSkyPixel pixel = m_counts.dir2pix(dir); - // Skip event if corresponding counts cube pixel is outside RoI + // Skip event if it is outside the RoI if (roi.centre().dir().dist_deg(dir) > roi.radius()) { num_outside_roi++; continue; } + // Determine sky pixel + GSkyPixel pixel; + try { + pixel = m_counts.dir2pix(dir); + } + catch (const GException::wcs_invalid_phi_theta&) { + num_invalid_wcs++; + continue; + } + // Skip event if corresponding counts cube pixel is outside the // counts cube map range if (pixel.x() < -0.5 || pixel.x() > (m_counts.nx()-0.5) || @@ -547,7 +557,8 @@ void ctbin::fill_cube(GCTAObservation* obs) // Log filling results log_value(NORMAL, "Events in list", obs->events()->size()); log_value(NORMAL, "Events in cube", num_in_map); - log_value(NORMAL, "Event bins outside RoI", num_outside_roi); + log_value(NORMAL, "Events outside RoI", num_outside_roi); + log_value(NORMAL, "Events/data with invalid WCS", num_invalid_wcs); log_value(NORMAL, "Events outside cube area", num_outside_map); log_value(NORMAL, "Events outside energy bins", num_outside_ebds); -- libgit2 0.21.4