gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master c387914: Library (txt.h): other metadata used


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master c387914: Library (txt.h): other metadata used when type can't be read
Date: Thu, 2 Sep 2021 09:41:32 -0400 (EDT)

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

    Library (txt.h): other metadata used when type can't be read
    
    Until now, when the input plain-text table's metadata contains a type
    identifier that is not understood, Gnuastro's plain-text table library
    would ignore the full metadata. However, the numeric data type is an
    optional metadata, and it if doesn't exist, Gnuastro will use a default
    data type (float64). So if it is not understood (usually due to a typo), it
    is unexpected to ignore the metadata over all, we should just use the
    default type.
    
    With this commit, this change has been implemented and the description of
    Gnuastro's plain-text table format has been updated correspondingly.
    
    This bug was reported by Sepideh Eskandarlou.
    
    This fixes bug #61108.
---
 NEWS              |  2 ++
 doc/gnuastro.texi |  5 +++--
 lib/txt.c         | 14 +++++++-------
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index 6024565..738c3ee 100644
--- a/NEWS
+++ b/NEWS
@@ -129,6 +129,8 @@ See the end of the file for license conditions.
   bug #60999: No content check when plain-text table doesn't have metadata.
   bug #61007: Crash due to CFITSIO 4.0.0 version format change, reported by
               Vincenzo Testa and Zohreh Ghaffari.
+  bug #61108: Plain text table metadata ignored when numeric data type was
+              not understood, reported by Sepideh Eskandarlou.
 
 
 
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 20f40f5..20944c0 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -8629,6 +8629,7 @@ A column information comment is assumed to have the 
following format:
 Any sequence of characters between `@key{:}' and `@key{[}' will be interpreted 
as the column name (so it can contain anything except the `@key{[}' character).
 Anything between the `@key{]}' and the end of the line is defined as a comment.
 Within the brackets, anything before the first `@key{,}' is the units 
(physical units, for example km/s, or erg/s), anything before the second 
`@key{,}' is the short type identifier (see below, and @ref{Numeric data 
types}).
+If the type identifier isn't recorgnized, the default 64-bit floating point 
type will be used.
 
 Finally (still within the brackets), any non-white characters after the second 
`@key{,}' are interpreted as the blank value for that column (see @ref{Blank 
pixels}).
 The blank value can either be in the same type as the column (for example 
@code{-99} for a signed integer column), or any string (for example @code{NaN} 
in that same column).
@@ -8636,7 +8637,7 @@ In both cases, the values will be stored in memory as 
Gnuastro's fixed blank val
 For floating point types, Gnuastro's internal blank value is IEEE NaN 
(Not-a-Number).
 For signed integers, it is the smallest possible value and for unsigned 
integers its the largest possible value.
 
-When a formatting problem occurs (for example you have specified the wrong 
type code, see below), or the column was already given meta-data in a previous 
comment, or the column number is larger than the actual number of columns in 
the table (the non-commented or empty lines), then the comment information line 
will be ignored.
+When a formatting problem occurs, or when the column was already given 
meta-data in a previous comment, or when the column number is larger than the 
actual number of columns in the table (the non-commented or empty lines), then 
the comment information line will be ignored.
 
 When a comment information line can be used, the leading and trailing white 
space characters will be stripped from all of the elements.
 For example in this line:
@@ -8653,7 +8654,7 @@ Hence, in the example above, the @code{BLANK} field will 
be given the value of `
 Except for the column number (@code{N}), the rest of the fields are optional.
 Also, the column information comments don't have to be in order.
 In other words, the information for column @mymath{N+m} (@mymath{m>0}) can be 
given in a line before column @mymath{N}.
-Also, you don't have to specify information for all columns.
+Furthermore, you don't have to specify information for all columns.
 Those columns that don't have this information will be interpreted with the 
default settings (like the case above: values are double precision floating 
point, and the column has no name, unit, or comment).
 So these lines are all acceptable for any table (the first one, with nothing 
but the column number is redundant):
 
diff --git a/lib/txt.c b/lib/txt.c
index 171ca37..8f4b706 100644
--- a/lib/txt.c
+++ b/lib/txt.c
@@ -245,12 +245,11 @@ txt_info_from_comment(char *in_line, gal_data_t **datall, 
char *comm_start,
 
 
       /* If 'typestr' was given, then check if this is a standard type. If
-         'typestr' wasn't specified, then the default double type code will
-         be used (see the variable definitions above). If the given type
-         isn't a standard type then ignore the line. Just note that if we
-         are dealing with the string type, we have to pull out the number
-         part first. If there is no number for a string type, then ignore
-         the line. */
+         'typestr' wasn't specified or couldn't be interpretted, then the
+         default double type code will be used (see the variable
+         definitions above). Just note that if we are dealing with the
+         string type, we have to pull out the number part first. If there
+         is no number for a string type, then ignore the line. */
       if(typestr && *typestr!='\0')
         {
           typestr=gal_txt_trim_space(typestr);
@@ -263,7 +262,8 @@ txt_info_from_comment(char *in_line, gal_data_t **datall, 
char *comm_start,
           else
             {
               type=gal_type_from_name(typestr);
-              if(type==GAL_TYPE_INVALID) return;
+              if(type==GAL_TYPE_INVALID)
+                type=GAL_TYPE_FLOAT64;
             }
         }
 



reply via email to

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