[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 22d0fba 089/113: Imported recent work in maste
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 22d0fba 089/113: Imported recent work in master, no conflicts |
Date: |
Fri, 16 Apr 2021 10:33:56 -0400 (EDT) |
branch: master
commit 22d0fbaa2faa01b654ff2b76abdc80e4a9319830
Merge: a8428fe 668599c
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Imported recent work in master, no conflicts
There weren't any conflicts in this merge.
---
NEWS | 6 ++-
bin/arithmetic/operands.c | 2 +
bin/fits/args.h | 13 +++++
bin/fits/fits.c | 69 +++++++++++++++++++------
bin/fits/main.h | 33 ++++++------
bin/fits/ui.c | 10 +++-
bin/fits/ui.h | 3 +-
bin/mkcatalog/main.h | 4 +-
bin/mkcatalog/ui.c | 6 +--
bin/mkcatalog/upperlimit.c | 8 +--
bin/mknoise/main.h | 2 +-
bin/mknoise/mknoise.c | 2 +-
bin/mknoise/ui.c | 2 +-
bin/mkprof/main.h | 2 +-
bin/mkprof/mkprof.c | 2 +-
bin/mkprof/mkprof.h | 2 +-
bin/mkprof/ui.c | 15 ++----
bin/segment/clumps.c | 109 +++++++++++++++++++++------------------
doc/gnuastro.texi | 27 ++++++++--
lib/checkset.c | 3 +-
lib/fits.c | 4 +-
lib/gnuastro-internal/checkset.h | 2 +-
lib/gnuastro-internal/timing.h | 2 +-
lib/gnuastro/type.h | 6 ++-
lib/timing.c | 10 +++-
25 files changed, 218 insertions(+), 126 deletions(-)
diff --git a/NEWS b/NEWS
index d6191b1..e84f45c 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,9 @@ GNU Astronomy Utilities NEWS -*-
outline -*-
Arithmetic:
--onedasimage: write output as an image if it has one dimension, not table.
+ Fits:
+ --numhdus: prints the number of HDUs in the given FITS file.
+
NoiseChisel:
- New outlier identification algorithm for quantile thresholds. This is
very useful when there are extended and bright sources in the
@@ -101,7 +104,8 @@ GNU Astronomy Utilities NEWS -*-
outline -*-
bug #54493: Warp crashes when type isn't set.
bug #54526: Invalid r, q and truncation of point profiles in MakeProfiles.
bug #54579: NoiseChisel pseudo-detection failure when dataset is negative.
-
+ bug #54782: Segment's check image not removing sky clumps some tiles.
+ bug #54810: Arithmetic crash when previously named operand renamed.
diff --git a/bin/arithmetic/operands.c b/bin/arithmetic/operands.c
index 92ebcc4..400a25d 100644
--- a/bin/arithmetic/operands.c
+++ b/bin/arithmetic/operands.c
@@ -127,6 +127,7 @@ operands_remove_name(struct arithmeticparams *p, char *name)
/* Nothing in the list points to it now. So we can safely modify and
return it. */
free(removed->name);
+ removed->next=NULL;
removed->name=NULL;
return removed;
}
@@ -218,6 +219,7 @@ operands_copy_named(struct arithmeticparams *p, char *name)
out=gal_data_copy(tmp);
free(out->name);
out->name=NULL;
+ out->next=NULL;
}
/* The named operand is not used any more. Remove it from the list
of named datasets and continue. */
diff --git a/bin/fits/args.h b/bin/fits/args.h
index 76baf3c..372c7c1 100644
--- a/bin/fits/args.h
+++ b/bin/fits/args.h
@@ -76,6 +76,19 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
+ {
+ "numhdus",
+ UI_KEY_NUMHDUS,
+ 0,
+ 0,
+ "Print number of HDUs in the given FITS file.",
+ UI_GROUP_EXTENSION,
+ &p->numhdus,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
diff --git a/bin/fits/fits.c b/bin/fits/fits.c
index 55c278b..2c47eed 100644
--- a/bin/fits/fits.c
+++ b/bin/fits/fits.c
@@ -221,8 +221,11 @@ fits_print_extension_info(struct fitsparams *p)
}
}
+ /* Close the file. */
+ fits_close_file(fptr, &status);
- /* Print the resutls. */
+
+ /* Print the results. */
if(!p->cp.quiet)
{
printf("%s\nRun on %s-----\n", PROGRAM_STRING, ctime(&p->rawtime));
@@ -244,6 +247,30 @@ fits_print_extension_info(struct fitsparams *p)
static void
+fits_hdu_number(struct fitsparams *p)
+{
+ fitsfile *fptr;
+ int numhdu, status=0;
+
+ /* Read the first extension (necessary for reading the rest). */
+ fptr=gal_fits_hdu_open(p->filename, "0", READONLY);
+
+ /* Get the number of HDUs. */
+ if( fits_get_num_hdus(fptr, &numhdu, &status) )
+ gal_fits_io_error(status, "finding number of HDUs");
+
+ /* Close the file. */
+ fits_close_file(fptr, &status);
+
+ /* Print the result. */
+ printf("%d\n", numhdu);
+}
+
+
+
+
+
+static void
fits_hdu_remove(struct fitsparams *p, int *r)
{
char *hdu;
@@ -332,24 +359,32 @@ fits(struct fitsparams *p)
/* HDU, functions defined here. */
case FITS_MODE_HDU:
- if(p->copy)
- {
- fits_hdu_copy(p, 0, &r);
- printhduinfo=0;
- }
- if(p->cut)
- {
- fits_hdu_copy(p, 1, &r);
- printhduinfo=0;
- }
- if(p->remove)
+ /* Options that must be called alone. */
+ if(p->numhdus)
+ fits_hdu_number(p);
+
+ /* Options that can be called together. */
+ else
{
- fits_hdu_remove(p, &r);
- printhduinfo=0;
- }
+ if(p->copy)
+ {
+ fits_hdu_copy(p, 0, &r);
+ printhduinfo=0;
+ }
+ if(p->cut)
+ {
+ fits_hdu_copy(p, 1, &r);
+ printhduinfo=0;
+ }
+ if(p->remove)
+ {
+ fits_hdu_remove(p, &r);
+ printhduinfo=0;
+ }
- if(printhduinfo)
- fits_print_extension_info(p);
+ if(printhduinfo)
+ fits_print_extension_info(p);
+ }
break;
/* Not recognized. */
diff --git a/bin/fits/main.h b/bin/fits/main.h
index 78681f0..43edc06 100644
--- a/bin/fits/main.h
+++ b/bin/fits/main.h
@@ -53,22 +53,23 @@ enum fits_mode
struct fitsparams
{
/* From the environment. */
- struct gal_options_common_params cp; /* Common parameters. */
- int hdu_in_commandline; /* HDU wasn't given in config. file. */
- char *filename; /* Name of input file. */
- gal_list_str_t *remove; /* Remove extensions from a file. */
- gal_list_str_t *copy; /* Copy extensions to output. */
- gal_list_str_t *cut; /* Copy ext. to output and remove. */
- uint8_t printallkeys; /* Print all the header keywords. */
- uint8_t date; /* Set DATE to current time. */
- gal_list_str_t *asis; /* Strings to write asis. */
- gal_list_str_t *delete; /* Keywords to remove. */
- gal_list_str_t *rename; /* Rename a keyword. */
- gal_list_str_t *update; /* For keywords to update. */
- gal_list_str_t *write; /* Full arg. for keywords to add. */
- gal_list_str_t *history; /* HISTORY value. */
- gal_list_str_t *comment; /* COMMENT value. */
- uint8_t quitonerror; /* Quit if an error occurs. */
+ struct gal_options_common_params cp; /* Common parameters. */
+ int hdu_in_commandline; /* HDU wasn't given in config. file. */
+ char *filename; /* Name of input file. */
+ gal_list_str_t *remove; /* Remove extensions from a file. */
+ gal_list_str_t *copy; /* Copy extensions to output. */
+ gal_list_str_t *cut; /* Copy ext. to output and remove. */
+ uint8_t numhdus; /* Print number of HDUs in FITS file. */
+ uint8_t printallkeys; /* Print all the header keywords. */
+ uint8_t date; /* Set DATE to current time. */
+ gal_list_str_t *asis; /* Strings to write asis. */
+ gal_list_str_t *delete; /* Keywords to remove. */
+ gal_list_str_t *rename; /* Rename a keyword. */
+ gal_list_str_t *update; /* For keywords to update. */
+ gal_list_str_t *write; /* Full arg. for keywords to add. */
+ gal_list_str_t *history; /* HISTORY value. */
+ gal_list_str_t *comment; /* COMMENT value. */
+ uint8_t quitonerror; /* Quit if an error occurs. */
/* Internal: */
int mode; /* Operating on HDUs or keywords. */
diff --git a/bin/fits/ui.c b/bin/fits/ui.c
index 787b9e4..6482d17 100644
--- a/bin/fits/ui.c
+++ b/bin/fits/ui.c
@@ -237,14 +237,20 @@ ui_read_check_only_options(struct fitsparams *p)
}
/* Same for the extension-related options */
- if( p->remove || p->copy || p->cut )
+ if( p->remove || p->copy || p->cut || p->numhdus)
{
/* A small sanity check. */
if(p->mode!=FITS_MODE_INVALID)
error(EXIT_FAILURE, 0, "extension and keyword manipulation options "
"cannot be called together");
- /* Set the mode and turn on the `needshdu' flag. */
+ /* Unlike the rest of the HDU-related options, `--numhdus' must be
+ called alone. */
+ if(p->numhdus==1 && (p->remove || p->copy || p->cut) )
+ error(EXIT_FAILURE, 0, "`--numhdus' option must be called alone (it "
+ "cannot be called with other extension or keyword options)");
+
+ /* Set the operating mode. */
p->mode=FITS_MODE_HDU;
/* Make sure the output name is set. */
diff --git a/bin/fits/ui.h b/bin/fits/ui.h
index e2668c8..be7fccf 100644
--- a/bin/fits/ui.h
+++ b/bin/fits/ui.h
@@ -43,7 +43,7 @@ enum program_args_groups
/* Available letters for short options:
- b e f g i j l m n s v x y z
+ b e f g i j l m s v x y z
A B E G J L O W X Y
*/
enum option_keys_enum
@@ -52,6 +52,7 @@ enum option_keys_enum
UI_KEY_REMOVE = 'R',
UI_KEY_COPY = 'C',
UI_KEY_CUT = 'k',
+ UI_KEY_NUMHDUS = 'n',
UI_KEY_PRINTALLKEYS = 'p',
UI_KEY_ASIS = 'a',
UI_KEY_DELETE = 'd',
diff --git a/bin/mkcatalog/main.h b/bin/mkcatalog/main.h
index b2f8e28..349b3c2 100644
--- a/bin/mkcatalog/main.h
+++ b/bin/mkcatalog/main.h
@@ -218,8 +218,8 @@ struct mkcatalogparams
pthread_mutex_t mutex; /* Mutex to change the total numbers. */
size_t clumprowsfilled; /* No. filled clump rows at this moment.*/
gsl_rng *rng; /* Main random number generator. */
- uint64_t seed; /* Random number generator seed. */
- const char *rngname; /* Name of random number generator. */
+ unsigned long int rng_seed; /* Random number generator seed. */
+ const char *rng_name; /* Name of random number generator. */
size_t rngmin; /* Minimum possible value of RNG. */
size_t rngdiff; /* Difference of RNG max and min. */
uint8_t uprangewarning; /* A warning must be printed. */
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index 090cfe2..e038270 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -1448,7 +1448,7 @@ ui_preparations_upperlimit(struct mkcatalogparams *p)
"that is reported as the upper-limit");
/* Set the random number generator. */
- p->rng=gal_checkset_gsl_rng(p->envseed, &p->rngname, &p->seed);
+ p->rng=gal_checkset_gsl_rng(p->envseed, &p->rng_name, &p->rng_seed);
/* Keep the minimum and maximum values of the random number generator. */
p->rngmin=gsl_rng_min(p->rng);
@@ -1657,8 +1657,8 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
mkcatalogparams *p)
p->upmaskfile, p->cp.hdu);
if(p->upperlimit)
{
- printf(" - Random number generator name: %s\n", p->rngname);
- printf(" - Random number generator seed: %"PRIu64"\n", p->seed);
+ printf(" - Random number generator name: %s\n", p->rng_name);
+ printf(" - Random number generator seed: %lu\n", p->rng_seed);
}
}
}
diff --git a/bin/mkcatalog/upperlimit.c b/bin/mkcatalog/upperlimit.c
index c28be22..96e9600 100644
--- a/bin/mkcatalog/upperlimit.c
+++ b/bin/mkcatalog/upperlimit.c
@@ -317,11 +317,11 @@ upperlimit_write_comments(struct mkcatalogparams *p,
gal_list_str_add(comments, str, 0);
}
- if( asprintf(&str, "Random number generator name: %s", p->rngname)<0 )
+ if( asprintf(&str, "Random number generator name: %s", p->rng_name)<0 )
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
gal_list_str_add(comments, str, 0);
- if( asprintf(&str, "Random number generator seed: %"PRIu64, p->seed)<0 )
+ if( asprintf(&str, "Random number generator seed: %lu", p->rng_seed)<0 )
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
gal_list_str_add(comments, str, 0);
@@ -770,7 +770,7 @@ upperlimit_calculate(struct mkcatalog_passparams *pp)
struct mkcatalogparams *p=pp->p;
/* First find the upper limit magnitude for this object. */
- upperlimit_one_tile(pp, pp->tile, p->seed+pp->object, 0);
+ upperlimit_one_tile(pp, pp->tile, p->rng_seed+pp->object, 0);
/* If a clumps image is present (a clump catalog is requested) and this
object has clumps, then find the upper limit magnitude for the clumps
@@ -798,7 +798,7 @@ upperlimit_calculate(struct mkcatalog_passparams *pp)
IDs. */
for(i=0;i<pp->clumpsinobj;++i)
{
- seed = p->seed + p->numobjects + p->numclumps * pp->object + i;
+ seed = p->rng_seed + p->numobjects + p->numclumps * pp->object + i;
upperlimit_one_tile(pp, &clumptiles[i], seed, i+1);
}
diff --git a/bin/mknoise/main.h b/bin/mknoise/main.h
index c443f2c..634a08b 100644
--- a/bin/mknoise/main.h
+++ b/bin/mknoise/main.h
@@ -55,7 +55,7 @@ struct mknoiseparams
double background; /* Background in units of brightness. */
gsl_rng *rng; /* Main instance of random number generator.*/
const char *rng_name; /* The type/name of the Random number gen. */
- uint64_t rng_seed; /* Seed of Random number generator. */
+ unsigned long rng_seed; /* Seed of Random number generator. */
time_t rawtime; /* Starting time of the program. */
};
diff --git a/bin/mknoise/mknoise.c b/bin/mknoise/mknoise.c
index 5c9d085..954fe85 100644
--- a/bin/mknoise/mknoise.c
+++ b/bin/mknoise/mknoise.c
@@ -91,7 +91,7 @@ convertsaveoutput(struct mknoiseparams *p)
"Random number generator (by GSL) type.",
0, NULL);
strcpy(keyname5, "RNGSEED");
- gal_fits_key_list_add_end(&headers, GAL_TYPE_UINT64, keyname5, 0,
+ gal_fits_key_list_add_end(&headers, GAL_TYPE_ULONG, keyname5, 0,
&p->rng_seed, 0,
"Random number generator (by GSL) seed.",
0, NULL);
diff --git a/bin/mknoise/ui.c b/bin/mknoise/ui.c
index 54a807d..471328d 100644
--- a/bin/mknoise/ui.c
+++ b/bin/mknoise/ui.c
@@ -400,7 +400,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
mknoiseparams *p)
ctime(&p->rawtime));
sprintf(message, "Random number generator type: %s", p->rng_name);
gal_timing_report(NULL, message, 1);
- sprintf(message, "Random number generator seed: %"PRIu64, p->rng_seed);
+ sprintf(message, "Random number generator seed: %lu", p->rng_seed);
gal_timing_report(NULL, message, 1);
}
}
diff --git a/bin/mkprof/main.h b/bin/mkprof/main.h
index aa908bc..53f6699 100644
--- a/bin/mkprof/main.h
+++ b/bin/mkprof/main.h
@@ -177,7 +177,7 @@ struct mkprofparams
float *t; /* Truncation distance. */
gsl_rng *rng; /* Main instance of random number generator.*/
const char *rng_name; /* Name of random number generator. */
- uint64_t rng_seed; /* Fixed seed of random number generator. */
+ unsigned long rng_seed; /* Fixed seed of random number generator. */
time_t rawtime; /* Starting time of the program. */
double *cat; /* Input catalog. */
gal_data_t *log; /* Log data to be printed. */
diff --git a/bin/mkprof/mkprof.c b/bin/mkprof/mkprof.c
index 2f575b4..997e4c8 100644
--- a/bin/mkprof/mkprof.c
+++ b/bin/mkprof/mkprof.c
@@ -225,7 +225,7 @@ saveindividual(struct mkonthread *mkp)
gal_fits_key_list_add(&keys, GAL_TYPE_STRING, "RNGNAME", 0,
(void *)(p->rng_name), 0,
"Name of random number generator", 0, NULL);
- gal_fits_key_list_add(&keys, GAL_TYPE_LONG, "RNGSEED", 0,
+ gal_fits_key_list_add(&keys, GAL_TYPE_ULONG, "RNGSEED", 0,
&mkp->rng_seed, 0, "Seed of random number generator",
0, NULL);
gal_fits_key_list_add(&keys, GAL_TYPE_SIZE_T, "NUMRANDOM", 0,
diff --git a/bin/mkprof/mkprof.h b/bin/mkprof/mkprof.h
index c97fcdc..9794d03 100644
--- a/bin/mkprof/mkprof.h
+++ b/bin/mkprof/mkprof.h
@@ -48,7 +48,7 @@ struct mkonthread
long *onaxes; /* Sides of the unover-sampled image. */
long fpixel_i[3]; /* fpixel_i before running overlap. */
int correction; /* ==1: correct the pixels afterwards. */
- long rng_seed; /* Seed used to generate this profile. */
+ unsigned long rng_seed; /* Seed used to generate this profile. */
/* Random number generator: */
gsl_rng *rng; /* Copy of main random number generator. */
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index 7cc505c..5475d63 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -1759,16 +1759,11 @@ ui_print_intro(struct mkprofparams *p)
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
gal_timing_report(NULL, jobname, 1);
free(jobname);
- if(p->envseed)
- {
- if( asprintf(&jobname, "RNG seed for all profiles: %lu",
- gsl_rng_default_seed)<0 )
- error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
- gal_timing_report(NULL, jobname, 1);
- free(jobname);
- }
- else
- gal_timing_report(NULL, "RNG seed differs for each profile.", 1);
+
+ if( asprintf(&jobname, "Basic RNG seed: %lu", p->rng_seed)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
+ gal_timing_report(NULL, jobname, 1);
+ free(jobname);
if(p->kernel==NULL)
{
diff --git a/bin/segment/clumps.c b/bin/segment/clumps.c
index cead77b..5f15794 100644
--- a/bin/segment/clumps.c
+++ b/bin/segment/clumps.c
@@ -229,56 +229,62 @@ clumps_correct_sky_labels_for_check(struct
clumps_thread_params *cltprm,
size_t len=cltprm->numinitclumps+1;
struct segmentparams *p=cltprm->clprm->p;
- /* If there are no clumps in this tile, then this function can be
- ignored. */
- if(cltprm->snind->size==0) return;
-
-
- /* A small sanity check. */
- if(gal_tile_block(tile)!=p->clabel)
- error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to address "
- "the problem. `tile->block' must point to the `clabel' dataset",
- __func__, PACKAGE_BUGREPORT);
-
-
- /* Allocate a dataset with the new indexs, note that it will need to have
- one element for each initial label (the excluded clumps need to be set
- to zero). So we also need to clear the allocated space. */
- newinds=gal_data_alloc(NULL, p->clabel->type, 1, &len, NULL, 0,
- p->cp.minmapsize, NULL, NULL, NULL);
-
-
- /* Get the next available label for these clumps. If more than one thread
- was used, we are first going to lock the mutex (so no other thread
- changes these values), we will then read the shared number for this
- thread to use, then update the shared number and finally, unlock the
- mutex so other threads can do the same when they get to this point. */
- if(p->cp.numthreads>1) pthread_mutex_lock(&cltprm->clprm->labmutex);
- curlab = p->numclumps+1; /* Note that counting begins from 1. */
- p->numclumps += cltprm->snind->size;
- if(p->cp.numthreads>1) pthread_mutex_unlock(&cltprm->clprm->labmutex);
-
-
- /* Initialize the newinds array to GAL_LABEL_INIT (which be used as a new
- label for all the clumps that must be removed. */
- lf = (l=newinds->array) + newinds->size;
- do *l++=GAL_LABEL_INIT; while(l<lf);
+ /* If any of the clumps must be kept (`cltprm->snind->size!=0'), then
+ re-label them for the check image. Otherwise, remove all clumps. */
+ if(cltprm->snind->size)
+ {
+ /* A small sanity check. */
+ if(gal_tile_block(tile)!=p->clabel)
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
+ "address the problem. `tile->block' must point to the "
+ "`clabel' dataset", __func__, PACKAGE_BUGREPORT);
+
+
+ /* Allocate a dataset with the new indexs, note that it will need to
+ have one element for each initial label (the excluded clumps need
+ to be set to zero). So we also need to clear the allocated
+ space. */
+ newinds=gal_data_alloc(NULL, p->clabel->type, 1, &len, NULL, 0,
+ p->cp.minmapsize, NULL, NULL, NULL);
+
+
+ /* Get the next available label for these clumps. If more than one
+ thread was used, we are first going to lock the mutex (so no other
+ thread changes these values), we will then read the shared number
+ for this thread to use, then update the shared number and finally,
+ unlock the mutex so other threads can do the same when they get to
+ this point. */
+ if(p->cp.numthreads>1) pthread_mutex_lock(&cltprm->clprm->labmutex);
+ curlab = p->numclumps+1; /* Note that counting begins from 1. */
+ p->numclumps += cltprm->snind->size;
+ if(p->cp.numthreads>1) pthread_mutex_unlock(&cltprm->clprm->labmutex);
+
+
+ /* Initialize the newinds array to GAL_LABEL_INIT (which be used as a
+ new label for all the clumps that must be removed. */
+ lf = (l=newinds->array) + newinds->size;
+ do *l++=GAL_LABEL_INIT; while(l<lf);
- /* The new indexs array has been initialized to zero. So we just need to
- go over the labels in `cltprm->sninds' and give them a value of
- `curlab++'. */
- ninds=newinds->array;
- lf = (l=cltprm->snind->array) + cltprm->snind->size;
- do { ninds[*l]=curlab++; *l=ninds[*l]; } while(++l<lf);
+ /* The new indexs array has been initialized to zero. So we just need
+ to go over the labels in `cltprm->sninds' and give them a value of
+ `curlab++'. */
+ ninds=newinds->array;
+ lf = (l=cltprm->snind->array) + cltprm->snind->size;
+ do { ninds[*l]=curlab++; *l=ninds[*l]; } while(++l<lf);
- /* Go over this tile and correct the values. */
- GAL_TILE_PARSE_OPERATE( tile, NULL, 0, 1,
- {if(*i>0) *i=ninds[ *(int32_t *)i ];} );
+ /* Go over this tile and correct the values. */
+ GAL_TILE_PARSE_OPERATE( tile, NULL, 0, 1,
+ {if(*i>0) *i=ninds[ *(int32_t *)i ];} );
- /* Clean up. */
- gal_data_free(newinds);
+ /* Clean up. */
+ gal_data_free(newinds);
+ }
+ else
+ /* There were no usable clumps in this tile, so just set all the pixels
+ larger than zero (a clump) to `GAL_LABEL_INIT'. */
+ GAL_TILE_PARSE_OPERATE( tile, NULL, 0, 1, {*i=*i>0?GAL_LABEL_INIT:*i;} );
}
@@ -472,11 +478,6 @@ clumps_find_make_sn_table(void *in_prm)
cltprm.sn, cltprm.snind);
- /* If there were no clumps, then just set the S/N table to NULL. */
- if( cltprm.clprm->sn[ cltprm.id ].size==0 )
- cltprm.snind=cltprm.sn=NULL;
-
-
/* If the user wanted to check the steps, remove the clumps that
weren't used from the `clabel' image (they have been already
excluded from the table). */
@@ -484,6 +485,14 @@ clumps_find_make_sn_table(void *in_prm)
clumps_correct_sky_labels_for_check(&cltprm, tile);
+ /* If there were no clumps, then just set the S/N table to
+ NULL. This must be done after the check image creation (if
+ necessary), because we use `cltprm.snind' as a proxy for the
+ check image.*/
+ if( cltprm.clprm->sn[ cltprm.id ].size==0 )
+ cltprm.snind=cltprm.sn=NULL;
+
+
/* Clean up. */
gal_data_free(cltprm.indexs);
}
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index ec32028..704b9c0 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -2911,7 +2911,7 @@ omatter 0.3
You can now tell CosmicCalculator to read this file for option values
immediately using the @option{--config} option as shown below. Do you see
how the output of the following command corresponds to the option values in
-@file{my-cosmology.txt} (previous command)?
+@file{my-cosmology.conf} (previous command)?
@example
$ astcosmiccal --config=my-cosmology.conf -z2
@@ -2976,9 +2976,9 @@ $ astwarp flat-ir/xdf-f160w.fits --rotate=20
@end example
@noindent
-Open the output and see the output. If your final image is already aligned
-with RA and Dec, you can simply use the @option{--align} option and let
-Warp calculate the necessary rotation.
+Open the output and see it. If your final image is already aligned with RA
+and Dec, you can simply use the @option{--align} option and let Warp
+calculate the necessary rotation and apply it.
Warp can generally be used for any kind of pixel grid manipulation
(warping). For example the outputs of the commands below will respectively
@@ -9862,6 +9862,17 @@ HDUs given to this option (see @ref{Automatic output}).
@table @option
+@item -n
+@itemx --numhdus
+Print the number of extensions/HDUs in the given file. Note that this
+option must be called alone and will only print a single number. It is thus
+useful in scripts, for example when you need to do check the number of
+extensions in a FITS file.
+
+For a complete list of basic meta-data on the extensions in a FITS file,
+don't use any of the options in this section or in @ref{Keyword
+manipulation}. For more, see @ref{Invoking astfits}.
+
@item -C STR
@itemx --copy=STR
Copy the specified extension into the output file, see explanations above.
@@ -23148,6 +23159,12 @@ Identifier for a @code{size_t} type. This is just an
alias to
respectively.
@end deffn
+@deffn {Global integer} GAL_TYPE_ULONG
+Identifier for a @code{unsigned long} type. This is just an alias to
+@code{uint32}, or @code{uint64} types for 32-bit, or 64-bit systems
+respectively.
+@end deffn
+
@deffn {Global integer} GAL_TYPE_LONG
Identifier for a @code{long} type. This is just an alias to @code{int32},
or @code{int64} types for 32-bit, or 64-bit systems respectively.
@@ -30657,7 +30674,7 @@ completely rely.
@end quotation
Please get in touch with the Gnuastro maintainer (currently Mohammad
-Akhlaghi, akhlaghi -at- gnu -dot- org) to follow the procedures. It is
+Akhlaghi, mohammad -at- akhlaghi -dot- org) to follow the procedures. It is
possible to do this for each change (good for for a single contribution),
and also more generally for all the changes/additions you do in the future
within Gnuastro. So if you have already assigned the copyright of your work
diff --git a/lib/checkset.c b/lib/checkset.c
index b58e96f..063de37 100644
--- a/lib/checkset.c
+++ b/lib/checkset.c
@@ -50,7 +50,8 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
environment. This function is designed to make the job easier for any
program using GSL's RNG. If the user doesn't want to set the */
gsl_rng *
-gal_checkset_gsl_rng(uint8_t envseed_bool, const char **name, uint64_t *seed)
+gal_checkset_gsl_rng(uint8_t envseed_bool, const char **name,
+ unsigned long int *seed)
{
gsl_rng *rng;
diff --git a/lib/fits.c b/lib/fits.c
index ad6a854..9e6f77e 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -300,8 +300,8 @@ gal_fits_type_to_datatype(uint8_t type)
case GAL_TYPE_STRING: return TSTRING;
/* Types that depend on the host system. The C standard says that the
- `short', `int' and `long' types are ATLEAST 2, 2, 4 bytes, so be
- safe, we will checking all of them for the 32-bit types.*/
+ `short', `int' and `long' types are ATLEAST 2, 2, 4 bytes, so to be
+ safe, we will check all of them for the 32-bit types.*/
case GAL_TYPE_UINT16:
w=2;
if ( sizeof(short) == w ) return TUSHORT;
diff --git a/lib/gnuastro-internal/checkset.h b/lib/gnuastro-internal/checkset.h
index 204c325..e528b6e 100644
--- a/lib/gnuastro-internal/checkset.h
+++ b/lib/gnuastro-internal/checkset.h
@@ -55,7 +55,7 @@ __BEGIN_C_DECLS /* From C++ preparations */
/**************************************************************/
gsl_rng *
gal_checkset_gsl_rng(uint8_t envseed_bool, const char **name,
- uint64_t *seed);
+ unsigned long int *seed);
diff --git a/lib/gnuastro-internal/timing.h b/lib/gnuastro-internal/timing.h
index d43d76a..245b1a0 100644
--- a/lib/gnuastro-internal/timing.h
+++ b/lib/gnuastro-internal/timing.h
@@ -52,7 +52,7 @@ __BEGIN_C_DECLS /* From C++ preparations */
#define GAL_TIMING_VERB_MSG_LENGTH_V 50
#define GAL_TIMING_VERB_MSG_LENGTHS_2_V 65
-long
+unsigned long
gal_timing_time_based_rng_seed();
void
diff --git a/lib/gnuastro/type.h b/lib/gnuastro/type.h
index 975ce17..e3ae316 100644
--- a/lib/gnuastro/type.h
+++ b/lib/gnuastro/type.h
@@ -106,9 +106,11 @@ enum gal_types
#endif
#if GAL_CONFIG_SIZEOF_LONG == 4
-#define GAL_TYPE_LONG GAL_TYPE_INT32
+#define GAL_TYPE_LONG GAL_TYPE_INT32
+#define GAL_TYPE_ULONG GAL_TYPE_UINT32
#elif GAL_CONFIG_SIZEOF_LONG == 8
-#define GAL_TYPE_LONG GAL_TYPE_INT64
+#define GAL_TYPE_LONG GAL_TYPE_INT64
+#define GAL_TYPE_ULONG GAL_TYPE_UINT64
#endif
diff --git a/lib/timing.c b/lib/timing.c
index cdb88fb..86b66e4 100644
--- a/lib/timing.c
+++ b/lib/timing.c
@@ -31,8 +31,14 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* Micro-second based timer, which can be used to generate random numbers.
The type of `tv_sec' and `tv_usec' is `long int' (from the GNU C Library
- manual), so this function will also return long. */
-long
+ manual). But the expected type used by GSL's random number generator is
+ `unsigned long int'. Since the only random number generator that is
+ currently in Gnuastro is GSL's (and it asks for seeds of type `unsigned
+ long int'), this function will return in `unsigned long int'. Note that
+ `unsigned long' will be able to hold any positive `long' integer, which
+ is the case for `tv_sec' and `tv_usec': they are both positive, while
+ the opposite isn't true. */
+unsigned long int
gal_timing_time_based_rng_seed()
{
struct timeval tv;
- [gnuastro-commits] master a42ac37 085/113: Fixed MakeProfiles loop in checking radius values, (continued)
- [gnuastro-commits] master a42ac37 085/113: Fixed MakeProfiles loop in checking radius values, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 1f9d941 090/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 737a0cd 046/113: Merged recent corrections in master branch, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 486f915 067/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master d6051a1 074/113: Upperlimit magnitude in 3D, corrected creation of check table, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 5dac3c3 075/113: Recent work in master imported, small conflict in book fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 3882956 077/113: Narrow-band areas from MakeCatalog in 3D datasets, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master abe82cb 086/113: Imported recent work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 924787b 098/113: Updated copyright year in files specific to this branch, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master fbbc2fc 100/113: Imported recent work in master, minor conflict fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 22d0fba 089/113: Imported recent work in master, no conflicts,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 8edc804 092/113: Imported recent work in master, minor conflic fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master b5385f7 093/113: Projected spectra given NaN when no measurement on slice, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master ac2a821 103/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 3f51e31 108/113: Imported work in master, conflicts fixed, corrections made, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 45bd003 049/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6f85919 060/113: Connectivity of 2, for filling pseudo-detection holes in 3D, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 442d052 061/113: Imported work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 9285abe 057/113: Imported recent work from master with corrections, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master c91d988 063/113: Recent work in master merged, conflicts corrected, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 05cc693 080/113: Added 3rd dimension to MakeCatalog's minimum-maximum columns, Mohammad Akhlaghi, 2021/04/16