[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master bcff855c 1/2: astscript-fits-view: new --globa
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master bcff855c 1/2: astscript-fits-view: new --globalhdu like Arithmetic or ConvertType |
Date: |
Tue, 6 Feb 2024 15:06:29 -0500 (EST) |
branch: master
commit bcff855c168146f5bb4bf0d7a659bf7136c5360d
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
astscript-fits-view: new --globalhdu like Arithmetic or ConvertType
Until now, when multiple inputs were given to this script, but only a
single HDU was given, the script would not check and call DS9 with an empty
'[]' (the way DS9 knows which HDU to open). As a result, DS9 would crash!
With this commit, this script now has '--globalhdu' (or '-g') with an
identical behavior to Arithmetic or ConvertType (that also take multiple
files). A check (with an elaborate description) has also been to make sure
that if '-h' (or '--hdu') is given, it is at least the same number as the
number of inputs. As a result of this change, it was necessary to change
the short format of the '--ds9geometry' option to '-G'.
This fixes bug #65267.
---
NEWS | 15 +++++++++++++++
bin/script/fits-view.sh | 37 +++++++++++++++++++++++++++++--------
doc/gnuastro.texi | 12 ++++++++++--
3 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/NEWS b/NEWS
index 88697cf3..ef14d612 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,11 @@ See the end of the file for license conditions.
* Noteworthy changes in release X.XX (library XX.X.X) (YYYY-MM-DD)
** New publications
** New features
+*** astscript-fits-view
+ --globalhdu: use the same HDU in any number of input files (with the
+ short format of '-g'); similar to the same option in Arithmetic or
+ ConvertType.
+
** Removed features
** Changed features
*** All programs
@@ -23,11 +28,21 @@ See the end of the file for license conditions.
instead of '$HOME/.local/etc/'. See the description of system
configuration files above for more.
+*** astscript-fits-view
+ - The short format of the '--ds9geometry' option is '-G' (until now it
+ was '-g'). This was necessary to allow the '-g' of this script to have
+ a similar behavior to the other Gnuastro programs that take multiple
+ inputs (like Arithmetic or ConvertType) and '-g' is short for
+ '--globalhdu' (so the same HDU is opened in all the inputs).
+
** Bugs fixed
- bug #65255: description of CosmicCalculator's '--arcsectandist' didn't
specify if it is in physical or comoving coordinates. Found and fixed
by Boud Roukema.
+ - bug #65267: astscript-fits-view created incorrect call to ds9 when the
+ number of input files was more than the specified HDUs.
+
diff --git a/bin/script/fits-view.sh b/bin/script/fits-view.sh
index 528d9d88..bde2b872 100644
--- a/bin/script/fits-view.sh
+++ b/bin/script/fits-view.sh
@@ -46,6 +46,7 @@ ds9mode=""
ds9scale=""
ds9extra=""
ds9center=""
+globalhdu=""
ds9geometry=""
version=@VERSION@
ds9colorbarmulti=""
@@ -89,9 +90,10 @@ experienced Gnuastro users and developers. For more
information, please run:
$scriptname options:
Input:
-h, --hdu=STR Extension name or number of input data.
+ -g, --globalhdu=STR Use this HDU for all inputs, ignore '--hdu'.
Output:
- -g, --ds9geometry=INTxINT Size of DS9 window, e.g., for HD (800x1000) and
+ -G, --ds9geometry=INTxINT Size of DS9 window, e.g., for HD (800x1000) and
for 4K (1800x3000). If not given, the script will
attempt to find your screen resolution and find a
good match, otherwise, use the default size.
@@ -195,11 +197,14 @@ do
-h|--hdu) aux="$2"; check_v
"$1" "$aux"; hdu="$hdu $aux"; shift;shift;;
-h=*|--hdu=*) aux="${1#*=}"; check_v
"$1" "$aux"; hdu="$hdu $aux"; shift;;
-h*) aux="$(echo "$1" | sed -e's/-h//')"; check_v
"$1" "$aux"; hdu="$hdu $aux"; shift;;
+ -g|--globalhdu) aux="$2"; check_v
"$1" "$aux"; globalhdu="$aux"; shift;shift;;
+ -g=*|--globalhdu=*) aux="${1#*=}"; check_v
"$1" "$aux"; globalhdu="$aux"; shift;;
+ -g*) aux="$(echo "$1" | sed -e's/-g//')"; check_v
"$1" "$aux"; globalhdu="$aux"; shift;;
# Output options
- -g|--ds9geometry) ds9geometry="$2"; check_v
"$1" "$ds9geometry"; shift;shift;;
- -g=*|--ds9geometry=*) ds9geometry="${1#*=}"; check_v
"$1" "$ds9geometry"; shift;;
- -g*) ds9geometry=$(echo "$1" | sed -e's/-g//');
check_v "$1" "$ds9geometry"; shift;;
+ -G|--ds9geometry) ds9geometry="$2"; check_v
"$1" "$ds9geometry"; shift;shift;;
+ -G=*|--ds9geometry=*) ds9geometry="${1#*=}"; check_v
"$1" "$ds9geometry"; shift;;
+ -G*) ds9geometry=$(echo "$1" | sed -e's/-g//');
check_v "$1" "$ds9geometry"; shift;;
-s|--ds9scale) ds9scale="$2"; check_v
"$1" "$ds9scale"; shift;shift;;
-s=*|--ds9scale=*) ds9scale="${1#*=}"; check_v
"$1" "$ds9scale"; shift;;
-s*) ds9scale=$(echo "$1" | sed -e's/-s//');
check_v "$1" "$ds9scale"; shift;;
@@ -281,6 +286,18 @@ EOF
fi
fi
+# If HDUs are given, make sure they are the same number as images.
+if ! [ x"$hdu" = x ]; then
+ nhdu=$(echo $hdu | wc -w)
+ nin=$(echo $inputs | wc -w)
+ if [ $nhdu -lt $nin ]; then
+ cat <<EOF
+$scriptname: number of input HDUs (values to '--hdu' or '-h') is less than the
number of inputs. If all the HDUs are the same, you can use the '--globalhdu'
or '-g' option
+EOF
+ exit 1
+ fi
+fi
+
@@ -377,15 +394,19 @@ else
# If the file was a image, then `check` will be 1.
if [ "$type" = 1 ]; then
- # If a HDU is given, add it to all the input file names (within
- # square brackets for DS9).
- if [ x"$hdu" = x ]; then
+ # If a HDU is given, add it to all the input file names
+ # (within square brackets for DS9).
+ if [ x"$hdu" = x ] && [ x"$globalhdu" = x ]; then
inwithhdu="$inputs"
else
c=1
inwithhdu=""
for i in $inputs; do
- h=$(echo $hdu | awk -vc=$c '{print $c}')
+ if [ x"$hdu" = x ]; then
+ h="$globalhdu"
+ else
+ h=$(echo $hdu | awk -vc=$c '{print $c}')
+ fi
inwithhdu="$inwithhdu $i[$h]"
c=$((c+1))
done
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 098c20b0..b907555c 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -34131,8 +34131,16 @@ This script takes the following options
@item -h STR
@itemx --hdu=STR
-The HDU (extension) of the input dataset to display.
-The value can be the HDU name or number (the first HDU is counted from 0).
+The HDU(s), or extension(s), of the input dataset(s) to display.
+The value can be the HDU name (a string) or number (the first HDU is counted
from 0).
+If there are multiple inputs, this option needs to be called multiple times:
the first input will be opened with the first call to this option, the second
input with the second call and etc.
+If you want to open the same HDU of all your inputs, you don't need to repeat
this option, use @option{--globalhdu} instead.
+
+@item -g STR
+@itemx --globalhdu=STR
+The HDU/extension name or number to use for all inputs.
+Note that HDU counting starts from 0.
+If @option{--hdu} called, it takes precedence over this.
@item -p STR
@itemx --prefix=STR