[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master ca8fc03a 55/69: PSF scripts: getting proper NA
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master ca8fc03a 55/69: PSF scripts: getting proper NAXIS values when data is compressed as .fz |
Date: |
Wed, 26 Jan 2022 12:39:15 -0500 (EST) |
branch: master
commit ca8fc03aa0e088a9a89d993684fc87aff0779d86
Author: Raul Infante-Sainz <infantesainz@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
PSF scripts: getting proper NAXIS values when data is compressed as .fz
Until this commit, if some of the input images were compressed as .fz
files, the computation of the dimension of the images were not properly
done. This is because it was reading the keywords NAXIS1 and NAXIS2.
However, when the data is compressed, these keywords are not the original
image dimensions but the dimensions of the table (data compressed).
With this commit, this bug has been corrected. Now, the scripts read the
keywords: ZNAXIS1, ZNAXIS2, NAXIS1, and NAXIS2. If ZNAXIS keyword values
exist, then use them as the original image dimensions. Otherwise, the size
will be computed from the normal NAXIS and NAXIS2 keywords.
---
bin/script/psf-create-junction.in | 47 ++++++++++++++++++++++++++-------
bin/script/psf-model-scattered-light.in | 46 +++++++++++++++++++++++++-------
2 files changed, 73 insertions(+), 20 deletions(-)
diff --git a/bin/script/psf-create-junction.in
b/bin/script/psf-create-junction.in
index 32f189da..9982ae00 100644
--- a/bin/script/psf-create-junction.in
+++ b/bin/script/psf-create-junction.in
@@ -314,11 +314,29 @@ fi
#
# The center of the PSF is assumed to be at the center of the PSF image.
# So, the center of the PSF is computed here from the size of the PSF image
-# along the two axis (in pixels).
-xaxis=$(astfits $inputs --hdu=$hdu \
- | awk '/^NAXIS1/{print $3}')
-yaxis=$(astfits $inputs --hdu=$hdu \
- | awk '/^NAXIS2/{print $3}')
+# along the two axis (in pixels). it is necessary to compute the original
+# size of the input image. It is possible that the input image is
+# compressed as '.fz' file. In these situations, the keywords with the
+# original dimesion of the array are ZNAXIS1 and ZNAXIS2, instead of NAXIS1
+# and NAXIS2. The former are the real size of the array (as it were not
+# compressed), the latter are the size after compressing the data (as a
+# table). If there are not ZNAXIS keywords, output values are "n/a". So,
+# they are removed with sed, and then count the number of remaining values.
+# Overall, when there are 4 remaining keywords, the data is compressed,
+# otherwise use the simple NAXIS1 and NAXIS2 keywords (that are always into
+# the header).
+axises=$(astfits $inputs --hdu=$hdu --quiet \
+ --keyvalue ZNAXIS1,ZNAXIS2,NAXIS1,NAXIS2)
+naxises=$(echo $axises \
+ | sed 's/n\/a//g' \
+ | awk '{print NF}')
+if [ x$naxises = x4 ]; then
+ xaxis=$(echo $axises | awk '{print $1}')
+ yaxis=$(echo $axises | awk '{print $2}')
+else
+ xaxis=$(echo $axises | awk '{print $3}')
+ yaxis=$(echo $axises | awk '{print $4}')
+fi
# To obtain the center of the PSF (in pixels), just divide by 2 the size of
# the PSF image.
@@ -334,11 +352,20 @@ ycenter=$(astarithmetic $yaxis 2 / --quiet)
#
# The center of the core PSF is assumed to be at the center of the PSF
# image. So, the center of the PSF is computed here from the size of the
-# PSF image along the two axis (in pixels).
-xpsfaxis=$(astfits $core --hdu=$corehdu \
- | awk '/^NAXIS1/{print $3}')
-ypsfaxis=$(astfits $core --hdu=$corehdu \
- | awk '/^NAXIS2/{print $3}')
+# PSF image along the two axis (in pixels). Dimension values are computed
+# as described above.
+psfaxises=$(astfits $psf --hdu=$psfhdu --quiet \
+ --keyvalue ZNAXIS1,ZNAXIS2,NAXIS1,NAXIS2)
+psfnaxises=$(echo $psfaxises \
+ | sed 's/n\/a//g' \
+ | awk '{print NF}')
+if [ x$psfnaxises = x4 ]; then
+ xpsfaxis=$(echo $psfaxises | awk '{print $1}')
+ ypsfaxis=$(echo $psfaxises | awk '{print $2}')
+else
+ xpsfaxis=$(echo $psfaxises | awk '{print $3}')
+ ypsfaxis=$(echo $psfaxises | awk '{print $4}')
+fi
# To obtain the center of the PSF (in pixels), just divide by 2 the size of
# the PSF image.
diff --git a/bin/script/psf-model-scattered-light.in
b/bin/script/psf-model-scattered-light.in
index d2ef5db1..4d73609f 100644
--- a/bin/script/psf-model-scattered-light.in
+++ b/bin/script/psf-model-scattered-light.in
@@ -384,11 +384,28 @@ astarithmetic $psf --hdu=$psfhdu $fluxfactor x \
# ----------------------------
#
# In order to have the final PSF with the same size than the input image,
-# it is necessary to compute the original size of the input image.
-xaxis=$(astfits $inputs --hdu=$hdu \
- | awk '/^NAXIS1/{print $3}')
-yaxis=$(astfits $inputs --hdu=$hdu \
- | awk '/^NAXIS2/{print $3}')
+# it is necessary to compute the original size of the input image. It is
+# possible that the input image is compressed as '.fz' file. In these
+# situations, the keywords with the original dimesion of the array are
+# ZNAXIS1 and ZNAXIS2, instead of NAXIS1 and NAXIS2. The former are the
+# real size of the array (as it were not compressed), the latter are the
+# size after compressing the data (as a table). If there are not ZNAXIS
+# keywords, output values are "n/a". So, they are removed with sed, and
+# then count the number of remaining values. Overall, when there are 4
+# remaining keywords, the data is compressed, otherwise use the simple
+# NAXIS1 and NAXIS2 keywords (that are always into the header).
+axises=$(astfits $inputs --hdu=$hdu --quiet \
+ --keyvalue ZNAXIS1,ZNAXIS2,NAXIS1,NAXIS2)
+naxises=$(echo $axises \
+ | sed 's/n\/a//g' \
+ | awk '{print NF}')
+if [ x$naxises = x4 ]; then
+ xaxis=$(echo $axises | awk '{print $1}')
+ yaxis=$(echo $axises | awk '{print $2}')
+else
+ xaxis=$(echo $axises | awk '{print $3}')
+ yaxis=$(echo $axises | awk '{print $4}')
+fi
@@ -399,11 +416,20 @@ yaxis=$(astfits $inputs --hdu=$hdu \
#
# The center of the PSF is assumed to be at the center of the PSF image.
# So, the center of the PSF is computed here from the size of the PSF image
-# along the two axis (in pixels).
-xpsfaxis=$(astfits $psf --hdu=$psfhdu \
- | awk '/^NAXIS1/{print $3}')
-ypsfaxis=$(astfits $psf --hdu=$psfhdu \
- | awk '/^NAXIS2/{print $3}')
+# along the two axis (in pixels). Dimension values are computed as
+# described above.
+psfaxises=$(astfits $psf --hdu=$psfhdu --quiet \
+ --keyvalue ZNAXIS1,ZNAXIS2,NAXIS1,NAXIS2)
+psfnaxises=$(echo $psfaxises \
+ | sed 's/n\/a//g' \
+ | awk '{print NF}')
+if [ x$psfnaxises = x4 ]; then
+ xpsfaxis=$(echo $psfaxises | awk '{print $1}')
+ ypsfaxis=$(echo $psfaxises | awk '{print $2}')
+else
+ xpsfaxis=$(echo $psfaxises | awk '{print $3}')
+ ypsfaxis=$(echo $psfaxises | awk '{print $4}')
+fi
# To obtain the center of the PSF (in pixels), just divide by 2 the size of
# the PSF image.
- [gnuastro-commits] master 30e33ec6 06/69: PSF model: new script for computing the PSF flux factor, (continued)
- [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, 2022/01/26
- [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 <=
- [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
- [gnuastro-commits] master aae0d156 64/69: PSF tutorial: running of Segment on saturated images added, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 5fdd3a4a 31/69: PSF create: including the make check step for two PSF scripts, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master d6e6f9da 47/69: PSF flux-factor: correct the indentation, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 809be22b 67/69: Book: PSF construction tutorial, completed until the outer part, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 2b0b6294 56/69: PSF scripts: fixed two FAILS during make checks, Mohammad Akhlaghi, 2022/01/26