gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master b0d5fab 034/113: Merged recent work from maste


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master b0d5fab 034/113: Merged recent work from master, no conflicts
Date: Fri, 16 Apr 2021 10:33:38 -0400 (EDT)

branch: master
commit b0d5fab211c8f86c196783958d0e77b9c1ad1c13
Merge: be3bfd8 59e301a
Author: Mohammad Akhlaghi <akhlaghi@gnu.org>
Commit: Mohammad Akhlaghi <akhlaghi@gnu.org>

    Merged recent work from master, no conflicts
---
 Makefile.am                         |   2 +-
 NEWS                                |  14 ++-
 bin/arithmetic/arithmetic.c         |   9 +-
 bin/arithmetic/operands.c           |  21 +++-
 bin/buildprog/Makefile.am           |   4 +-
 bin/buildprog/args.h                |  14 +++
 bin/buildprog/buildprog.c           |  18 ++-
 bin/buildprog/main.h                |   1 +
 bin/buildprog/ui.c                  |  19 ++-
 bin/buildprog/ui.h                  |   3 +-
 bin/convertt/ui.c                   |   3 +-
 bin/convolve/ui.c                   |  10 +-
 bin/crop/ui.c                       |   3 +-
 bin/mkcatalog/ui.c                  |  18 +--
 bin/mknoise/ui.c                    |   6 +-
 bin/mkprof/ui.c                     |  17 ++-
 bin/noisechisel/astnoisechisel.conf |   2 +-
 bin/noisechisel/detection.c         |   7 +-
 bin/noisechisel/ui.c                |   4 +-
 bin/statistics/ui.c                 |   5 +-
 bin/warp/ui.c                       |   6 +-
 configure.ac                        |  26 +++-
 doc/gnuastro.texi                   | 231 ++++++++++++++++++++++--------------
 lib/binary.c                        |   3 +
 lib/fits.c                          |  22 +++-
 lib/gnuastro-internal/commonopts.h  |   2 +-
 lib/gnuastro/fits.h                 |   8 +-
 lib/options.c                       |   6 +
 tests/Makefile.am                   |   4 +
 tests/buildprog/simpleio.c          |   2 +-
 tests/buildprog/simpleio.sh         |  15 ++-
 tests/lib/multithread.c             |   2 +-
 32 files changed, 337 insertions(+), 170 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 8555c23..2d2308d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -190,7 +190,7 @@ check-local:
         echo 
"==================================================================="; \
         echo 
"==================================================================="; \
         echo "Your build of Gnuastro $(VERSION) didn't fail on any tests.";    
     \
-        echo "To install Gnuastro, please run the commands below:";            
     \
+        echo "To install Gnuastro, please run the command(s) below:";          
     \
         echo;                                                                  
     \
         if [ ! -w $(prefix) ] ; then                                           
     \
          echo "(NOTE: As the user $$USER, you don't have writing permissions"; 
     \
diff --git a/NEWS b/NEWS
index 8ae540f..e4f4b4b 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,12 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
 
 ** New features
 
+  All programs: a value of `0' to the `--numthreads' option will use the
+  number of threads available to the system at run time.
+
+  BuildProgram: The new `--la' option allows the identification of a
+  different Libtool `.la' file for Libtool linking information.
+
   Fits: when an extension/HDU is identified on the command-line with the
   `--hdu' option and no operation is requested, the full list of header
   keywords in that HDU will be printed (as if only `--printallkeys' was
@@ -50,6 +56,12 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
   accept a new `withblank' option to set all pixels that are blank in the
   tile's block to be blank in the check image.
 
+  `gal_fits_img_read' and `gal_fits_img_read_to_type' now also read the WCS
+  structure of the extension/HDU in a FITS file and have two extra
+  arguments: `hstartwcs' and `hendwcs'. With these options it is possible
+  to limit the range of header keywords to read the WCS, similar to how
+  they are used in `gal_wcs_read'.
+
 ** Bug fixes
 
   ConvertType crash when changing values (bug #52010).
@@ -59,7 +71,7 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
 
   NoiseChisel segfault when memory mapping to a file (bug #52043).
 
-
+  CFITSIO 3.42 and libcurl crash at Gnuastro configure time (bug #52152).
 
 
 
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 622af73..b213e7d 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -335,7 +335,7 @@ reversepolish(struct arithmeticparams *p)
     error(EXIT_FAILURE, 0, "too many operands");
 
 
-  /* If the final operand has a filename, but it `data' element is NULL,
+  /* If the final operand has a filename, but its `data' element is NULL,
      then the file hasn't actually be read yet. In this case, we need to
      read the contents of the file and put the resulting dataset into the
      operands `data' element. This can happen for example if no operators
@@ -348,8 +348,11 @@ reversepolish(struct arithmeticparams *p)
       filename=p->operands->filename;
       if( gal_fits_name_is_fits(filename) )
         {
-          p->operands->data=gal_fits_img_read(filename,hdu,p->cp.minmapsize);
-          p->refdata.wcs=gal_wcs_read(filename, hdu, 0, 0, &p->refdata.nwcs);
+          p->operands->data=gal_fits_img_read(filename,hdu,p->cp.minmapsize,
+                                              0, 0);
+          p->refdata.wcs=p->operands->data->wcs;
+          p->refdata.nwcs=p->operands->data->nwcs;
+          p->operands->data->wcs=NULL;
           if(!p->cp.quiet) printf(" - %s (hdu %s) is read.\n", filename, hdu);
         }
       else
diff --git a/bin/arithmetic/operands.c b/bin/arithmetic/operands.c
index 585ea0b..76fd166 100644
--- a/bin/arithmetic/operands.c
+++ b/bin/arithmetic/operands.c
@@ -121,13 +121,22 @@ operands_pop(struct arithmeticparams *p, char *operator)
       hdu=operands->hdu;
       filename=operands->filename;
 
-      /* In case this is the first image that is read, then read the WCS
-         information.*/
-      if(p->popcounter==0)
-        p->refdata.wcs=gal_wcs_read(filename, hdu, 0, 0, &p->refdata.nwcs);
-
       /* Read the dataset. */
-      data=gal_fits_img_read(filename, hdu, p->cp.minmapsize);
+      data=gal_fits_img_read(filename, hdu, p->cp.minmapsize, 0, 0);
+
+      /* In case this is the first image that is read, then keep the WCS
+         information in the `refdata' structure. Otherwise, the WCS is not
+         necessary and we can safely free it. In any case, `data' must not
+         have a WCS structure. */
+      if(p->popcounter==0)
+        {
+          p->refdata.wcs=data->wcs;
+          p->refdata.nwcs=data->nwcs;
+        }
+      else
+        wcsfree(data->wcs);
+      data->wcs=NULL;
+      data->nwcs=0;
 
       /* When the reference data structure's dimensionality is non-zero, it
          means that this is not the first image read. So, write its basic
diff --git a/bin/buildprog/Makefile.am b/bin/buildprog/Makefile.am
index e20c19f..89e480e 100644
--- a/bin/buildprog/Makefile.am
+++ b/bin/buildprog/Makefile.am
@@ -25,8 +25,8 @@
 ## Buildprog will also need some system-specific information that is
 ## gathered at compile time (for example the library installation directory
 ## (LIBDIR) and the executive file suffix (EXEEXT).
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib                   \
-              -DLIBDIR=\"$(libdir)\" -DEXEEXT=\"$(EXEEXT)\"
+AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -DLIBDIR=\"$(libdir)\"  \
+              -DINCLUDEDIR=\"$(includedir)\" -DEXEEXT=\"$(EXEEXT)\"
 
 
 
diff --git a/bin/buildprog/args.h b/bin/buildprog/args.h
index 6d4f9fd..01a96fc 100644
--- a/bin/buildprog/args.h
+++ b/bin/buildprog/args.h
@@ -73,6 +73,20 @@ struct argp_option program_options[] =
       GAL_OPTIONS_NOT_SET
     },
 
+    {
+      "la",
+      UI_KEY_LA,
+      "STR",
+      0,
+      "Libtool `.la' to use instead of default.",
+      GAL_OPTIONS_GROUP_INPUT,
+      &p->la,
+      GAL_TYPE_STRING,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET
+    },
+
 
     {
       "debug",
diff --git a/bin/buildprog/buildprog.c b/bin/buildprog/buildprog.c
index 155ec10..24fbce1 100644
--- a/bin/buildprog/buildprog.c
+++ b/bin/buildprog/buildprog.c
@@ -23,6 +23,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <config.h>
 
 #include <stdio.h>
+#include <errno.h>
+#include <error.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -71,6 +73,7 @@ buildprog(struct buildprogparams *p)
   /* Note that the first node of `sourceargs' is the acutal source and the
      rest are arguments to be run later. */
   int retval;
+  char *fullla;
   char *command, *optimize=NULL, *warning=NULL;
   char *include   = buildprog_as_one_string("-I", p->include);
   char *linkdir   = buildprog_as_one_string("-L", p->linkdir);
@@ -88,9 +91,13 @@ buildprog(struct buildprogparams *p)
   if(p->warning)   asprintf(&warning,  "-W%s", p->warning);
   if(p->optimize)  asprintf(&optimize, "-O%s", p->optimize);
 
+  /* Libtool `.la' file: */
+  if(p->la) fullla=p->la;
+  else      asprintf(&fullla, "%s/libgnuastro.la", LIBDIR);
+
   /* Put the command to run into a string. */
   asprintf(&command, "libtool %s --mode=link gcc %s %s %s %s %s %s %s "
-           "%s/libgnuastro.la -o %s",
+           "-I%s %s -o %s",
            p->cp.quiet ? "--quiet" : "",
            warning     ? warning   : "",
            p->debug    ? "-g"      : "",
@@ -99,12 +106,15 @@ buildprog(struct buildprogparams *p)
            linkdir     ? linkdir   : "",
            p->sourceargs->v,
            linklib     ?linklib    : "",
-           LIBDIR,
+           INCLUDEDIR,
+           fullla,
            p->cp.output);
 
   /* Compile (and link): */
   retval=system(command);
-  if( retval==EXIT_SUCCESS && p->onlybuild==0)
+  if(retval!=EXIT_SUCCESS)
+    error(EXIT_FAILURE, 0, "failed to build, see libtool error above");
+  else if(p->onlybuild==0)
     {
       /* Free the initial command. */
       free(command);
@@ -126,7 +136,7 @@ buildprog(struct buildprogparams *p)
       /* Print the executed command if necessary, then run it. */
       if(!p->cp.quiet)
         {
-          printf("\nRun the compiled program\n");
+          printf("Run the compiled program\n");
           printf("------------------------\n");
           printf("%s\n", command);
         }
diff --git a/bin/buildprog/main.h b/bin/buildprog/main.h
index 56a9eed..2e3902c 100644
--- a/bin/buildprog/main.h
+++ b/bin/buildprog/main.h
@@ -48,6 +48,7 @@ struct buildprogparams
   gal_list_str_t     *include;    /* Libraries to link against.         */
   gal_list_str_t     *linkdir;    /* Libraries to link against.         */
   gal_list_str_t     *linklib;    /* Libraries to link against.         */
+  char                    *la;    /* Libtool `.la' instead of default.  */
 
   char              *optimize;    /* Optimization level.                */
   char                 *debug;    /* Keep debugging information.        */
diff --git a/bin/buildprog/ui.c b/bin/buildprog/ui.c
index 473a1c2..28c172b 100644
--- a/bin/buildprog/ui.c
+++ b/bin/buildprog/ui.c
@@ -26,6 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <errno.h>
 #include <error.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <gnuastro/fits.h>
 
@@ -216,13 +217,23 @@ parse_opt(int key, char *arg, struct argp_state *state)
 /***************       Sanity Check         *******************/
 /**************************************************************/
 /* Read and check ONLY the options. When arguments are involved, do the
-   check in `ui_check_options_and_arguments'.
+   check in `ui_check_options_and_arguments'. */
 static void
 ui_read_check_only_options(struct buildprogparams *p)
 {
+  size_t len;
 
+  /* If an `.la' file is given, make sure it has the correct suffix. */
+  if(p->la)
+    {
+      len=strlen(p->la);
+      if(len>=4)
+        if(strcmp(&p->la[len-3], ".la"))
+          error(EXIT_FAILURE, 0, "`%s' is not a Libtool control file name "
+                "(with a `.la' suffix). The file name given to the `--la' "
+                "(`-a') option must be a Libtool control file", p->la);
+    }
 }
-*/
 
 
 
@@ -327,9 +338,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
buildprogparams *p)
 
 
   /* Read the options into the program's structure, and check them and
-     their relations prior to printing.
+     their relations prior to printing. */
   ui_read_check_only_options(p);
-  */
+
 
   /* Print the option values if asked. Note that this needs to be done
      after the option checks so un-sane values are not printed in the
diff --git a/bin/buildprog/ui.h b/bin/buildprog/ui.h
index 7adccb3..40c72ad 100644
--- a/bin/buildprog/ui.h
+++ b/bin/buildprog/ui.h
@@ -29,7 +29,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 /* Available letters for short options:
 
-   a c d e f i j k l n p r s t u v w x y z
+   c d e f i j k n p r s t u v w x y z
    A B C E G H J Q R X Y
 */
 enum option_keys_enum
@@ -38,6 +38,7 @@ enum option_keys_enum
   UI_KEY_INCLUDE     = 'I',
   UI_KEY_LINKDIR     = 'L',
   UI_KEY_LINKLIB     = 'l',
+  UI_KEY_LA          = 'a',
   UI_KEY_ONLYBUILD   = 'b',
   UI_KEY_DEBUG       = 'g',
   UI_KEY_OPTIMIZE    = 'O',
diff --git a/bin/convertt/ui.c b/bin/convertt/ui.c
index 2f9f4d2..e52d85b 100644
--- a/bin/convertt/ui.c
+++ b/bin/convertt/ui.c
@@ -433,8 +433,7 @@ ui_make_channels_ll(struct converttparams *p)
                   "for each input FITS image (in the same order)");
 
           /* Read in the array and its WCS information. */
-          data=gal_fits_img_read(name->v, hdu, p->cp.minmapsize);
-          data->wcs=gal_wcs_read(name->v, hdu, 0, 0, &data->nwcs);
+          data=gal_fits_img_read(name->v, hdu, p->cp.minmapsize, 0, 0);
           gal_list_data_add(&p->chll, data);
 
           /* A FITS file only has one channel. */
diff --git a/bin/convolve/ui.c b/bin/convolve/ui.c
index 34c6c89..fb80e8f 100644
--- a/bin/convolve/ui.c
+++ b/bin/convolve/ui.c
@@ -304,8 +304,9 @@ ui_read_kernel(struct convolveparams *p)
 
   /* Read the image into file. */
   p->kernel = gal_fits_img_read_to_type(p->kernelname, p->khdu,
-                                        GAL_TYPE_FLOAT32,
-                                        p->cp.minmapsize);
+                                        GAL_TYPE_FLOAT32, p->cp.minmapsize,
+                                        0, 0);
+  if(p->kernel->wcs) { wcsfree(p->kernel->wcs); p->kernel->wcs=NULL; }
 
   /* Convert all the NaN pixels to zero if the kernel contains blank
      pixels, also update the flags so it is not checked any more. */
@@ -350,10 +351,9 @@ ui_preparations(struct convolveparams *p)
     }
 
 
-  /* Read the input image as a float64 array and its WCS info. */
+  /* Read the input image as a float64 array. */
   p->input=gal_fits_img_read_to_type(p->filename, cp->hdu,
-                                     GAL_TYPE_FLOAT32, cp->minmapsize);
-  p->input->wcs=gal_wcs_read(p->filename, cp->hdu, 0, 0, &p->input->nwcs);
+                                     GAL_TYPE_FLOAT32, cp->minmapsize, 0, 0);
 
 
   /* Domain specific checks. */
diff --git a/bin/crop/ui.c b/bin/crop/ui.c
index cf7d043..3d4a3e9 100644
--- a/bin/crop/ui.c
+++ b/bin/crop/ui.c
@@ -377,7 +377,8 @@ ui_read_check_only_options(struct cropparams *p)
   if(p->section && p->mode!=IMGCROP_MODE_IMG)
     error(EXIT_FAILURE, 0, "The `--section' option is only available in "
           "image coordinate mode, currently it doesn't work with WCS mode. "
-          "Please run with `--mode=img' and change the values accordingly");
+          "Please run with `--mode=img' and if necessary, change the "
+          "values accordingly");
 
 
   /* Sanity checks and mode setting based on the desired crop. */
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index 87f95a1..4e89812 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -340,7 +340,7 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
 
   /* Read the input image. */
   p->input=gal_fits_img_read_to_type(p->inputname, p->cp.hdu,
-                                     GAL_TYPE_FLOAT32, p->cp.minmapsize);
+                                     GAL_TYPE_FLOAT32, p->cp.minmapsize, 0,0);
 
 
   /* Currently MakeCatalog is only implemented for 2D images. */
@@ -356,7 +356,7 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
 
   /* Read the object label image and check its size. */
   p->objects = gal_fits_img_read(objectsfile, p->objectshdu,
-                                 p->cp.minmapsize);
+                                 p->cp.minmapsize, 0, 0);
   if( gal_data_dsize_is_different(p->input, p->objects) )
     error(EXIT_FAILURE, 0, "`%s' (hdu: %s) and `%s' (hdu: %s) have a"
           "different dimension/size", objectsfile, p->objectshdu,
@@ -365,7 +365,7 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
 
   /* Read the Sky image and check its size. */
   p->sky=gal_fits_img_read_to_type(skyfile, p->skyhdu, GAL_TYPE_FLOAT32,
-                                   p->cp.minmapsize);
+                                   p->cp.minmapsize, 0, 0);
   if( gal_data_dsize_is_different(p->input, p->sky) )
     error(EXIT_FAILURE, 0, "`%s' (hdu: %s) and `%s' (hdu: %s) have a"
           "different dimension/size", skyfile, p->skyhdu, p->inputname,
@@ -374,7 +374,7 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
 
   /* Read the Sky standard deviation image and check its size. */
   p->std=gal_fits_img_read_to_type(stdfile, p->stdhdu, GAL_TYPE_FLOAT32,
-                                   p->cp.minmapsize);
+                                   p->cp.minmapsize, 0, 0);
   if( gal_data_dsize_is_different(p->input, p->std) )
     error(EXIT_FAILURE, 0, "`%s' (hdu: %s) and `%s' (hdu: %s) have a"
           "different dimension/size", stdfile, p->stdhdu, p->inputname,
@@ -386,7 +386,7 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
     {
       /* Read the mask image. */
       p->upmask = gal_fits_img_read(p->upmaskfile, p->upmaskhdu,
-                                    p->cp.minmapsize);
+                                    p->cp.minmapsize, 0, 0);
       if( gal_data_dsize_is_different(p->input, p->upmask) )
         error(EXIT_FAILURE, 0, "`%s' (hdu: %s) and `%s' (hdu: %s) have a"
               "different dimension/size", p->upmaskfile, p->upmaskhdu,
@@ -442,7 +442,7 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
 
       /* Read the clumps image and check its size. */
       p->clumps = gal_fits_img_read(clumpsfile, p->clumpshdu,
-                                    p->cp.minmapsize);
+                                    p->cp.minmapsize, 0, 0);
       if( gal_data_dsize_is_different(p->input, p->std) )
         error(EXIT_FAILURE, 0, "`%s' (hdu: %s) and `%s' (hdu: %s) have a"
               "different dimension/size", clumpsfile, p->clumpshdu,
@@ -481,12 +481,6 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
     p->clumps=gal_data_copy_to_new_type_free(p->clumps, GAL_TYPE_INT32);
 
 
-  /* Read the WCS structure of the input dataset. Even if no WCS-related
-     columns are requested, we still need it to report the pixel area of
-     the input dataset. */
-  p->input->wcs=gal_wcs_read(p->inputname, p->cp.hdu, 0, 0, &p->input->nwcs);
-
-
   /* Clean up. */
   key->name=NULL;
   gal_data_array_free(key, 1, 1);
diff --git a/bin/mknoise/ui.c b/bin/mknoise/ui.c
index 7388979..606e957 100644
--- a/bin/mknoise/ui.c
+++ b/bin/mknoise/ui.c
@@ -282,11 +282,7 @@ ui_preparations(struct mknoiseparams *p)
 {
   /* Read the input image as a double type */
   p->input=gal_fits_img_read_to_type(p->inputname, p->cp.hdu,
-                                     GAL_TYPE_FLOAT64, p->cp.minmapsize);
-
-
-  /* Read the WSC structure. */
-  p->input->wcs=gal_wcs_read(p->inputname, p->cp.hdu, 0, 0, &p->input->nwcs);
+                                     GAL_TYPE_FLOAT64, p->cp.minmapsize, 0,0);
 
 
   /* If we are dealing with an input table, make sure the format of the
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index 9f9df1f..78cc20e 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -1386,14 +1386,26 @@ ui_prepare_canvas(struct mkprofparams *p)
           p->ndim = *(size_t *)(keysll->array);
           keysll->name=NULL;
           gal_data_array_free(keysll, 1, 1);
+
+          /* Read the WCS structure of the background image. */
+          p->wcs=gal_wcs_read(p->backname, p->backhdu, 0, 0, &p->nwcs);
         }
       else
         {
           /* Read the image. */
           p->out=gal_fits_img_read_to_type(p->backname, p->backhdu,
                                            GAL_TYPE_FLOAT32,
-                                           p->cp.minmapsize);
+                                           p->cp.minmapsize, 0, 0);
+
+          /* Put the WCS structure and number of dimensions in the
+             MakeProfiles's main structure for generality. The WCS
+             structure will be put back in the end when writing. */
+          p->wcs=p->out->wcs;
+          p->nwcs=p->out->nwcs;
           p->ndim=p->out->ndim;
+          p->out->wcs=NULL;
+          p->out->nwcs=0;
+
 
           /* If p->dsize was given as an option, free it. */
           if( p->dsize ) free(p->dsize);
@@ -1422,9 +1434,6 @@ ui_prepare_canvas(struct mkprofparams *p)
       if(p->shift) free(p->shift);
       p->shift=gal_data_calloc_array(GAL_TYPE_SIZE_T, p->ndim, __func__,
                                      "p->shift (1)");
-
-      /* Read the WCS structure of the background image. */
-      p->wcs=gal_wcs_read(p->backname, p->backhdu, 0, 0, &p->nwcs);
     }
   else
     {
diff --git a/bin/noisechisel/astnoisechisel.conf 
b/bin/noisechisel/astnoisechisel.conf
index b3ab828..bf44ac6 100644
--- a/bin/noisechisel/astnoisechisel.conf
+++ b/bin/noisechisel/astnoisechisel.conf
@@ -41,7 +41,7 @@
  dthresh            0.0
  detsnminarea        10
  detquant          0.95
- detgrowquant      0.65
+ detgrowquant      0.70
  detgrowmaxholesize 100
 
 # Segmentation
diff --git a/bin/noisechisel/detection.c b/bin/noisechisel/detection.c
index 405612c..51c1456 100644
--- a/bin/noisechisel/detection.c
+++ b/bin/noisechisel/detection.c
@@ -977,12 +977,13 @@ detection_quantile_expand(struct noisechiselparams *p, 
gal_data_t *workbin)
   exp_thresh_full=gal_tile_block_write_const_value(p->expand_thresh,
                                                    p->cp.tl.tiles, 0, 0);
 
+
   /* Count the pixels that must be expanded. */
   e_th=exp_thresh_full->array;
   do { if(*b++==0 && *arr>*e_th) ++counter; ++arr; ++e_th; } while(b<bf);
 
-  /* Allocate the space necessary to keep all the index of all the pixels
-     that must be expanded and re-initialize the necessary pointers. */
+  /* Allocate the space necessary to keep the index of all the pixels that
+     must be expanded and re-initialize the necessary pointers. */
   diffuseindexs=gal_data_alloc(NULL, GAL_TYPE_SIZE_T, 1, &counter, NULL, 0,
                                p->cp.minmapsize, NULL, NULL, NULL);
 
@@ -1056,7 +1057,9 @@ detection_quantile_expand(struct noisechiselparams *p, 
gal_data_t *workbin)
     }
 
   /* Clean up and return */
+  gal_data_free(p->expand_thresh);
   gal_data_free(exp_thresh_full);
+  gal_data_free(diffuseindexs);
   return numexpanded;
 }
 
diff --git a/bin/noisechisel/ui.c b/bin/noisechisel/ui.c
index ab52ee2..0d6efa8 100644
--- a/bin/noisechisel/ui.c
+++ b/bin/noisechisel/ui.c
@@ -650,8 +650,7 @@ ui_preparations_read_input(struct noisechiselparams *p)
   /* Read the input as a single precision floating point dataset. */
   p->input = gal_fits_img_read_to_type(p->inputname, p->cp.hdu,
                                        GAL_TYPE_FLOAT32,
-                                       p->cp.minmapsize);
-  p->input->wcs=gal_wcs_read(p->inputname, p->cp.hdu, 0, 0, &p->input->nwcs);
+                                       p->cp.minmapsize, 0, 0);
   if(p->input->name==NULL)
     gal_checkset_allocate_copy("INPUT", &p->input->name);
 
@@ -899,6 +898,7 @@ ui_free_report(struct noisechiselparams *p, struct timeval 
*t1)
   /* Free the simply allocated spaces. */
   free(p->cp.hdu);
   free(p->maxtsize);
+  free(p->maxltsize);
   free(p->cp.output);
   if(p->skyname)          free(p->skyname);
   if(p->detskyname)       free(p->detskyname);
diff --git a/bin/statistics/ui.c b/bin/statistics/ui.c
index dd705b5..d1a9de9 100644
--- a/bin/statistics/ui.c
+++ b/bin/statistics/ui.c
@@ -789,10 +789,7 @@ ui_preparations(struct statisticsparams *p)
   if(p->isfits && p->hdu_type==IMAGE_HDU)
     {
       p->inputformat=INPUT_FORMAT_IMAGE;
-      p->input=gal_fits_img_read(p->inputname, cp->hdu, cp->minmapsize);
-      if(p->ontile)
-        p->input->wcs=gal_wcs_read(p->inputname, cp->hdu, 0, 0,
-                                   &p->input->nwcs);
+      p->input=gal_fits_img_read(p->inputname, cp->hdu, cp->minmapsize, 0, 0);
     }
   else
     {
diff --git a/bin/warp/ui.c b/bin/warp/ui.c
index 898f118..0d72447 100644
--- a/bin/warp/ui.c
+++ b/bin/warp/ui.c
@@ -347,10 +347,8 @@ ui_check_options_and_arguments(struct warpparams *p)
 
       /* Read the input image as double type and its WCS structure. */
       p->input=gal_fits_img_read_to_type(p->inputname, p->cp.hdu,
-                                         GAL_TYPE_FLOAT64,
-                                         p->cp.minmapsize);
-      p->input->wcs=gal_wcs_read(p->inputname, p->cp.hdu, p->hstartwcs,
-                                 p->hendwcs, &p->input->nwcs);
+                                         GAL_TYPE_FLOAT64, p->cp.minmapsize,
+                                         p->hstartwcs, p->hendwcs);
       if(p->input->wcs)
         {
           p->pixelscale=gal_wcs_pixel_scale(p->input->wcs);
diff --git a/configure.ac b/configure.ac
index 73d8679..898770b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,6 +148,13 @@ AC_SEARCH_LIBS([cblas_sdsdot], [gslcblas], [],
     [AC_MSG_ERROR([GSL CBLAS not present, cannot continue.])])
 AC_SEARCH_LIBS([gsl_integration_qng], [gsl], [],
     [AC_MSG_ERROR([GSL not found, cannot continue.])])
+
+# Since version 0.42, if `libcurl' is installed, CFITSIO will link with it
+# and thus it will be necessary to explicitly link with libcurl also. If it
+# doesn't exist on the system, then CFITSIO won't link with it and there is
+# no problem for Gnuastro either. So there is no need to stop the configure
+# script if libcurl isn't found.
+AC_SEARCH_LIBS([curl_global_init], [curl], [], [])
 AC_SEARCH_LIBS([ffopen], [cfitsio], [],
     [AC_MSG_ERROR([CFITSIO not found, cannot continue.])])
 AC_SEARCH_LIBS([wcspih], [wcs], [],
@@ -226,6 +233,15 @@ AC_SUBST(HAVE_LIBGIT2, [$has_libgit2])
 
 
 
+# Check libtool: need by BuildProgram.
+AC_CHECK_PROG(has_libtool, libtool, [yes], [no])
+AS_IF([test "x$has_libtool" = "xno"], [anywarnings=yes])
+AM_CONDITIONAL([COND_HASLIBTOOL], [test "x$has_libtool" = "xyes"])
+
+
+
+
+
 # Check Ghostscript: "-dPDFFitPage" option to Ghostscript, used by
 # ConvertType to convert from EPS to PDF, has been introduced in
 # Ghostscript 9.10.  Make sure we have at least that version.
@@ -715,13 +731,21 @@ AS_IF([test x$enable_guide_message = xyes],
                AS_ECHO(["    output files if Gnuastro's programs were called 
within a Git"])
                AS_ECHO(["    version controlled directory to help in 
reproducibility."])
                AS_ECHO([]) ])
+        AS_IF([test "x$has_libtool" = "xno"],
+              [AS_ECHO(["  - GNU Libtool, could not be found in your search 
path."])
+               AS_ECHO(["    Gnuastro's BuildProgram uses libtool to link your 
source code"])
+               AS_ECHO(["    with the various libraries (Gnuastro's 
dependencies). Note that"])
+               AS_ECHO(["    not having libtool in your search path will not 
harm Gnuastro's"])
+               AS_ECHO(["    building and installation process. This warning 
is only for"])
+               AS_ECHO(["    using BuildProgram after Gnuastro has been built 
and installed."])
+               AS_ECHO([]) ])
         AS_IF([test "x$has_ghostscript" = "xno"],
               [AS_ECHO(["  - GPL GhostScript version 9.10 or later, with the 
executable"])
                AS_ECHO(["    name \`gs', was not found in your PATH 
environment variable."])
                AS_ECHO(["    If PDF outputs are desired from ConvertType, it 
will abort"])
                AS_ECHO(["    with an EPS output which you can convert to PDF 
by other means."])
                AS_ECHO([]) ])
-        AS_ECHO(["  All checks related to the warning(s) will be skipped."])
+        AS_ECHO(["  All checks related to the warning(s) above will be 
skipped."])
         AS_ECHO([])
       ]
      )
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 55c6d5b..af0f025 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -1760,9 +1760,9 @@ distributions. If you use another graphical desktop 
environment, replace
 @command{eog} with any other image viewer.}. Since he has used it before,
 he knows that once it opens an image, he can use the @key{ENTER} or
 @key{SPACE} keys on the keyboard to go to the next image in the directory
-or the @key{Backspace} key to to go the previous image. So he opens the
-image of the first object with the command below and with his cup of coffee
-in his other hand, he flips through his targets very fast to get a good
+or the @key{Backspace} key to go the previous image. So he opens the image
+of the first object with the command below and with his cup of coffee in
+his other hand, he flips through his targets very fast to get a good
 initial impression of the morphologies of these extra-galactic nebulae.
 
 @example
@@ -2597,6 +2597,23 @@ take effect.
 
 @table @asis
 
+@item libtool
+@cindex GNU Libtool
+GNU Libtool is a program to simplify managing of the libraries to build an
+executable (program). It is used by @ref{BuildProgram} in Gnuastro to help
+you easily link to all the necessary libraries that Gnuastro's library
+depends on. Libtool is a low-level program that is probably already present
+on your system (and in your operating system package manager). However, if
+you want to install it's latest version from source, please visit its
+@url{https://www.gnu.org/software/libtool/, webpage}.
+
+Gnuastro's tarball ships with Libtool and it is extensively used during its
+building and installing. Therefore, you can easily build Gnuastro even if
+you don't have Libtool installed on your system. However, this internal
+Libtool does not get installed. Hence, if you want to use the installed
+BuildProgram to compile and link your own source code later, you need to
+have Libtool on your system (independent of Gnuastro).
+
 @item libgit2
 @cindex Git
 @cindex libgit2
@@ -3001,7 +3018,9 @@ telling it to copy some files (instead of making symbolic 
links, with the
 @option{--copy} option, this is not mandatory@footnote{The @option{--copy}
 option is recommended because some backup systems might do strange things
 with symbolic links.}) and where to look for Gnulib (with the
-@option{--gnulib-srcdir} option).
+@option{--gnulib-srcdir} option). Please note that teh address given to
+@option{--gnulib-srcdir} has to be an absolute address (so don't use
+@file{~} or @file{../} for example).
 
 @example
 $ cd $TOPGNUASTRO/gnuastro
@@ -4929,10 +4948,13 @@ ignored.
 @item -N INT
 @itemx --numthreads=INT
 Use @option{INT} CPU threads when running a Gnuastro program (see
-@ref{Multi-threaded operations}). Note that multi-threaded programming is only
-relevant to some programs. In others, this option will be ignored. If this
-option is not specified on the command-line or any configuration file, the
-number of threads will be determined by the programs at configuration time.
+@ref{Multi-threaded operations}). If the value is zero (@code{0}), or this
+option is not given on the command-line or any configuration file, the
+value will be determined at run-time: the maximum number of threads
+available to the system when you run a Gnuastro program.
+
+Note that multi-threaded programming is only relevant to some programs. In
+others, this option will be ignored.
 
 @end vtable
 
@@ -4971,15 +4993,15 @@ necessary parameters are not given through any of these 
methods, the
 program will print a missing option error and abort. The only exception to
 this is @option{--numthreads}, whose default value is determined at
 run-time using the number of threads available to your system, see
-@ref{Multi-threaded operations}. Of course, you can still provide a default 
value
-for the number of threads at any of the levels below, but if you don't, the
-program will not abort. Also note that through automatic output name
-generation, the value to the @option{--output} option is also not mandatory
-on the command-line or in the configuration files for all programs which
-don't rely on that value as an input@footnote{One example of a program
-which uses the value given to @option{--output} as an input is ConvertType,
-this value specifies the type of the output through the value to
-@option{--output}, see @ref{Invoking astconvertt}.}, see @ref{Automatic
+@ref{Multi-threaded operations}. Of course, you can still provide a default
+value for the number of threads at any of the levels below, but if you
+don't, the program will not abort. Also note that through automatic output
+name generation, the value to the @option{--output} option is also not
+mandatory on the command-line or in the configuration files for all
+programs which don't rely on that value as an input@footnote{One example of
+a program which uses the value given to @option{--output} as an input is
+ConvertType, this value specifies the type of the output through the value
+to @option{--output}, see @ref{Invoking astconvertt}.}, see @ref{Automatic
 output}.
 
 
@@ -17402,6 +17424,17 @@ confronts).
 @itemx --onlybuild
 Only build the program, don't run it. By default, the built program is
 immediately run afterwards.
+
+@item -a STR
+@itemx --la=STR
+Use the given @file{.la} file (Libtool control file) instead of the one
+that was produced from Gnuastro's configuration results. The Libtool
+control file keeps all the necesary information for building and linking a
+program with a library built by Libtool. The default
+@file{prefix/lib/libgnuastro.la} keeps all the information necessary to
+build a program using the Gnuastro library gathered during configure time
+(see @ref{Installation directory} for prefix). This option is useful when
+you prefer to use another Libtool control file.
 @end table
 
 
@@ -19599,9 +19632,9 @@ this example multiple images are linked together as a 
list:
 @example
 size_t minmapsize=-1;
 gal_data_t *tmp, *list=NULL;
-tmp = gal_fits_img_read("file1.fits", "1", minmapsize);
+tmp = gal_fits_img_read("file1.fits", "1", minmapsize, 0, 0);
 gal_list_data_add( &list, tmp );
-tmp = gal_fits_img_read("file2.fits", "1", minmapsize);
+tmp = gal_fits_img_read("file2.fits", "1", minmapsize, 0, 0);
 gal_list_data_add( &list, tmp );
 @end example
 @end deftypefun
@@ -20040,23 +20073,30 @@ then if the image has a name and units, the 
respective string will be put
 in these pointers.
 @end deftypefun
 
-@deftypefun {gal_data_t *} gal_fits_img_read (char @code{*filename}, char 
@code{*hdu}, size_t @code{minmapsize})
+@deftypefun {gal_data_t *} gal_fits_img_read (char @code{*filename}, char 
@code{*hdu}, size_t @code{minmapsize}, size_t @code{hstartwcs}, size_t 
@code{hendwcs})
 Read the contents of the @code{hdu} extension/HDU of @code{filename} into a
 Gnuastro generic data container (see @ref{Generic data container}) and
 return it. If the necessary space is larger than @code{minmapsize}, then
 don't keep the data in RAM, but in a file on the HDD/SSD. For more on
 @code{minmapsize} see the description under the same name in @ref{Generic
 data container}.
+
+The @code{hstartwcs} and @code{hendwcs} arguments are the starting and
+ending header keywords to search for WCS information, if no limit is
+needed, set them to zero. For more on these two options, please see the
+description of @code{gal_wcs_read_fitsptr} in @ref{World Coordinate
+System}.
 @end deftypefun
 
-@deftypefun {gal_data_t *} gal_fits_img_read_to_type (char @code{*inputname}, 
char @code{*inhdu}, uint8_t @code{type}, size_t @code{minmapsize})
+@deftypefun {gal_data_t *} gal_fits_img_read_to_type (char @code{*inputname}, 
char @code{*inhdu}, uint8_t @code{type}, size_t @code{minmapsize}, )
 Read the contents of the @code{hdu} extension/HDU of @code{filename} into a
 Gnuastro generic data container (see @ref{Generic data container}) of type
 @code{type} and return it.
 
 This is just a wrapper around @code{gal_fits_img_read} (to read the
 image/array of any type) and @code{gal_data_copy_to_new_type_free} (to
-convert it to @code{type} and free the initially read dataset).
+convert it to @code{type} and free the initially read dataset). See the
+description there for more.
 @end deftypefun
 
 @cindex NaN
@@ -21365,7 +21405,7 @@ char *filename="input.fits", *hdu="1";
 ...
 
 /* Read the input dataset. */
-input=gal_fits_img_read(filename, hdu, -1);
+input=gal_fits_img_read(filename, hdu, -1, 0, 0);
 
 /* Do a sanity check and preparations. */
 gal_tile_full_sanity_check(filename, hdu, input, &tl);
@@ -21653,7 +21693,7 @@ both polygons have to be sorted in an anti-clock-wise 
manner.
 
 The C programming language comes with the @code{qsort} (Quick sort)
 function. @code{qsort} is a generic function which allows you to sort any
-kind of data structure (not just a single number). To to define greater and
+kind of data structure (not just a single number). To define greater and
 smaller (for sorting), @code{qsort} needs another function, even for simple
 numerical types. To facilitate numerical sorting for Gnuastro's
 programs/libraries, Gnuastro defines a function for each type's increasing
@@ -22033,14 +22073,15 @@ Apply @mymath{\sigma}-clipping on a given dataset and 
return a dataset that
 contains the results. For a description of @mymath{\sigma}-clipping see
 @ref{Sigma clipping}. @code{multip} is the multiple of the standard
 deviation (@mymath{\sigma} that is used to define outliers in each round of
-clipping.
+clipping).
 
 The role of @code{param} is determined based on its value. If @code{param}
 is larger than @code{1} (one), it must be an integer and will be
 interpretted as the number clips to do. If it is less than @code{1} (one),
 it is interpretted as the tolerance level to stop the iteration.
 
-The output dataset has the following elements:
+The output dataset has the following elements with a
+@code{GAL_TYPE_FLOAT32} type:
 @example
 array[0]: Number of points used.
 array[1]: Median.
@@ -22422,7 +22463,8 @@ main(void)
 
 
   /* Read `img.fits' (HDU: 1) as a float32 array. */
-  image=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32, -1);
+  image=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32, -1,
+                                  0, 0);
 
 
   /* Use the allocated space as a single precision floating
@@ -22471,7 +22513,8 @@ main(void)
   float *array;
   size_t i, num, *dinc;
   gal_data_t *input=gal_fits_img_read_to_type("input.fits", "1",
-                                              GAL_TYPE_FLOAT32, -1);
+                                              GAL_TYPE_FLOAT32, -1,
+                                              0, 0);
 
   /* To avoid the `void *' pointer and have `dinc'. */
   array=input->array;
@@ -22612,7 +22655,7 @@ main(void)
    * `-1' for `minmapsize' to ensure that the image is read into
    * memory. */
   p.image=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32,
-                                    -1);
+                                    -1, 0, 0);
 
 
   /* Print some basic information before the actual contents: */
@@ -22794,9 +22837,8 @@ benefit, and the larger community if they are willing 
to share it. In
 short, we hope that at least from the software point of view, the
 ``obscurantist faith in the expert's special skill and in his personal
 knowledge and authority'' can be broken, see @ref{Science and its
-tools}. With this aim in mind, Gnuastro was designed to to have a very
-basic, simple, and easy to understand architecture for any interested
-inquirer.
+tools}. With this aim in mind, Gnuastro was designed to have a very basic,
+simple, and easy to understand architecture for any interested inquirer.
 
 This chapter starts with very general design choices, in particular
 @ref{Why C} and @ref{Program design philosophy}. It will then get a little
@@ -22949,15 +22991,19 @@ speed'' is desired.
 @node Program design philosophy, Coding conventions, Why C, Developing
 @section Program design philosophy
 
+@cindex Gnulib
 The core processing functions of each program (and all libraries) are
 written mostly with the basic ISO C90 standard. We do make lots of use of
-the GNU additions to the C language in the GNU C library, but these
-additional functions are mainly used in the user interface functions
-(reading your inputs and preparing them prior to or after the
-analysis). The actual algorithms, which most scientists would be more
-interested in, are much more closer to ISO C90. For this reason, program
-source files that deal with user interface issues and those doing the
-actual processing are clearly separated, see @ref{Program source}. If
+the GNU additions to the C language in the GNU C library@footnote{Gnuastro
+uses many GNU additions to the C library. However, thanks to the GNU
+Portability library (Gnulib) which is included in the Gnuastro tarball,
+users of non-GNU/Linux operating systems can also benefit from all these
+features when using Gnuastro.}, but these functions are mainly used in the
+user interface functions (reading your inputs and preparing them prior to
+or after the analysis). The actual algorithms, which most scientists would
+be more interested in, are much more closer to ISO C90. For this reason,
+program source files that deal with user interface issues and those doing
+the actual processing are clearly separated, see @ref{Program source}. If
 anything particular to the GNU C library is used in the processing
 functions, it is explained in the comments in between the code.
 
@@ -23025,17 +23071,16 @@ in. However, this visual aid greatly helps in general 
inspections of the
 code and help the reader get a grip of the function's processing.
 
 @item
-When ever you see that the function cannot be fully displayed (vertically)
-in your monitor, this is a sign that it has probably become too long and
-should be broken up into multiple functions. 40 lines is usually a good
-reference. When the start and end of a function are clearly visible in one
-glance, the function is much more easier to understand. This is most
-important for low-level functions (which usually define a lot of
-variables). Low-level functions do most of the processing, they will also
-be the most interesting part of a program for an inquiring astronomer. This
-convention is less important for higher level functions that don't define
-too many variables and whose only purpose is to run the lower-level
-functions in a specific order and with checks.
+A function that cannot be fully displayed (vertically) in your monitor is
+probably too long and may be more useful if it is broken up into multiple
+functions. 40 lines is usually a good reference. When the start and end of
+a function are clearly visible in one glance, the function is much more
+easier to understand. This is most important for low-level functions (which
+usually define a lot of variables). Low-level functions do most of the
+processing, they will also be the most interesting part of a program for an
+inquiring astronomer. This convention is less important for higher level
+functions that don't define too many variables and whose only purpose is to
+run the lower-level functions in a specific order and with checks.
 
 @cindex Optimization flag
 @cindex GNU Compiler Collection
@@ -23329,11 +23374,11 @@ program containing all these files, see @ref{The 
TEMPLATE program}.
 @item main.c
 @cindex @code{main} function
 Each executable has a @code{main} function, which is located in
-@file{main.c}. Therefore this file in any program's source code will be the
-starting point. No actual processing functions must be defined in this
-file, the function(s) in this file are only meant to connect the most high
-level steps of each program. Generally, @code{main} will first call the top
-user interface function to read user input and make all the
+@file{main.c}. Therefore this file is the starting point when reading any
+program's source code. No actual processing functions must be defined in
+this file, the function(s) in this file are only meant to connect the most
+high level steps of each program. Generally, @code{main} will first call
+the top user interface function to read user input and make all the
 preparations. Then it will pass control to the top processing function for
 that program. The functions to do both these jobs must be defined in other
 source files.
@@ -23683,9 +23728,8 @@ $ ./configure --disable-shared CFLAGS="-g -O0"
 @end example
 
 @noindent
-These options to configure are already included in
-@file{tmpfs-config-make}, you just have to un-comment them when you want to
-start developing or debugging.
+In @file{tmpfs-config-make} you can ask for this behavior by setting
+@code{debug_noshared} to @code{1}.
 
 In order to understand the building process, you can go through the
 Autoconf, Automake and Libtool manuals, like all GNU manuals they provide
@@ -23728,10 +23772,11 @@ executable.
 The most important thing to have in mind about all the test scripts is that
 they are run from inside the @file{tests/} directory in the ``build
 tree''. Which can be different from the directory they are stored in (known
-as the ``source tree''). The @file{tmpfs-config-make} script uses this
-feature (see @ref{Configure and build in RAM}). This distinction is made by
-GNU Autoconf and Automake (which configure, build and install Gnuastro) so
-that you can install the program even if you don't have write access to the
+as the ``source tree'')@footnote{The @file{tmpfs-config-make} script also
+uses this feature to keep the source and build directories separate (see
+@ref{Configure and build in RAM}).}. This distinction is made by GNU
+Autoconf and Automake (which configure, build and install Gnuastro) so that
+you can install the program even if you don't have write access to the
 directory keeping the source files. See the ``Parallel build trees (a.k.a
 VPATH builds)'' in the Automake manual for a nice explanation.
 
@@ -23960,7 +24005,7 @@ addition/change with the whole community as part of the 
official
 release. This is great and your contribution is most welcome. This section
 and the next (see @ref{Developer's checklist}) are written in the hope of
 making it as easy as possible for you to share your great idea with the
-Gnuastro community.
+community.
 
 @cindex FSF
 @cindex Free Software Foundation
@@ -24216,22 +24261,24 @@ might change and evolve to better suit our needs.
 @node Forking tutorial,  , Production workflow, Contributing to Gnuastro
 @subsection Forking tutorial
 
-This is a tutorial on the second suggested method that you can submit your
-modifications in Gnuastro (see @ref{Production workflow}), which is
-commonly known as forking. Let's assume you want to start contributing to
-Gnuastro and you would like to use GitLab@footnote{See
+This is a tutorial on the second suggested method (commonly known as
+forking) that you can submit your modifications in Gnuastro (see
+@ref{Production workflow}).
+
+To start, please create an empty repository on your hosting service webpage
+(we recommend GitLab@footnote{See
 @url{https://www.gnu.org/software/repo-criteria-evaluation.html} for an
-evaluation of the major existing repositories.} to host your work remotely
-and share it with other Gnuastro developers once you are ready. You can
-create an empty repository on your hosting service webpage. If this is your
-first hosted repository on the webpage, you also have to upload your public
-SSH key@footnote{For example see this explanation provided by GitLab:
+evaluation of the major existing repositories. Gnuastro uses GNU Savannah
+(which also has the highest ranking in the evaluation), but for starters,
+GitLab may be easier.}). If this is your first hosted repository on the
+webpage, you also have to upload your public SSH key@footnote{For example
+see this explanation provided by GitLab:
 @url{http://docs.gitlab.com/ce/ssh/README.html}.} for the @command{git
 push} command below to work. Here we'll assume you use the name
 @file{janedoe} to refer to yourself everywhere and that you choose
 @file{gnuastro-janedoe} as the name of your Gnuastro fork. Any online
-hosting service will give you an address (similar to
-`@file{git@@gitlab.com:}' below) of the empty repository you have created
+hosting service will give you an address (similar to the
+`@file{git@@gitlab.com:...}' below) of the empty repository you have created
 using their webpage, use that address in the third line below.
 
 @example
@@ -24252,20 +24299,19 @@ repository.
 
 To test (compile) your changes during your work, you will need to bootstrap
 the version controlled source, see @ref{Bootstrapping} for a full
-description. The process above is only necessary for your first time setup,
-you don't need to repeat it. However, please repeat the steps below for
-each independent issue you intend to work on.
+description. The cloning process above is only necessary for your first
+time setup, you don't need to repeat it. However, please repeat the steps
+below for each independent issue you intend to work on.
 
 Let's assume you have found a bug in @file{lib/statistics.c}'s median
-calculating function. You announce it (see @ref{Report a bug}) so everyone
-knows you are working on it. However, if it is a very simple, clear/obvious
-and straightforward bug to fix you can skip this initial announcement. With
-the commands below, you make a branch, checkout to it, correct the bug,
-check if it is indeed fixed, add it to the staging area, commit it to the
-new branch and push it to your hosting service. But before all of them,
-make sure that you are on the @file{master} branch and that your
-@file{master} branch is up to date with the main Gnuastro repository with
-the first two commands.
+calculating function. Before actually doing anything, please announce it
+(see @ref{Report a bug}) so everyone knows you are working on it or to find
+out others aren't already working on it. With the commands below, you make
+a branch, checkout to it, correct the bug, check if it is indeed fixed, add
+it to the staging area, commit it to the new branch and push it to your
+hosting service. But before all of them, make sure that you are on the
+@file{master} branch and that your @file{master} branch is up to date with
+the main Gnuastro repository with the first two commands.
 
 @example
 $ git checkout master
@@ -24286,8 +24332,8 @@ be merged into the main Gnuastro history, they will 
merge it into the
 @file{master} branch. After that is done, you can simply checkout your
 local @file{master} branch and pull all the changes from the main
 repository. After the pull you can run `@command{git log}' as shown below,
-to see how @file{bug-median-stats} is merged with master. So you can push
-all the changes to your hosted repository and delete the branches:
+to see how @file{bug-median-stats} is merged with master. To finalize, you
+can push all the changes to your hosted repository and delete the branch:
 
 @example
 $ git checkout master
@@ -24301,10 +24347,11 @@ $ git push janedoe --delete bug-median-stats    # 
delete remote branch
 Just as a reminder, always keep your work on each issue in a separate local
 and remote branch so work can progress on them independently. After you
 make your announcement, other people might contribute to the branch before
-merging it in to @file{master}, so this is very important. Also before
-starting each issue branch from @file{master}, be sure to run @command{git
-pull} in @file{master} as shown above, to start your branch (work) from the
-most recent history point and thus simplify the final merging of your work.
+merging it in to @file{master}, so this is very important. As a final
+reminder: before starting each issue branch from @file{master}, be sure to
+run @command{git pull} in @file{master} as shown above. This will enable
+you to start your branch (work) from the most recent commit and thus
+simplify the final merging of your work.
 
 
 
diff --git a/lib/binary.c b/lib/binary.c
index 077c1ab..98187a6 100644
--- a/lib/binary.c
+++ b/lib/binary.c
@@ -728,6 +728,9 @@ gal_binary_fill_holes(gal_data_t *input, int connectivity, 
size_t maxsize)
       do
         if(*i!=GAL_BLANK_INT32) *i = sizes[*i]>maxsize ? 1 : *i;
       while(++i<fi);
+
+      /* Clean up. */
+      free(sizes);
     }
 
   /* The type of the tile is already known (it is `int32_t') and we have no
diff --git a/lib/fits.c b/lib/fits.c
index b0f901e..052a5df 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -1435,9 +1435,11 @@ gal_fits_img_info(fitsfile *fptr, int *type, size_t 
*ndim, size_t **dsize,
     gal_fits_io_error(status, NULL);
   *ndim=naxis;
 
+
   /* Convert bitpix to Gnuastro's known types. */
   *type=gal_fits_bitpix_to_type(bitpix);
 
+
   /* Define the names of the possibly existing important keywords about the
      dataset. We are defining these in the opposite order to be read by
      CFITSIO. The way Gnuastro writes the FITS keywords, the output will
@@ -1476,6 +1478,8 @@ gal_fits_img_info(fitsfile *fptr, int *type, size_t 
*ndim, size_t **dsize,
       ++i;
     }
 
+
+  /* If a type correction is necessary, then do it. */
   if( !isnan(bscale) || bzero_str )
     fits_type_correct(type, bscale, bzero_str);
 
@@ -1489,6 +1493,7 @@ gal_fits_img_info(fitsfile *fptr, int *type, size_t 
*ndim, size_t **dsize,
 
   /* Clean up. */
   gal_list_data_free(keysll);
+  if(bzero_str) free(bzero_str);
 }
 
 
@@ -1497,7 +1502,8 @@ gal_fits_img_info(fitsfile *fptr, int *type, size_t 
*ndim, size_t **dsize,
 
 /* Read a FITS image HDU into a Gnuastro data structure. */
 gal_data_t *
-gal_fits_img_read(char *filename, char *hdu, size_t minmapsize)
+gal_fits_img_read(char *filename, char *hdu, size_t minmapsize,
+                  size_t hstartwcs, size_t hendwcs)
 {
   void *blank;
   long *fpixel;
@@ -1553,6 +1559,10 @@ gal_fits_img_read(char *filename, char *hdu, size_t 
minmapsize)
   free(blank);
 
 
+  /* Read the WCS structure (if the FITS file has any). */
+  img->wcs=gal_wcs_read_fitsptr(fptr, hstartwcs, hendwcs, &img->nwcs);
+
+
   /* Close the input FITS file. */
   fits_close_file(fptr, &status);
   gal_fits_io_error(status, NULL);
@@ -1571,12 +1581,13 @@ gal_fits_img_read(char *filename, char *hdu, size_t 
minmapsize)
    used to convert the input file to the desired type. */
 gal_data_t *
 gal_fits_img_read_to_type(char *inputname, char *hdu, uint8_t type,
-                          size_t minmapsize)
+                          size_t minmapsize, size_t hstartwcs,
+                          size_t hendwcs)
 {
   gal_data_t *in, *converted;
 
   /* Read the specified input image HDU. */
-  in=gal_fits_img_read(inputname, hdu, minmapsize);
+  in=gal_fits_img_read(inputname, hdu, minmapsize, hstartwcs, hendwcs);
 
   /* If the input had another type, convert it to float. */
   if(in->type!=type)
@@ -1603,9 +1614,10 @@ gal_fits_img_read_kernel(char *filename, char *hdu, 
size_t minmapsize)
   gal_data_t *kernel;
   float *f, *fp, tmp;
 
-  /* Read the image as a float */
+  /* Read the image as a float and if it has a WCS structure, free it. */
   kernel=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32,
-                                   minmapsize);
+                                   minmapsize, 0, 0);
+  if(kernel->wcs) { wcsfree(kernel->wcs); kernel->wcs=NULL; }
 
   /* Check if the size along each dimension of the kernel is an odd
      number. If they are all an odd number, then the for each dimension,
diff --git a/lib/gnuastro-internal/commonopts.h 
b/lib/gnuastro-internal/commonopts.h
index be69dee..735ac5c 100644
--- a/lib/gnuastro-internal/commonopts.h
+++ b/lib/gnuastro-internal/commonopts.h
@@ -306,7 +306,7 @@ struct argp_option gal_commonopts_options[] =
       GAL_OPTIONS_GROUP_OPERATING_MODE,
       &cp->numthreads,
       GAL_TYPE_SIZE_T,
-      GAL_OPTIONS_RANGE_GT_0,
+      GAL_OPTIONS_RANGE_GE_0,
       GAL_OPTIONS_NOT_MANDATORY,
       GAL_OPTIONS_NOT_SET
     },
diff --git a/lib/gnuastro/fits.h b/lib/gnuastro/fits.h
index 2744062..906fa63 100644
--- a/lib/gnuastro/fits.h
+++ b/lib/gnuastro/fits.h
@@ -209,11 +209,13 @@ gal_fits_img_info(fitsfile *fptr, int *type, size_t 
*ndim, size_t **dsize,
                   char **name, char **unit);
 
 gal_data_t *
-gal_fits_img_read(char *filename, char *hdu, size_t minmapsize);
+gal_fits_img_read(char *filename, char *hdu, size_t minmapsize,
+                  size_t hstartwcs, size_t hendwcs);
 
 gal_data_t *
-gal_fits_img_read_to_type(char *inputname, char *inhdu, uint8_t type,
-                          size_t minmapsize);
+gal_fits_img_read_to_type(char *inputname, char *hdu, uint8_t type,
+                          size_t minmapsize, size_t hstartwcs,
+                          size_t hendwcs);
 
 gal_data_t *
 gal_fits_img_read_kernel(char *filename, char *hdu, size_t minmapsize);
diff --git a/lib/options.c b/lib/options.c
index b7ac93d..dea2d0e 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -34,6 +34,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/data.h>
 #include <gnuastro/table.h>
 #include <gnuastro/blank.h>
+#include <gnuastro/threads.h>
 #include <gnuastro/arithmetic.h>
 
 #include <gnuastro-internal/timing.h>
@@ -1600,6 +1601,11 @@ gal_options_read_config_set(struct 
gal_options_common_params *cp)
 
   /* Abort if any of the mandatory options are not set. */
   gal_options_abort_if_mandatory_missing(cp);
+
+  /* If `numthreads' is 0, use the number of threads available to the
+     system. */
+  if(cp->numthreads==0)
+    cp->numthreads=gal_threads_number();
 }
 
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cca7d8a..213f94e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -48,6 +48,9 @@ endif
 if COND_HASLIBJPEG
   MAYBE_HASLIBJPEG = "yes"
 endif
+if COND_HASLIBTOOL
+  MAYBE_HASLIBTOOL = "yes"
+endif
 if COND_ARITHMETIC
   MAYBE_ARITHMETIC_TESTS = arithmetic/snimage.sh arithmetic/onlynumbers.sh \
   arithmetic/where.sh arithmetic/or.sh
@@ -191,6 +194,7 @@ AM_TESTS_ENVIRONMENT =                              \
 export mkdir_p="$(MKDIR_P)";                        \
 export topsrc=$(top_srcdir);                        \
 export haslibjpeg=$(MAYBE_HASLIBJPEG);              \
+export haslibtool=$(MAYBE_HASLIBTOOL);              \
 export hasghostscript=$(MAYBE_HASGHOSTSCRIPT);
 
 
diff --git a/tests/buildprog/simpleio.c b/tests/buildprog/simpleio.c
index ac34d41..6be745e 100644
--- a/tests/buildprog/simpleio.c
+++ b/tests/buildprog/simpleio.c
@@ -39,7 +39,7 @@ main(int argc, char *argv[])
     }
 
   /* Read the image into memory. */
-  image=gal_fits_img_read(argv[1], argv[2], -1);
+  image=gal_fits_img_read(argv[1], argv[2], -1, 0, 0);
 
   /* Let the user know. */
   printf("%s (hdu %s) is read into memory.\n", argv[1], argv[2]);
diff --git a/tests/buildprog/simpleio.sh b/tests/buildprog/simpleio.sh
index e45ab26..6fa9e83 100755
--- a/tests/buildprog/simpleio.sh
+++ b/tests/buildprog/simpleio.sh
@@ -41,14 +41,25 @@ source=$topsrc/tests/$prog/simpleio.c
 #
 #   - The input data was not made (for example the test that created the
 #     data file failed).
+#
+#   - Gnuastro ships with its own version of Libtool for the building of
+#     the libraries and programs. But here, we want to test the user's
+#     libtool (and how it works with BuildProgram). So if libtool wasn't
+#     found at configure time, we need to skip this test.
 if [ ! -f $execname ]; then echo "$execname not created.";  exit 77; fi
 if [ ! -f $img      ]; then echo "$img does not exist.";    exit 77; fi
 if [ ! -f $source   ]; then echo "$source does not exist."; exit 77; fi
-
+if [ "x$haslibtool" != "xyes" ];then echo "libtool not present.";  exit 77;fi
 
 
 
 
 # Actual test script
 # ==================
-$execname $source $img 1
+#
+# We want to use the `libgnuastro.la' corresponding to this install, not
+# the one (that is possibly) installed (hence the use of `--la').
+#
+# Except for `gnuastro/config.h', all headers are installed in
+# `$topsrc/lib' and `gnuastro/config.h' is in "../lib/"
+$execname $source $img 1 --la=../lib/libgnuastro.la -I$topsrc/lib -I../lib/
diff --git a/tests/lib/multithread.c b/tests/lib/multithread.c
index 1043a41..eaa2945 100644
--- a/tests/lib/multithread.c
+++ b/tests/lib/multithread.c
@@ -95,7 +95,7 @@ main(void)
 
 
   /* Read the image into memory as a float32 data type. */
-  p.image=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32, -1);
+  p.image=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32, -1,0,0);
 
 
   /* Print some basic information before the actual contents: */



reply via email to

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