[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 03bc1e69 22/69: PSF model: using PSF radial pr
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 03bc1e69 22/69: PSF model: using PSF radial profile as input for flux factor computation |
Date: |
Wed, 26 Jan 2022 12:39:11 -0500 (EST) |
branch: master
commit 03bc1e698625d4d8a374c65f502b06e99f38286f
Author: Raul Infante-Sainz <infantesainz@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
PSF model: using PSF radial profile as input for flux factor computation
Until this commit, when computing the flux factor, only the PSF image was
provided. As a consequence, each time this script is executed, two radial
profiles have to be computed: the PSF and the object radial profiles.
However, in many situations, the PSF would be the same for many different
calls to this script. So, it would be good to have the possibility of
passing the radial profile of the PSf directly to the script to avoid
computing it. In this case, the radial profile has to be computed outside
of the script.
With this commit, this new feature has been added. Now the script is able
to use the radial profile of the PSF directly, without having to compute
it.
---
bin/script/psf-model-flux-factor.in | 69 ++++++++++++++++++++++++++++++++-----
doc/gnuastro.texi | 18 ++++++++++
2 files changed, 79 insertions(+), 8 deletions(-)
diff --git a/bin/script/psf-model-flux-factor.in
b/bin/script/psf-model-flux-factor.in
index 87a096d5..2db419d8 100644
--- a/bin/script/psf-model-flux-factor.in
+++ b/bin/script/psf-model-flux-factor.in
@@ -46,7 +46,10 @@ corewidth=""
normradii=""
sigmaclip=""
stampwidth=""
+psfprofile=""
+psfprofilehdu=1
normop="median"
+psfprofilecol=""
version=@VERSION@
scriptname=@SCRIPT_NAME@
@@ -89,8 +92,11 @@ experienced Gnuastro users and developers. For more
information, please run:
$scriptname options:
Input:
-h, --hdu=STR HDU/extension of all input FITS files.
- -p, --psf=STR PSF fits file.
- -P, --psfhdu=STR HDU/extension of all input FITS files.
+ -p, --psf=STR PSF image fits file.
+ -P, --psfhdu=STR HDU/extension of the PSF image.
+ -f, --psfprofile=STR PSF radial profile fits file.
+ -F, --psfprofilehdu=STR HDU/extension of the PSF radial profile.
+ -C, --psfprofilecol=STR,STR Column names (radius, flux) for PSF radial
profile.
-O, --mode=STR Coordinates mode ('wcs' or 'img').
-c, --center=FLT,FLT Center coordinates of the object.
-W, --stampwidth=INT Width of the stamp in pixels.
@@ -204,6 +210,15 @@ do
-P|--psfhdu) psfhdu="$2";
check_v "$1" "$psfhdu"; shift;shift;;
-P=*|--psfhdu=*) psfhdu="${1#*=}";
check_v "$1" "$psfhdu"; shift;;
-P*) psfhdu=$(echo "$1" | sed -e's/-P//');
check_v "$1" "$psfhdu"; shift;;
+ -f|--psfprofile) psfprofile="$2";
check_v "$1" "$psfprofile"; shift;shift;;
+ -f=*|--psfprofile=*) psfprofile="${1#*=}";
check_v "$1" "$psfprofile"; shift;;
+ -f*) psfprofile=$(echo "$1" | sed -e's/-f//');
check_v "$1" "$psfprofile"; shift;;
+ -F|--psfprofilehdu) psfprofilehdu="$2";
check_v "$1" "$psfprofilehdu"; shift;shift;;
+ -F=*|--psfprofilehdu=*) psfprofilehdu="${1#*=}";
check_v "$1" "$psfprofilehdu"; shift;;
+ -F*) psfprofilehdu=$(echo "$1" | sed -e's/-F//');
check_v "$1" "$psfprofilehdu"; shift;;
+ -C|--psfprofilecol) psfprofilecol="$2";
check_v "$1" "$psfprofilecol"; shift;shift;;
+ -C=*|--psfprofilecol=*) psfprofilecol="${1#*=}";
check_v "$1" "$psfprofilecol"; shift;;
+ -C*) psfprofilecol=$(echo "$1" | sed -e's/-C//');
check_v "$1" "$psfprofilecol"; shift;;
-n|--normradii) normradii="$2";
check_v "$1" "$normradii"; shift;shift;;
-n=*|--normradii=*) normradii="${1#*=}";
check_v "$1" "$normradii"; shift;;
-n*) normradii=$(echo "$1" | sed -e's/-n//');
check_v "$1" "$normradii"; shift;;
@@ -280,13 +295,35 @@ if [ x"$inputs" = x ]; then
exit 1
fi
-# If a PSF image (--psf) is not given at all.
-if [ x"$psf" = x ]; then
- echo "$scriptname: no PSF image provided."
- echo "A PSF image has to be specified with --psf or -p."
+# If a PSF image (--psf) and profile (--psfprofile) are not given at all.
+if [ x"$psf" = x ] && [ x"$psfprofile" = x ]; then
+ echo "$scriptname: no PSF image or profile provided."
+ echo "A PSF image (profile) has to be specified with --psf or -p
(--psfprofile or -f)."
exit 1
fi
+# If a PSF image (--psf) and profile (--psfprofile) are given.
+if [ x"$psf" != x ] && [ x"$psfprofile" != x ]; then
+ echo "$scriptname: both PSF image and profile provided."
+ echo "Only one PSF input (image or profile) has to be provided. Image
(--psf, -p), profile (--psfprofile, -f)."
+ exit 1
+fi
+
+# If PSF profile provided, ensure also column names are provided.
+if [ x"$psfprofile" != x ]; then
+ if [ x"$psfprofilecol" = x ]; then
+ echo "$scriptname: no PSF profile column names provided."
+ echo "Values to '--psfprofilecol' ('-C') should be provided."
+ exit 1
+ else
+ npsfprofilecols=$(echo $psfprofilecol | awk 'BEGIN{FS=","}END{print
NF}')
+ if [ x$npsfprofilecols != x2 ]; then
+ echo "$scriptname: '--psfprofilecol' (or '-C') only take two
values, but $npsfprofilecols were given."
+ exit 1
+ fi
+ fi
+fi
+
# If center coordinates (--center) is not given at all.
if [ x"$center" = x ]; then
echo "$scriptname: no center coordinates provided."
@@ -342,6 +379,13 @@ ycoord=$(echo "$center" | awk 'BEGIN{FS=","} {print $2}')
normradiusmin=$(echo "$normradii" | awk 'BEGIN{FS=","} {print $1}')
normradiusmax=$(echo "$normradii" | awk 'BEGIN{FS=","} {print $2}')
+# If PSF radial profile provided
+if [ x"$psfprofile" != x ]; then
+ psfprofilecolradius=$(echo "$psfprofilecol" | awk 'BEGIN{FS=","} {print
$1}')
+ psfprofilecolflux=$(echo "$psfprofilecol" | awk 'BEGIN{FS=","} {print $2}')
+fi
+
+
# With the center coordinates, generate a specific label for the object
# consisting in its coordinates.
objectid="$xcoord"_"$ycoord"
@@ -504,8 +548,17 @@ fi
astscript-radial-profile $cropped_masked --hdu=1 $maximumradius \
--measure=$normop --output=$radialprofile $quiet
-astscript-radial-profile $psf --hdu=$psfhdu $maximumradius \
- --measure=$normop --output=$psfradialprofile $quiet
+# If the user provide a PSF image, compute the radial profile of that PSF.
+# Else, consider the PSF radial profile provided.
+if [ x"$psfprofile" = x ]; then
+ astscript-radial-profile $psf --hdu=$psfhdu $maximumradius $quiet \
+ --measure=$normop --output=$psfradialprofile
+else
+ asttable $psfprofile \
+ --output=$psfradialprofile $quiet \
+ --column=$psfprofilecolradius,$psfprofilecolflux \
+ --range=$psfprofilecolradius,$normradiusmin,$normradiusmax
+fi
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index b4118a5a..905b903a 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -23861,6 +23861,24 @@ The PSF is assumed to be centered in this image.
@itemx --psfhdu=STR
The HDU/extension of the PSF image.
+@item -f STR
+@itemx --psfprofile=STR
+Filename of the PSF radial profile.
+Instead of using @option{--psf} to provide the PSF image, it is possible to
provide the radial profile of the PSF directly.
+By doing this, the script does not calculate the radial profile internally and
the execution is faster.
+This is convenient when the same PSF image is used for many stars.
+In this situation, it is necessary to compute the radial profile only once,
and then feed the radial profile to this script.
+
+@item -F STR
+@itemx --psfprofilehdu=STR
+The HDU/extension of the PSF radial profile.
+
+@item -C STR,STR
+@itemx --psfprofilecol=STR,STR
+The column names for the radial profile of the PSF.
+It takes two values separated by a comma (@key{,}).
+The values are the column names for the radius and the flux of the radial
profile.
+
@item -O STR
@itemx --mode=STR
Interpret the center position of the object (values given to
@option{--center}) in image or WCS coordinates.
- [gnuastro-commits] master 31f0373a 05/69: PSF model: new script for putting a PSF image into a sky position, (continued)
- [gnuastro-commits] master 31f0373a 05/69: PSF model: new script for putting a PSF image into a sky position, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 0ea23b70 69/69: Book: PSF tutorial now with instruction to build first inner region, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 00f2ab56 63/69: PSF select-stars: simplifying some parts and language corrections, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 6638c671 53/69: Book: correct the definition of option --minaxisratio, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master e9f4d343 09/69: PSF model: fixed bug in defining the radial profiles for flux factor, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 30e33ec6 06/69: PSF model: new script for computing the PSF flux factor, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 65fb6894 02/69: PSF stamp: wrong script location, fixing it, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 8d4e7f3d 14/69: Book: adding documentation of 'psf-create-junction' script, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 5a236622 21/69: PSF model: computing radial profile up to the minimum possible value, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master b5262f34 26/69: PSF stamp: rmax option was redundant, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 03bc1e69 22/69: PSF model: using PSF radial profile as input for flux factor computation,
Mohammad Akhlaghi <=
- [gnuastro-commits] master df256000 35/69: PSF select-stars: Add 'astscript-psf-create-select-stars' section to the, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 117fd766 24/69: PSF select stars: new script for selecting stars, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 5d9a6d9b 50/69: PSF select-stars: make check steps done again because some new option are added, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 1e0cc1a0 43/69: PSF select-stars: changing default values to not crash in make check, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master ca8fc03a 55/69: PSF scripts: getting proper NAXIS values when data is compressed as .fz, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 5eac0cea 40/69: Book: polishing the description of the PSF select-stars script, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master d99fc9df 60/69: PSF select-stars: add new option for selecting more bright stars, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 69a2e6ee 54/69: Book: correct some comments in the psf-create-select-stars, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master f42832f8 23/69: PSF stamp: allowingto use a position angle and axis ratio, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 2894b35a 32/69: PSF model: including the make check step for two PSF scripts, Mohammad Akhlaghi, 2022/01/26