Commit 1bd7c9f129f82de1412f2229400e04e619e69d9e
1 parent
af73395e
method to clip skymap at threshold
Showing
3 changed files
with
42 additions
and
0 deletions
include/GSkyMap.hpp
| ... | ... | @@ -92,6 +92,7 @@ class GSkyMap : public GBase { |
| 92 | 92 | friend GSkyMap log10(const GSkyMap& map); |
| 93 | 93 | friend GSkyMap abs(const GSkyMap& map); |
| 94 | 94 | friend GSkyMap sign(const GSkyMap& map); |
| 95 | + friend GSkyMap clip(const GSkyMap& map,const double& thresh); | |
| 95 | 96 | |
| 96 | 97 | public: |
| 97 | 98 | // Constructors and destructors | ... | ... |
pyext/GSkyMap.i
src/sky/GSkyMap.cpp
| ... | ... | @@ -3296,6 +3296,44 @@ GSkyMap sqrt(const GSkyMap& map) |
| 3296 | 3296 | return result; |
| 3297 | 3297 | } |
| 3298 | 3298 | |
| 3299 | +/***********************************************************************//** | |
| 3300 | + * @brief Clips map at given value | |
| 3301 | + * | |
| 3302 | + * @param[in] map Sky map. | |
| 3303 | + * @param[in] thresh Threshold value. | |
| 3304 | + * @return Sky map containing the value in the original map if >= thresh, | |
| 3305 | + * otherwise thresh | |
| 3306 | + ***************************************************************************/ | |
| 3307 | +GSkyMap clip(const GSkyMap& map,const double& thresh) | |
| 3308 | +{ | |
| 3309 | + // Initialise result vector | |
| 3310 | + GSkyMap result(map); | |
| 3311 | + | |
| 3312 | + // Loop over all maps | |
| 3313 | + for (int i = 0; i < map.nmaps(); ++i) { | |
| 3314 | + | |
| 3315 | + // Loop over all bins | |
| 3316 | + for (int j = 0; j < map.npix(); ++j) { | |
| 3317 | + | |
| 3318 | + // Get the content from the bin | |
| 3319 | + double content = map(j,i); | |
| 3320 | + | |
| 3321 | + // Ic content is below threshold, set to thresh | |
| 3322 | + if (content < thresh) { | |
| 3323 | + result(j,i) = thresh; | |
| 3324 | + } | |
| 3325 | + | |
| 3326 | + else { | |
| 3327 | + result(j,i) = content; | |
| 3328 | + } | |
| 3329 | + | |
| 3330 | + } // endfor: looped over all bins | |
| 3331 | + | |
| 3332 | + } // endfor: looped over all maps | |
| 3333 | + | |
| 3334 | + // Return sky map | |
| 3335 | + return result; | |
| 3336 | +} | |
| 3299 | 3337 | |
| 3300 | 3338 | /***********************************************************************//** |
| 3301 | 3339 | * @brief Computes the natural logarithm of sky map elements | ... | ... |