[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 5e84045 04/32: astscript-radial-profile: allow
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 5e84045 04/32: astscript-radial-profile: allowing to manipulate the final profile |
Date: |
Wed, 24 Feb 2021 22:36:14 -0500 (EST) |
branch: master
commit 5e84045e459e60aa317f94f9d52c2d83ffcb8688
Author: Raul Infante-Sainz <infantesainz@gmail.com>
Commit: Raul Infante-Sainz <infantesainz@gmail.com>
astscript-radial-profile: allowing to manipulate the final profile
Until this commit, the only possible manipulation for obtaining the
final radial profile was the binning of the data. However, it is
convenient to have the possibility of modify the radial profile as the
user want. For example, scaling the radius column to obtain them in
arcsec instead of pixels. The same for the second column: it could be
necessary to obtain surface brightness magnitudes instead of the raw
measure done until now.
With this commit, it has been added the possibility to manipulate the
two columns of the radial profile. There is just necessary to specify
the wanted operation with the options --X and --Y (--xarith and
--yarith) from the command line. The syntaxis and notation for
manipulate the columns is the same used by Table when arithmeting
different columns. If nothing is wanted to be done, then the data (both
columns) is just multiplied by 1.
---
bin/script/radial-profile.in | 75 ++++++++++++++++++++++++++++++++------------
1 file changed, 55 insertions(+), 20 deletions(-)
diff --git a/bin/script/radial-profile.in b/bin/script/radial-profile.in
index 325ee80..ae6d480 100644
--- a/bin/script/radial-profile.in
+++ b/bin/script/radial-profile.in
@@ -43,6 +43,8 @@ p=0
b=1
w=1
k=1
+X="1 x"
+Y="1 x"
quiet=0
prefix=./
version=0.11
@@ -95,6 +97,8 @@ $scriptname options:
-b, --binning=INT Size of the bin for averaging group of pixels.
-a, --cprofiles=STR Configuration file for astmkprof.
-c, --ccatalog=STR Configuration file for astmkcatalog.
+ -X, --xarith=STR Operation for the first column of radial profile.
+ -Y, --yarith=STR Operaton for the second column of the radial profile.
Output:
-k, --keeptemp Keep temporal/auxiliar files.
@@ -221,6 +225,12 @@ do
-c|--ccat) c="$2"; check_v "$1" "$c";
shift;shift;;
-c=*|--ccat=*) c="${1#*=}"; check_v "$1" "$c";
shift;;
-c*) c=$(echo "$1" | sed -e's/-c//'); check_v "$1" "$c";
shift;;
+ -X|--xarith) X="$2"; check_v "$1" "$X";
shift;shift;;
+ -X=*|--xarith=*) X="${1#*=}"; check_v "$1" "$X";
shift;;
+ -X*) X=$(echo "$1" | sed -e's/-X//'); check_v "$1" "$X";
shift;;
+ -Y|--yarith) Y="$2"; check_v "$1" "$Y";
shift;shift;;
+ -Y=*|--yarith=*) Y="${1#*=}"; check_v "$1" "$Y";
shift;;
+ -Y*) Y=$(echo "$1" | sed -e's/-Y//'); check_v "$1" "$Y";
shift;;
# Output parameters
-k|--keeptemp) k=0; shift;;
@@ -329,8 +339,8 @@ astmkprof $aperturestxt --background=$inputs --backhdu=$hdu
\
# to obtain a catalogue using the segmentation image previously generated
# (the elliptical apertures) and the original input image for computing the
# values.
-fprofiles=$(echo $output | sed -e"s|.fits|-profile_"$mode"_$x-$y.fits|g")
-astmkcatalog $aperturesfits -h1 --valuesfile=$inputs -o$fprofiles \
+fprofile=$(echo $output | sed -e"s|.fits|-profile_"$mode"_$x-$y.fits|g")
+astmkcatalog $aperturesfits -h1 --valuesfile=$inputs -o$fprofile \
--ids --$m --config=$c
@@ -344,9 +354,13 @@ astmkcatalog $aperturesfits -h1 --valuesfile=$inputs
-o$fprofiles \
# is possible to bin the data. It is done in any case, if the user has not
# changed the default value, the binning will be equal to 1 so the output
# binned will be the same as the input. To do the binning of the data, a
-# small Awk script is used.
-asttable $fprofiles --colinfoinstdout \
- | awk -v b=$b 'BEGIN { N = b }
+# small Awk script is used. Since the Awk script will print the columns as
+# float values, it is necessary to change the headers. To do that, Sed is
+# used to replace all ocurrences of i32 to f32.
+bprofile=$(echo $output | sed -e"s|.fits|-binned-profile_"$mode"_$x-$y.fits|g")
+asttable $fprofile --colinfoinstdout \
+ | awk -v b=$b '/^#/{print} \
+ BEGIN { N = b }
{ for (i = 1; i <= NF; i++) sum[i] += $i }
NR % N == 0 { for (i = 1; i <= NF; i++)
{
@@ -354,32 +368,53 @@ asttable $fprofiles --colinfoinstdout \
sum[i] = 0
}
}' \
- | asttable -o$output
+ | sed -e"s/i32/f32/g" \
+ | asttable -o$bprofile
+# Modify the radial profile
+# -------------------------
+#
+# The user may want to operate the different columns of the radial profile
+# to obtain them in different units. For example, it is common to use radial
+# distances in arcec or arcmin in astronomical images. If this is the case,
+# the user will specify the operation to transform the radius in pixels to
+# arcsecs with the --X option. The same happen with the measured column
+# (--Y). They are strings that will be used in the Table program for operate
+# appropiately the different columns. But before this, the necessary
+# metadata information is saved in a temporal file. The metadata consists in
+# the column names (radius and $m), column units (modified), column type
+# (float32), and comment (here it is said how the columns have been
+# modified.
+aprofile=$(echo $output | sed -e"s|.fits|-arith-profile_"$mode"_$x-$y.fits|g")
+echo "# Column 1: radius [modified,f32,] Modified with $X" > $aprofile
+echo "# Column 2: $m [modified,f32,] Modified with $Y" >> $aprofile
+
+# Make the appropiate operation over the two columns of the radial profile
+# and add it to the temporal file with the meta-data.
+asttable $bprofile \
+ -c"arith c1 $X" \
+ -c"arith c2 $Y" >> $aprofile
+
+# Finally, read the temporal file with the metadata information as well as
+# the radial profile values, and save it as a fits table using Table.
+cat $aprofile | asttable -o$output
+
+
+
+
# Remove temporal files
# ---------------------
#
# If the user has specified this option, temporal files will be removed.
if [ $k = 1 ]; then
- rm $fprofiles \
+ rm $aprofile \
+ $bprofile \
+ $fprofile \
$aperturestxt \
$aperturesfits
fi
-
-
-
-# Additional code for making surface brightness profiles. Not working yet
-#zp=$(astfits $inputs -h$hdu | grep -w ZP | awk '{print $3}')
-#pscale=0.389
-#muprofile=$(echo $inputs | sed -e"s|.fits|-sbprofile_"$mode"_$x-$y.fits|g")
-#asttable $fprofiles \
-# -c"arith OBJ_ID $pscale x" \
-# -c"arith MEDIAN log10 -2.5 x $zp + $pscale log10 5 x +" \
-# -o$output
-
-
- [gnuastro-commits] master updated (ea59208 -> 4294506), Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master 863abd7 01/32: astscript-radial-profile: adding script for making radial profiles, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master 7eac053 03/32: astscript-radial-profile: improving comments and information, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master 4e019cb 05/32: astscript-radial-profile: fixing some bugs and modifying metadata, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master dd4f925 06/32: astscript-radial-profile: adding documentation to the GNUASTRO book, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master 5e84045 04/32: astscript-radial-profile: allowing to manipulate the final profile,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 82f8176 08/32: astscript-radial-profile: adding usage example to GNUASTRO book, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master 0634f04 14/32: Book: describing remaining options of radial profile script, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master 2f2970f 09/32: Adding Vim .swp temporal files to .gitignore, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master 3fcd49a 10/32: astscript-radial-profile: setting name and version from the compilation, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master ebab496 15/32: Book: changed the place of radial profile script documentation, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master 6400ca4 16/32: Some minor correction in description, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master 4f3d70d 20/32: Binning data in some case, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master b36c21f 17/32: astscript-radial-profile: modification to use $ instead of c in Table, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master e24caa6 07/32: astscript-radial-profile: user can now specify output column names, Mohammad Akhlaghi, 2021/02/24
- [gnuastro-commits] master e1ded16 11/32: Book: minor typos and corrections in radial profile script examples, Mohammad Akhlaghi, 2021/02/24