[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 5d17cfa 2/6: New macro to check columns for in
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 5d17cfa 2/6: New macro to check columns for input catalogs |
Date: |
Fri, 12 Aug 2016 23:58:02 +0000 (UTC) |
branch: master
commit 5d17cfa143abec459252446477d95ad5aecec602
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
New macro to check columns for input catalogs
A new macro (`GAL_CHECKSET_CHECK_COL_NUM_IN_CAT') was added to
`lib/gnuastro/checkset.h' to only check the number of columns in a catalog
with a column that the user has specified. The old macro
(`GAL_CHECKSET_CHECK_COL_IN_CAT') would complain with an error on coming up
with such elements. The old macro was also modified to generally complain
for any non-finite number, not just NaNs.
This was mainly done as part of the work on task #14115 ("MakeProfiles flat
profiles have a given value"). For that task, it was necessary for the
catalog to have NaN values. Used when the user wants NaN covered profiles
to mask an elliptical region.
---
lib/gnuastro/checkset.h | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/lib/gnuastro/checkset.h b/lib/gnuastro/checkset.h
index 61a10ba..532a64d 100644
--- a/lib/gnuastro/checkset.h
+++ b/lib/gnuastro/checkset.h
@@ -30,6 +30,20 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/**************************************************************/
/********* Macros **************/
/**************************************************************/
+/* Check if the column number is within the boundaries of a catalog. */
+#define GAL_CHECKSET_CHECK_COL_NUM_IN_CAT(INCOL,NAME) { \
+ if( (INCOL) >= p->cs1 ) \
+ error(EXIT_FAILURE, 0, "%s only has %lu columns while you " \
+ "have requested column %lu (counting from zero) for " \
+ "`--%s`", p->up.catname, p->cs1, (INCOL), (NAME)); \
+ }
+
+
+
+
+
+/* Check both the column number and that the values in the column are
+ finitte numbers (not infinities or NAN). */
#define GAL_CHECKSET_CHECK_COL_IN_CAT(INCOL,NAME) { \
size_t i; \
\
@@ -39,7 +53,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
"`--%s`", p->up.catname, p->cs1, (INCOL), (NAME)); \
\
for(i=0;i<p->cs0;++i) \
- if( isnan(p->cat[i*p->cs1+(INCOL)]) ) \
+ if( !isfinite(p->cat[i*p->cs1+(INCOL)]) ) \
error(EXIT_FAILURE, 0, "%s: column %lu (--%s) in row %lu " \
"could not be read as a number. See %s. Note that " \
"counting starts from zero", \
@@ -48,6 +62,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
+
#define GAL_CHECKSET_PRINT_STRING_MAYBE_WITH_SPACE(name,string) { \
if(gal_checkset_string_has_space(string)) \
fprintf(fp, CONF_SHOWFMT"\"%s\"\n", name, string); \
- [gnuastro-commits] master updated (0b9d8f0 -> 463dd0c), Mohammad Akhlaghi, 2016/08/12
- [gnuastro-commits] master 93afc48 3/6: Macro to read numbers in txtarray is now a function, Mohammad Akhlaghi, 2016/08/12
- [gnuastro-commits] master 5d17cfa 2/6: New macro to check columns for input catalogs,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 231a69e 5/6: New function to replace non-NaN pixels in arraymanip, Mohammad Akhlaghi, 2016/08/12
- [gnuastro-commits] master 0fe062a 1/6: Two indentations corrected, Mohammad Akhlaghi, 2016/08/12
- [gnuastro-commits] master 463dd0c 6/6: MakeProfiles can now use input image as canvas, Mohammad Akhlaghi, 2016/08/12
- [gnuastro-commits] master 799c83b 4/6: Flat profiles in MakeProfiles are given values, Mohammad Akhlaghi, 2016/08/12