gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 8c8667fe: fits-view script: single ds9 colorba


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 8c8667fe: fits-view script: single ds9 colorbar by default
Date: Sun, 21 Aug 2022 04:54:13 -0400 (EDT)

branch: master
commit 8c8667fec0c30f00f2944e5177ae64e78c0f9d6d
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    fits-view script: single ds9 colorbar by default
    
    Until now, when DS9 was called with this script, it would load a separate
    color bar for each separate image. But this would waste a lot of space when
    viewing many images.
    
    With this commit, by default a single color-bar is shown and the user is
    able to have the old behavior (multiple color bars) with the
    '--ds9colorbarmulti' option.
    
    In the process, two other minor corrections were made to this script:
    
     - Some of the lines in this script were indented with a TAB! This has been
       corrected.
    
     - The list of options to DS9 was getting long and hard to read. So there
       DS9 options are now called on a one-line-per-option format.
---
 NEWS                    |  5 +++
 bin/script/fits-view.in | 89 ++++++++++++++++++++++++++++++++-----------------
 doc/gnuastro.texi       |  7 ++++
 3 files changed, 70 insertions(+), 31 deletions(-)

diff --git a/NEWS b/NEWS
index fe9066d0..7edb3b11 100644
--- a/NEWS
+++ b/NEWS
@@ -68,6 +68,11 @@ See the end of the file for license conditions.
     surface brightness image using the new 'counts-to-sb' operator of
     Arithmetic.
 
+  astscript-fits-view:
+  --ds9colorbarmulti: show a separate color-bar for each image in DS9. By
+    default this script will show a single color-bar for all the images to
+    help save space on the monitor when there are many images.
+
   astscript-psf-stamp:
   - sub-pixel warping is applied to ensure that your coordinate is at the
     center of the central pixel of the output image. This results in a
diff --git a/bin/script/fits-view.in b/bin/script/fits-view.in
index e8f20485..bd49e615 100644
--- a/bin/script/fits-view.in
+++ b/bin/script/fits-view.in
@@ -47,6 +47,7 @@ ds9extra=""
 ds9center=""
 ds9geometry=""
 version=@VERSION@
+ds9colorbarmulti=""
 scriptname=@SCRIPT_NAME@
 
 
@@ -97,6 +98,7 @@ $scriptname options:
   -s, --ds9scale=STR      Custom value to '-scale' option in DS9.
   -c, --ds9center=FLT,FLT Coordinates of center in shown DS9 window.
   -O, --ds9mode=img/wcs   Coord system to interpret '--ds9center' (img/wcs).
+  -m, --ds9colorbarmulti  Separate color bars for each loaded image.
   -p, --prefix=STR        Directory containing DS9 or TOPCAT executables.
 
  Operating mode:
@@ -209,6 +211,8 @@ do
         -O|--ds9mode)         ds9mode="$2";                       check_v "$1" 
"$ds9mode"; shift;shift;;
         -O=*|--ds9mode=*)     ds9mode="${1#*=}";                  check_v "$1" 
"$ds9mode"; shift;;
         -O*)                  ds9mode=$(echo "$1"  | sed -e's/-s//');  check_v 
"$1" "$ds9mode"; shift;;
+        -m|--ds9colorbarmulti)    ds9colorbarmulti=1; shift;;
+        -m*|--ds9colorbarmulti=*) on_off_option_error --ds9colorbarmulti -m;;
         -p|--prefix)          prefix="$2";                         check_v 
"$1" "$prefix"; shift;shift;;
         -p=*|--prefix=*)      prefix="${1#*=}";                    check_v 
"$1" "$prefix"; shift;;
         -p*)                  prefix=$(echo "$1"  | sed -e's/-p//');  check_v 
"$1" "$prefix"; shift;;
@@ -367,11 +371,11 @@ else
     # 0 ('astfits' was successful).
     if [ "$check" = 0 ]; then
 
-       # Input is image or table.
-       type=$(astfits $input1 --hasimagehdu)
+        # Input is image or table.
+        type=$(astfits $input1 --hasimagehdu)
 
-       # If the file was a image, then  `check` will be 1.
-       if [ "$type" = 1 ]; then
+        # 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).
@@ -387,39 +391,62 @@ else
 
             # Find the number of dimensions.
             if [ "$n0" = 0 ]; then
-               ndim=$(astfits $input1 -h1 | awk '$1=="NAXIS"{print $3}')
+                ndim=$(astfits $input1 -h1 | awk '$1=="NAXIS"{print $3}')
             else
-               ndim=$n0
+                ndim=$n0
             fi;
 
+            # If multiple colorbars should be used.
+            if [ x"$ds9colorbarmulti" = x ]; then multicolorbars=no;
+            else                                  multicolorbars=yes;
+            fi
+
             # Open DS9 based on the number of dimension.
             if [ "$ndim" = 2 ]; then
 
-               # 2D multi-extension file: use the "Cube" window to
-               # flip/slide through the extensions.
-               execom="$ds9exec $ds9scaleopt $ds9geoopt -mecube $inwithhdu \
-                                 -zoom to fit -wcs degrees -cmap sls \
-                                -match frame image -match frame colorbar \
-                                -frame lock image -colorbar lock yes \
-                                 -lock slice image $ds9pan $ds9extra"
+                # 2D multi-extension file: use the "Cube" window to
+                # flip/slide through the extensions.
+                execom="$ds9exec $ds9scaleopt \
+                                 $ds9geoopt \
+                                 -mecube \
+                                 $inwithhdu \
+                                 -zoom to fit \
+                                 -wcs degrees \
+                                 -cmap sls \
+                                 -match frame image \
+                                 -match frame colorbar \
+                                 -frame lock image \
+                                 -colorbar lock yes \
+                                 -view multi $multicolorbars \
+                                 -lock slice image \
+                                 $ds9pan \
+                                 $ds9extra"
             else
 
-               # 3D multi-extension file: The "Cube" window will slide
-               # between the slices of a single extension. To flip through
-               # the extensions (not the slices), press the top row
-               # "frame" button and from the last four buttons of the
-               # bottom row ("first", "previous", "next" and "last") can
-               # be used to switch through the extensions (while keeping
-               # the same slice).
-               execom="$ds9exec $ds9scaleopt $ds9geoopt -wcs degrees \
-                                 -multiframe $inwithhdu -lock slice image \
-                                 -lock frame image -zoom to fit -cmap sls \
-                                 -match frame colorbar -colorbar lock yes \
-                                 $ds9pan $ds9extra"
+                # 3D multi-extension file: The "Cube" window will slide
+                # between the slices of a single extension. To flip through
+                # the extensions (not the slices), press the top row
+                # "frame" button and from the last four buttons of the
+                # bottom row ("first", "previous", "next" and "last") can
+                # be used to switch through the extensions (while keeping
+                # the same slice).
+                execom="$ds9exec $ds9scaleopt \
+                                 $ds9geoopt -wcs degrees \
+                                 -multiframe \
+                                 $inwithhdu \
+                                 -lock slice image \
+                                 -lock frame image \
+                                 -zoom to fit \
+                                 -cmap sls \
+                                 -match frame colorbar \
+                                 -colorbar lock yes \
+                                 -view multi $multicolorbars \
+                                 $ds9pan \
+                                 $ds9extra"
             fi
 
-       # When input was table.
-       else
+        # When input was table.
+        else
 
             # If a HDU is given, add it to all the input file names (with a
             # '#' between the filename and HDU in TOPCAT).
@@ -431,8 +458,8 @@ else
             fi
 
             # TOPCAT command.
-           execom="$topcatexec $inwithhdu"
-       fi
+            execom="$topcatexec $inwithhdu"
+        fi
 
         # Run the final command and print it if not in '--quiet' mode.
         if [ $quiet = 0 ]; then
@@ -443,9 +470,9 @@ else
     # 'astfits' couldn't open the file.
     else
         if [ -f "$input1" ]; then
-           echo "'$input1' isn't a FITS file."
+            echo "'$input1' isn't a FITS file."
         else
-           echo "'$input1' doesn't exist."
+            echo "'$input1' doesn't exist."
         fi
     fi
 fi
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 1ce9616a..bc764d61 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -27011,6 +27011,13 @@ This can either be @option{img} (or DS9's ``Image'' 
coordinates) or @option{wcs}
 @item -g INTxINT
 @itemx --ds9geometry=INTxINT
 The initial DS9 window geometry (value to DS9's @option{-geometry} option).
+
+@item -m
+@itemx --ds9colorbarmulti
+Don't show a single color bar for all the loaded images.
+By default this script will call DS9 in a way that a single color bar is shown 
for any number of images.
+A single color bar is preferred for two reasons: 1) when there are a lot of 
images, they consume a large fraction of the display area. 2) the color-bars 
are locked by this script, so there is no difference between!
+With this option, you can have separate color bars under each image.
 @end table
 
 @node PSF construction and subtraction,  , Viewing FITS file contents with DS9 
or TOPCAT, Installed scripts



reply via email to

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