[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 6901ec82 49/69: PSF select-stars: check the im
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 6901ec82 49/69: PSF select-stars: check the image and catalog have a overlap area or not |
Date: |
Wed, 26 Jan 2022 12:39:14 -0500 (EST) |
branch: master
commit 6901ec823d3a03d1c42e84585b72ca9caf2aed2a
Author: Sepideh Eskandarlou <sepideh.eskandarlou@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
PSF select-stars: check the image and catalog have a overlap area or not
Until now, if the user provides a catalog of stars and want based on that
and input image, select the stars in the specific range of the magnitude,
just check the image are smaller than the catalog or larger than it. But
did not check that image and catalog have an overlap area together or not.
With this commit, before selecting the stars in the specific range of
magnitude, at first by using the 'astfits' and '--skycoverage' option we
find the four coordinate of the iamge, then based on these coordinate and
by using the '--polygon' option in 'asttable' the overlap area between the
image and the catalog has been found and if they have not to overlap area
(if the number of rows in table to be zero) the script will be stopped and
print an error, otherwise, if the number of rows in this table not to be
zero the script will be run and select the stars in the range of magnitude
between minimum and maximum.
---
bin/script/psf-create-select-stars.in | 52 +++++++++++++++++++----------------
1 file changed, 29 insertions(+), 23 deletions(-)
diff --git a/bin/script/psf-create-select-stars.in
b/bin/script/psf-create-select-stars.in
index cc9f42e7..9ab27c54 100755
--- a/bin/script/psf-create-select-stars.in
+++ b/bin/script/psf-create-select-stars.in
@@ -414,39 +414,49 @@ fi
# filter the objects to have only the ones with proper brightness. If the
# user does not provide a catalogue, obtain it using the program
# 'astquery'.
+#
+# The output name of the catalog of stars in the range of the
+# magnitude.
catalog_magfiltered=$tmpdir/catalog-mag-$minmag-$maxmag.fits
+
+# The output name of the sky coverage.
+skycoverage=$tmpdir/skycoverage.fits
+
+# If the catalog and the image have an overlap area, then select the stars
+# in the range of magnitude between minimum and maximum.
if [ x"$catalog" != x ]; then
# Find minimum and maximum RA/Dec values of the input image.
minraimg=$(astfits $inputs --hdu=$hdu --skycoverage \
- | grep 'RA' | awk '{print $2}')
+ | grep 'RA' | awk '{print $2}')
maxraimg=$(astfits $inputs --hdu=$hdu --skycoverage \
- | grep 'RA' | awk '{print $3}')
+ | grep 'RA' | awk '{print $3}')
mindecimg=$(astfits $inputs --hdu=$hdu --skycoverage \
- | grep 'DEC' | awk '{print $2}')
+ | grep 'DEC' | awk '{print $2}')
maxdecimg=$(astfits $inputs --hdu=$hdu --skycoverage \
- | grep 'DEC' | awk '{print $3}')
+ | grep 'DEC' | awk '{print $3}')
- # Find minimum and maximum RA/Dec values of the input catalog.
- minracatalog=$(asttable $catalog -c$racolumn \
- | aststatistics --minimum)
- maxracatalog=$(asttable $catalog -c$racolumn \
- | aststatistics --maximum)
+ # Find the overlap area between catalog and image.
+ asttable $catalog --inpolygon=$racolumn,$deccolumn \
+ --polygon="$minraimg,$mindecimg \
+ : $minraimg,$maxdecimg \
+ : $maxraimg,$mindecimg \
+ : $maxraimg,$maxdecimg" \
+ --output=$skycoverage
- mindeccatalog=$(asttable $catalog -c$deccolumn \
- | aststatistics --minimum)
- maxdeccatalog=$(asttable $catalog -c$deccolumn \
- | aststatistics --maximum)
-
- # Check if the catalog overlap the image or not.
- checkoverlap=$(echo $minraimg $minracatalog $mindecimg $mindeccatalog \
- $maxraimg $maxracatalog $maxdecimg $maxdeccatalog \
- | awk '{print ($1 <= $2 && $3 <= $4 && $5 >= $6 && $7 >=
$8)}')
+ # The number of stars in the overlap area.
+ number=$(asttable $skycoverage | wc -l)
# If catalog overlap the image, select stars with magnitudes between
# the minimum and maximum values.
- if [ "$checkoverlap" = 1 ]; then
+ if [ "$number" = 0 ]; then
+
+ # Stop if the catalog doesn't overlap with the image.
+ echo "Image and catalog do not overlap."
+ echo "Please provide an iamge and a catalog which overlap together."
+ exit 1
+ else
# Make a file for output of 'asttable'.
if [ -f $catalog_magfiltered ]; then
@@ -467,10 +477,6 @@ if [ x"$catalog" != x ]; then
exit 2
fi
fi
- else
- # Stop if the catalog doesn't overlap with the image.
- echo "The catalog is smaller than the image and doesn't overlap with
the image."
- exit 1
fi
# If the user doesn't provide a catalog, use 'astquery' to obtain it.
- [gnuastro-commits] master f58c3211 08/69: PSF model: checking that a PSF image is given for computing flux factor, (continued)
- [gnuastro-commits] master f58c3211 08/69: PSF model: checking that a PSF image is given for computing flux factor, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master a6788c50 13/69: Book: adding documentation of 'psf-create-make-stamp' script, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 57b27b9e 12/69: PSF scripts: correcting several bugs and homogenizing the notation, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master b14fdf1d 04/69: PSF stamp: fixing wrong directory of this script, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 4c5fe969 17/69: Book: fully working example on how to construct and correct the PSF, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master ccae240f 29/69: PSF stamp: bug in --rmax option introduced in previous commit fixed, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master de1b645b 20/69: PSF stamp: computing radial profile up to the minimum possible value, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 194b49d1 59/69: PSF select-stars: change the name of the two varibales., Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 781f0f33 39/69: PSF scripts: checking that the input file actually exists, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 0a6625ab 61/69: Book: explain about two new option in the psf-create-select-stars, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 6901ec82 49/69: PSF select-stars: check the image and catalog have a overlap area or not,
Mohammad Akhlaghi <=
- [gnuastro-commits] master f9b7edfa 10/69: PSF stamp: removing the option --oversample as it is not enabled, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 81720014 15/69: Book: adding documentation of 'psf-model-flux-factor' script, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 9ca784e4 27/69: PSF select stars: if the image has not stars in `--min` and `--max` range, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master f1cfd384 25/69: PSF select stars: remove --input add --output and --catalog, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master bf8792c2 52/69: Book: For selecting stars some mandatory options did not mention, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master f3619dd5 57/69: Book: edits in the PSF scripts, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master ce020710 41/69: Book: new section for the tutorial on how to construct and extended PSF, Mohammad Akhlaghi, 2022/01/26
- [gnuastro-commits] master 9ab3dd28 51/69: PSF stamp: new option to set a mask sky pixel value: maskskyval, Mohammad Akhlaghi, 2022/01/26
- [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