gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 4f3d70d 20/32: Binning data in some case


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 4f3d70d 20/32: Binning data in some case
Date: Wed, 24 Feb 2021 22:36:18 -0500 (EST)

branch: master
commit 4f3d70d21c8e35d9e30b48ebcdaa0494437ab9f3
Author: Zahra Sharbaf <zahra.sharbaf2@gmail.com>
Commit: Zahra Sharbaf <zahra.sharbaf2@gmail.com>

    Binning data in some case
    
    With this commit, I did some small change to do binning the data for the
    time that user set binning variable except 1.
---
 bin/script/radial-profile.in | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/bin/script/radial-profile.in b/bin/script/radial-profile.in
index 8f5559e..b192ecc 100644
--- a/bin/script/radial-profile.in
+++ b/bin/script/radial-profile.in
@@ -398,23 +398,27 @@ astmkcatalog $aperturesfits -h1 --valuesfile=$inputs 
--valueshdu=$hdu \
 # ------------
 #
 # In order to increase the signal-to-noise ratio of the radial profile, it
-# is possible to bin the data. It is done in any case, if the user has not
-# changed the default value, the binning will be equal to 1 so the output
-# binned will be the same as the input. To do the binning of the data, a
-# small Awk script is used. Since the Awk script will print the columns as
-# float values, it is necessary to change the headers. To do that, Sed is
-# used to replace all ocurrences of i32 to f32.
+# is possible to bin the data. It is done in any case, if the user set the
+# default value of binning variable($b) except 1, because the binning will
+# be equal to 1 so the output binned will be the same as the input. To do
+# the binning of the data, a small Awk script is used. Since the Awk script
+# will print the columns as float values, it is necessary to change the
+# headers. To do that, Sed is used to replace all ocurrences of i32 to f32.
 bprofile=$(echo $output | sed -e"s|.fits|_binned.fits|g")
-asttable $fprofile \
-         | awk -v b=$b '/^#/{print} BEGIN { N = b }                            
                                                                                
                        { for (i = 1; i <= 2; i++)                              
                                                                                
            sum[i] += $i}
-                      { for (i = 3; i == 3; i++) sum[i] = $i ** 2 / $i ** 0.5}
+if [ $b != 1 ]; then
+
+  asttable $fprofile \
+           | awk -v b=$b '/^#/{print} BEGIN { N = b }                          
                                                                                
                    { for (i = 1; i <= 2; i++) sum[i] += $i}
+                                 { for (i = 3; i == 3; i++) sum[i] += $i ** 2}
            NR % N == 0 { for (i = 1; i <= NF; i++)
                           {
                             printf("%.6f%s",sum[i]/N, ( i == NF) ? "\n" : " ")
                             sum[i] = 0
                           }
                         }' | asttable -o$bprofile
-
+else
+  cp $fprofile $bprofile
+fi
 
 
 



reply via email to

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