[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master a3c0f0e2 31/39: Zeropoint: optimize the script
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master a3c0f0e2 31/39: Zeropoint: optimize the script for overlaping check |
Date: |
Wed, 19 Apr 2023 12:18:27 -0400 (EDT) |
branch: master
commit a3c0f0e24c5fee428620f8349338fb2bfeea5dd7
Author: Sepideh Eskandarlou <sepideh.eskandarlou@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Zeropoint: optimize the script for overlaping check
Until now, if the reference was catalog it check that input image and
catalog overlap together or not. While, if the user has reference images
this criteria did not check.
With this commit, if the user has reference images and based on them wants
obtain the zero point, it will check they have overlap with input image or
not.
---
bin/script/zeropoint.in | 78 ++++++++++++++++++++++++++++---------------------
1 file changed, 45 insertions(+), 33 deletions(-)
diff --git a/bin/script/zeropoint.in b/bin/script/zeropoint.in
index 725fb747..fdd2d1eb 100644
--- a/bin/script/zeropoint.in
+++ b/bin/script/zeropoint.in
@@ -396,8 +396,8 @@ fi
-# Overlap check between input and reference images and catalog
-# ------------------------------------------------------------
+# Overlap check between input and reference images
+# ------------------------------------------------------------------------
#
# In this step, we have to check and be sure the input imge has overlap
# with reference catalog or reference images or not. If they have overlap
@@ -408,29 +408,27 @@ fi
# If the user insert the catalog as reference, check it overlap with input
# image or not.
# Find minimum and maximum RA/Dec values of the input image.
-minraimg=$(astfits $inputs --hdu=$hdu --skycoverage \
- | grep 'RA' | awk '{print $2}')
-maxraimg=$(astfits $inputs --hdu=$hdu --skycoverage \
- | grep 'RA' | awk '{print $3}')
-mindecimg=$(astfits $inputs --hdu=$hdu --skycoverage \
- | grep 'DEC' | awk '{print $2}')
-maxdecimg=$(astfits $inputs --hdu=$hdu --skycoverage \
- | grep 'DEC' | awk '{print $3}')
+allradecinput=$(astfits $inputs --hdu=$hdu --skycoverage -q | awk 'NR==2')
+minrainput=$(echo $allradecinput | awk '{print $1}')
+maxrainput=$(echo $allradecinput | awk '{print $2}')
+mindecinput=$(echo $allradecinput | awk '{print $3}')
+maxdecinput=$(echo $allradecinput | awk '{print $4}')
if [ x"$catalog" != x ]; then
+
# Find the overlap area between catalog and image.
skycoverage=$tmpdir/skycoverage.fits
asttable $catalog --inpolygon=$racolumn,$deccolumn \
- --polygon="$minraimg,$mindecimg \
- : $minraimg,$maxdecimg \
- : $maxraimg,$mindecimg \
- : $maxraimg,$maxdecimg" \
+ --polygon="$minrainput,$mindecinput \
+ : $minrainput,$maxdecinput \
+ : $maxrainput,$mindecinput \
+ : $maxrainput,$maxdecinput" \
--output=$skycoverage
# The number of stars in the overlaping area.
number=$(asttable $skycoverage | wc -l)
- # If catalog overlap the image, select stars with magnitudes between
- # the fainter and larger than bright values.
+ # If catalog overlap the image, the script will continue and obtain the
+ # zero point. While, if they do not overlap the script will stopped.
if [ "$number" = 0 ]; then
# Stop if the catalog doesn't overlap with the image.
@@ -439,24 +437,38 @@ if [ x"$catalog" != x ]; then
exit 1
fi
elif [ x"$reference" != x ]; then
- listimgs=$(echo $reference | sed 's|,| |g')
- for img in $listimgs; do
- minra=$(astfits $img -h0 --skycoverage -q \
- | awk 'FNR == 2 {print $1}')
- maxra=$(astfits $img -h0 --skycoverage -q \
- | awk 'FNR == 2 {print $2}')
- mindec=$(astfits $img -h0 --skycoverage -q \
- | awk 'FNR == 2 {print $3}')
- maxdec=$(astfits $img -h0 --skycoverage -q \
- | awk 'FNR == 2 {print $4}')
- condminra=$(echo $minraimg '<=' $minra | bc -l)
- condmindec=$(echo $mindecimg '<=' $mindec | bc -l)
- condmaxra=$(echo $maxraimg '>=' $maxra | bc -l)
- condmaxdec=$(echo $maxdecimg '>=' $maxdec | bc -l)
- if [ "$condminra" = "0" ] || [ "$condmindec" = "0" ] || [ "$condmaxra"
= "0" ] || [ "$condmaxdec" = "0" ]; then
+
+ # Compute how many references images is used.
+ nums=$(echo $reference \
+ | awk 'BEGIN{FS=","}{for(i=1;i<=NF;++i) printf "%s ", i}')
+
+ for n in $nums; do
+
+ # Extract the reference images name and their hdu.
+ img=$(echo $reference | awk 'BEGIN{FS=","}{printf "%s", $'$n'}')
+ hduimg=$(echo $referencehdu | awk 'BEGIN{FS=","}{printf "%s", $'$n'}')
+
+ # Find the overlap area between catalog and image.
+ skycoverage=$tmpdir/skycoverage-$n.fits
+ astfits $img --hdu=$hduimg --skycoverage -q \
+ | awk 'NR==2 {printf "%f %f\n%f %f\n%f %f\n%f %f\n",
$1,$3,$1,$4,$2,$3,$2,$4}' \
+ | asttable --polygon="$minrainput,$mindecinput \
+ : $minrainput,$maxdecinput \
+ : $maxrainput,$mindecinput \
+ : $maxrainput,$maxdecinput" \
+ --output=$skycoverage
+
+ # The number of stars in the overlaping area.
+ number=$(asttable $skycoverage | wc -l)
+
+ # If reference image overlap with input image, the script will
+ # continue and obtain the zero point. While, if they do not overlap
+ # the script will stopped.
+ if [ "$number" = 0 ]; then
+
# Stop if the catalog doesn't overlap with the image.
- echo "Input image and $listimgs do not overlap."
- echo "Please provide an image and a reference image that overlap
together."
+ echo "Image and catalog do not overlap."
+ echo "Please provide an image that overlap with $input image."
exit 1
fi
done
- [gnuastro-commits] master 8be4edd7 18/39: Zeropoint: a bug about the magnitude range, (continued)
- [gnuastro-commits] master 8be4edd7 18/39: Zeropoint: a bug about the magnitude range, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 10030cfc 11/39: Zeropoint: add magnitude range into the header of output, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master e39330ab 17/39: Zeropoint: adding sanity check for aperture option, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 46d328cd 12/39: Book: writing a tutorial for the zero-point script; preface, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 01dcbeed 15/39: Book: tutorial of zero point; magnitude range and aperture size, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master b3077f0d 27/39: Book: revision of the first part of the zeropoint tutorial, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 17b5fa81 36/39: Book: simplifying and polishing the zero point script tutorial, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 7769e279 07/39: zeropoint: new options for magnitude and keeping the results are added, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master a1c7a277 16/39: Book: tutorial of zero point; select the best aperture, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 1a987e04 19/39: Book: tutorial of zero point; using keepzpap and completion of results, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master a3c0f0e2 31/39: Zeropoint: optimize the script for overlaping check,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 156da6c7 28/39: Book: Increase readability and correction, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master d8402f1a 32/39: Book: some command and some tips is added to better recognition, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 6ff43d00 05/39: Zeropoint: script for estimating the zeropoint of an image, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 76c8a482 03/39: Zeropoint: add a script for bing it on Gnuastro, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master dddb483f 01/39: zeropoint: First make file for obtainaing the zeropoint photometry, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master a841d3f2 02/39: zeropoint: catalogs can be used as reference, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 2c027224 08/39: Zeropoint: change the output file, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master ea79c2ba 14/39: Book: tutorial of zero point; removing the sky and running the script, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 48edcd91 13/39: Book: tutorial of zero point; preparing images for using the script, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master 88b4c298 23/39: Book: tutorial of zero point; subsection catalog reference, Mohammad Akhlaghi, 2023/04/19