[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 7769e279 07/39: zeropoint: new options for mag
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 7769e279 07/39: zeropoint: new options for magnitude and keeping the results are added |
Date: |
Wed, 19 Apr 2023 12:18:22 -0400 (EDT) |
branch: master
commit 7769e2796251805cb46685cb214cff70af1ac93a
Author: Sepideh Eskandarlou <sepideh.eskandarlou@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
zeropoint: new options for magnitude and keeping the results are added
Until now, we did not have any option for considering the magnitude range
and keeping the zeropoint obtained from the different aperture.
With this commit, a new option for considering the magnitude range is
added. However, new option for keeping the magnitude versus apperture in
different extension.
---
bin/script/zeropoint.in | 83 +++++++++++++++++++++++++++++++++++++------------
bin/script/zeropoint.mk | 28 ++++++++++++++---
2 files changed, 86 insertions(+), 25 deletions(-)
diff --git a/bin/script/zeropoint.in b/bin/script/zeropoint.in
index 425fb396..f52b76ac 100644
--- a/bin/script/zeropoint.in
+++ b/bin/script/zeropoint.in
@@ -42,6 +42,7 @@ output=""
tmpdir=""
catalog=""
keeptmp=""
+keepzpap=""
refrence=""
aperarcsec=""
cataloghdu=""
@@ -49,7 +50,8 @@ refrencezp=""
racolumn="RA"
refrencehdu=""
deccolumn="DEC"
-version=@VERSION@
+version=@VERSION@magmg
+magnituderange=""
magcolumn="MAGNITUDE"
scriptname=@SCRIPT_NAME@
@@ -86,11 +88,13 @@ $scriptname options:
-d, --deccolumn=STR Declination (Dec) column name of the reference
catalog.
-m, --magcolumn=STR Magnitude column name of the reference catalog.
+ -M, --magnituderange=FLT,FLT Range of the magnitude.
-R, --reference=STR[,STR] Rerence image(s) which based on them zeropoint
of
input will be compute.
-z, --referencezp=FLT[,FLT] Zeropoints of reference images.
-H, --referencehdu=STR/INT HDU/Extension name of number of the refrence
files.
-a, --aperarcsec=FLT[,FLT] Aperure arcseconds.
+ -K, --keepzpap Keep zeropoint of each aperture in different
extension.
Output:
-o, --output Output with zeropoint estimation and best aperture.
@@ -244,24 +248,28 @@ while [ $# -gt 0 ]
do
case "$1" in
# Input parameters.
- -h|--hdu) hdu="$2";
check_v "$1" "$hdu"; shift;shift;;
- -h=*|--hdu=*) hdu="${1#*=}";
check_v "$1" "$hdu"; shift;;
- -h*) hdu=$(echo "$1" | sed -e's/-h//');
check_v "$1" "$hdu"; shift;;
- -c|--catalog) catalog="$2";
check_v "$1" "$catalog"; shift;shift;;
- -c=*|--catalog=*) catalog="${1#*=}";
check_v "$1" "$catalog"; shift;;
- -c*) catalog=$(echo "$1" | sed -e's/-c//');
check_v "$1" "$catalog"; shift;;
- -C|--cataloghdu) cataloghdu="$2";
check_v "$1" "$cataloghdu"; shift;shift;;
- -C=*|--cataloghdu=*) cataloghdu="${1#*=}";
check_v "$1" "$cataloghdu"; shift;;
- -C*) cataloghdu=$(echo "$1" | sed -e's/-C//');
check_v "$1" "$cataloghdu"; shift;;
- -r|--racolumn) racolumn="$2";
check_v "$1" "$racolumn"; shift;shift;;
- -r=*|--racolumn=*) racolumn="${1#*=}";
check_v "$1" "$racolumn"; shift;;
- -r*) racolumn=$(echo "$1" | sed -e's/-r//');
check_v "$1" "$racolumn"; shift;;
- -d|--deccolumn) deccolumn="$2";
check_v "$1" "$deccolumn"; shift;shift;;
- -d=*|--deccolumn=*) deccolumn="${1#*=}";
check_v "$1" "$deccolumn"; shift;;
- -d*) deccolumn=$(echo "$1" | sed -e's/-d//');
check_v "$1" "$deccolumn"; shift;;
- -m|--magcolumn) magcolumn="$2";
check_v "$1" "$magcolumn"; shift;shift;;
- -m=*|--magcolumn=*) magcolumn="${1#*=}";
check_v "$1" "$magcolumn"; shift;;
- -m*) magcolumn=$(echo "$1" | sed -e's/-m//');
check_v "$1" "$magcolumn"; shift;;
+ -h|--hdu) hdu="$2";
check_v "$1" "$hdu"; shift;shift;;
+ -h=*|--hdu=*) hdu="${1#*=}";
check_v "$1" "$hdu"; shift;;
+ -h*) hdu=$(echo "$1" | sed -e's/-h//');
check_v "$1" "$hdu"; shift;;
+ -c|--catalog) catalog="$2";
check_v "$1" "$catalog"; shift;shift;;
+ -c=*|--catalog=*) catalog="${1#*=}";
check_v "$1" "$catalog"; shift;;
+ -c*) catalog=$(echo "$1" | sed -e's/-c//');
check_v "$1" "$catalog"; shift;;
+ -C|--cataloghdu) cataloghdu="$2";
check_v "$1" "$cataloghdu"; shift;shift;;
+ -C=*|--cataloghdu=*) cataloghdu="${1#*=}";
check_v "$1" "$cataloghdu"; shift;;
+ -C*) cataloghdu=$(echo "$1" | sed -e's/-C//');
check_v "$1" "$cataloghdu"; shift;;
+ -r|--racolumn) racolumn="$2";
check_v "$1" "$racolumn"; shift;shift;;
+ -r=*|--racolumn=*) racolumn="${1#*=}";
check_v "$1" "$racolumn"; shift;;
+ -r*) racolumn=$(echo "$1" | sed -e's/-r//');
check_v "$1" "$racolumn"; shift;;
+ -d|--deccolumn) deccolumn="$2";
check_v "$1" "$deccolumn"; shift;shift;;
+ -d=*|--deccolumn=*) deccolumn="${1#*=}";
check_v "$1" "$deccolumn"; shift;;
+ -d*) deccolumn=$(echo "$1" | sed -e's/-d//');
check_v "$1" "$deccolumn"; shift;;
+ -m|--magcolumn) magcolumn="$2";
check_v "$1" "$magcolumn"; shift;shift;;
+ -m=*|--magcolumn=*) magcolumn="${1#*=}";
check_v "$1" "$magcolumn"; shift;;
+ -m*) magcolumn=$(echo "$1" | sed -e's/-m//');
check_v "$1" "$magcolumn"; shift;;
+
+ -M|--magnituderange) magnituderange="$2";
check_v "$1" "$magnituderange"; shift;shift;;
+ -M=*|--magnituderange=*) magnituderange="${1#*=}";
check_v "$1" "$magnituderange"; shift;;
+ -M*) magnituderange=$(echo "$1" | sed -e's/-M//');
check_v "$1" "$magnituderange"; shift;;
-R|--reference) reference="$2";
check_v "$1" "$reference"; shift;shift;;
-R=*|--reference=*) reference="${1#*=}";
check_v "$1" "$reference"; shift;;
-R*) reference=$(echo "$1" | sed -e's/-R//');
check_v "$1" "$reference"; shift;;
@@ -274,7 +282,8 @@ do
-a|--aperarcsec) aperarcsec="$2";
check_v "$1" "$aperarcsec"; shift;shift;;
-a=*|--aperarcsec=*) aperarcsec="${1#*=}";
check_v "$1" "$aperarcsec"; shift;;
-a*) aperarcsec=$(echo "$1" | sed -e's/-a//');
check_v "$1" "$aperarcsec"; shift;;
-
+ -K|--keepzpap) keepzpap=1; shift;;
+ -K*|--keepzpap=*) on_off_option_error --keepzpap -K;;
# Output parameters
-k|--keeptmp) keeptmp=1; shift;;
@@ -325,6 +334,17 @@ EOF
exit 1
fi
+# If the brighter and fainter range of magnitude are not given at all.
+if [ x$magnituderange != x ]; then
+ nmagrange=$(echo $magnituderange | awk 'BEGIN{FS=","}END{print NF}')
+ if [ x$nmagrange != x2 ]; then
+ cat<<EOF
+$scriptname: ERROR: '--magnituderange' (or '-m') only take two values, but
$nmagrange were given
+EOF
+ exit 1
+ fi
+fi
+
@@ -372,6 +392,14 @@ echo "input = $inputs" > $config
echo "output =$output" >> $config
echo "hduinput = $hdu" >> $config
echo "tmpdir = $tmpdir" >> $config
+
+# Obtain the magnitude range from the command line arguments.
+if [ x$magnituderange = x ]; then
+ echo "magrange = " >> $config
+else
+ echo "magrange = $magnituderange" >> $config
+fi
+
# Put the size of the apertures in a variables. The comma should be
# change with a space.
aper=$(echo $aperarcsec | sed 's|,| |g')
@@ -409,6 +437,21 @@ fi
+# Keep the zeropoint of different appertures in different extension.
+# ------------------------------------------------------------------
+#
+# If user specify to keep the zeropoint of the different appeertures it
+# will be saved in the different extension of the output.
+if [ x"$keepzpap" = x ]; then
+ echo "zeropointap = " >> $config
+else
+ echo "zeropointap = keep" >> $config
+fi
+
+
+
+
+
# Call the Makefile
make -f zeropoint.mk tmpdir=$tmpdir
diff --git a/bin/script/zeropoint.mk b/bin/script/zeropoint.mk
index b882d706..0fda8d4f 100644
--- a/bin/script/zeropoint.mk
+++ b/bin/script/zeropoint.mk
@@ -5,7 +5,7 @@
#
# Contributers:
# Copyright (C) 2019-2022 Mohammad Akhlaghi <mohammad@akhlaghi.org>
-# Copyright (C) 2019-2022 Zahra sharbaf <ahra.sharbaf2@gmail.com>
+# Copyright (C) 2019-2022 Zahra sharbaf <zahra.sharbaf2@gmail.com>
# Copyright (C) 2022 Sepideh Eskandarlou <sepideh.eskandarlou@gmail.com>
#
# This Makefile is free software: you can redistribute it and/or modify
@@ -241,17 +241,35 @@ $(aperzeropoint): $(tmpdir)/zeropoint-%.txt: \
#
# Using the standard deviation of the zeropoints for each aperture,
# select the one with the least scatter.
-zeropoint=$(tmpdir)/zeropoint.txt
+zeropoint=$(tmpdir)/zeropoint.fits
$(zeropoint): $(aperzeropoint)
- zp=$(subst .txt,-tmp.txt,$@)
+ zp=$(subst .fits,-tmp.txt,$@)
echo "# Column 1: APERTURE [arcsec,f32,]" > $$zp
echo "# Column 2: ZEROPOINT [mag,f32,]" >> $$zp
echo "# Column 3: ZPSTD [mag,f32,]" >> $$zp
for a in $(aper-arcsec); do
cat $(tmpdir)/zeropoint-$$a.txt >> $$zp
done
- asttable $$zp --sort=ZPSTD --head=1 \
- --column=APERTURE,ZEROPOINT >$@
+ asttable $$zp --output=$@.fits
+ bestzpaper=$$(asttable $$zp --sort=ZPSTD --head=1 \
+ --column=APERTURE,ZEROPOINT)
+
+ astfits $@.fits --write=BESTAPZE,"$$bestzpaper","Beat aperture and
zeropoitn."
+
+ if [ x"$(zeropointap)" = x ]; then
+ mv $@.fits $@
+ else
+ counter=1
+ for i in $(aper-arcsec); do
+ counter=$$((counter+1))
+ astfits $(tmpdir)/zeropoint-$$i-merged.fits --copy=1 -o$@.fits
+ astfits $@.fits -h$$counter --update=EXTNAME,APER-$$i
+ done
+ mv $@.fits $@
+ fi
+
+# Clean up.
+ rm $$zp
- [gnuastro-commits] master 1ddcf29a 06/39: zeropoint: options of zeropoint estimation is written in book, (continued)
- [gnuastro-commits] master 1ddcf29a 06/39: zeropoint: options of zeropoint estimation is written in book, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master c3fc5214 04/39: Zeropoint: add options with variable, Mohammad Akhlaghi, 2023/04/19
- [gnuastro-commits] master d44ce8c0 10/39: zeropoint: use --magrage provided by user, Mohammad Akhlaghi, 2023/04/19
- [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 <=
- [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, 2023/04/19
- [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