[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 9ab3dd28 51/69: PSF stamp: new option to set a
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 9ab3dd28 51/69: PSF stamp: new option to set a mask sky pixel value: maskskyval |
Date: |
Wed, 26 Jan 2022 12:39:14 -0500 (EST) |
branch: master
commit 9ab3dd28e6dd32718b9c935c2cfd09fb06272dc4
Author: Raul Infante-Sainz <infantesainz@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
PSF stamp: new option to set a mask sky pixel value: maskskyval
Until this commit, when using a mask (labeled image) this script assumed
that sky background values (pixels that don't have to be masked) were equal
to 0. The reason is that we used to treat mask images from Gnuastro. For
Gnuastro (NoiseChisel and Segment outputs) the sky is considered as 0 in
the detection and segmentation outputs. However, there may be other software
that don't follow this convention. In that situation it is good to have an
option to specify what is the sky background pixel value on the mask image.
With this commit, this new option has been added: --maskskyval or -v. Now
the user is able to specify the sky background value of the mask image. A
bug has been also corrected. Until now, when the cropped core image (those
that is used to detect the central object and not mask it) had more sky
background pixels than the labeled object, the central object was
considered to be the sky (just because there are more pixels!). This is a
bug and it has been corrected by changing the sky background pixel values
to nan values before computing the pixel value of the central object.
This bug was reported by Pablo Manuel Sanchez Alarcon.
---
bin/script/psf-create-make-stamp.in | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/bin/script/psf-create-make-stamp.in
b/bin/script/psf-create-make-stamp.in
index 01cd075a..ee3f0212 100644
--- a/bin/script/psf-create-make-stamp.in
+++ b/bin/script/psf-create-make-stamp.in
@@ -48,6 +48,7 @@ maskhdu=1
output=""
tmpdir=""
axisratio=1
+maskskyval=0
corewidth=""
saturation=0
normradii=""
@@ -223,6 +224,9 @@ do
-M|--maskhdu) maskhdu="$2";
check_v "$1" "$maskhdu"; shift;shift;;
-M=*|--maskhdu=*) maskhdu="${1#*=}";
check_v "$1" "$maskhdu"; shift;;
-M*) maskhdu=$(echo "$1" | sed -e's/-M//');
check_v "$1" "$maskhdu"; shift;;
+ -v|--maskskyval) maskskyval="$2";
check_v "$1" "$maskskyval"; shift;shift;;
+ -v=*|--maskskyval=*) maskskyval="${1#*=}";
check_v "$1" "$maskskyval"; shift;;
+ -v*) maskskyval=$(echo "$1" | sed -e's/-v//');
check_v "$1" "$maskskyval"; shift;;
-O|--mode) mode="$2";
check_v "$1" "$mode"; shift;shift;;
-O=*|--mode=*) mode="${1#*=}";
check_v "$1" "$mode"; shift;;
-O*) mode=$(echo "$1" | sed -e's/-O//');
check_v "$1" "$mode"; shift;;
@@ -460,8 +464,16 @@ if [ x"$mask" != x ]; then
--center=$xcenter,$ycenter \
--width=$corewidth --output=$cropped_core $quiet
+ # If the cropped core labeled image has sky background values (zero by
+ # default), convert them to nan. This prevent considering the central
+ # object to be the sky if there are a lot of sky background pixels
+ # compared to the labeled region.
+ cropped_core_nonzeros=$tmpdir/cropped_core_nozeros-$objectid.fits
+ astarithmetic $cropped_core set-i $quiet \
+ i i $maskskyval eq nan where --output=$cropped_core_nonzeros
+
# Compute the label of the central object from the core cropped image.
- centrallabel=$(aststatistics $cropped_core --median -q)
+ centrallabel=$(aststatistics $cropped_core_nonzeros --median -q)
# Check if the user has determined the --saturation option.
if [ $saturation = 0 ]; then
@@ -473,12 +485,12 @@ if [ x"$mask" != x ]; then
# Unlabel the central object and then mask everything else.
cropped_masked=$tmpdir/cropped_masked-$objectid.fits
astarithmetic $cropped --hdu=1 set-i \
- $cropped_mask --hdu=1 set-m \
+ $cropped_mask --hdu=1 set-m \
\
- $mask_saturated \
- m m $centrallabel eq 0 where set-a \
- a 0 ne set-mask \
- \
+ $mask_saturated \
+ m m $centrallabel eq $maskskyval where set-a \
+ a $maskskyval ne set-mask \
+ \
i mask nan where \
--output=$cropped_masked $quiet
else
@@ -547,3 +559,4 @@ astarithmetic $cropped_masked --hdu=1 $normvalue /
--output=$output $quiet
if [ $keeptmp = 0 ]; then
rm -r $tmpdir
fi
+
- [gnuastro-commits] master 781f0f33 39/69: PSF scripts: checking that the input file actually exists, (continued)
- [gnuastro-commits] master 781f0f33 39/69: PSF scripts: checking that the input file actually exists, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 0a6625ab 61/69: Book: explain about two new option in the psf-create-select-stars, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 6901ec82 49/69: PSF select-stars: check the image and catalog have a overlap area or not, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master f9b7edfa 10/69: PSF stamp: removing the option --oversample as it is not enabled, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 81720014 15/69: Book: adding documentation of 'psf-model-flux-factor' script, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 9ca784e4 27/69: PSF select stars: if the image has not stars in `--min` and `--max` range, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master f1cfd384 25/69: PSF select stars: remove --input add --output and --catalog, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master bf8792c2 52/69: Book: For selecting stars some mandatory options did not mention, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master f3619dd5 57/69: Book: edits in the PSF scripts, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master ce020710 41/69: Book: new section for the tutorial on how to construct and extended PSF, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 9ab3dd28 51/69: PSF stamp: new option to set a mask sky pixel value: maskskyval,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 31f0373a 05/69: PSF model: new script for putting a PSF image into a sky position, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 0ea23b70 69/69: Book: PSF tutorial now with instruction to build first inner region, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 00f2ab56 63/69: PSF select-stars: simplifying some parts and language corrections, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 6638c671 53/69: Book: correct the definition of option --minaxisratio, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master e9f4d343 09/69: PSF model: fixed bug in defining the radial profiles for flux factor, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 30e33ec6 06/69: PSF model: new script for computing the PSF flux factor, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 65fb6894 02/69: PSF stamp: wrong script location, fixing it, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 8d4e7f3d 14/69: Book: adding documentation of 'psf-create-junction' script, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 5a236622 21/69: PSF model: computing radial profile up to the minimum possible value, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master b5262f34 26/69: PSF stamp: rmax option was redundant, Mohammad Akhlaghi, 2022/01/26