[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 9258f68 096/113: Imported recent work in maste
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 9258f68 096/113: Imported recent work in master, minor conflict fixed |
Date: |
Fri, 16 Apr 2021 10:33:58 -0400 (EDT) |
branch: master
commit 9258f686a82d69326fb1212d44df8b283b7fb149
Merge: 175354f 13a7e18
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Imported recent work in master, minor conflict fixed
In a previous merge with the master branch a check on the number of input
dimensions to Convolve wasn't corrected for this branch. This has been
fixed with this merge.
---
NEWS | 2 ++
bin/arithmetic/arithmetic.c | 13 ++++++++++---
bin/arithmetic/main.h | 1 +
bin/convolve/ui.c | 4 ++--
doc/gnuastro.texi | 12 ++++++------
lib/convolve.c | 11 +++++++++++
lib/tile-internal.c | 5 ++---
lib/type.c | 15 +++++++++++----
lib/wcs.c | 11 ++++++-----
9 files changed, 51 insertions(+), 23 deletions(-)
diff --git a/NEWS b/NEWS
index bf2af0a..8ddb577 100644
--- a/NEWS
+++ b/NEWS
@@ -153,6 +153,8 @@ GNU Astronomy Utilities NEWS -*-
outline -*-
bug #55025: MakeCatalog's `--prepforconv' option being ignored.
bug #55079: Blank EPS or PDF page when width options not given.
bug #55157: No sanity check on values given to Crop's --section.
+ bug #55295: Crash when more than one collapse operator called.
+ bug #55298: Arithmetic reading 255 on command-line as blank.
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index d747e85..143ebd4 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -733,7 +733,11 @@ arithmetic_collapse(struct arithmeticparams *p, char
*token, int operator)
/* If a WCS structure has been read, we'll need to pass it to
`gal_dimension_collapse', so it modifies it respectively. */
- input->wcs=p->refdata.wcs;
+ if(p->wcs_collapsed==0)
+ {
+ p->wcs_collapsed=1;
+ input->wcs=p->refdata.wcs;
+ }
/* Run the relevant library function. */
@@ -770,8 +774,11 @@ arithmetic_collapse(struct arithmeticparams *p, char
*token, int operator)
`collapsed->wcs'. So we'll let the freeing of `input' free the old
`p->refdata.wcs' structure and we'll put the new one there, then we'll
set `collapsed->wcs' to `NULL', so the new one isn't freed. */
- p->refdata.wcs = collapsed->wcs;
- collapsed->wcs = NULL;
+ if(collapsed->wcs)
+ {
+ p->refdata.wcs = collapsed->wcs;
+ collapsed->wcs = NULL;
+ }
/* We'll also need to correct the size of the reference dataset. We'll
diff --git a/bin/arithmetic/main.h b/bin/arithmetic/main.h
index ce36ebb..48512d1 100644
--- a/bin/arithmetic/main.h
+++ b/bin/arithmetic/main.h
@@ -79,6 +79,7 @@ struct arithmeticparams
size_t tokencounter; /* Counter for finding place in tokens. */
/* Operating mode: */
+ int wcs_collapsed; /* If the internal WCS is already collapsed.*/
/* Internal: */
struct operand *operands; /* The operands linked list. */
diff --git a/bin/convolve/ui.c b/bin/convolve/ui.c
index 47f7f95..0f43c11 100644
--- a/bin/convolve/ui.c
+++ b/bin/convolve/ui.c
@@ -492,8 +492,8 @@ ui_preparations(struct convolveparams *p)
ui_read_input(p);
- /* Currently Convolve only works on 1D and 2D datasets. */
- if(p->input->ndim>2)
+ /* Currently Convolve only works on 1D, 2D and 3D datasets. */
+ if(p->input->ndim>3)
error(EXIT_FAILURE, 0, "%s (hdu %s) has %zu dimensions. Currently "
"Convolve only operates on 1D (table column, spectrum), 2D "
"(image), and 3D (data cube) datasets", p->filename, cp->hdu,
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index fc91c2a..99e2840 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -26270,15 +26270,15 @@ linked list. It is recommended to use
@code{gal_table_read} for generic
reading of tables, see @ref{Table input output}.
@end deftypefun
-@deftypefun void gal_fits_tab_write (gal_data_t @code{*cols}, gal_list_str_t
@code{*comments}, int @code{tableformat}, char @code{*filename})
+@deftypefun void gal_fits_tab_write (gal_data_t @code{*cols}, gal_list_str_t
@code{*comments}, int @code{tableformat}, char @code{*filename}, char
@code{*extname})
Write the list of datasets in @code{cols} (see @ref{List of gal_data_t}) as
separate columns in a FITS table in @code{filename}. If @code{filename}
already exists then this function will write the table as a new extension
-after all existing ones. The format of the table (ASCII or binary) may be
-specified with the @code{tableformat} (see @ref{Table input output}). If
-@code{comments!=NULL}, each node of the list of strings will be written as
-a @code{COMMENT} keywords in the output FITS file (see @ref{List of
-strings}.
+called @code{extname}, after all existing ones. The format of the table
+(ASCII or binary) may be specified with the @code{tableformat} (see
+@ref{Table input output}). If @code{comments!=NULL}, each node of the list
+of strings will be written as a @code{COMMENT} keywords in the output FITS
+file (see @ref{List of strings}.
This is a low-level function for tables. It is recommended to use
@code{gal_table_write} for generic writing of tables in a variety of
diff --git a/lib/convolve.c b/lib/convolve.c
index 5fd9b62..0423b55 100644
--- a/lib/convolve.c
+++ b/lib/convolve.c
@@ -501,6 +501,17 @@ gal_convolve_spatial_general(gal_data_t *tiles, gal_data_t
*kernel,
error(EXIT_FAILURE, 0, "%s: only accepts `float32' type input and "
"kernel currently", __func__);
+ /* It may happen that an input dataset is part of a linked list, but it
+ is not actually a tile structure (the user wants to convolve the whole
+ dataset without using tiles)! In that case, this function should break
+ beacuse a linked list is interpretted as a tile structure here.*/
+ if( tiles->block==NULL && tiles->next && tiles->next->block==NULL )
+ error(EXIT_FAILURE, 0, "%s: the input is a linked list but not a "
+ "tessellation (a list of tiles). This function is optimized to "
+ "work on a list of tiles. Please (temporarily) set the `next' "
+ "element of the input to `NULL' and call this funciton again",
+ __func__);
+
/* Set the output datastructure. */
if(tocorrect) out=tocorrect;
diff --git a/lib/tile-internal.c b/lib/tile-internal.c
index 7e51fe2..7a83e6d 100644
--- a/lib/tile-internal.c
+++ b/lib/tile-internal.c
@@ -106,7 +106,7 @@ tileinternal_no_outlier_work(gal_data_t *first, gal_data_t
*second,
nbs=gal_statistics_no_blank_sorted(second, 0);
outlier=gal_statistics_outlier_positive(nbs, nbs->size, outliersigma,
outliersclip[0], outliersclip[1],
- 0, 0);
+ 0, 1);
gal_data_free(nbs);
if(outlier)
{
@@ -124,7 +124,7 @@ tileinternal_no_outlier_work(gal_data_t *first, gal_data_t
*second,
outlier=gal_statistics_outlier_positive(nbs, nbs->size/2,
outliersigma,
outliersclip[0],
- outliersclip[1], 0, 0);
+ outliersclip[1], 0, 1);
gal_data_free(nbs);
if(outlier)
{
@@ -143,7 +143,6 @@ tileinternal_no_outlier_work(gal_data_t *first, gal_data_t
*second,
if(third) arr3[i] = NAN;
}
-
/* Correct the values, if they were changed. */
if(start || tottilesinch!=osize)
{
diff --git a/lib/type.c b/lib/type.c
index 5d89a72..5a42e84 100644
--- a/lib/type.c
+++ b/lib/type.c
@@ -568,10 +568,17 @@ gal_type_string_to_number(char *string, uint8_t *type)
}
else
{
- if (d<=UINT8_MAX) { u8=d; ptr=&u8; *type=GAL_TYPE_UINT8; }
- else if(d<=UINT16_MAX) { u16=d; ptr=&u16; *type=GAL_TYPE_UINT16; }
- else if(d<=UINT32_MAX) { u32=d; ptr=&u32; *type=GAL_TYPE_UINT32; }
- else { u64=d; ptr=&u64; *type=GAL_TYPE_UINT64; }
+ /* Note that the blank values are set to the maximum values in
+ unsigned types. A blank value should be given as a blank
+ string to this function (`GAL_BLANK_STRING'). So, to avoid
+ confusing situations (for example when the user gives 255), if
+ the value is equal to the given maximum of the given type,
+ we'll assign it to a larger type. In other words, we won't be
+ using the `<=MAX', but `<MAX'. */
+ if (d<UINT8_MAX) { u8=d; ptr=&u8; *type=GAL_TYPE_UINT8; }
+ else if(d<UINT16_MAX) { u16=d; ptr=&u16; *type=GAL_TYPE_UINT16; }
+ else if(d<UINT32_MAX) { u32=d; ptr=&u32; *type=GAL_TYPE_UINT32; }
+ else { u64=d; ptr=&u64; *type=GAL_TYPE_UINT64; }
}
}
else
diff --git a/lib/wcs.c b/lib/wcs.c
index dfb3d83..8d3cb5a 100644
--- a/lib/wcs.c
+++ b/lib/wcs.c
@@ -288,17 +288,18 @@ wcs_ctype_has_tan(char *str)
void
gal_wcs_remove_dimension(struct wcsprm *wcs, size_t fitsdim)
{
- size_t c, i, j, naxis=wcs->naxis;
+ size_t c, i, j, naxis;
+
+ /* If the WCS structure is NULL, just return. */
+ if(wcs==NULL) return;
/* Sanity check. */
- if(fitsdim==0 || fitsdim>wcs->naxis)
+ naxis=wcs->naxis;
+ if(fitsdim==0 || fitsdim>naxis)
error(EXIT_FAILURE, 0, "%s: requested dimension (fitsdim=%zu) must be "
"larger than zero and smaller than the number of dimensions in "
"the given WCS structure (%zu)", __func__, fitsdim, naxis);
- /* If the WCS structure is NULL, just return. */
- if(wcs==NULL) return;
-
/**************************************************/
#if WCS_REMOVE_DIM_CHECK
printf("\n\nfitsdim: %zu\n", fitsdim);
- [gnuastro-commits] master ac2a821 103/113: Imported recent work in master, conflicts fixed, (continued)
- [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
- [gnuastro-commits] master 0eaf0dc 091/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 9e2397a 094/113: Imported recent work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 9258f68 096/113: Imported recent work in master, minor conflict fixed,
Mohammad Akhlaghi <=
- [gnuastro-commits] master d0d8d20 109/113: Imported recent work in master, minor conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6e11585 111/113: Imported recent work in master, minor conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master aa80ac4 112/113: Imported recent updates in master branch, minor conflict fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master dadb3f3 107/113: Imported recent work in master, minor conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 313d522 099/113: Imported recent work in master, minor conflict fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 536b056 110/113: Imported recent changes in master, conflicts in book fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master dd4d43e 113/113: NoiseChisel and Segment: now working on 3D data cubes, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master eb91303 042/113: Merged recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 2dba72f 101/113: Imported work in master, conflicts fixed, changes made, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master b3416de 102/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16