gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 2df5a22 19/32: Signal to noise ratio for each


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 2df5a22 19/32: Signal to noise ratio for each radius
Date: Wed, 24 Feb 2021 22:36:18 -0500 (EST)

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

    Signal to noise ratio for each radius
    
    With this commit, Signal to noise ratio has been added as part of the
    radial profile. This can be useful for the time that you want to compare
    the radial profile of different stars.
---
 bin/script/radial-profile.in | 81 +++++++++++++++++++++++++++++---------------
 1 file changed, 53 insertions(+), 28 deletions(-)

diff --git a/bin/script/radial-profile.in b/bin/script/radial-profile.in
index 1ab9210..8f5559e 100644
--- a/bin/script/radial-profile.in
+++ b/bin/script/radial-profile.in
@@ -44,8 +44,10 @@ w=1
 k=1
 X="1 x"
 Y="1 x"
+Z="1 x"
 i="radius"
 j="v"
+l="S/N"
 quiet=0
 prefix=./
 output="default"
@@ -232,12 +234,18 @@ do
         -Y|--yarith)     Y="$2";                            check_v "$1" "$Y"; 
 shift;shift;;
         -Y=*|--yarith=*) Y="${1#*=}";                       check_v "$1" "$Y"; 
 shift;;
         -Y*)             Y=$(echo "$1"  | sed -e's/-Y//');  check_v "$1" "$Y"; 
 shift;;
+        -Z|--zarith)     Z="$2";                            check_v "$1" "$Z"; 
 shift;shift;;
+        -Z=*|--zarith=*) Z="${1#*=}";                       check_v "$1" "$Z"; 
 shift;;
+        -Z*)             Z=$(echo "$1"  | sed -e's/-Z//');  check_v "$1" "$Z"; 
 shift;;
         -i|--iname)      i="$2";                            check_v "$1" "$i"; 
 shift;shift;;
         -i=*|--iname=*)  i="${1#*=}";                       check_v "$1" "$i"; 
 shift;;
         -i*)             i=$(echo "$1"  | sed -e's/-i//');  check_v "$1" "$i"; 
 shift;;
         -j|--jname)      j="$2";                            check_v "$1" "$j"; 
 shift;shift;;
         -j=*|--jname=*)  j="${1#*=}";                       check_v "$1" "$j"; 
 shift;;
         -j*)             j=$(echo "$1"  | sed -e's/-j//');  check_v "$1" "$j"; 
 shift;;
+        -l|--lname)      l="$2";                            check_v "$1" "$k"; 
 shift;shift;;
+        -l=*|--lname=*)  l="${1#*=}";                       check_v "$1" "$k"; 
 shift;;
+        -l*)             l=$(echo "$1"  | sed -e's/-l//');  check_v "$1" "$k"; 
 shift;;
 
         # Output parameters
         -k|--keeptemp)    k=0; shift;;
@@ -357,16 +365,30 @@ astmkprof $aperturestxt --background=$inputs 
--backhdu=$hdu \
 
 
 
+# Detection signal
+# ----------------
+#
+# To obtain signal to noise ratio for each radial profile; at first we have
+# to detect signal of noise.
+detection=$(echo $output | sed -e"s|.fits|_detected.fits|g")
+astnoisechisel $inputs -o$detection
+
+
+
+
+
 # Obtain the radial profile
 # -------------------------
 #
-# The radial profile is obtained using Catalog. In practice, what is done is
-# to obtain a catalogue using the segmentation image previously generated
-# (the elliptical apertures) and the original input image for computing the
-# values.
+# The radial profile is obtained using Catalog. In practice, what is done
+# is to obtain a catalogue using the segmentation image previously
+# generated (the elliptical apertures) and the original input image for
+# computing the values. Also using of SKY_STD extinction of noisechisel
+# output for computing signal to noise ratio.
 fprofile=$(echo $output | sed -e"s|.fits|_catalogue.fits|g")
 astmkcatalog $aperturesfits -h1 --valuesfile=$inputs --valueshdu=$hdu \
-             --ids --$m --config=$c -o$fprofile
+             --instd=$detection --stdhdu=SKY_STD --ids --$m --sn \
+             --config=$c -o$fprofile
 
 
 
@@ -384,16 +406,14 @@ astmkcatalog $aperturesfits -h1 --valuesfile=$inputs 
--valueshdu=$hdu \
 # 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 <= NF; i++) sum[i] += $i }
-               NR % N == 0 { for (i = 1; i <= NF; i++)
-                             {
-                               printf("%.6f%s", sum[i]/N, (i == NF) ? "\n" : " 
")
-                               sum[i] = 0
-                             }
-                           }' \
-         | asttable -o$bprofile
+         | 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}
+           NR % N == 0 { for (i = 1; i <= NF; i++)
+                          {
+                            printf("%.6f%s",sum[i]/N, ( i == NF) ? "\n" : " ")
+                            sum[i] = 0
+                          }
+                        }' | asttable -o$bprofile
 
 
 
@@ -414,21 +434,23 @@ asttable $fprofile \
 # The metadata consists in the column names and comment about the
 # modification by the operation. First column is the radius in pixels, the
 # name of this column is set by the parameter --i (set to radius by
-# default). Second column is the measured values, the name of this column is
-# set by the parameter --j (set to v by default). If the user does not give
-# a name for the second column, the output name will be the combination of
-# the default and the operator used for measuring in the apertures. For
-# example, if the user choose the mean to make the measure (--measure or -m)
-# and do not specify any name for the output column (--jname or -j), the
-# output column name will be: vmean. The reason of adding the character v to
-# the operator is because it may happen that in later step, the user will
-# use the column value with the Table program. If this is the case, the
-# program will crash because it will mix the name of the operator with the
-# name of the column.
-
+# default). Second column is the measured values, the name of this column
+# is set by the parameter --j (set to v by default). Third column is the
+# S/N values, the name of this column is set by the parameter --l (set to
+# S/N by default). If the user does not give a name for the second column,
+# the output name will be the combination of the default and the operator
+# used for measuring in the apertures. For example, if the user choose the
+# mean to make the measure (--measure or -m) and do not specify any name
+# for the output column (--jname or -j), the output column name will be:
+# vmean. The reason of adding the character v to the operator is because it
+# may happen that in later step, the user will use the column value with
+# the Table program. If this is the case, the program will crash because it
+# will mix the name of the operator with the name of the column.
+#
 # Column names
 xcolname=$i
 ycolname=$j
+zcolname=$l
 if [ z$j = zv ]; then
   ycolname=$j$m
 fi
@@ -436,12 +458,14 @@ fi
 aprofile=$(echo $output | sed -e"s|.fits|_arith.fits|g")
 echo "# Column 1: $xcolname [modified,f32,] Binned $b and arith $X" > $aprofile
 echo "# Column 2: $ycolname [modified,f32,] Binned $b and arith $Y" >> 
$aprofile
+echo "# Column 3: $zcolname [modified,f32,] Binned $b and arith $Z" >> 
$aprofile
 
 # Make the appropiate operation over the two columns of the radial profile
 # and add it to the temporal file with the meta-data.
 asttable $bprofile \
          -c'arith $1 '"$X" \
-         -c'arith $2 '"$Y" >> $aprofile
+         -c'arith $2 '"$Y" \
+         -c'arith $3 '"$Z" >> $aprofile
 
 # Finally, read the temporal file with the metadata information as well as
 # the radial profile values, and save it as a fits table using Table.
@@ -466,6 +490,7 @@ if [ $k = 1 ]; then
   rm $aprofile \
      $bprofile \
      $fprofile \
+     $detection \
      $aperturestxt \
      $aperturesfits
 fi



reply via email to

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