Commit 31d36e03b23f0fa0affc88cd7654be8bc0219c59

Authored by Andreas Specovius
Committed by Jürgen Knödlseder
1 parent 0be0a1a4

Piping for ctskymap implemented.

pyext/ctskymap.i
@@ -48,6 +48,9 @@ public: @@ -48,6 +48,9 @@ public:
48 void run(void); 48 void run(void);
49 void save(void); 49 void save(void);
50 void publish(const std::string& name = ""); 50 void publish(const std::string& name = "");
  51 +
  52 + void exclmap(const GSkyMap& exclusionmap);
  53 + const GSkyMap& exclmap(void) const;
51 const GSkyMap& skymap(void) const; 54 const GSkyMap& skymap(void) const;
52 }; 55 };
53 56
src/ctskymap/ctskymap.cpp
@@ -337,6 +337,21 @@ void ctskymap::publish(const std::string& name) @@ -337,6 +337,21 @@ void ctskymap::publish(const std::string& name)
337 } 337 }
338 338
339 339
  340 +/***********************************************************************//**
  341 + * @brief Set the exclusion map
  342 + *
  343 + * @param[in] exclmap Exclusion map object.
  344 + ***************************************************************************/
  345 +void ctskymap::exclmap(const GSkyMap& exclusionmap)
  346 +{
  347 + // Assign exclusion map
  348 + m_exclmap = exclusionmap;
  349 +
  350 + // Return
  351 + return;
  352 +}
  353 +
  354 +
340 /*========================================================================== 355 /*==========================================================================
341 = = 356 = =
342 = Private methods = 357 = Private methods =
@@ -522,6 +537,7 @@ void ctskymap::get_parameters(void) @@ -522,6 +537,7 @@ void ctskymap::get_parameters(void)
522 if (m_iterations > 0) { 537 if (m_iterations > 0) {
523 m_threshold = (*this)["threshold"].real(); 538 m_threshold = (*this)["threshold"].real();
524 } 539 }
  540 +
525 (*this)["inexclusion"].query(); 541 (*this)["inexclusion"].query();
526 m_usefft = (*this)["usefft"].boolean(); 542 m_usefft = (*this)["usefft"].boolean();
527 543
@@ -576,7 +592,12 @@ void ctskymap::setup_maps(void) @@ -576,7 +592,12 @@ void ctskymap::setup_maps(void)
576 if (m_bkgsubtract != "NONE") { 592 if (m_bkgsubtract != "NONE") {
577 593
578 // Setup the exclusions map 594 // Setup the exclusions map
579 - setup_exclusion_map(); 595 + if (m_exclmap.is_empty()) {
  596 + setup_exclusion_map();
  597 + }
  598 + else {
  599 + adjust_exclusion_map();
  600 + }
580 601
581 // Cache the pixel solid angles and sky directions 602 // Cache the pixel solid angles and sky directions
582 m_solidangle.reserve(m_counts.npix()); 603 m_solidangle.reserve(m_counts.npix());
@@ -648,24 +669,11 @@ void ctskymap::setup_exclusion_map(void) @@ -648,24 +669,11 @@ void ctskymap::setup_exclusion_map(void)
648 ***************************************************************************/ 669 ***************************************************************************/
649 void ctskymap::setup_exclusion_map_fits(const GFilename& filename) 670 void ctskymap::setup_exclusion_map_fits(const GFilename& filename)
650 { 671 {
651 - // Load the fits image  
652 - GSkyMap inmap(filename);  
653 -  
654 - // Loop through the individual pixels in the exclusion map  
655 - for (int i = 0; i < m_exclmap.npix(); ++i) {  
656 -  
657 - // Get the pixel direction  
658 - GSkyDir dir = m_exclmap.pix2dir(i); 672 + // Load the fits image to the exclusion map
  673 + m_exclmap = GSkyMap(filename);
659 674
660 - // Check this sky position in the fits map  
661 - if (inmap.contains(dir) && (inmap(inmap.dir2inx(dir)) != 0.0)) {  
662 -  
663 - // Set the pixel to 1  
664 - m_exclmap(i) = 1.0;  
665 -  
666 - } // endif: pixel,region overlap check  
667 -  
668 - } // endfor: looped over exclusion map pixels 675 + // Verify exclusion map
  676 + adjust_exclusion_map();
669 677
670 // Return 678 // Return
671 return; 679 return;
@@ -704,6 +712,45 @@ void ctskymap::setup_exclusion_map_region(const GFilename&amp; filename) @@ -704,6 +712,45 @@ void ctskymap::setup_exclusion_map_region(const GFilename&amp; filename)
704 712
705 713
706 /***********************************************************************//** 714 /***********************************************************************//**
  715 + * @brief Verifys that exclusion map points in fov of counts
  716 + *
  717 + * Adjust exclusion map. Reinitialise exclusion map via the counts object
  718 + * and transfer the masked areas provided by the current exclusion map to the
  719 + * updated fov.
  720 + ***************************************************************************/
  721 +void ctskymap::adjust_exclusion_map(void)
  722 +{
  723 + // Initialise working map
  724 + GSkyMap dest_map = m_counts;
  725 +
  726 + // Set all pixels to 0 (no pixel excluded)
  727 + dest_map = 0.0;
  728 +
  729 + // Loop through the individual pixels in the exclusion map
  730 + for (int i = 0; i < dest_map.npix(); ++i) {
  731 +
  732 + // Get the pixel direction
  733 + GSkyDir dir = dest_map.pix2dir(i);
  734 +
  735 + // Check this sky position in the exclusion map
  736 + if (m_exclmap.contains(dir) && (m_exclmap(m_exclmap.dir2inx(dir)) != 0.0)) {
  737 +
  738 + // Set the pixel to 1
  739 + dest_map(i) = 1.0;
  740 +
  741 + } // endif: pixel,region overlap check
  742 +
  743 + } // endfor: looped over exclusion map pixels
  744 +
  745 + // Set exclusion map
  746 + m_exclmap = dest_map;
  747 +
  748 + // Return
  749 + return;
  750 +}
  751 +
  752 +
  753 +/***********************************************************************//**
707 * @brief Fill maps from observation container 754 * @brief Fill maps from observation container
708 * 755 *
709 * Fill counts and optionally acceptance maps from data in the observation 756 * Fill counts and optionally acceptance maps from data in the observation
src/ctskymap/ctskymap.hpp
@@ -60,6 +60,9 @@ public: @@ -60,6 +60,9 @@ public:
60 void run(void); 60 void run(void);
61 void save(void); 61 void save(void);
62 void publish(const std::string& name = ""); 62 void publish(const std::string& name = "");
  63 +
  64 + void exclmap(const GSkyMap& exclusionmap);
  65 + const GSkyMap& exclmap(void) const;
63 const GSkyMap& skymap(void) const; 66 const GSkyMap& skymap(void) const;
64 67
65 protected: 68 protected:
@@ -72,6 +75,7 @@ protected: @@ -72,6 +75,7 @@ protected:
72 void setup_exclusion_map(void); 75 void setup_exclusion_map(void);
73 void setup_exclusion_map_fits(const GFilename& filename); 76 void setup_exclusion_map_fits(const GFilename& filename);
74 void setup_exclusion_map_region(const GFilename& filename); 77 void setup_exclusion_map_region(const GFilename& filename);
  78 + void adjust_exclusion_map(void);
75 void fill_maps(void); 79 void fill_maps(void);
76 void fill_maps_counts(GCTAObservation* obs); 80 void fill_maps_counts(GCTAObservation* obs);
77 void fill_maps_acceptance(GCTAObservation* obs); 81 void fill_maps_acceptance(GCTAObservation* obs);
@@ -131,6 +135,18 @@ protected: @@ -131,6 +135,18 @@ protected:
131 135
132 136
133 /***********************************************************************//** 137 /***********************************************************************//**
  138 + * @brief Return exclusion map
  139 + *
  140 + * @return Reference to exclusion map
  141 + ***************************************************************************/
  142 +inline
  143 +const GSkyMap& ctskymap::exclmap(void) const
  144 +{
  145 + return m_exclmap;
  146 +}
  147 +
  148 +
  149 +/***********************************************************************//**
134 * @brief Return observation container 150 * @brief Return observation container
135 * 151 *
136 * @return Reference to observation container 152 * @return Reference to observation container