gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 30c533d1 2/3: astscript-radial-profile: includ


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 30c533d1 2/3: astscript-radial-profile: including the --azimuth option
Date: Mon, 21 Feb 2022 10:03:26 -0500 (EST)

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

    astscript-radial-profile: including the --azimuth option
    
    Until this commit, the radial profile script was not able to generate
    azimuthal radial profiles. The reason is that the azimuthal profile of
    MakeProfile was added after the radial profile script was included in
    Gnuastro.
    
    With this commit, the necessary steps have been added in order to be able
    to construct azimuthal radial profiles. The option --azimuth (or -a) is
    used for specifying two angles that will be considered together with the
    radial apertures to later measure the radial profile only in such portion
    of the image.
---
 bin/script/radial-profile.in | 58 +++++++++++++++++++++++++++++++++++++++++---
 doc/gnuastro.texi            |  6 +++++
 2 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/bin/script/radial-profile.in b/bin/script/radial-profile.in
index f70fd835..8c426f66 100644
--- a/bin/script/radial-profile.in
+++ b/bin/script/radial-profile.in
@@ -44,6 +44,7 @@ tmpdir=""
 output=""
 keeptmp=0
 mode="img"
+azimuth=""
 measure=""
 axisratio=1
 zeropoint=""
@@ -101,6 +102,7 @@ $scriptname options:
   -c, --center=FLT,FLT    Coordinate of the center along 2 axes.
   -R, --rmax=FLT          Maximum radius for the radial profile (in pixels).
   -Q, --axisratio=FLT     Axis ratio for ellipse profiles (A/B).
+  -a, --azimuth=FLT,FLT   Azimuthal angles range (from the major axis).
   -p, --positionangle=FLT Position angle for ellipse profiles.
   -s, --sigmaclip=FLT,FLT Sigma-clip multiple and tolerance.
   -z, --zeropoint=FLT     Zeropoint magnitude of input dataset.
@@ -217,6 +219,9 @@ do
         -Q|--axisratio)     axisratio="$2";                            check_v 
"$1" "$axisratio";  shift;shift;;
         -Q=*|--axisratio=*) axisratio="${1#*=}";                       check_v 
"$1" "$axisratio";  shift;;
         -Q*)                axisratio=$(echo "$1"  | sed -e's/-Q//');  check_v 
"$1" "$axisratio";  shift;;
+        -a|--azimuth)       azimuth="$2";                               
check_v "$1" "$azimuth";  shift;shift;;
+        -a=*|--azimuth=*)   azimuth="${1#*=}";                          
check_v "$1" "$azimuth";  shift;;
+        -a*)                azimuth=$(echo "$1"  | sed -e's/-a//');     
check_v "$1" "$azimuth";  shift;;
         -p|--positionangle) positionangle="$2";                        check_v 
"$1" "$positionangle";  shift;shift;;
         -p=*|--positionangle=*) positionangle="${1#*=}";               check_v 
"$1" "$positionangle";  shift;;
         -p*)                positionangle=$(echo "$1"  | sed -e's/-p//'); 
check_v "$1" "$positionangle";  shift;;
@@ -314,6 +319,15 @@ else
     exit 1
 fi
 
+# If a '--azimuth' has been given, make sure it only has two numbers.
+if [ x"$azimuth" != x ]; then
+    nazimuth=$(echo $azimuth | awk 'BEGIN{FS=","}END{print NF}')
+    if [ x$nazimuth != x2 ]; then
+        echo "$scriptname: '--azimuth' (or '-a') only take two values, but 
$nazimuth were given"
+        exit 1
+    fi
+fi
+
 # If no specific measurement has been requested, use the mean.
 if [ x"$measure" = x ]; then measure=mean; fi
 
@@ -542,18 +556,56 @@ fi
 # axisratio     -- axis ratio.
 # rmax          -- magnitude of the profile within the truncation radius 
(rmax).
 # 1             -- Truncation in radius unit.
-aperturesrawbase=apertures-raw.fits
-aperturesraw=$tmpdir/$aperturesrawbase
+radialaperturesrawbase=radial-raw.fits
+radialaperturesraw=$tmpdir/$radialaperturesrawbase
 echo "1 $xcenter $ycenter 7 $rmax 1 $positionangle $axisratio 1 1" \
      | astmkprof --background=$values --backhdu=1 --mforflatpix \
                  --mode=img --clearcanvas --type=int16 \
-                 --circumwidth=1 --replace --output=$aperturesraw \
+                 --circumwidth=1 --replace --output=$radialaperturesraw \
                  $quiet
 
 
 
 
 
+# Generate an azimuthal profile
+# -----------------------------
+#
+# Create an azimuthal apertures image if the user specifies a range of
+# angles over which compute the radial profile. The azimuthal radial
+# profile is combined with the radial apertures generated above, to only
+# consider the desired portion of the image.
+aperturesraw=$radialaperturesraw
+if [ x"$azimuth" != x ]; then
+
+    # Get the initial and final azimuth angles
+    azimuth_ini=$(echo "$azimuth" | awk 'BEGIN{FS=","} {print $1}')
+    azimuth_fin=$(echo "$azimuth" | awk 'BEGIN{FS=","} {print $2}')
+
+    # Generate the azimuthal apertures
+    azimuth_apertures_raw=$tmpdir/azimuth-raw.fits
+    echo "1 $xcenter $ycenter 9 $rmax 1 $positionangle $axisratio 1 1" \
+         | astmkprof --background=$values --backhdu=1 --mforflatpix \
+                     --mode=img --clearcanvas --type=int16 \
+                     --circumwidth=1 --replace --output=$azimuth_apertures_raw 
\
+                     $quiet
+
+    # From the azimuthal aperture image, consider only that portion that
+    # are in between the two specified angles. Set the rest of the pixels
+    # to zero values (on the radial apertures image)
+    aperturesraw=$tmpdir/apertures-raw.fits
+    astarithmetic $radial_apertures_raw -h1 set-radial \
+                  $azimuth_apertures_raw -h1 set-azimuth \
+                  azimuth $azimuth_ini gt \
+                  azimuth $azimuth_fin lt \
+                  and set-arc \
+                  radial arc 1 ne 0 where --output $aperturesraw
+fi
+
+
+
+
+
 # Undersampling the aperture image
 # --------------------------------
 #
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index e1c6504a..bdcd523a 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -23893,6 +23893,12 @@ The axis ratio of the apertures (minor axis divided by 
the major axis in a 2D el
 By default (when this option isn't given), the radial profile will be circular 
(axis ratio of 1).
 This parameter is used as the option @option{--qcol} in the generation of the 
apertures with @command{astmkprof}.
 
+@item -a FLT[,FLT[,...]]
+@itemx --azimuth=FLT[,FLT[,...]]
+Azimuthal angles range (in degrees, from 0 to 360) from the major axis.
+This parameter is used as the option @option{--qcol=azimuth} in the generation 
of the apertures with @command{astmkprof}.
+For example, if you want to obtain the radial profile only in between 55 and 
78 degrees (taking as the reference the major axis), use 
@command{--azimuth=55,78}.
+
 @item -p FLT
 @itemx --positionangle=FLT
 The position angle (in degrees) of the profiles relative to the first FITS 
axis (horizontal when viewed in SAO DS9).



reply via email to

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