gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 950b91a: MakeProfiles: NaN value in custom pro


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 950b91a: MakeProfiles: NaN value in custom profile will be NaN in output
Date: Fri, 2 Apr 2021 16:22:12 -0400 (EDT)

branch: master
commit 950b91a60b7133015c939d42c0ce1c8f2251808c
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    MakeProfiles: NaN value in custom profile will be NaN in output
    
    Until now, when MakeProfiles was given a custom profile with a NaN value it
    would put a 0 for those pixels. This didn't conform with the documentation
    (which claimed that any value given to the third column will be
    used). Also, it could cause a confusion for radii that are in the custom
    profile (but with a value of NaN), and radii that are not in the custom
    profile's range.
    
    This wrong feature was manually inserted at the end of the custom profile
    function: we would check the output value, and if it was NaN, we would
    insert a 0 instead!
    
    With this commit, the feature the raw value from the user's catalog is used
    and the 'out' value for the custom profile function is initialized to
    '0.0', so the function has also been polished/cleaned for this.
    
    This has also been reflected inside the documentation. Also, I noticed that
    in the book, two commands were given to construct the custom table, one
    with Gnuastro's Table and one with AWK. But because they were under each
    other in a single code block, it could confuse the readers on a first
    reading. Also, the extra explanation made the description long and
    confusing. So the AWK command has been removed with this commit.
    
    This issue was reported by Carlos Morales Socorro.
---
 bin/mkprof/profiles.c        | 10 ++++------
 doc/announce-acknowledge.txt |  1 +
 doc/gnuastro.texi            | 20 ++++++++++----------
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/bin/mkprof/profiles.c b/bin/mkprof/profiles.c
index ebd69ac..d6a3984 100644
--- a/bin/mkprof/profiles.c
+++ b/bin/mkprof/profiles.c
@@ -56,19 +56,18 @@ profiles_radial_distance(struct mkonthread *mkp)
 double
 profiles_custom_table(struct mkonthread *mkp)
 {
-  double out;
-  long i;  /* May become negative. */
+  long i; /* May become negative. */
   double *reg=mkp->p->customregular;
   double *min=mkp->p->custom->array;
   double *max=mkp->p->custom->next->array;
   double *value=mkp->p->custom->next->next->array;
+  double out=0.0f; /* Zero means no value, user may want a NaN value! */
 
   /* If the table isn't regular ('reg[0]' isn't NaN), then we have to parse
      over the whole table. However, if its regular, we can find the proper
      value much more easily. */
   if( isnan(reg[0]) )
     {
-      out=0;
       for(i=0;i<mkp->p->custom->size;++i)
         if( mkp->r >= min[i] && mkp->r < max[i] )
           { out=value[i]; break; }
@@ -76,12 +75,11 @@ profiles_custom_table(struct mkonthread *mkp)
   else
     {
       i=(mkp->r - reg[0])/reg[1];
-      if(i<0 || i>mkp->p->custom->size) out=0;
-      else                                   out=value[i];
+      if(i>=0 && i<=mkp->p->custom->size) out=value[i];
     }
 
   /* Return the output value. */
-  return isnan(out) ? 0 : out;
+  return out;
 }
 
 
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 42c395e..99e3627 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -4,6 +4,7 @@ Mark Calabretta
 Raul Infante-Sainz
 Alberto Madrigal
 Juan Miro
+Carlos Morales Socorro
 Sylvain Mottet
 Francois Ochsenbein
 Samane Raji
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 323c7c3..589c166 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -11076,7 +11076,7 @@ If this option is given, the raw string is directly 
passed to the server and all
 With the high-level options (like @option{--column}, @option{--center}, 
@option{--radius}, @option{--range} and other constraining options below), the 
low-level query will be constructed automatically for the particular database.
 This method is only limited to the generic capabilities that Query provides 
for all servers.
 So @option{--query} is more powerful, however, in this mode, you don't need 
any knowledge of the database's query language.
-You can see the internally generated query on the terminal (if 
@option{--quiet} is not used) or in the 0-th extension of the output (if its a 
FITS file).
+You can see the internally generated query on the terminal (if 
@option{--quiet} is not used) or in the 0-th extension of the output (if it is 
a FITS file).
 This full command contains the internally generated query.
 @end itemize
 
@@ -19302,11 +19302,11 @@ Also note that in such cases, besides de-convolution, 
you will have to set @opti
 
 @item --customtable FITS/TXT
 The filename of the table to use in the custom profiles (see description of 
@option{--fcol} in @ref{MakeProfiles catalog}.
-This can be a plain-text table, or FITS table, see @ref{Tables}, if its a FITS 
table, you can use @option{--customtablehdu} to specify which HDU should be 
used (described below).
+This can be a plain-text table, or FITS table, see @ref{Tables}, if it is a 
FITS table, you can use @option{--customtablehdu} to specify which HDU should 
be used (described below).
 
-A custom profile can have any value you want for a given radial profile.
-Each interval is defined by its minimum (inclusive) and maximum (exclusive) 
radius, when a pixel falls within this radius the value specified for that 
interval will be used.
-If a pixel is not in the given intervals, a value of 0 will be used for it.
+A custom profile can have any value you want for a given radial profile 
(including NaN/blank values).
+Each interval is defined by its minimum (inclusive) and maximum (exclusive) 
radius, when a pixel center falls within a radius interval, the value specified 
for that interval will be used.
+If a pixel is not in the given intervals, a value of 0.0 will be used for that 
pixel.
 
 The table should have 3 columns as shown below.
 If the intervals are contiguous (the maximum value of the previous interval is 
equal to the minimum value of an interval) and the intervals all have the same 
size (difference between minimum and maximum values) the creation of these 
profiles will be fast.
@@ -19318,11 +19318,11 @@ The interval's minimum radius.
 @item Column 2:
 The interval's maximum radius.
 @item Column 3:
-The value to be used for pixels within the given interval.
+The value to be used for pixels within the given interval (including 
NaN/blank).
 @end table
 
 For example let's assume you have the radial profile below in a file called 
@file{radial.txt}.
-The first column is the larger interval radius and the second column is the 
value in that interval:
+The first column is the larger interval radius (in units of pixels) and the 
second column is the value in that interval:
 
 @example
 1    100
@@ -19335,15 +19335,15 @@ The first column is the larger interval radius and 
the second column is the valu
 @end example
 
 @noindent
-You can construct the table to give to @option{--customtable} with either of 
the commands below: the first one with Gnuastro's @ref{Column arithmetic} which 
can also work on FITS tables, and the second one with an AWK command that only 
works on plain-text tables..
+You can construct the table to give to @option{--customtable} with the command 
below (using Gnuastro's @ref{Column arithmetic}).
 
 @example
 asttable radial.fits -c'arith $1 1 -' -c1,2 -ocustom.fits
-awk '@{print $1-1, $1, $2@}' radial.txt > custom.txt
 @end example
 
 @noindent
-In case the intervals are different from 1 (for example 0.5), change them 
respectively: for Gnuastro's table change @code{$1 1 -} to @code{$1 0.5 -} and 
for AWK change  @code{$1-1} to @code{$1-0.5}.
+In case the intervals are different from 1 (for example 0.5), change the 
@code{$1 1 -} to @code{$1 0.5 -}.
+On a side-note, Gnuastro has features to extract the radial profile of an 
object from the image, see @ref{Generate radial profile}.
 
 
 @item --customtablehdu INT/STR



reply via email to

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