[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 1af4ea9 062/113: Correct checks for kernel dim
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 1af4ea9 062/113: Correct checks for kernel dimension in NoiseChisel and Segment |
Date: |
Fri, 16 Apr 2021 10:33:47 -0400 (EDT) |
branch: master
commit 1af4ea9d19bd6a3a34ce6a29215e87de95b11ba3
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Correct checks for kernel dimension in NoiseChisel and Segment
Until now, NoiseChisel wasn't checking if the dimensionality of the kernel
is the same as the input. Also, Segment was checking the dimensionality
after possibly setting `p->kernel=NULL' (when `--kernel=none' is called,
which caused a segmentation fault).
With this commit, we now check the dimensionality of the kernel in both
NoiseChisel and Segment. In both cases, this check is also done only when
`--kernel' has not been `none'.
---
bin/noisechisel/ui.c | 14 ++++++++++++--
bin/segment/ui.c | 19 +++++++++++--------
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/bin/noisechisel/ui.c b/bin/noisechisel/ui.c
index 156dc7e..4bb3d12 100644
--- a/bin/noisechisel/ui.c
+++ b/bin/noisechisel/ui.c
@@ -420,9 +420,19 @@ ui_prepare_kernel(struct noisechiselparams *p)
kernel. */
if(p->kernelname)
{
+ /* Read the kernel. */
if( strcmp(p->kernelname, UI_NO_CONV_KERNEL_NAME) )
- p->kernel=gal_fits_img_read_kernel(p->kernelname, p->khdu,
- p->cp.minmapsize);
+ {
+ /* Read the kernel into memory. */
+ p->kernel=gal_fits_img_read_kernel(p->kernelname, p->khdu,
+ p->cp.minmapsize);
+
+ /* Make sure it has the same dimensions as the input. */
+ if( p->kernel->ndim != p->input->ndim )
+ error(EXIT_FAILURE, 0, "%s (hdu %s): is %zuD, however, %s (%s) "
+ "is a %zuD dataset", p->kernelname, p->khdu,
+ p->kernel->ndim, p->inputname, p->cp.hdu, p->input->ndim);
+ }
else
p->kernel=NULL;
}
diff --git a/bin/segment/ui.c b/bin/segment/ui.c
index 648aaf4..8231dc3 100644
--- a/bin/segment/ui.c
+++ b/bin/segment/ui.c
@@ -513,16 +513,19 @@ ui_prepare_kernel(struct segmentparams *p)
{
/* Read the kernel. */
if( strcmp(p->kernelname, UI_NO_CONV_KERNEL_NAME) )
- p->kernel=gal_fits_img_read_kernel(p->kernelname, p->khdu,
- p->cp.minmapsize);
+ {
+ /* Read the kernel into memory. */
+ p->kernel=gal_fits_img_read_kernel(p->kernelname, p->khdu,
+ p->cp.minmapsize);
+
+ /* Make sure it has the same dimensions as the input. */
+ if( p->kernel->ndim != p->input->ndim )
+ error(EXIT_FAILURE, 0, "%s (hdu %s): is %zuD, however, %s (%s) "
+ "is a %zuD dataset", p->kernelname, p->khdu,
+ p->kernel->ndim, p->inputname, p->cp.hdu, p->input->ndim);
+ }
else
p->kernel=NULL;
-
- /* Make sure it has the same dimensions as the input. */
- if( p->kernel->ndim != p->input->ndim )
- error(EXIT_FAILURE, 0, "%s (hdu %s): is %zuD, however, %s (%s) is a"
- "%zuD dataset", p->kernelname, p->khdu, p->kernel->ndim,
- p->inputname, p->cp.hdu, p->input->ndim);
}
else
{
- [gnuastro-commits] master ec3c102 056/113: Single to conditionally open ds9 for multi-HDU 2D or 3D, (continued)
- [gnuastro-commits] master ec3c102 056/113: Single to conditionally open ds9 for multi-HDU 2D or 3D, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 2491c91 064/113: Imported work in master, minor conflict in book fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 9dda05c 040/113: Merged recent work from the master branch with corrections, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 218a7db 041/113: Brought in recent work from master, corrections made, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6f4e484 032/113: Merged with recent updates in master, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 4fedb9d 038/113: Merged with master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 325d717 045/113: 3D matching now in Match program and library, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master d7e0037 047/113: Brought in recent work in master, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 303e6e2 048/113: Incorporated recent work, minor conflict corrected, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 5831e9e 052/113: Recent work in master imported, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 1af4ea9 062/113: Correct checks for kernel dimension in NoiseChisel and Segment,
Mohammad Akhlaghi <=
- [gnuastro-commits] master d13c715 065/113: Imported work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 91f2d3e 068/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 63b4edd 070/113: Imported work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 0ced9e5 072/113: Imported recent work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 88935ae 073/113: Dataset pointers initialized to NULL in upperlimit_write_check, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master d02c999 079/113: Recent work in master imported, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 4021652 078/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 8d64628 081/113: Recent work in master imported, minor conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 800c769 082/113: Imported all the work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master ac91655 084/113: Imported recent work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16