gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 1c443a08 6/9: PSF scripts: forcing to use floa


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 1c443a08 6/9: PSF scripts: forcing to use float32 operations with Arithmetic
Date: Wed, 2 Mar 2022 21:40:42 -0500 (EST)

branch: master
commit 1c443a081d58f08601f8127a4f1f1f77b4f87a47
Author: Raul Infante-Sainz <infantesainz@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    PSF scripts: forcing to use float32 operations with Arithmetic
    
    Until now, the operations done with Arithmetic were done without explicitly
    setting the data type. However, as a consequence of a recent change, in
    some cases that causes a problem. The issue is described in bug #62096:
    https://savannah.gnu.org/bugs/?62096
    
    With this commit, this issue has been fixed for the PSF scripts. In all
    places where Arithmetic is used and it is possible that the data type are
    uint or int, they are forced to be float32. By doing this, the scripts work
    without any problem.
---
 bin/script/psf-create-junction.in       | 16 ++++++++--------
 bin/script/psf-create-select-stars.in   |  2 +-
 bin/script/psf-model-flux-factor.in     |  2 +-
 bin/script/psf-model-scattered-light.in | 10 +++++-----
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/bin/script/psf-create-junction.in 
b/bin/script/psf-create-junction.in
index 524e054f..76a7cb40 100644
--- a/bin/script/psf-create-junction.in
+++ b/bin/script/psf-create-junction.in
@@ -340,8 +340,8 @@ fi
 
 # To obtain the center of the PSF (in pixels), just divide by 2 the size of
 # the PSF image.
-xcenter=$(astarithmetic $xaxis 2 / --quiet)
-ycenter=$(astarithmetic $yaxis 2 / --quiet)
+xcenter=$(astarithmetic $xaxis float32 2.0 / --quiet)
+ycenter=$(astarithmetic $yaxis float32 2.0 / --quiet)
 
 
 
@@ -369,8 +369,8 @@ fi
 
 # To obtain the center of the PSF (in pixels), just divide by 2 the size of
 # the PSF image.
-xpsfcenter=$(astarithmetic $xpsfaxis 2 / --quiet)
-ypsfcenter=$(astarithmetic $ypsfaxis 2 / --quiet)
+xpsfcenter=$(astarithmetic $xpsfaxis float32 2.0 / --quiet)
+ypsfcenter=$(astarithmetic $ypsfaxis float32 2.0 / --quiet)
 
 
 
@@ -382,8 +382,8 @@ ypsfcenter=$(astarithmetic $ypsfaxis 2 / --quiet)
 # In order to allocate the PSF into the center coordinates provided by the
 # user, it is necessary to compute the appropiate offsets along the X and Y
 # axis. After that, the PSF image is warped using that offsets.
-xdiff=$(astarithmetic $xcenter $xpsfcenter - --quiet)
-ydiff=$(astarithmetic $ycenter $ypsfcenter - --quiet)
+xdiff=$(astarithmetic $xcenter float32 $xpsfcenter float32 - --quiet)
+ydiff=$(astarithmetic $ycenter float32 $ypsfcenter float32 - --quiet)
 
 coretranslated=$tmpdir/"$bname_core"_translated.fits
 astwarp $core --translate=$xdiff,$ydiff \
@@ -461,8 +461,8 @@ astarithmetic $corecropped --hdu=1 set-i \
 # As a consequence, the final image will be the sum of these two masked
 # images.
 maskimage=$tmpdir/mask-image.fits
-xcentmask=$(astarithmetic $xcenter 1 + --quiet)
-ycentmask=$(astarithmetic $ycenter 1 + --quiet)
+xcentmask=$(astarithmetic $xcenter float32 1.0 + --quiet)
+ycentmask=$(astarithmetic $ycenter float32 1.0 + --quiet)
 echo "1 $xcentmask $ycentmask 5 $radius 1 $positionangle $axisratio 1 1" \
       | astmkprof --background=$corefluxscaled \
                  --mode=img \
diff --git a/bin/script/psf-create-select-stars.in 
b/bin/script/psf-create-select-stars.in
index 81aa1903..0ebd63ae 100644
--- a/bin/script/psf-create-select-stars.in
+++ b/bin/script/psf-create-select-stars.in
@@ -371,7 +371,7 @@ faintmag=$(echo "$magnituderange" | awk 'BEGIN{FS=","} 
{print $2}')
 
 # Range of magnitude which are in the wider range of brighter and fainter
 # magnitude.
-fainter=$(astarithmetic $faintmag $faintmagdiff + --quiet)
+fainter=$(astarithmetic $faintmag float32 $faintmagdiff float32 + --quiet)
 
 # Obtain the parallax and parallax error column names.
 parallax=$(echo "$parallaxanderrorcolumn" \
diff --git a/bin/script/psf-model-flux-factor.in 
b/bin/script/psf-model-flux-factor.in
index 38d4a8dc..40468353 100644
--- a/bin/script/psf-model-flux-factor.in
+++ b/bin/script/psf-model-flux-factor.in
@@ -461,7 +461,7 @@ fi
 # maximum radius for computing the flux factor. This is the maximum radius
 # that is needed for computing the flux value.
 if [ x"$stampwidth" = x ]; then
-    stampwidth=$(astarithmetic $normradiusmax 2 x 1 + --quiet)
+    stampwidth=$(astarithmetic $normradiusmax float32 2.0 x 1.0 + --quiet)
 fi
 
 
diff --git a/bin/script/psf-model-scattered-light.in 
b/bin/script/psf-model-scattered-light.in
index 4d73609f..35532349 100644
--- a/bin/script/psf-model-scattered-light.in
+++ b/bin/script/psf-model-scattered-light.in
@@ -373,7 +373,7 @@ fi
 # specified factor (--fluxfactor) in order to appropiately obtain the PSF
 # brightness.
 psffluxscaled=$tmpdir/psf-flux-scaled-$objectid.fits
-astarithmetic $psf --hdu=$psfhdu $fluxfactor x \
+astarithmetic $psf --hdu=$psfhdu $fluxfactor float32 x \
                    --output=$psffluxscaled $quiet
 
 
@@ -433,8 +433,8 @@ fi
 
 # To obtain the center of the PSF (in pixels), just divide by 2 the size of
 # the PSF image.
-xpsfcenter=$(astarithmetic $xpsfaxis 2 / --quiet)
-ypsfcenter=$(astarithmetic $ypsfaxis 2 / --quiet)
+xpsfcenter=$(astarithmetic $xpsfaxis float32 2.0 / --quiet)
+ypsfcenter=$(astarithmetic $ypsfaxis float32 2.0 / --quiet)
 
 
 
@@ -448,8 +448,8 @@ ypsfcenter=$(astarithmetic $ypsfaxis 2 / --quiet)
 # axis. After that, the PSF image is warped using that offsets. Note that
 # in order to account for a 1 pixel offset, it is necessary to subtract the
 # value 1.
-xdiff=$(astarithmetic $xcenter $xpsfcenter - 1.0 - --quiet)
-ydiff=$(astarithmetic $ycenter $ypsfcenter - 1.0 - --quiet)
+xdiff=$(astarithmetic $xcenter float32 $xpsfcenter float32 - 1.0 - --quiet)
+ydiff=$(astarithmetic $ycenter float32 $ypsfcenter float32 - 1.0 - --quiet)
 
 psftranslated=$tmpdir/psf-translated-$objectid.fits
 astwarp $psffluxscaled --translate=$xdiff,$ydiff \



reply via email to

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