gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 00b08df2 28/69: PSF stamp: add --saturation op


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 00b08df2 28/69: PSF stamp: add --saturation option for masking the saturated pixels
Date: Wed, 26 Jan 2022 12:39:12 -0500 (EST)

branch: master
commit 00b08df21521937218768ccb2eb5ac83ea7dbfec
Author: Sepideh Eskandarlou <sepideh.eskandarlou@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    PSF stamp: add --saturation option for masking the saturated pixels
    
    Until now, just the main stars had been cropped and extra objects around
    them masked and finally normalized it. Without considering the saturated
    pixels in the center of stars. In this situation the user do the
    normalization mistakenly, because in the normalization, the statistic value
    in each radius, are obtained mistakenly.
    In the mask step, two 'astarithmetic' had been used.
    
    Now, in the mask step instead of two 'astarithmetic', one 'astarithmetic'
    has been used. Which technicaly the mask step will be done faster.
    If the user wants to mask the saturation pixels, he/she can use
    '--saturation' option and then mask the saturated pixels and if the user
    does not determined this option the saturated pixels are not masked.
---
 bin/script/psf-create-make-stamp.in | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/bin/script/psf-create-make-stamp.in 
b/bin/script/psf-create-make-stamp.in
index e3ad91ef..fc5fc1c1 100644
--- a/bin/script/psf-create-make-stamp.in
+++ b/bin/script/psf-create-make-stamp.in
@@ -49,6 +49,7 @@ output=""
 tmpdir=""
 axisratio=1
 corewidth=""
+saturation=0
 normradii=""
 sigmaclip=""
 stampwidth=""
@@ -100,6 +101,7 @@ $scriptname options:
                           for computing the normalization value.
   -m, --mask=STR          Segmentation image (sky = 0).
   -M, --maskhdu=STR       HDU/extension of the segmentation image.
+  -l, --saturation        saturation limit for masking saturation pixels.
   -w, --corewidth=INT     Area width of the central object in pixels for 
unmasking.
   -S, --mask=STR          Segmentation image (sky = 0).
   -s, --maskhdu=STR       HDU/extension of the segmentation image.
@@ -203,6 +205,9 @@ do
         -h|--hdu)            hdu="$2";                                  
check_v "$1" "$hdu";  shift;shift;;
         -h=*|--hdu=*)        hdu="${1#*=}";                             
check_v "$1" "$hdu";  shift;;
         -h*)                 hdu=$(echo "$1"  | sed -e's/-h//');        
check_v "$1" "$hdu";  shift;;
+        -l|--saturation)     saturation="$2";                           
check_v "$1" "$saturation";  shift;shift;;
+        -l=*|--saturation=*) saturation="${1#*=}";                      
check_v "$1" "$saturation";  shift;;
+        -l*)                 saturation=$(echo "$1"  | sed -e's/-l//'); 
check_v "$1" "$saturation";  shift;;
         -n|--normradii)      normradii="$2";                            
check_v "$1" "$normradii";  shift;shift;;
         -n=*|--normradii=*)  normradii="${1#*=}";                       
check_v "$1" "$normradii";  shift;;
         -n*)                 normradii=$(echo "$1"  | sed -e's/-n//');  
check_v "$1" "$normradii";  shift;;
@@ -455,17 +460,24 @@ if [ x"$mask" != x ]; then
   # Compute the label of the central object from the core cropped image.
   centrallabel=$(aststatistics $cropped_core --median -q)
 
-  # Unlabel the central object.
-  cropped_unlabel=$tmpdir/cropped_unlabel-$objectid.fits
-  astarithmetic $cropped_mask --hdu=1 \
-                $cropped_mask --hdu=1 \
-                $centrallabel eq 0 where --output=$cropped_unlabel $quiet
+  # Check if the user has determined the --saturation option.
+  if [ $saturation = 0 ]; then
+      mask_saturated=""
+  else
+      mask_saturated="i i $saturation gt nan where set-i"
+  fi
 
-  # All objects that are not the central are masked here.
+  # Unlabel the central object and then mask everything else.
   cropped_masked=$tmpdir/cropped_masked-$objectid.fits
-  astarithmetic $cropped --hdu=1 \
-                $cropped_unlabel --hdu=1 \
-                0 ne nan where --output=$cropped_masked $quiet
+  astarithmetic $cropped      --hdu=1 set-i \
+                $cropped_mask --hdu=1  set-m \
+                                            \
+                $mask_saturated \
+                m m $centrallabel eq 0 where set-a \
+                a 0 ne set-mask \
+                                \
+                i mask nan where \
+                --output=$cropped_masked $quiet
 else
   cropped_masked=$cropped
 fi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]