gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 781f0f33 39/69: PSF scripts: checking that the


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 781f0f33 39/69: PSF scripts: checking that the input file actually exists
Date: Wed, 26 Jan 2022 12:39:13 -0500 (EST)

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

    PSF scripts: checking that the input file actually exists
    
    Until this commit, all PSF related scripts checked if the 'inputs' variable
    was empty or not. If it was empty, an error and message was printed to
    warn the user that no input was provided. However, if the input file was
    not properly specified (i.e., a typo while writing it), the scripts tried
    to continue without checking if the inputs actually exists. This is bad,
    and the script should stop as soon as it detects that the input file does
    not exists. With this commit, this bug has been fixed for several scripts.
    
    This problem was reported by Sepideh Eskandarlou.
---
 bin/script/psf-create-junction.in       | 6 ++++++
 bin/script/psf-create-make-stamp.in     | 3 +++
 bin/script/psf-create-select-stars.in   | 8 +++++++-
 bin/script/psf-model-flux-factor.in     | 3 +++
 bin/script/psf-model-scattered-light.in | 6 ++++++
 bin/script/radial-profile.in            | 3 +++
 6 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/bin/script/psf-create-junction.in 
b/bin/script/psf-create-junction.in
index fc481a6e..32f189da 100644
--- a/bin/script/psf-create-junction.in
+++ b/bin/script/psf-create-junction.in
@@ -244,6 +244,9 @@ if [ x"$inputs" = x ]; then
     echo "$scriptname: no input FITS image files."
     echo "Run with '--help' for more information on how to run."
     exit 1
+elif [ ! -f $inputs ]; then
+    echo "$scriptname: $inputs: No such file or directory."
+    exit 1
 fi
 
 # If a core image (--core) is not given at all.
@@ -251,6 +254,9 @@ if [ x"$core" = x ]; then
     echo "$scriptname: no core image provided."
     echo "A core image of the PSF to be specified with --stampwidth or -w."
     exit 1
+elif [ ! -f $core ]; then
+    echo "$scriptname: $core: No such file or directory."
+    exit 1
 fi
 
 # If a radius (--radius) is not given at all.
diff --git a/bin/script/psf-create-make-stamp.in 
b/bin/script/psf-create-make-stamp.in
index 125d8070..01cd075a 100644
--- a/bin/script/psf-create-make-stamp.in
+++ b/bin/script/psf-create-make-stamp.in
@@ -285,6 +285,9 @@ if [ x"$inputs" = x ]; then
     echo "$scriptname: no input FITS image files."
     echo "Run with '--help' for more information on how to run."
     exit 1
+elif [ ! -f $inputs ]; then
+    echo "$scriptname: $inputs: No such file or directory."
+    exit 1
 fi
 
 # If a stamp width (--stampwidth) is not given at all.
diff --git a/bin/script/psf-create-select-stars.in 
b/bin/script/psf-create-select-stars.in
index da7497be..37727001 100644
--- a/bin/script/psf-create-select-stars.in
+++ b/bin/script/psf-create-select-stars.in
@@ -271,7 +271,10 @@ done
 if [ x"$inputs" = x ]; then
     echo " $scriptname: no input image file specified."
     echo "Run with '--help' for more information on how to run."
-       exit 1
+    exit 1
+elif [ ! -f $inputs ]; then
+    echo "$scriptname: $inputs: No such file or directory."
+    exit 1
 fi
 
 # Check that 'segmented' is output of 'astsegment'.
@@ -286,6 +289,9 @@ $scriptname: the file given to '--segmented' does not have 
'CLUMPS' and
 EOF
         exit 1
     fi
+elif [ ! -f $segmented ]; then
+    echo "$scriptname: $segmented: No such file or directory."
+    exit 1
 fi
 
 
diff --git a/bin/script/psf-model-flux-factor.in 
b/bin/script/psf-model-flux-factor.in
index 8e78b614..752e0877 100644
--- a/bin/script/psf-model-flux-factor.in
+++ b/bin/script/psf-model-flux-factor.in
@@ -293,6 +293,9 @@ if [ x"$inputs" = x ]; then
     echo "$scriptname: no input FITS image files."
     echo "Run with '--help' for more information on how to run."
     exit 1
+elif [ ! -f $inputs ]; then
+    echo "$scriptname: $inputs: No such file or directory."
+    exit 1
 fi
 
 # If a PSF image (--psf) and profile (--psfprofile) are not given at all.
diff --git a/bin/script/psf-model-scattered-light.in 
b/bin/script/psf-model-scattered-light.in
index b07e1f52..d2ef5db1 100644
--- a/bin/script/psf-model-scattered-light.in
+++ b/bin/script/psf-model-scattered-light.in
@@ -241,6 +241,9 @@ if [ x"$inputs" = x ]; then
     echo "$scriptname: no input FITS image files."
     echo "Run with '--help' for more information on how to run."
     exit 1
+elif [ ! -f $inputs ]; then
+    echo "$scriptname: $inputs: No such file or directory."
+    exit 1
 fi
 
 # If a PSF image (--psf) is not given at all.
@@ -248,6 +251,9 @@ if [ x"$psf" = x ]; then
     echo "$scriptname: no PSF image provided."
     echo "$scriptname: a PSF image '--psf' ('-p') should be provided."
     exit 1
+elif [ ! -f $psf ]; then
+    echo "$scriptname: $psf: No such file or directory."
+    exit 1
 fi
 
 # If a flux factor (--fluxfactor) is not given at all.
diff --git a/bin/script/radial-profile.in b/bin/script/radial-profile.in
index df1af166..6908b4fc 100644
--- a/bin/script/radial-profile.in
+++ b/bin/script/radial-profile.in
@@ -286,6 +286,9 @@ if [ x"$inputs" = x ]; then
     echo "$scriptname: no input FITS image files."
     echo "Run with '--help' for more information on how to run."
     exit 1
+elif [ ! -f $inputs ]; then
+    echo "$scriptname: $inputs: No such file or directory."
+    exit 1
 fi
 
 # If a '--center' has been given, make sure it only has two numbers.



reply via email to

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