gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master c33b313: MakeCatalog: corrected potential issu


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master c33b313: MakeCatalog: corrected potential issue in cpscorr estimation
Date: Wed, 6 Nov 2019 09:51:49 -0500 (EST)

branch: master
commit c33b3132cc009838247ef92bcd8b5ba98822a134
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    MakeCatalog: corrected potential issue in cpscorr estimation
    
    In the previous commit where the counter-per-second correction
    (`p->cpscorr') was also set for numbers, I had just used it as an `else' to
    `if(p->std && p->std->size>1)'. So if no `std' was given at all, it would
    also go and attempt to find `cpscorr'.
    
    With this commit, this is fixed by separating the two statements in the
    `if' above: the `std' number is only read when `p->std' is defined.
---
 bin/mkcatalog/ui.c | 67 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 35 insertions(+), 32 deletions(-)

diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index 084d78e..adcfe46 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -1312,42 +1312,45 @@ ui_preparations_read_keywords(struct mkcatalogparams *p)
   float std, minstd;
   gal_data_t *keys=NULL;
 
-  /* When a Sky standard deviation dataset (not number) is given. */
-  if(p->std && p->std->size>1)
+  /* Set the counts-per-second correction. */
+  if(p->std)
     {
-      /* Read the keywords from the standard deviation image. */
-      keys=gal_data_array_calloc(2);
-      keys[0].next=&keys[1];
-      keys[0].name="MINSTD";              keys[1].name="MEDSTD";
-      keys[0].type=GAL_TYPE_FLOAT32;      keys[1].type=GAL_TYPE_FLOAT32;
-      keys[0].array=&minstd;              keys[1].array=&p->medstd;
-      gal_fits_key_read(p->usedstdfile, p->stdhdu, keys, 0, 0);
-
-      /* If the two keywords couldn't be read. We don't want to slow down
-         the user for the median (which needs sorting). So we'll just
-         calculate the minimum which is necessary for the `p->cpscorr'. */
-      if(keys[1].status) p->medstd=NAN;
-      if(keys[0].status)
+      if(p->std->size>1)
         {
-          /* Calculate the minimum STD. */
-          tmp=gal_statistics_minimum(p->std);
-          minstd=*((float *)(tmp->array));
-          gal_data_free(tmp);
+          /* Read the keywords from the standard deviation image. */
+          keys=gal_data_array_calloc(2);
+          keys[0].next=&keys[1];
+          keys[0].name="MINSTD";              keys[1].name="MEDSTD";
+          keys[0].type=GAL_TYPE_FLOAT32;      keys[1].type=GAL_TYPE_FLOAT32;
+          keys[0].array=&minstd;              keys[1].array=&p->medstd;
+          gal_fits_key_read(p->usedstdfile, p->stdhdu, keys, 0, 0);
+
+          /* If the two keywords couldn't be read. We don't want to slow down
+             the user for the median (which needs sorting). So we'll just
+             calculate the minimum which is necessary for the `p->cpscorr'. */
+          if(keys[1].status) p->medstd=NAN;
+          if(keys[0].status)
+            {
+              /* Calculate the minimum STD. */
+              tmp=gal_statistics_minimum(p->std);
+              minstd=*((float *)(tmp->array));
+              gal_data_free(tmp);
 
-          /* If the units are in variance, then take the square root. */
-          if(p->variance) minstd=sqrt(minstd);
-        }
-      p->cpscorr = minstd>1 ? 1.0f : minstd;
+              /* If the units are in variance, then take the square root. */
+              if(p->variance) minstd=sqrt(minstd);
+            }
+          p->cpscorr = minstd>1 ? 1.0f : minstd;
 
-      /* Clean up. */
-      keys[0].name=keys[1].name=NULL;
-      keys[0].array=keys[1].array=NULL;
-      gal_data_array_free(keys, 2, 1);
-    }
-  else
-    {
-      std=((float *)(p->std->array))[0];
-      p->cpscorr=std>1 ? 1.0f : std;
+          /* Clean up. */
+          keys[0].name=keys[1].name=NULL;
+          keys[0].array=keys[1].array=NULL;
+          gal_data_array_free(keys, 2, 1);
+        }
+      else
+        {
+          std=((float *)(p->std->array))[0];
+          p->cpscorr=std>1 ? 1.0f : std;
+        }
     }
 }
 



reply via email to

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