gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 231a69e 5/6: New function to replace non-NaN p


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 231a69e 5/6: New function to replace non-NaN pixels in arraymanip
Date: Fri, 12 Aug 2016 23:58:02 +0000 (UTC)

branch: master
commit 231a69e62ac94181d5a0c80deffadb541a4c68cc
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    New function to replace non-NaN pixels in arraymanip
    
    A new function was added to `lib/arraymanip.c' to replace non-NaN pixels in
    an array with a given value. The main purpose was for task #14116
    ("MakeProfiles option to set non-masked pixels in background image to
    zero").
    
    Also one indentation case was corrected in fits.c
---
 lib/arraymanip.c          |   14 ++++++++++++++
 lib/fits.c                |    2 +-
 lib/gnuastro/arraymanip.h |    3 +++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/lib/arraymanip.c b/lib/arraymanip.c
index ac5e62c..419f880 100644
--- a/lib/arraymanip.c
+++ b/lib/arraymanip.c
@@ -206,6 +206,20 @@ gal_arraymanip_freplace_value(float *in, size_t size, 
float from, float to)
 
 
 
+/* Only replace non-NaN values in a float array. */
+void
+gal_arraymanip_freplace_nonnans(float *in, size_t size, float to)
+{
+  float *fpt;
+  fpt=in+size;
+  do
+    *in = isnan(*in) ? *in : to;
+  while(++in<fpt);
+}
+
+
+
+
 
 /* Move all the non-NaN elements in the array to the start of the
    array so that the non-NaN alements are contiguous. This is useful
diff --git a/lib/fits.c b/lib/fits.c
index 538e248..a48cfb7 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -734,7 +734,7 @@ hdutypestring(int hdutype)
    desired type. */
 void
 gal_fits_read_hdu(char *filename, char *hdu, int desiredtype,
-                       fitsfile **outfptr)
+                  fitsfile **outfptr)
 {
   size_t len;
   char *ffname;
diff --git a/lib/gnuastro/arraymanip.h b/lib/gnuastro/arraymanip.h
index 761c4d7..69765f4 100644
--- a/lib/gnuastro/arraymanip.h
+++ b/lib/gnuastro/arraymanip.h
@@ -51,6 +51,9 @@ void
 gal_arraymanip_freplace_value(float *in, size_t size, float from, float to);
 
 void
+gal_arraymanip_freplace_nonnans(float *in, size_t size, float to);
+
+void
 gal_arraymanip_no_nans(float *in, size_t *size);
 
 void



reply via email to

[Prev in Thread] Current Thread [Next in Thread]