gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master e38dc602: MakeProfiles: unified function for r


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master e38dc602: MakeProfiles: unified function for reading input columns
Date: Thu, 24 Mar 2022 13:48:03 -0400 (EDT)

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

    MakeProfiles: unified function for reading input columns
    
    Until now, when MakeProfiles was given an input from the standard input and
    the user requested a 3D catalog, MakeProfiles would write the final output,
    but abort with a segmentation fault.
    
    This happened because the inputs for 2D and 3D inputs (which just have a
    different number of columns) are done in separate functions (because the
    number and meaning of the columns change).
    
    We didn't confront this issue in 2D outputs, because this issue (of not
    having a file name for the input when its from standard input) was solved
    there. However, we had forgot to fix it in the same part of the 3D
    function.
    
    With this commit, to avoid having repetative code, a single low-level
    function has been defined for only reading the desired columns and both
    functions simply use that (after they have defined their necessary
    columns). In this way, the bug has been fixed in 3D inputs also, and any
    future bug or added feature just has to be implemented in one place.
    
    Also, while updating this bug notice in the 'NEWS' file, I found some minor
    missed things within the NEWS component of the 0.17 release that have been
    fixed now.
    
    This bug was found by Irene Pintos Castro.
    
    This fixes bug #62216.
---
 NEWS                         | 22 ++++++++++++
 THANKS                       |  1 +
 bin/mkprof/ui.c              | 82 ++++++++++++++++++++++++--------------------
 doc/announce-acknowledge.txt |  2 +-
 4 files changed, 69 insertions(+), 38 deletions(-)

diff --git a/NEWS b/NEWS
index 5c388ced..863fe365 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,22 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
 Copyright (C) 2015-2022 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
+* Noteworthy changes in release X.XX (library XX.X.X) (YYYY-MM-DD) [not yet 
released]
+
+** New features
+
+** Removed features
+
+** Changed features
+
+** Bugs fixed
+  bug #62216: MakeProfiles crash when a 3D cube is requested and input
+              catalog is from a pipe. Found by Irene Pintos Castro.
+
+
+
+
+
 * Noteworthy changes in release 0.17 (library 15.0.0) (2022-03-20)
 
 ** New features
@@ -51,6 +67,10 @@ See the end of the file for license conditions.
           of the PSF, scale it to the star and subtract it from the image.
 
   Book:
+   - New tutorial on how to extract the extended Point Spread Function
+     (PSF) from the actual science data and how to subtract
+     it. Written with the help of Raul Infante-Sainz and Sepideh
+     Eskandarlou.
    - New section called "Skewness cased by signal and its measurement"
      added to the third tutorial (Detecting large extended targets). It
      describes the significant advantages of using the quantile of the mean
@@ -152,6 +172,8 @@ See the end of the file for license conditions.
 
 ** Removed features
 
+   Nothing was removed in this release.
+
 ** Changed features
 
   Arithmetic:
diff --git a/THANKS b/THANKS
index dbc2c2a8..ab6f32cd 100644
--- a/THANKS
+++ b/THANKS
@@ -89,6 +89,7 @@ support in Gnuastro. The list is ordered alphabetically (by 
family name).
     Dmitrii Oparin                       doparin2@gmail.com
     Bertrand Pain                        bertrand.pain@inserm.fr
     William Pence                        william.pence@nasa.gov
+    Irene Pintos Castro                  ipintos@cefca.es
     Mamta Pommier                        mamta.pommier@univ-lyon1.fr
     Marcel Popescu                       mpopescu@iac.es
     Bob Proulx                           bob@proulx.com
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index a446e769..b6b63f7b 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -651,14 +651,47 @@ ui_check_options_and_arguments(struct mkprofparams *p)
 /**************************************************************/
 /***************       Preparations         *******************/
 /**************************************************************/
+static gal_data_t *
+ui_read_cols_general(struct mkprofparams *p, gal_list_str_t *colstrs)
+{
+  gal_data_t *cols;
+  gal_list_str_t *lines;
+
+  /* Reverse the order to make the column orders correspond to how we added
+     them here and avoid possible bugs. */
+  gal_list_str_reverse(&colstrs);
+
+  /* Read the desired columns from the file. */
+  lines=gal_options_check_stdin(p->catname, p->cp.stdintimeout, "input");
+  cols=gal_table_read(p->catname, p->cp.hdu, lines, colstrs,
+                      p->cp.searchin, p->cp.ignorecase, p->cp.numthreads,
+                      p->cp.minmapsize, p->cp.quietmmap, NULL);
+  gal_list_str_free(lines, 1);
+
+  /* The name of the input catalog is only for informative steps from now
+     on (we won't be dealing with the actual file any more). So if the
+     standard input was used (therefore 'catname==NULL', set it to
+     'stdin'). */
+  if(p->catname==NULL)
+    gal_checkset_allocate_copy("standard-input", &p->catname);
+
+  /* Set the number of objects and return the columns. */
+  p->num = cols ? cols->size : 0;
+  return cols;
+}
+
+
+
+
+
 static void
 ui_read_cols_2d(struct mkprofparams *p)
 {
   int checkblank;
   size_t i, counter=0;
   char *colname=NULL, **strarr;
+  gal_list_str_t *ccol, *colstrs=NULL;
   gal_data_t *cols, *tmp, *corrtype=NULL;
-  gal_list_str_t *ccol, *lines, *colstrs=NULL;
 
   /* The coordinate columns are a linked list of strings. */
   ccol=p->ccol;
@@ -668,7 +701,9 @@ ui_read_cols_2d(struct mkprofparams *p)
       ccol=ccol->next;
     }
 
-  /* Add the rest of the columns in a specific order. */
+  /* Add the rest of the columns in a specific order. Later (before
+     reading), we will reverse them, this order here helps in readability
+     at this stage */
   gal_list_str_add(&colstrs, p->fcol, 0);
   gal_list_str_add(&colstrs, p->rcol, 0);
   gal_list_str_add(&colstrs, p->ncol, 0);
@@ -677,26 +712,8 @@ ui_read_cols_2d(struct mkprofparams *p)
   gal_list_str_add(&colstrs, p->mcol, 0);
   gal_list_str_add(&colstrs, p->tcol, 0);
 
-  /* Reverse the order to make the column orders correspond to how we added
-     them here and avoid possible bugs. */
-  gal_list_str_reverse(&colstrs);
-
-  /* Read the desired columns from the file. */
-  lines=gal_options_check_stdin(p->catname, p->cp.stdintimeout, "input");
-  cols=gal_table_read(p->catname, p->cp.hdu, lines, colstrs,
-                      p->cp.searchin, p->cp.ignorecase, p->cp.numthreads,
-                      p->cp.minmapsize, p->cp.quietmmap, NULL);
-  gal_list_str_free(lines, 1);
-
-  /* The name of the input catalog is only for informative steps from now
-     on (we won't be dealing with the actual file any more). So if the
-     standard input was used (therefore 'catname==NULL', set it to
-     'stdin'). */
-  if(p->catname==NULL)
-    gal_checkset_allocate_copy("standard-input", &p->catname);
-
-  /* Set the number of objects. */
-  p->num = cols ? cols->size : 0;
+  /* Read the columns. */
+  cols=ui_read_cols_general(p, colstrs);
 
   /* Put each column's data in the respective internal array. */
   while(cols!=NULL)
@@ -887,8 +904,8 @@ ui_read_cols_3d(struct mkprofparams *p)
   int checkblank;
   size_t i, counter=0;
   char *colname=NULL, **strarr;
+  gal_list_str_t *ccol, *colstrs=NULL;
   gal_data_t *cols, *tmp, *corrtype=NULL;
-  gal_list_str_t *lines, *ccol, *colstrs=NULL;
 
   /* The 3D-specific columns are not mandatory in 'args.h', so we need to
      check here if they are given or not before starting to read them. */
@@ -905,7 +922,9 @@ ui_read_cols_3d(struct mkprofparams *p)
       ccol=ccol->next;
     }
 
-  /* Put the columns a specific order to read. */
+  /* Add the rest of the columns in a specific order. Later (before
+     reading), we will reverse them, this order here helps in readability
+     at this stage */
   gal_list_str_add(&colstrs, p->fcol,  0);
   gal_list_str_add(&colstrs, p->rcol,  0);
   gal_list_str_add(&colstrs, p->ncol,  0);
@@ -917,19 +936,8 @@ ui_read_cols_3d(struct mkprofparams *p)
   gal_list_str_add(&colstrs, p->mcol,  0);
   gal_list_str_add(&colstrs, p->tcol,  0);
 
-  /* Reverse the order to make the column orders correspond to how we added
-     them here and avoid possible bugs. */
-  gal_list_str_reverse(&colstrs);
-
-  /* Read the desired columns from the file. */
-  lines=gal_options_check_stdin(p->catname, p->cp.stdintimeout, "input");
-  cols=gal_table_read(p->catname, p->cp.hdu, lines, colstrs,
-                      p->cp.searchin, p->cp.ignorecase, p->cp.numthreads,
-                      p->cp.minmapsize, p->cp.quietmmap, NULL);
-  gal_list_str_free(lines, 1);
-
-  /* Set the number of objects. */
-  p->num=cols->size;
+  /* Read the columns. */
+  cols=ui_read_cols_general(p, colstrs);
 
   /* Put each column's data in the respective internal array. */
   while(cols!=NULL)
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index b2dac715..a6272ba6 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -1,6 +1,6 @@
 Alphabetically ordered list to acknowledge in the next release.
 
-
+Irene Pintos Castro
 
 
 



reply via email to

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