Commit 523cbd4b23340d659cb19768780e56941f32ffe4
1 parent
b1afe41a
Catch events in ctbin that have an invalid WCS transformation
Showing
1 changed file
with
15 additions
and
4 deletions
src/ctbin/ctbin.cpp
| @@ -491,6 +491,7 @@ void ctbin::fill_cube(GCTAObservation* obs) | @@ -491,6 +491,7 @@ void ctbin::fill_cube(GCTAObservation* obs) | ||
| 491 | 491 | ||
| 492 | // Initialise binning statistics | 492 | // Initialise binning statistics |
| 493 | int num_outside_roi = 0; | 493 | int num_outside_roi = 0; |
| 494 | + int num_invalid_wcs = 0; | ||
| 494 | int num_outside_map = 0; | 495 | int num_outside_map = 0; |
| 495 | int num_outside_ebds = 0; | 496 | int num_outside_ebds = 0; |
| 496 | int num_in_map = 0; | 497 | int num_in_map = 0; |
| @@ -501,17 +502,26 @@ void ctbin::fill_cube(GCTAObservation* obs) | @@ -501,17 +502,26 @@ void ctbin::fill_cube(GCTAObservation* obs) | ||
| 501 | // Get event | 502 | // Get event |
| 502 | const GCTAEventAtom* event = (*events)[i]; | 503 | const GCTAEventAtom* event = (*events)[i]; |
| 503 | 504 | ||
| 504 | - // Determine sky pixel | 505 | + // Determine event sky direction |
| 505 | GCTAInstDir* inst = (GCTAInstDir*)&(event->dir()); | 506 | GCTAInstDir* inst = (GCTAInstDir*)&(event->dir()); |
| 506 | GSkyDir dir = inst->dir(); | 507 | GSkyDir dir = inst->dir(); |
| 507 | - GSkyPixel pixel = m_counts.dir2pix(dir); | ||
| 508 | 508 | ||
| 509 | - // Skip event if corresponding counts cube pixel is outside RoI | 509 | + // Skip event if it is outside the RoI |
| 510 | if (roi.centre().dir().dist_deg(dir) > roi.radius()) { | 510 | if (roi.centre().dir().dist_deg(dir) > roi.radius()) { |
| 511 | num_outside_roi++; | 511 | num_outside_roi++; |
| 512 | continue; | 512 | continue; |
| 513 | } | 513 | } |
| 514 | 514 | ||
| 515 | + // Determine sky pixel | ||
| 516 | + GSkyPixel pixel; | ||
| 517 | + try { | ||
| 518 | + pixel = m_counts.dir2pix(dir); | ||
| 519 | + } | ||
| 520 | + catch (const GException::wcs_invalid_phi_theta&) { | ||
| 521 | + num_invalid_wcs++; | ||
| 522 | + continue; | ||
| 523 | + } | ||
| 524 | + | ||
| 515 | // Skip event if corresponding counts cube pixel is outside the | 525 | // Skip event if corresponding counts cube pixel is outside the |
| 516 | // counts cube map range | 526 | // counts cube map range |
| 517 | if (pixel.x() < -0.5 || pixel.x() > (m_counts.nx()-0.5) || | 527 | if (pixel.x() < -0.5 || pixel.x() > (m_counts.nx()-0.5) || |
| @@ -547,7 +557,8 @@ void ctbin::fill_cube(GCTAObservation* obs) | @@ -547,7 +557,8 @@ void ctbin::fill_cube(GCTAObservation* obs) | ||
| 547 | // Log filling results | 557 | // Log filling results |
| 548 | log_value(NORMAL, "Events in list", obs->events()->size()); | 558 | log_value(NORMAL, "Events in list", obs->events()->size()); |
| 549 | log_value(NORMAL, "Events in cube", num_in_map); | 559 | log_value(NORMAL, "Events in cube", num_in_map); |
| 550 | - log_value(NORMAL, "Event bins outside RoI", num_outside_roi); | 560 | + log_value(NORMAL, "Events outside RoI", num_outside_roi); |
| 561 | + log_value(NORMAL, "Events/data with invalid WCS", num_invalid_wcs); | ||
| 551 | log_value(NORMAL, "Events outside cube area", num_outside_map); | 562 | log_value(NORMAL, "Events outside cube area", num_outside_map); |
| 552 | log_value(NORMAL, "Events outside energy bins", num_outside_ebds); | 563 | log_value(NORMAL, "Events outside energy bins", num_outside_ebds); |
| 553 | 564 |