[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master e958450: Correct checking of number of clumps
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master e958450: Correct checking of number of clumps with --checksn |
Date: |
Tue, 24 Apr 2018 08:21:56 -0400 (EDT) |
branch: master
commit e958450ad62295cccda7533b8cec4164eef1cfff
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Correct checking of number of clumps with --checksn
Until now, the function that wrote the clump S/N values into a table (when
`--checksn' is called) didn't check if there are actually clumps in that
object. Therefore a check was added when counting the total number of
clumps and also when writing them into the table.
---
bin/segment/segment.c | 23 ++++++++++++++---------
lib/table.c | 7 ++-----
2 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/bin/segment/segment.c b/bin/segment/segment.c
index da38458..312f325 100644
--- a/bin/segment/segment.c
+++ b/bin/segment/segment.c
@@ -591,11 +591,13 @@ segment_on_threads(void *in_prm)
if(clprm->step==1 || p->checksn)
{ gal_data_free(topinds); continue; }
+
/* Only keep true clumps and abort if the user only wants clumps. */
clumps_det_keep_true_relabel(&cltprm);
gal_data_free(topinds);
if(clprm->step==2) continue;
+
/* When only clumps are desired ignore the rest of the process. */
if(!p->onlyclumps)
{
@@ -717,14 +719,16 @@ segment_save_sn_table(struct clumps_params *clprm)
int32_t *oiarr, *cioarr;
gal_list_str_t *comments=NULL;
size_t i, j, c=0, totclumps=0;
- gal_data_t *sn, *objind, *clumpinobj;
struct segmentparams *p=clprm->p;
+ gal_data_t *sn, *objind, *clumpinobj;
/* Find the total number of clumps in all the initial detections. Recall
that the `size' values were one more than the actual number because
the labelings start from 1. */
- for(i=1;i<p->numdetections+1;++i) totclumps += clprm->sn[i].size-1;
+ for(i=1;i<p->numdetections+1;++i)
+ if( clprm->sn[i].size > 1 )
+ totclumps += clprm->sn[i].size-1;
/* Allocate the columns for the table. */
@@ -744,13 +748,14 @@ segment_save_sn_table(struct clumps_params *clprm)
oiarr=objind->array;
cioarr=clumpinobj->array;
for(i=1;i<p->numdetections+1;++i)
- for(j=1;j<clprm->sn[i].size;++j)
- {
- oiarr[c] = i;
- cioarr[c] = j;
- sarr[c] = ((float *)(clprm->sn[i].array))[j];
- ++c;
- }
+ if( clprm->sn[i].size > 1 )
+ for(j=1;j<clprm->sn[i].size;++j)
+ {
+ oiarr[c] = i;
+ cioarr[c] = j;
+ sarr[c] = ((float *)(clprm->sn[i].array))[j];
+ ++c;
+ }
/* Write the comments. */
diff --git a/lib/table.c b/lib/table.c
index a263700..e22fb4b 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -493,10 +493,8 @@ gal_table_comments_add_intro(gal_list_str_t **comments,
char *program_string,
/* Get the Git description in the running folder. */
tmp=gal_git_describe();
- if(tmp) sprintf(gitdescribe, " from %s,", tmp);
- else gitdescribe[0]='\0';
- free(tmp);
-
+ if(tmp) { sprintf(gitdescribe, " from %s,", tmp); free(tmp); }
+ else gitdescribe[0]='\0';
/* Git version and time of program's starting, this will be the second
line. Note that ctime puts a `\n' at the end of its string, so we'll
@@ -507,7 +505,6 @@ gal_table_comments_add_intro(gal_list_str_t **comments,
char *program_string,
tmp[ strlen(tmp)-1 ]='\0';
gal_list_str_add(comments, tmp, 0);
-
/* Program name: this will be the top of the list (first line). We will
need to set the allocation flag for this one, because program_string
is usually statically allocated.*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master e958450: Correct checking of number of clumps with --checksn,
Mohammad Akhlaghi <=