gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master a9e0049: wcslib_version and restrict config ma


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master a9e0049: wcslib_version and restrict config macros
Date: Tue, 25 Apr 2017 00:11:39 -0400 (EDT)

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

    wcslib_version and restrict config macros
    
    To verify if `wcslib_version' is present, previously we would only check
    the existence of `GAL_CONFIG_HAVE_WCSLIB_VERSION'. But this was changed and
    the macro now always exists, it just has a value of 0 or 1. So on Systems
    where this function isn't present, there were unidentified linker
    errors. This has been corrected.
    
    Also, to help speed up the low-level processing of the `array' element of
    `gal_data_t', we defined it as a restricted pointer. However, when the C89
    compiler doesn't have an actual `restrict', this would cause compiler
    problems during the checks (and later for library users). This problem
    didn't exist in Gnuastro's programs because Gnulib has some good tests to
    avoid such problems. So the result of Gnulib's configure time checks have
    been used to define `restrict' in `gnulib/config.h'. This way, library
    users can also benefit from the restrict pointer if their system supports
    it. If it doesn't, `restrict' will be ignored (defined as an empty CPP
    macro).
    
    The dependency of the `mkcatalog/aperturephot.sh' test was missing a `.log'
    so it would be skipped sometimes in parallel checks. This has been
    corrected.
    
    These issues were found and corrected with the great help of Alan Lefor on
    some of his systems and his prompt remote checks. So I am very grateful to
    him.
    
    I am also working on updating the library documentation and some is
    included in this commit.
---
 configure.ac                      |  13 +-
 doc/gnuastro.texi                 | 576 +++++++++++++++++---------------------
 lib/Makefile.am                   |   1 +
 lib/fits.c                        |   4 +-
 lib/gnuastro-internal/config.h.in |   5 +
 lib/gnuastro/data.h               |  13 +-
 tests/Makefile.am                 |   2 +-
 7 files changed, 297 insertions(+), 317 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6afc7de..a6211ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -180,12 +180,23 @@ AC_SUBST(HAVE_PTHREAD_BARRIER, [$has_pthread_barrier])
 
 
 
-#Gnulib checks:
+# Gnulib checks:
 gl_INIT
 
 
 
 
+# Gnulib checks for the proper name for the C99 equivalent `restrict'
+# keyword and puts it in the `ac_cv_c_restrict' variable. If none exists,
+# it will put a `no' inside of this variable. As described in the output
+# `bootstrapped/m4/gnulib-common.m4', this is only necessary until Autoconf
+# 2.70 is released. Afterwards, we can use AC_C_RESTRICT.
+AS_IF([test "x$ac_cv_c_restrict" = "xno"],
+      [gal_restrict_replace=], [gal_restrict_replace=$ac_cv_c_restrict])
+AC_SUBST(RESTRICT_REPLACEMENT, [$gal_restrict_replace])
+
+
+
 
 
 # To add the help2man:
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 4349cfa..f0286df 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -527,18 +527,24 @@ Review of library fundamentals
 Gnuastro library
 
 * Configuration information::   General information about library config.
+* Library data container::
+* Library data types::
+* Arithmetic on datasets::
 * Bounding box::                Finding the bounding box.
 * FITS files::                  Working with FITS data.
+* Text files::
 * Git wrappers::                Wrappers for functions in libgit2.
 * Linked lists::                Various types of linked lists.
-* Mesh grid for an image::      Breaking an image into a grid.
 * Polygons::                    Working with the vertices of a polygon.
 * Qsort functions::             Helper functions for Qsort.
-* Spatial convolution::         Doing spatial convolution on an image
 * Statistical operations::      Functions for basic statistics.
 * Multithreaded programming::   Facilitating use of pthreads.
 * World Coordinate System::     Dealing with the world coordinate system.
 
+Data container (@file{data.h})
+
+* Data container type::
+
 FITS files (@file{fits.h})
 
 * FITS macros and data structures::  Gnuastro FITS related macros and 
structures.
@@ -16395,16 +16401,47 @@ you feel all these linkings can be confusing, please 
have a look at
 The number and order of libraries that are necessary for linking a program
 with Gnuastro library might be too confusing when you need to compile a
 small program for one particular job (with one source file). To solve this
-problem, please add these lines to your @file{~/.bashrc} with a text editor
-and replace @code{PREFIX} with Gnuastro's installation directory (see
address@hidden directory}).
+problem, please add the following lines to your @file{~/.bashrc} with a
+text editor and replace @code{PREFIX} with Gnuastro's installation
+directory (see @ref{Installation directory}, if you haven't changed it the
+installation directory explicity at installation, put @file{/usr/local} in
+place of @code{PREFIX}). Also copy the comments to help readability later.
 
 @example
-# Compile and correctly link Gnuastro related programs
-# example:
-#    $ gnuastro-gcc myprog "-lfirst -lsecond"
-function gnuastro-gcc @{
-  libtool --mode=link gcc $1.c $2 PREFIX/lib/libgnuastro.la -o $1
+# Program-like function to compile and run (once) programs that use
+# the Gnuastro library. The general usage pattern is:
+#
+#     $ astcompilerun SOURCE  [ARGUMENTS]  [OTHER-LIBRARIES]
+#
+#
+#   SOURCE: the name of the `.c' source file without the `.c', for
+#      example, for `myprog.c', SOURCE would be `myprog'.
+#
+#   ARGUMENTS: any arguments to run the program with after
+#      compilation. If there are multiple arguments, put them in
+#      double quotes, for example "img1.fits img2.fits". This is
+#      optional.
+#
+#   OTHER-LIBRARIES: If your program depends on any libraries other
+#      than Gnuastro's dependencies. For example if it needs libfirst
+#      and libsecond, use "-lfirst -lsecond". This is optional.
+#
+# When there are no arguments and no libraries other than Gnuastro's
+# dependencies, you can simply run this command (when your source is
+# in `myprog.c'
+#
+#     $ astcompilerun myprog
+#
+function astcompilerun @{
+  echo "---- compilation command ----"
+  if libtool --mode=link gcc $1.c $3 PREFIX/lib/libgnuastro.la -o $1
+    then
+      echo "-----------------------------"
+      echo " \"$1\" created in this directory and will be run below."
+      echo " For later runs in this directory, run: \"\$ ./$1 $2\""
+      echo "-----------------------------"
+      ./$1 $2
+  fi
 @}
 @end example
 
@@ -16418,7 +16455,7 @@ you want to compile a C program that uses Gnuastro 
library (for example
 contains the source file:
 
 @example
-$ gnuastro-gcc myprog
+$ astcompilerun myprog
 @end example
 
 @noindent
@@ -16430,10 +16467,8 @@ $ gnuastro-gcc myprog "-lfirst -lsecond"
 @end example
 
 @noindent
-If you also want to execute the compiled program without typing a second
-command, add @command{&& ./myprog} to either of the lines above, like the
-example below. If your program can take arguments, then you can also
-include them afterwards.
+If your program can take arguments, then you can also include them
+afterwards.
 
 @example
 $ gnuastro-gcc myprog && ./myprog
@@ -16443,31 +16478,30 @@ $ gnuastro-gcc myprog && ./myprog
 @node Gnuastro library,  , Review of library fundamentals, Libraries
 @section Gnuastro library
 
-Gnuastro library's exported constructs (functions, macros, data structures,
-or global variables) are classified by context into multiple header files
-(see @ref{Headers})@footnote{Within Gnuastro's source, all installed
address@hidden files in @file{lib/gnuastro/} are accompanied by a @file{.c} file
-in @file{/lib/}.}. In this section, the functions in each header will be
-discussed under a separate sub-section, which includes the name of the
-header. Assuming a function declaration is in @file{headername.h}, you can
-include its declaration in your source code with:
+Gnuastro library's programming constructs (function declarations, macros,
+data structures, or global variables) are classified by context into
+multiple header files (see @ref{Headers})@footnote{Within Gnuastro's
+source, all installed @file{.h} files in @file{lib/gnuastro/} are
+accompanied by a @file{.c} file in @file{/lib/}.}. In this section, the
+functions in each header will be discussed under a separate sub-section,
+which includes the name of the header. Assuming a function declaration is
+in @file{headername.h}, you can include its declaration in your source code
+with:
 
 @example
 # include <gnuastro/headername.h>
 @end example
 
 @noindent
-The names of all constructs are prefixed with @code{gal_headername_} (or
address@hidden for macros). The @code{gal_} prefix stands for
address@hidden @emph{A}stronomy @emph{L}ibrary. The @code{headername} prefix is
-replaced by the header file name (without the @file{.h}) which contains the
-construct.
+The names of all constructs in @file{headername.h} are prefixed with
address@hidden (or @code{GAL_HEADERNAME_} for macros). The
address@hidden prefix stands for @emph{G}NU @emph{A}stronomy @emph{L}ibrary.
 
-All Gnuastro library functions are compiled into a single file which can be
+Gnuastro library functions are compiled into a single file which can be
 linked on the command-line with the @option{-lgnuastro} option, (see
 @ref{Linking} and @ref{Summary and example on libraries} for an
-introduction). Gnuastro library is a high-level library which depends on
-lower level libraries for some operations (see
+introduction on linking and example). Gnuastro library is a high-level
+library which depends on lower level libraries for some operations (see
 @ref{Dependencies}). Therefore if at least one of Gnuastro's functions in
 your program use functions from the dependencies, you will also need to
 link those dependencies after linking with Gnuastro. The outside libraries
@@ -16483,33 +16517,33 @@ your exciting science.
 @strong{Libraries are still under heavy development: } Gnuastro was
 initially created to be a collection of command-line programs. However, as
 the programs and their the shared functions grew, internal (not installed)
-libraries were added. With the 0.2 release, the libraries are
-install able. Because of this history in these early phases, the libraries
-are not fully programmer friendly yet: they abort the program on an error,
-their naming and arguments are not fully uniform, or modular, and most of
-the interesting functions (that are currently only used within one program)
-are still internal to the program. During the next releases, Gnuastro's
-library structure will undergo significant evolution to address all these
-problems. It will stabilize with the removal of this notice. Check the
address@hidden file for interface changes.
+libraries were added. Since the 0.2 release, the libraries are
+installable. Hence the libraries are currently under heavy development and
+will significantly evolve between releases and will become more mature and
+stable in due time. It will stabilize with the removal of this
+notice. Check the @file{NEWS} file for interface changes. If you use the
+Info version of this manual (see @ref{Info}), you don't have to worry: the
+documentation will correspond to your installed version.
 @end cartouche
 
 @menu
 * Configuration information::   General information about library config.
+* Library data container::
+* Library data types::
+* Arithmetic on datasets::
 * Bounding box::                Finding the bounding box.
 * FITS files::                  Working with FITS data.
+* Text files::
 * Git wrappers::                Wrappers for functions in libgit2.
 * Linked lists::                Various types of linked lists.
-* Mesh grid for an image::      Breaking an image into a grid.
 * Polygons::                    Working with the vertices of a polygon.
 * Qsort functions::             Helper functions for Qsort.
-* Spatial convolution::         Doing spatial convolution on an image
 * Statistical operations::      Functions for basic statistics.
 * Multithreaded programming::   Facilitating use of pthreads.
 * World Coordinate System::     Dealing with the world coordinate system.
 @end menu
 
address@hidden Configuration information, Bounding box, Gnuastro library, 
Gnuastro library
address@hidden Configuration information, Library data container, Gnuastro 
library, Gnuastro library
 @subsection Configuration information (@file{config.h})
 
 The @file{gnuastro/config.h} header contains information about the full
@@ -16517,8 +16551,8 @@ Gnuastro installation on your system. Gnuastro 
developers should note that
 this is the only header that is not available within Gnuastro, it is only
 available to a Gnuastro library user @emph{after} installation. Within
 Gnuastro, @file{config.h} (which is included in every Gnuastro @file{.c}
-file, see @ref{Coding conventions}) should have more than enough
-information about the overall Gnuastro installation.
+file, see @ref{Coding conventions}) has more than enough information about
+the overall Gnuastro installation.
 
 @deffn Macro GAL_CONFIG_VERSION
 This macro can be used as a string
@@ -16542,25 +16576,192 @@ char *gnuastro_version=GAL_CONFIG_VERSION;
 @deffn Macro GAL_CONFIG_HAVE_LIBGIT2
 Libgit2 is an optional dependency of Gnuastro (see @ref{Optional
 dependencies}). When it is installed and detected at configure time, this
-macro will have a value of @code{1}. Otherwise, it will have a value of
address@hidden Gnuastro also comes with some wrappers to make it easier to use
-libgit2 (see @ref{Git wrappers}).
+macro will have a value of @code{1} (one). Otherwise, it will have a value
+of @code{0} (zero). Gnuastro also comes with some wrappers to make it
+easier to use libgit2 (see @ref{Git wrappers}).
 @end deffn
 
 
address@hidden Macro GAL_CONFIG_HAVE_WCSLIB_VERSION
+WCSLIB is the reference library for world coordinate system transformation
+(see @ref{WCSLIB} and @ref{World Coordinate System}). However, only more
+recent versions of WCSLIB also provide its version number. If the WCSLIB
+that is installed on the system provides its version (through the possibly
+existing @code{wcslib_version} function), this macro will have a value of
+one, otherwise it will have a value of zero.
address@hidden deffn
+
 @deffn Macro GAL_CONFIG_HAVE_PTHREAD_BARRIER
 The POSIX threads standard define barriers as an optional
-requirement. Therefore, some operating systems choose to not include
-it. While installing Gnuastro, we check if your system has this construct
-and if so, we give this macro a value of @code{1}, otherwise it will have a
-value of @code{0}. see @ref{Implementation of pthread_barrier} for more.
+requirement. Therefore, some operating systems choose to not include it. As
+one of the @command{./configure} step checks, Gnuastro we check if your
+system has this POSIX thread barriers. If so, this macro will have a value
+of @code{1}, otherwise it will have a value of @code{0}. see
address@hidden of pthread_barrier} for more.
 @end deffn
 
address@hidden Macro GAL_CONFIG_BIN_OP_UINT8
address@hidden Macro GAL_CONFIG_BIN_OP_INT8
address@hidden Macro GAL_CONFIG_BIN_OP_UINT16
address@hidden Macro GAL_CONFIG_BIN_OP_INT16
address@hidden Macro GAL_CONFIG_BIN_OP_UINT32
address@hidden Macro GAL_CONFIG_BIN_OP_INT32
address@hidden Macro GAL_CONFIG_BIN_OP_UINT64
address@hidden Macro GAL_CONFIG_BIN_OP_INT64
address@hidden Macro GAL_CONFIG_BIN_OP_FLOAT32
address@hidden Macro GAL_CONFIG_BIN_OP_FLOAT64
+If biniary arithmetic operators were configured for any type, the
+respective macro will have a value of @code{1} (one), otherwise its value
+will be @code{0} (zero). Please see the similar configure-time options in
address@hidden configure options} for a thorough explanation. These are only
+relevant for you if you intend to use the binary operators of
address@hidden on datasets}
address@hidden deffn
+
address@hidden 32-bit
address@hidden 64-bit
address@hidden bit-32
address@hidden bit-64
address@hidden Macro GAL_CONFIG_SIZEOF_SIZE_T
+The size of (number of bytes in) the system's @code{size_t} type. Its value
+is either 4 or 8 for 32-bit and 64-bit systems. You can also get this value
+with the expression address@hidden size_t}' without having to include this
+header.
address@hidden deffn
+
address@hidden Library data container, Library data types, Configuration 
information, Gnuastro library
address@hidden Data container (@file{data.h})
+
+Astronomical datasets have various dimensions, for example 1D spectra or
+table columns, 2D images, or 3D Integral field data cubes. Datasets can
+also have various numeric data types, depending on the operation/purpose,
+for example processed images are in commonly in floating point, but their
+mask images are integers using bit-wise flags to identify certain classes
+of special pixels, see @ref{Numeric data types}). Certain other information
+about a dataset are also commonly necessary, for example the units of the
+dataset, the name of the dataset and some comments. To deal with any
+generic dataset, Gnuastro defines the @code{gal_data_t} type.
+
address@hidden
+* Data container type::
address@hidden menu
+
address@hidden Data container type,  , Library data container, Library data 
container
address@hidden Data container type (@code{gal_data_t})
 
+For a generic operation on any dataset (with various dimensions, numeric
+data types, units and higher-level structures), Gnuastro defines the
address@hidden type which is the main input/output of many Gnuastro's
+library functions. It is defined in @file{gnuastro/data.h}. If you will be
+using (address@hidden include}'ing) those libraries, you don't need to include
+this header explicity, it is already included by any library header that
+uses @code{gal_data_t}.
 
address@hidden {Type (C @code{struct})} gal_data_t
+The main container for datasets in Gnuastro. It can host data of any
+dimensionality, with any numeric data type. It is actually a structure, but
address@hidden'd as a new type to avoid having to write the @code{struct}
+before any declaration. The actual structure is shown below which is
+followed by a description of each element.
 
address@hidden
+typedef struct gal_data_t
address@hidden
+  void     *restrict array;  /* Basic array information.   */
+  uint8_t             type;
+  size_t              ndim;
+  size_t            *dsize;
+  size_t              size;
+  char           *mmapname;
+  size_t        minmapsize;
+
+  int                 nwcs;  /* WCS information.           */
+  struct wcsprm       *wcs;
+
+  uint8_t             flag;  /* Content description.       */
+  int               status;
+  char               *name;
+  char               *unit;
+  char            *comment;
+
+  int             disp_fmt;  /* For text printing.         */
+  int           disp_width;
+  int       disp_precision;
+
+  struct gal_data_t  *next;  /* For higher-level datasets. */
+  struct gal_data_t *block;
address@hidden gal_data_t;
address@hidden example
address@hidden deftp
+
address@hidden
+The list below contains a description for each @code{gal_data_t} element.
+
address@hidden @code
address@hidden void *restrict array
+This is the pointer to the main array of the dataset containing the raw
+data (values). All the other elements in this data-structure are actually
+meta-data enabling us to use/understand the series of values in this
+array. Since it is to use data of any type, the array is actually a
address@hidden *} pointer. A @code{void *} array is not directly usable, you
+can use a procedure like the example below to use the array in any
+type. You can compile and run this program with the script described in
address@hidden linking script}
+
+
address@hidden
+#include <stdio.h>
+#include <stdlib.h>
+#include <gnuastro/fits.h>
+#include <gnuastro/statistics.h>
 
address@hidden Bounding box, FITS files, Configuration information, Gnuastro 
library
+int
+main(void)
address@hidden
+  size_t i;
+  float *farray;
+  double sum=0.0f;
+  gal_data_t *image;
+  char *filename="img.fits", *hdu="1";
+
+  /* Read `img.fits' (HDU: 1) as a float32 array. */
+  image=gal_fits_img_read_to_type(filename, hdu,
+                                  GAL_TYPE_FLOAT32, -1);
+
+  /* Use the allocated space as a single precision floating
+   * point array (recall that `image->array' has `void *'
+   * type, so it is not directly usable. */
+  farray=image->array;
+
+  /* Calculate the sum of all the values. */
+  for(i=0; i<image->size; ++i)
+    sum += farray[i];
+
+  /* Report the sum. */
+  printf("Sum of values in %s (hdu %s) is: %f\n",
+         filename, hdu, sum);
+
+  /* Clean up and return. */
+  gal_data_free(image);
+  return EXIT_SUCCESS;
address@hidden
address@hidden example
+
address@hidden table
+
+
+
address@hidden Library data types, Arithmetic on datasets, Library data 
container, Gnuastro library
address@hidden Library data types (@file{type.h})
+
+This header defines basic type identifiers and functions relating to the
+different types.
+
address@hidden Arithmetic on datasets, Bounding box, Library data types, 
Gnuastro library
address@hidden Arithmetic on datasets (@file{arithmetic.h})
+
+
address@hidden Bounding box, FITS files, Arithmetic on datasets, Gnuastro 
library
 @subsection Bounding box (@file{box.h})
 
 Functions related to reporting a the bounding box of certain inputs are
@@ -16592,7 +16793,7 @@ last pixels of the overlap will be put in 
@code{fpixel_o} and
 @code{lpixel_o}.
 @end deftypefun
 
address@hidden FITS files, Git wrappers, Bounding box, Gnuastro library
address@hidden FITS files, Text files, Bounding box, Gnuastro library
 @subsection FITS files (@file{fits.h})
 
 @cindex FITS
@@ -17018,7 +17219,11 @@ error notice.
 @address@hidden deftypefun
 
 
address@hidden Git wrappers, Linked lists, FITS files, Gnuastro library
address@hidden Text files, Git wrappers, FITS files, Gnuastro library
address@hidden Text files (@file{txt.h})
+
+
address@hidden Git wrappers, Linked lists, Text files, Gnuastro library
 @subsection Git wrappers (@file{git.h})
 
 @cindex Git
@@ -17054,7 +17259,7 @@ not installed or the program calling this function is 
not within a version
 controlled directory, then the output will be the @code{NULL} pointer.
 @end deftypefun
 
address@hidden Linked lists, Mesh grid for an image, Git wrappers, Gnuastro 
library
address@hidden Linked lists, Polygons, Git wrappers, Gnuastro library
 @subsection Linked lists (@file{linkedlist.h})
 
 @cindex Array
@@ -17449,222 +17654,7 @@ within the nodes will also be discarded.
 @end deftypefun
 
 
address@hidden Mesh grid for an image, Polygons, Linked lists, Gnuastro library
address@hidden Mesh grid for an image (@file{mesh.h})
-
-The basic concepts behind the mesh and channel grids in Gnuastro were
-explained in @ref{Tessellation}. Besides the improved measurement purposes
-introduced there, tiling an image can also greatly speed up some processing
-operations over the image, since each mesh can be given to a different
-thread and so the CPU can be working on multiple regions of the image
-simultaneously. The mesh structure and functions introduced here are
-declared in @file{gnuastro/mesh.h} and allow you to also use operate on an
-image mesh.
-
-Please note that as discussed in @ref{Gnuastro library}, most library
-functions will significantly evolve with future releases. The mesh
-structure and functions introduced here are high on this list: until now
-they were only internally used and so not much attention had been paid to
-their usability outside Gnuastro. Gnuastro's @file{lib/mesh.c} contains the
-full function definitions and is heavily commented, please also consult
-that file if the explanations here are not clear enough. However, the basic
-idea behind this structure, and the functions to manipulate data over it,
-is a powerful tool that can be generically used in many contexts. So please
-use the structure and functions here very critically and share your
-criticisms, thoughts and ideas on them. Hopefully in future releases the
-structure and functions were will evolve to become an easy to use and
-generically applicable mesh grid system.
-
-
-
address@hidden Structure gal_mesh_params
-This structure keeps all the necessary parameters for a particular mesh and
-channel grid over an image. This structure only keeps the information about
-the mesh and channel grid structure. It doesn't keep a copy of the
-different parts of the image. So when working on several images of the same
-size, you can use the same mesh structure. Its individual elements are too
-many to fully list here, if you are interested please look into the
-installed @file{gnuastro/mesh.h} header.
-
-One important component of the structure which is commonly used in the
-functions is the @code{garray}, where each mesh has a unique
address@hidden @code{garray} stands for grid-array. It is used for operations
-on the mesh grid, where one value is to be assigned for each mesh. It has
-one element for each mesh in the image. However, due to the (possible)
-existence of channels (see @ref{Tessellation}), each channel needs its own
-contiguous part (group of meshes) in the full @code{garray}. Each channel
-has @code{gs0*gs1} (dimensions of meshes in each channel) elements. There
-are @code{nch} parts (or channels) in total.  In short, the meshs in each
-channel have to be contiguous to facilitate the neighbor analysis in
-interpolation and other channel specific jobs. So, the over-all structure
-can be viewed as a 3D array. The operations on the meshs might need more
-than one output, for example the mean and the standard deviation. So we
-have two @code{garray}s and two @code{nearest} arrays (for interpolation).
address@hidden deftp
-
address@hidden size_t gal_mesh_ch_based_id_from_gid (struct gal_mesh_params 
@code{*mp}, size_t @code{gid})
-As discussed in the description of @code{gal_mesh_params}, there are two
-internal ways to refer to a mesh (with an ID):
-
address@hidden
address@hidden
-By default, the mesh IDs are set based on their position within the
-channels (so the meshs in each channel are contiguous). We call this the
-channel-based mesh ID. The @code{cgarray1} and @code{cgarray2} in
address@hidden store the mesh values based on this ID. All the
-basic mesh properties, like their types and height and widths are stored
-based on this ID.
-
address@hidden
-If the user asks for a full image interpolation or smoothing, then two new
-arrays are created called @code{fgarray1} and @code{fgarray2}. These arrays
-keep the mesh values as they appear on the image, irrespective of which
-channel they belong to. We call this the image-based ID. The image based ID
-is contiguous over the image.
address@hidden itemize
-
-The @code{garray1} and @code{garray2} pointers can point to either the
address@hidden or the @code{fgarrays}. Ideally, the user should not worry
-about what garray is pointing to. The caller knows the type of IDs they are
-using, but they don't know what to put into @code{garray}. We call the ID
-that should be put into garray the channel-based ID. It can be either of
-the two kinds above. So we have the following two functions
address@hidden and
address@hidden for changing between these IDs.
-
-The former (this function) is used when you are going over the elements in
-garray (and you are completely ignorant to which one of cgarrays or
-fgarrays garray points to) and you need the channel based IDs to get basic
-mesh information like the mesh type and size.
address@hidden deftypefun
-
address@hidden size_t gal_mesh_gid_from_ch_based_id (struct gal_mesh_params 
@code{*mp}, size_t @code{chbasedid})
-See the explanations in @code{gal_mesh_ch_based_id_from_gid} first. This
-function is used when you are going over the meshs through the
-channel-based IDs, but you need to know what ID to use for @code{garray}.
address@hidden deftypefun
-
address@hidden size_t gal_mesh_img_xy_to_mesh_id (struct gal_mesh_params 
@code{*mp}, size_t @code{x}, size_t @code{y})
-You have a pixel's position as @code{x} and @code{y} in the final image (in
-C-based dimensions) and want to know the id to be used in the
address@hidden to get a value for this pixel in the mesh-grid. This
-function will return that ID. As an example, you can get the mesh value at
-a specific position in the image with:
address@hidden
-mp->garray[ gal_mesh_img_xy_to_mesh_id(mp, x, y) ];
address@hidden example
address@hidden deftypefun
-
address@hidden void gal_mesh_check_mesh_id (struct gal_mesh_params @code{*mp}, 
long @code{**out})
-Save the meshid of each pixel into an array the size of the original
-image. All the pixels over the mesh will get the value of the mesh ID. The
-output array @code{out} can then be written to a FITS file for
-viewing. This is mainly used for checking/debugging purposes, hence the
address@hidden in the name.
address@hidden deftypefun
-
address@hidden void gal_mesh_check_garray (struct gal_mesh_params @code{*mp}, 
float @code{**out1}, float @code{**out2})
-Save the values in the @code{garray}s of the input @code{mp} structure into
-two arrays the size of the input image. All the pixels over each mesh will
-get the value corresponding to that mesh in the @code{garray}s. The output
-arrays can then be written to a FITS file for viewing. This is mainly used
-for checking/debugging purposes, hence the @code{check} in the
-name. @code{out2} will only be set if there are two @code{garray}s.
address@hidden deftypefun
-
address@hidden void gal_mesh_value_file (struct gal_mesh_params @code{*mp}, 
char @code{*filename}, char @code{*extname1}, char @code{*extname2}, struct 
wcsprm @code{*wcs}, char @code{*spack_string})
-Save the mesh grid values into the @file{filename} FITS file with
address@hidden and @code{extname2} extension names (for the two possible
address@hidden), a WCS structure may also optionally be given and
address@hidden is the name of your program to be written in the
-header. The output FITS file will have one pixel for each mesh, so its
-dimensions will be significantly smaller than the input image. If you want
-the mesh values in the same dimension as the input image, use
address@hidden
address@hidden deftypefun
-
address@hidden void gal_mesh_full_garray (struct gal_mesh_params @code{*mp}, 
int @code{reverse})
-As described in @code{gal_mesh_ch_based_id_from_gid}, the there can be two
-arrays that keep a value for each mesh in @code{gal_mesh_params}:
address@hidden and @code{fgarray}. When @code{reverse==0}, then this
-function will fill in the @code{fgarray}s using the @code{cgarray}s and
-vice-versa when @code{reverse==1}.
address@hidden deftypefun
-
address@hidden void gal_mesh_make_mesh (struct gal_mesh_params @code{*mp})
-Make the mesh structure using the basic information that must already be
-present within it. The complete list of necessary parameters are as
-follows, but note that some might not be necessary for your desired
-functionality. @code{s0}, @code{s1}, @code{ks0}, @code{ks1}, @code{nch1},
address@hidden, @code{kernel}, @code{img}, @code{params}, @code{minmodeq},
address@hidden, @code{fullsmooth}, @code{numnearest},
address@hidden, @code{lastmeshfrac}, @code{meshbasedcheck},
address@hidden, @code{fullinterpolation}, @code{numthreads}. See
-the installed @file{gnuastro/mesh.h} for a comment on each parameter within
-the @code{gal_mesh_params} structure.
address@hidden deftypefun
-
address@hidden void gal_mesh_free_mesh (struct gal_mesh_params @code{*mp})
-Free all the allocated spaces within the @code{gal_mesh_params} structure.
address@hidden deftypefun
-
address@hidden void gal_mesh_operate_on_mesh (struct gal_mesh_params 
@code{*mp}, void @code{*(*meshfunc)(void *)}, size_t @code{oneforallsize}, int 
@code{makegarray2}, int @code{initialize})
address@hidden NaN
address@hidden Pthread
address@hidden IEEE NaN
-Run the @code{meshfunc} function on each mesh in parallel. As the
-declaration above shows, @code{meshfunc} should only take one @code{void *}
-input and return one @code{void *} output. This function will setup a
-pthread environment and make @code{mp->numthreads} (a number!) calls
address@hidden which will work on each
-mesh. @code{gal_mesh_operate_on_mesh} will return when all the threads have
-finished their work. If @code{meshfunc} needs to store more than one value
-for each mesh, then set @code{makegarray2=1}. When @code{initialize==1},
-the @code{garray}(s) will be initialized to NaN.
-
-This function is commonly used within Gnuastro (mainly in NoiseChisel, see
address@hidden), so search for its applications in the programs for
-some real-world examples. You can do this with the following command in the
-top Gnuastro source directory (after unpacking the tarball):
address@hidden
-grep -r gal_mesh_operate_on_mesh ./bin/*
address@hidden example
address@hidden deftypefun
-
address@hidden void gal_mesh_interpolate (struct gal_mesh_params @code{*mp}, 
char @code{*errstart})
address@hidden NaN
address@hidden IEEE NaN
-Interpolate the mesh values (@code{garray}s). After you have run a function
-on all the meshes with @code{gal_mesh_operate_on_mesh}, some meshes might
-not get any values. This function will fill the meshes that didn't get any
-values (have a value of NaN) using the meshes that received a value. The
-interpolation is done based on the nearest neighbors, specified within the
address@hidden structure.
address@hidden deftypefun
-
address@hidden void gal_mesh_smooth (struct gal_mesh_params @code{*mp})
-Smooth the mesh values arrays based on the parameters in
address@hidden
address@hidden deftypefun
-
address@hidden void gal_mesh_spatial_convolve_on_mesh (struct gal_mesh_params 
@code{*mp}, float @code{**conv})
-Do spatial convolution (see @ref{Spatial domain convolution}) on each
-channel of the mesh grid independently, therefore two adjacent pixels within
-the image that are not in the same channel will not affect each other during
-the convolution.
address@hidden deftypefun
-
address@hidden void gal_mesh_change_to_full_convolution (struct gal_mesh_params 
@code{*mp}, float @code{*conv})
-After running @code{gal_mesh_spatial_convolve_on_mesh}, it might become
-necessary to change the convolution into a full image convolution. This
-function will do the convolution process only on the regions near the
-channel borders that need to be changed, the rest of the pixels will not be
-changed by this function.
address@hidden deftypefun
-
-
-
address@hidden Polygons, Qsort functions, Mesh grid for an image, Gnuastro 
library
address@hidden Polygons, Qsort functions, Linked lists, Gnuastro library
 @subsection Polygons (@file{polygon.h})
 
 Polygons are commonly necessary in image processing. In Gnuastro, they are
@@ -17774,7 +17764,7 @@ both polygons have to be sorted in an anti-clock-wise 
manner.
 
 
 
address@hidden Qsort functions, Spatial convolution, Polygons, Gnuastro library
address@hidden Qsort functions, Statistical operations, Polygons, Gnuastro 
library
 @subsection Qsort functions (@file{qsort.h})
 
 The C programming language comes with the @code{qsort} (Quick sort)
@@ -17851,51 +17841,13 @@ The output will be: @code{2, 0, 1, 3}.
 
 
 
address@hidden Spatial convolution, Statistical operations, Qsort functions, 
Gnuastro library
address@hidden Spatial convolution (@file{spatialconvolve.h})
-
-Convolution is a common operation in data processing and is fully explained
-in @ref{Spatial domain convolution} as part of @ref{Convolve}. We will
-therefore not explain the details, or its purpose here. The main high-level
-function here is @code{gal_spatialconvolve_convolve} which will do spatial
-convolution on multiple threads. The structure and functions introduced
-here are declared in @file{gnuastro/spatialconvolve.h}.
-
-In the first release of the Gnuastro libraries, this is the most high-level
-library since it was needed by multiple programs. In future releases this
-library will most probably merge with the frequency domain convolution
-functions to allow programmers to choose from the type of convolution they
-want. The main
-
address@hidden Structure gal_spatialconvolve_params
-This structure keeps all the basic convolution information so subsequent
-calls can be simpler. Please see the header for the details of its
-elements, complemented with comments.
address@hidden deffn
-
address@hidden void gal_spatialconvolve_pparams (float @code{*input}, size_t 
@code{is0}, size_t @code{is1}, float @code{*kernel}, size_t @code{ks0}, size_t 
@code{ks1}, size_t @code{nt}, int @code{edgecorrection}, float @code{*out}, 
size_t @code{*indexs}, struct gal_spatialconvolve_params @code{*scp})
-Initialize @code{gal_spatialconvolve_params} with the given arguments.
address@hidden deftypefun
 
address@hidden {void *} gal_spatialconvolve_thread (void @code{*inparam})
-This function should be passed onto @code{pthread_create} to create a new
-thread for convolution on a region of the image.
address@hidden deftypefun
-
address@hidden void gal_spatialconvolve_convolve (float @code{*input}, size_t 
@code{is0}, size_t @code{is1}, float @code{*kernel}, size_t @code{ks0}, size_t 
@code{ks1}, size_t @code{numthreads}, int @code{edgecorrection}, float 
@code{**out})
-Convolve @code{input} (with @code{is0*is1} pixels) with the @code{kernel}
-(with @code{ks0*ks1}) on @code{numthreads} CPU threads. If you want
-edge-correction (see @ref{Edges in the spatial domain}), then set
address@hidden to @code{1}, otherwise set it to @code{0}. Memory
-will be allocated for the output and the convolved image will be stored in
address@hidden
address@hidden deftypefun
 
 
 
 
 
address@hidden Statistical operations, Multithreaded programming, Spatial 
convolution, Gnuastro library
address@hidden Statistical operations, Multithreaded programming, Qsort 
functions, Gnuastro library
 @subsection Statistical operations (@file{statistics.h})
 
 This header includes a large variety of very basic statistical operators
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0658d15..9d8070a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -125,6 +125,7 @@ gnuastro/config.h: Makefile $(internaldir)/config.h.in
               -e 's|@address@hidden|$(HAVE_BIN_OP_FLOAT32)|g'    \
               -e 's|@address@hidden|$(HAVE_BIN_OP_FLOAT64)|g'    \
               -e 's|@address@hidden|$(SIZEOF_SIZE_T)|g'                \
+              -e 's|@address@hidden|$(RESTRICT_REPLACEMENT)|g'  \
                $(internaldir)/config.h.in >> address@hidden
        chmod a-w address@hidden
        mv address@hidden $@
diff --git a/lib/fits.c b/lib/fits.c
index 6fbe8d3..e3a56f4 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -1123,7 +1123,7 @@ gal_fits_key_write_version(fitsfile *fptr, struct 
gal_fits_key_ll *headers,
      defined. Sometime in the future were everyone has moved to more
      recent versions of WCSLIB, we can remove this macro and its check
      in configure.ac.*/
-#ifdef GAL_CONFIG_HAVE_WCSLIB_VERSION
+#if GAL_CONFIG_HAVE_WCSLIB_VERSION == 1
   int wcslibvers[3];
   char wcslibversion[20];
   const char *wcslibversion_const;
@@ -1165,7 +1165,7 @@ gal_fits_key_write_version(fitsfile *fptr, struct 
gal_fits_key_ll *headers,
                   "CFITSIO version.", &status);
 
   /* Write the WCSLIB version. */
-#ifdef GAL_CONFIG_HAVE_WCSLIB_VERSION
+#if GAL_CONFIG_HAVE_WCSLIB_VERSION == 1
   wcslibversion_const=wcslib_version(wcslibvers);
   strcpy(wcslibversion, wcslibversion_const);
   fits_update_key(fptr, TSTRING, "WCSLIB", wcslibversion,
diff --git a/lib/gnuastro-internal/config.h.in 
b/lib/gnuastro-internal/config.h.in
index 0a094c9..600cf58 100644
--- a/lib/gnuastro-internal/config.h.in
+++ b/lib/gnuastro-internal/config.h.in
@@ -26,6 +26,11 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
    must be included before the C++ preparations below */
 
 
+/* The restrict keyword might not be present on some systems, so we are
+   redefining it here based on the checks in `configure.ac', see there for
+   more comments. */
+#define restrict @RESTRICT_REPLACEMENT@
+
 
 /* Configuration macros: */
 
diff --git a/lib/gnuastro/data.h b/lib/gnuastro/data.h
index 1383efe..4b29476 100644
--- a/lib/gnuastro/data.h
+++ b/lib/gnuastro/data.h
@@ -26,9 +26,20 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Include other headers if necessary here. Note that other header files
    must be included before the C++ preparations below */
 #include <math.h>
-
 #include <wcslib/wcs.h>
 
+/* When we are within Gnuastro's building process, `IN_GNUASTRO_BUILD' is
+   defined. In the build process, installation information (in particular
+   the `restrict' replacement) is kept in `config.h' (top source
+   directory). When building a user's programs, this information is kept in
+   `gnuastro/config.h'. Note that all `.c' files in Gnuastro's source must
+   start with the inclusion of `config.h' and that `gnuastro/config.h' is
+   only created at installation time (not present during the building of
+   Gnuastro). */
+#ifndef IN_GNUASTRO_BUILD
+#include <gnuastro/config.h>
+#endif
+
 #include <gnuastro/type.h>
 #include <gnuastro/linkedlist.h>
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 167ba79..6b9a8c1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -114,7 +114,7 @@ if COND_MKCATALOG
 
   mkcatalog/simple.sh: noisechisel/noisechisel.sh.log
   mkcatalog/aperturephot.sh: noisechisel/noisechisel.sh.log          \
-                             mkprof/clearcanvas.sh
+                             mkprof/clearcanvas.sh.log
 endif
 if COND_MKNOISE
   MAYBE_MKNOISE_TESTS = mknoise/addnoise.sh



reply via email to

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