gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 96137885 09/39: Zeropoint: keep Mag-vs-Zeropoi


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 96137885 09/39: Zeropoint: keep Mag-vs-Zeropoint for best aperture in output
Date: Wed, 19 Apr 2023 12:18:23 -0400 (EDT)

branch: master
commit 96137885426be82afcdbe9cf173154ed3e1bfff4
Author: Sepideh Eskandarlou <sepideh.eskandarlou@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Zeropoint: keep Mag-vs-Zeropoint for best aperture in output
    
    Until now, if the user did not use the '--keepzpap' option best aperture
    and its zeropoint just was written in header of output. Although, for input
    image we did not consider any value for the input Zeropoint.
    
    With this commit, even if user do not use the '--keepzpap' option the
    Magnitude versus Zeropoint table is saved in the second extension of the
    output.  On the other hand, in making the catalog Zeropoint of the input
    image consider as zero.
---
 bin/script/zeropoint.in | 20 +++++++++++++-------
 bin/script/zeropoint.mk | 44 +++++++++++++++++++++++++++++++++-----------
 2 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/bin/script/zeropoint.in b/bin/script/zeropoint.in
index f52b76ac..0bb04f80 100644
--- a/bin/script/zeropoint.in
+++ b/bin/script/zeropoint.in
@@ -388,10 +388,11 @@ fi
 # At first the user wants to compute the Zeropoint for input image based on
 # the images or catalog.
 config=$tmpdir/zeropoint.conf
-echo "input = $inputs" > $config
-echo "output =$output" >> $config
-echo "hduinput = $hdu" >> $config
-echo "tmpdir = $tmpdir" >> $config
+echo "input    = $inputs"  > $config
+echo "output   = $output" >> $config
+echo "hduinput = $hdu"    >> $config
+echo "zpinput  = 0"       >> $config
+echo "tmpdir   = $tmpdir" >> $config
 
 # Obtain the magnitude range from the command line arguments.
 if [ x$magnituderange = x ]; then
@@ -443,9 +444,9 @@ fi
 # 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
+    echo "keepzpap =    " >> $config
 else
-    echo "zeropointap = keep" >> $config
+    echo "keepzpap = keep" >> $config
 fi
 
 
@@ -453,7 +454,12 @@ fi
 
 
 # Call the Makefile
-make -f zeropoint.mk tmpdir=$tmpdir
+if [ x$installdir = x ]; then
+    mksrc=zeropoint.mk
+else
+    mksrc=$installdir/zeropoint.mk
+fi
+make -f $mksrc tmpdir=$tmpdir
 
 
 
diff --git a/bin/script/zeropoint.mk b/bin/script/zeropoint.mk
index b3f4c22b..8a87552b 100644
--- a/bin/script/zeropoint.mk
+++ b/bin/script/zeropoint.mk
@@ -219,6 +219,7 @@ $(aperzeropoint): $(tmpdir)/zeropoint-%.txt: \
 #      Merge all the rows from all the reference images into one.
        merged=$(subst .txt,-merged.fits,$@)
        asttable $(tmpdir)/ref1-$*-magdiff.fits $$opts -o$$merged
+       astfits $$merged --update=EXTNAME,APER-$*
 
 #      If the user requested a certain magnitude range, use it.
        rangeopt=""
@@ -243,6 +244,8 @@ $(aperzeropoint): $(tmpdir)/zeropoint-%.txt: \
 # select the one with the least scatter.
 zeropoint=$(output)
 $(zeropoint): $(aperzeropoint)
+
+#      Obtained the zeropoint and zeropoint std of each apertures.
        zp=$(subst .fits,-tmp.txt,$@)
        echo "# Column 1: APERTURE  [arcsec,f32,]" > $$zp
        echo "# Column 2: ZEROPOINT [mag,f32,]"  >> $$zp
@@ -250,20 +253,39 @@ $(zeropoint): $(aperzeropoint)
        for a in $(aper-arcsec); do
          cat $(tmpdir)/zeropoint-$$a.txt        >> $$zp
        done
-       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
+#      Find the best aperture and its zeropoint and write in the header of
+#      the output.
+       asttable $$zp --output=$@.fits
+       bestaper=$$(asttable $$zp --sort=ZPSTD --head=1 --column=APERTURE)
+       bestzp=$$(asttable $$zp --sort=ZPSTD --head=1  --column=ZEROPOINT)
+       beststd=$$(asttable $$zp --sort=ZPSTD --head=1  --column=ZPSTD)
+       astfits $@.fits --write=/,"Zeropoint properties"
+       astfits $@.fits --write=ZPAPER,"$$bestaper","Best aperture."
+       astfits $@.fits --write=ZPVALUE,"$$bestzp","Best zeropoint."
+       astfits $@.fits --write=ZPSTD,"$$beststd","Best standard deviation of 
zeropoint."
+
+       if [ x"$(keepzpap)" = x ]; then
+
+#         The 'bestaper' above is returned from 'asttable', so (which is
+#         saved as a floating point), so the extra digits in reading
+#         floating points
+          for a in $(aper-arcsec); do
+            check=$$(echo $$a \
+                          | awk -vb=$$bestaper \
+                                '$$1>b-1e-6 && $$1<b+1e-6{print "yes"}')
+            if [ x$$check == xyes ]; then bestaperstr=$$a; fi
+          done
+
+#         Move the main table to the output and copy the Mag-vs-Zeroppoint
+#         plot for the best aperture.
+          astfits $(tmpdir)/zeropoint-$$bestaperstr-merged.fits --copy=1 
-o$@.fits
           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
+#         Move the main table to the output and copy the Mag-vs-Zeroppoint
+#         plot for the whole aperture.
+         for a in $(aper-arcsec); do
+           astfits $(tmpdir)/zeropoint-$$a-merged.fits --copy=1 -o$@.fits
          done
          mv $@.fits $@
        fi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]