[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master e7dce2f: MakeCatalog: correcting accounting fo
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master e7dce2f: MakeCatalog: correcting accounting for ordered columns with no pixels |
Date: |
Sat, 23 May 2020 15:33:31 -0400 (EDT) |
branch: master
commit e7dce2f12190afbb6e185debadf7fd193c2e80fb
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
MakeCatalog: correcting accounting for ordered columns with no pixels
Until now, when some of MakeCatalog's input labels didn't cover any usable
pixels (for example on the 'values' dataset, all the pixels under a label
were NaN), and a column was requested that required ordering (for example
'--median'), MakeCatalog will crash with this error message.
gal_data_initialize: dsize[0]==0. The size of a dimension cannot be zero
This happened because at the start of the function to deal with columns
that need ordering ('parse_order_based'), we would immediately try to
allocate the necessary array to keep the object values (to be
sorted). However, in the situation above, the number of elemnts to allocate
was zero and that would cause this problem.
With this commit, instead of immediately allocating the array, first we
check if there are actually any pixels or not. If there aren't we'll just
write a '0' or NaN in the respective column and leave the function (won't
bother going down to the next steps causing this error).
In the meantime, I also noticed that when writing the sigma-clipping
columns for the clumps, we were mistakenly writing in the wrong array
('pp->ci'), it should have been 'ci'! So this potential/future bug is also
fixed with this commit.
This bug was found while working on a project with Raúl Infante Sainz and
Zahra Sharbaf.
This fixes bug #58434.
---
NEWS | 15 ++++++++++++++
bin/mkcatalog/parse.c | 47 +++++++++++++++++++++++++++++++++-----------
doc/announce-acknowledge.txt | 2 ++
3 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/NEWS b/NEWS
index f918dd3..fb7d08d 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,21 @@ GNU Astronomy Utilities NEWS -*-
outline -*-
Copyright (C) 2015-2020 Free Software Foundation, Inc.
See the end of the file for license conditions.
+* Noteworthy changes in release X.XX (library XX.X.X) (XXXX-XX-XX) [stable]
+
+** New features
+
+** Removed features
+
+** Changed features
+
+** Bugs fixed
+ bug #58434: MakeCatalog crash when ordering is required and no usable pixels
+
+
+
+
+
* Noteworthy changes in release 0.12 (library 10.0.0) (2020-05-20) [stable]
** New features
diff --git a/bin/mkcatalog/parse.c b/bin/mkcatalog/parse.c
index d92b5e6..4dc665a 100644
--- a/bin/mkcatalog/parse.c
+++ b/bin/mkcatalog/parse.c
@@ -1071,14 +1071,39 @@ parse_order_based(struct mkcatalog_passparams *pp)
float *sigcliparr;
gal_data_t *result;
int32_t *O, *OO, *C=NULL;
- gal_data_t **clumpsvals=NULL;
size_t i, increment=0, num_increment=1;
+ gal_data_t *objvals=NULL, **clumpsvals=NULL;
size_t *tsize=pp->tile->dsize, ndim=p->objects->ndim;
size_t counter=0, *ccounter=NULL, tmpsize=pp->oi[OCOL_NUM];
- gal_data_t *objvals=gal_data_alloc(NULL, p->values->type, 1, &tmpsize, NULL,
- 0, p->cp.minmapsize, p->cp.quietmmap,
- NULL, NULL, NULL);
+ /* It may happen that there are no usable pixels for this object (and
+ thus its possible clumps). In this case `tmpsize' will be zero and we
+ can just write NaN values for the necessary columns. */
+ if(tmpsize==0)
+ {
+ if(p->oiflag[ OCOL_MEDIAN ]) pp->oi[ OCOL_MEDIAN ] = NAN;
+ if(p->oiflag[ OCOL_SIGCLIPNUM ]) pp->oi[ OCOL_SIGCLIPNUM ] = 0;
+ if(p->oiflag[ OCOL_SIGCLIPSTD ]) pp->oi[ OCOL_SIGCLIPSTD ] = 0;
+ if(p->oiflag[ OCOL_SIGCLIPMEAN ]) pp->oi[ OCOL_SIGCLIPMEAN ] = NAN;
+ if(p->oiflag[ OCOL_SIGCLIPMEDIAN ]) pp->oi[ OCOL_SIGCLIPMEDIAN] = NAN;
+ if(p->clumps)
+ for(i=0;i<pp->clumpsinobj;++i)
+ {
+ ci=&pp->ci[ i * CCOL_NUMCOLS ];
+ if(p->ciflag[ CCOL_MEDIAN ]) ci[ CCOL_MEDIAN ] = NAN;
+ if(p->ciflag[ CCOL_SIGCLIPNUM ]) ci[ CCOL_SIGCLIPNUM ] = 0;
+ if(p->ciflag[ CCOL_SIGCLIPSTD ]) ci[ CCOL_SIGCLIPSTD ] = 0;
+ if(p->ciflag[ CCOL_SIGCLIPMEAN ]) ci[ CCOL_SIGCLIPMEAN ] = NAN;
+ if(p->ciflag[ CCOL_SIGCLIPMEDIAN ]) ci[CCOL_SIGCLIPMEDIAN] = NAN;
+ }
+ return;
+ }
+
+ /* We know we have pixels to use, so allocate space for the values within
+ the object. */
+ objvals=gal_data_alloc(NULL, p->values->type, 1, &tmpsize, NULL, 0,
+ p->cp.minmapsize, p->cp.quietmmap, NULL, NULL,
+ NULL);
/* Allocate space for the clump values. */
if(p->clumps)
@@ -1209,16 +1234,16 @@ parse_order_based(struct mkcatalog_passparams *pp)
p->sigmaclip[1], 1, 1);
sigcliparr=result->array;
if(p->ciflag[ CCOL_SIGCLIPNUM ])
- pp->ci[CCOL_SIGCLIPNUM]=sigcliparr[0];
+ ci[CCOL_SIGCLIPNUM]=sigcliparr[0];
if(p->ciflag[ CCOL_SIGCLIPSTD ])
- pp->ci[CCOL_SIGCLIPSTD]=( sigcliparr[3]
- - (ci[ CCOL_RIV_SUM ]/ci[
CCOL_RIV_NUM ]));
+ ci[CCOL_SIGCLIPSTD]=( sigcliparr[3]
+ - (ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM
]));
if(p->ciflag[ CCOL_SIGCLIPMEAN ])
- pp->ci[CCOL_SIGCLIPMEAN]=( sigcliparr[2]
- - (ci[ CCOL_RIV_SUM ]/ci[
CCOL_RIV_NUM ]));
+ ci[CCOL_SIGCLIPMEAN]=( sigcliparr[2]
+ - (ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM
]));
if(p->ciflag[ CCOL_SIGCLIPMEDIAN ])
- pp->ci[CCOL_SIGCLIPMEDIAN]=( sigcliparr[1]
- - (ci[ CCOL_RIV_SUM ]/ci[
CCOL_RIV_NUM ]));
+ ci[CCOL_SIGCLIPMEDIAN]=( sigcliparr[1]
+ - (ci[ CCOL_RIV_SUM ]/ci[
CCOL_RIV_NUM ]));
/* Clean up the sigma-clipped values. */
gal_data_free(result);
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 21a19bb..e160424 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -1,5 +1,7 @@
Alphabetically ordered list to acknowledge in the next release.
+Raúl Infante Sainz
+Zahra Sharbaf
Ole Streicher
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master e7dce2f: MakeCatalog: correcting accounting for ordered columns with no pixels,
Mohammad Akhlaghi <=