Commit 7c04755b92b8e73f23629d587d8eb870fd884ae1
1 parent
1aec5cfd
Intermediate commit (#2207)
Showing
3 changed files
with
44 additions
and
38 deletions
doc/source/users/reference_manual/ctskymap.rst
| @@ -74,7 +74,7 @@ General parameters | @@ -74,7 +74,7 @@ General parameters | ||
| 74 | ``yref [real]`` | 74 | ``yref [real]`` |
| 75 | Declination / Galactic latitude of image centre (J2000, in degrees). | 75 | Declination / Galactic latitude of image centre (J2000, in degrees). |
| 76 | 76 | ||
| 77 | -``bkgsubtract <NONE|IRF> [string]`` | 77 | +``bkgsubtract <NONE|IRF|RING> [string]`` |
| 78 | Background subtraction method. | 78 | Background subtraction method. |
| 79 | 79 | ||
| 80 | 80 |
src/ctskymap/ctskymap.cpp
| @@ -390,6 +390,14 @@ void ctskymap::copy_members(const ctskymap& app) | @@ -390,6 +390,14 @@ void ctskymap::copy_members(const ctskymap& app) | ||
| 390 | m_bkgsubtract = app.m_bkgsubtract; | 390 | m_bkgsubtract = app.m_bkgsubtract; |
| 391 | m_publish = app.m_publish; | 391 | m_publish = app.m_publish; |
| 392 | m_chatter = app.m_chatter; | 392 | m_chatter = app.m_chatter; |
| 393 | + m_solidangle = app.m_solidangle; | ||
| 394 | + | ||
| 395 | + // Variables for RING bkgd subtraction | ||
| 396 | + m_exclmap = app.m_exclmap; | ||
| 397 | + m_roiradius = app.m_roiradius; | ||
| 398 | + m_inradius = app.m_inradius; | ||
| 399 | + m_outradius = app.m_outradius; | ||
| 400 | + m_cnts = app.m_cnts; | ||
| 393 | 401 | ||
| 394 | // Return | 402 | // Return |
| 395 | return; | 403 | return; |
| @@ -442,9 +450,22 @@ void ctskymap::get_parameters(void) | @@ -442,9 +450,22 @@ void ctskymap::get_parameters(void) | ||
| 442 | // Read ahead parameters | 450 | // Read ahead parameters |
| 443 | if (read_ahead()) { | 451 | if (read_ahead()) { |
| 444 | m_outmap = (*this)["outmap"].filename(); | 452 | m_outmap = (*this)["outmap"].filename(); |
| 445 | - m_roiradius = (*this)["roiradius"].real(); | ||
| 446 | - m_inradius = (*this)["inradius"].real(); | ||
| 447 | - m_outradius = (*this)["outradius"].real(); | 453 | + |
| 454 | + if (m_bkgsubtract == "RING") { | ||
| 455 | + // Get the integration region radii | ||
| 456 | + m_roiradius = (*this)["roiradius"].real(); | ||
| 457 | + m_inradius = (*this)["inradius"].real(); | ||
| 458 | + m_outradius = (*this)["outradius"].real(); | ||
| 459 | + | ||
| 460 | + // Make sure the values are reasonable | ||
| 461 | + if (m_roiradius > m_inradius) { | ||
| 462 | + std::string err("'roiradius' must be smaller than inner ring radius"); | ||
| 463 | + throw GException::invalid_value(err); | ||
| 464 | + } else if (m_inradius > m_outradius) { | ||
| 465 | + std::string err("Inner ring radius must be smaller than outer ring radius"); | ||
| 466 | + throw GException::invalid_value(err); | ||
| 467 | + } // endif: Ring radius checks | ||
| 468 | + } | ||
| 448 | } | 469 | } |
| 449 | 470 | ||
| 450 | // Create background map and significance map if background subtraction | 471 | // Create background map and significance map if background subtraction |
| @@ -749,11 +770,8 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | @@ -749,11 +770,8 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | ||
| 749 | double exposure = obs->livetime() ; | 770 | double exposure = obs->livetime() ; |
| 750 | 771 | ||
| 751 | // Cached background IRF sensitivities | 772 | // Cached background IRF sensitivities |
| 752 | - std::vector<double> sens(m_cnts.size(), 0.0); | ||
| 753 | - | ||
| 754 | - // Keep track of the minimum and maximum pixels that need to be looped over | ||
| 755 | - int imin(m_bkgmap.npix()); | ||
| 756 | - int imax(0); | 773 | + std::vector<double> sens(m_cnts.size(), 0.0); |
| 774 | + std::vector<bool> obsoverlap(m_cnts.size(), false); | ||
| 757 | 775 | ||
| 758 | // Cache the IRF sensitivities | 776 | // Cache the IRF sensitivities |
| 759 | // Loop over all map pixels | 777 | // Loop over all map pixels |
| @@ -771,15 +789,14 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | @@ -771,15 +789,14 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | ||
| 771 | continue; | 789 | continue; |
| 772 | } | 790 | } |
| 773 | 791 | ||
| 792 | + // Notify that this bin overlaps the observation | ||
| 793 | + obsoverlap[i] = true; | ||
| 794 | + | ||
| 774 | // If bin is excluded in the exclusion, skip it | 795 | // If bin is excluded in the exclusion, skip it |
| 775 | if (m_exclmap(i) == 0.0) { | 796 | if (m_exclmap(i) == 0.0) { |
| 776 | continue; | 797 | continue; |
| 777 | } | 798 | } |
| 778 | 799 | ||
| 779 | - // Update pixel ranges | ||
| 780 | - if (i > imax) imax = i; | ||
| 781 | - if (i < imin) imin = i; | ||
| 782 | - | ||
| 783 | // Setup integration function | 800 | // Setup integration function |
| 784 | ctskymap::irf_kern integrand(bkg, &instdir); | 801 | ctskymap::irf_kern integrand(bkg, &instdir); |
| 785 | GIntegral integral(&integrand); | 802 | GIntegral integral(&integrand); |
| @@ -802,18 +819,14 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | @@ -802,18 +819,14 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | ||
| 802 | GSkyRegionCircle inner_reg(0.0, 0.0, m_inradius); | 819 | GSkyRegionCircle inner_reg(0.0, 0.0, m_inradius); |
| 803 | GSkyRegionCircle outer_reg(0.0, 0.0, m_outradius); | 820 | GSkyRegionCircle outer_reg(0.0, 0.0, m_outradius); |
| 804 | 821 | ||
| 822 | +log_string(NORMAL, "LOOPING ON BKG IRF DONE"); | ||
| 823 | +log_string(NORMAL, "LOOPING ON EVENTS!"); | ||
| 805 | // Loop over all map pixels | 824 | // Loop over all map pixels |
| 806 | - for (int i = imin; i <= imax; ++i) { | ||
| 807 | - | ||
| 808 | - // Get sky direction of pixel | ||
| 809 | - GSkyDir skydir = m_bkgmap.inx2dir(i); | 825 | + for (int i = 0; i < m_bkgmap.npix(); ++i) { |
| 810 | 826 | ||
| 811 | - // Convert sky direction in instrument direction | ||
| 812 | - GCTAInstDir instdir = obs->pointing().instdir(skydir); | 827 | + log_value(NORMAL, "PIXEL #", i); |
| 813 | 828 | ||
| 814 | - // If RoI is valid and instrument direction is not within RoI then | ||
| 815 | - // skip pixel | ||
| 816 | - if (roi.is_valid() && !roi.contains(instdir)) { | 829 | + if (!obsoverlap[i]) { |
| 817 | continue; | 830 | continue; |
| 818 | } | 831 | } |
| 819 | 832 | ||
| @@ -825,20 +838,16 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | @@ -825,20 +838,16 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | ||
| 825 | // Loop again over every pixel in the observation to compute Non/Noff | 838 | // Loop again over every pixel in the observation to compute Non/Noff |
| 826 | int n_on(0), n_off(0); | 839 | int n_on(0), n_off(0); |
| 827 | double alpha_on(0.0), alpha_off(0.0); | 840 | double alpha_on(0.0), alpha_off(0.0); |
| 828 | - for (int j = imin; j < imax; ++j) { | ||
| 829 | - | ||
| 830 | - // Get sky direction of pixel | ||
| 831 | - skydir = m_bkgmap.inx2dir(i); | 841 | + for (int j = 0; j < m_bkgmap.npix(); ++j) { |
| 832 | 842 | ||
| 833 | - // Convert sky direction in instrument direction | ||
| 834 | - instdir = obs->pointing().instdir(skydir); | ||
| 835 | - | ||
| 836 | - // If RoI is valid and instrument direction is not within RoI then | ||
| 837 | - // skip pixel | ||
| 838 | - if (roi.is_valid() && !roi.contains(instdir)) { | 843 | + // Check if the observation overlaps this pixel |
| 844 | + if (!obsoverlap[j]) { | ||
| 839 | continue; | 845 | continue; |
| 840 | } | 846 | } |
| 841 | 847 | ||
| 848 | + // Get sky direction of pixel | ||
| 849 | + skydir = m_bkgmap.inx2dir(i); | ||
| 850 | + | ||
| 842 | // Check if pixel is inside source region | 851 | // Check if pixel is inside source region |
| 843 | if (roi_reg.contains(skydir)) { | 852 | if (roi_reg.contains(skydir)) { |
| 844 | // Update n_on | 853 | // Update n_on |
| @@ -870,9 +879,6 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | @@ -870,9 +879,6 @@ void ctskymap::map_background_ring(GCTAObservation* obs) | ||
| 870 | 879 | ||
| 871 | } // endfor: looped over background map pixels | 880 | } // endfor: looped over background map pixels |
| 872 | 881 | ||
| 873 | - // Update the likelihood values in the | ||
| 874 | - | ||
| 875 | - | ||
| 876 | // Zero out the alpha map to prepare it for the next observation | 882 | // Zero out the alpha map to prepare it for the next observation |
| 877 | std::vector<int>::iterator iter; | 883 | std::vector<int>::iterator iter; |
| 878 | for (iter=m_cnts.begin(); iter!=m_cnts.end(); ++iter) { | 884 | for (iter=m_cnts.begin(); iter!=m_cnts.end(); ++iter) { |
src/ctskymap/ctskymap.par
| @@ -43,9 +43,9 @@ yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC | @@ -43,9 +43,9 @@ yref, r, a, 22.01,-90,90, "Second coordinate of image center in degrees (DEC | ||
| 43 | # Background subtraction parameters | 43 | # Background subtraction parameters |
| 44 | #================================== | 44 | #================================== |
| 45 | bkgsubtract, s, a, NONE, NONE|IRF|RING,, "Background subtraction method" | 45 | bkgsubtract, s, a, NONE, NONE|IRF|RING,, "Background subtraction method" |
| 46 | -roiradius, r, h, 0.0,,, "Region of interest radius" | ||
| 47 | -inradius, r, h, 0.6,,, "Inner ring radius" | ||
| 48 | -outradius, r, h, 0.8,,, "Outer ring radius" | 46 | +roiradius, r, a, 0.0,,, "Region of interest radius" |
| 47 | +inradius, r, a, 0.6,,, "Inner ring radius" | ||
| 48 | +outradius, r, a, 0.8,,, "Outer ring radius" | ||
| 49 | regfile, f, h, NONE,,, "Exclusion regions definition file" | 49 | regfile, f, h, NONE,,, "Exclusion regions definition file" |
| 50 | 50 | ||
| 51 | # | 51 | # |