gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 29c44da: General function to read arrays of an


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 29c44da: General function to read arrays of any type
Date: Sat, 17 Mar 2018 12:38:10 -0400 (EDT)

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

    General function to read arrays of any type
    
    For tables, we have the general `gal_table_read' function which makes it
    very easy to read the columns in the given file with any format. However,
    until now we didn't have such a generic function for arrays. Such a
    function will make it easy for all programs and library users to easily
    read the input from all known types. This function has now been added to
    the library.
    
    During the process, `gal_fits_img_read' was also modified to not read the
    WCS structure of the input FITS file. Because it would need two extra
    arguments and the WCS is not always necessary, so there is no need to waste
    time in such cases (reading and interpretting the WCS).
    
    This was done as part of task #14885 (not yet complete).
---
 NEWS                             |   6 +
 bin/arithmetic/arithmetic.c      |   8 +-
 bin/arithmetic/operands.c        |  15 +-
 bin/convertt/ui.c                |   3 +-
 bin/convolve/ui.c                |   7 +-
 bin/mkcatalog/ui.c               |  14 +-
 bin/mknoise/ui.c                 |   3 +-
 bin/mkprof/ui.c                  |   4 +-
 bin/noisechisel/ui.c             |   8 +-
 bin/statistics/ui.c              |   4 +-
 bin/warp/ui.c                    |   5 +-
 doc/gnuastro.texi                | 802 +++++++++++++++++++++------------------
 lib/Makefile.am                  |  28 +-
 lib/array.c                      |  97 +++++
 lib/fits.c                       |  14 +-
 lib/gnuastro/{tiff.h => array.h} |  27 +-
 lib/gnuastro/fits.h              |   6 +-
 lib/gnuastro/tiff.h              |   2 +-
 lib/tiff.c                       |   2 +-
 tests/buildprog/simpleio.c       |   2 +-
 tests/lib/multithread.c          |   2 +-
 21 files changed, 600 insertions(+), 459 deletions(-)

diff --git a/NEWS b/NEWS
index 4efa940..9f464f6 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,8 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
   values of the dataset.
 
   Libraries:
+    gal_array_read: read from file with all known formats (FITS, TIFF, etc).
+    gal_array_read_to_type: similar to `gal_array_read', but to given type.
     gal_tiff_name_is_tiff: check if name contains a TIFF suffix.
     gal_tiff_suffix_is_tiff: check if suffix is a TIFF suffix.
     gal_tiff_dir_string_read: convert a string to a TIFF directory number.
@@ -41,6 +43,10 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
 
   Libraries:
 
+   - `gal_fits_img_read': now only reads the data not the WCS, therefore it
+     no longer needs the last two arguments. A subsequent call to
+     `gal_wcs_read' can be used to read the WCS information in the file.
+
    - `gal_statistics_quantile_function': returns `inf' or `-inf' if the
      given value is smaller than the minimum or larger than the maximum of
      the input dataset's range. Until now, it would return blank in such
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index dd560bd..9bc4786 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -690,11 +690,9 @@ 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,
-                                              0, 0);
-          p->refdata.wcs=p->operands->data->wcs;
-          p->refdata.nwcs=p->operands->data->nwcs;
-          p->operands->data->wcs=NULL;
+          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);
           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 5948bbe..d775071 100644
--- a/bin/arithmetic/operands.c
+++ b/bin/arithmetic/operands.c
@@ -122,21 +122,12 @@ operands_pop(struct arithmeticparams *p, char *operator)
       filename=operands->filename;
 
       /* Read the dataset. */
-      data=gal_fits_img_read(filename, hdu, p->cp.minmapsize, 0, 0);
+      data=gal_fits_img_read(filename, hdu, p->cp.minmapsize);
 
       /* 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. */
+         information in the `refdata' 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;
+        p->refdata.wcs=gal_wcs_read(filename, hdu, 0, 0, &p->refdata.nwcs);
 
       /* 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/convertt/ui.c b/bin/convertt/ui.c
index bdd30bd..d90fbf3 100644
--- a/bin/convertt/ui.c
+++ b/bin/convertt/ui.c
@@ -424,7 +424,8 @@ 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, 0, 0);
+          data=gal_fits_img_read(name->v, hdu, p->cp.minmapsize);
+          data->wcs=gal_wcs_read(name->v, hdu, 0, 0, &data->nwcs);
           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 43cfd88..3dbfa85 100644
--- a/bin/convolve/ui.c
+++ b/bin/convolve/ui.c
@@ -295,9 +295,7 @@ 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,
-                                        0, 0);
-  if(p->kernel->wcs) { wcsfree(p->kernel->wcs); p->kernel->wcs=NULL; }
+                                        GAL_TYPE_FLOAT32, p->cp.minmapsize);
 
   /* Convert all the NaN pixels to zero if the kernel contains blank
      pixels, also update the flags so it is not checked any more. */
@@ -344,7 +342,8 @@ ui_preparations(struct convolveparams *p)
 
   /* 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, 0, 0);
+                                     GAL_TYPE_FLOAT32, cp->minmapsize);
+  p->input->wcs=gal_wcs_read(p->filename, cp->hdu, 0, 0, &p->input->nwcs);
 
 
   /* Currently Convolve only works on 2D images. */
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index aaf192a..ce329c8 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -29,6 +29,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <string.h>
 #include <inttypes.h>
 
+#include <gnuastro/wcs.h>
 #include <gnuastro/fits.h>
 #include <gnuastro/blank.h>
 #include <gnuastro/threads.h>
@@ -372,7 +373,8 @@ 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, 0,0);
+                                     GAL_TYPE_FLOAT32, p->cp.minmapsize);
+  p->input->wcs=gal_wcs_read(p->inputname, p->cp.hdu, 0, 0, &p->input->nwcs);
 
 
   /* Read basic WCS information for final table meta-data. */
@@ -392,7 +394,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, 0, 0);
+                                 p->cp.minmapsize);
   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,
@@ -401,7 +403,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, 0, 0);
+                                   p->cp.minmapsize);
   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,
@@ -410,7 +412,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, 0, 0);
+                                   p->cp.minmapsize);
   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,
@@ -422,7 +424,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, 0, 0);
+                                    p->cp.minmapsize);
       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,
@@ -478,7 +480,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, 0, 0);
+                                    p->cp.minmapsize);
       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,
diff --git a/bin/mknoise/ui.c b/bin/mknoise/ui.c
index eba6e4f..2ff070d 100644
--- a/bin/mknoise/ui.c
+++ b/bin/mknoise/ui.c
@@ -282,7 +282,8 @@ 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, 0,0);
+                                     GAL_TYPE_FLOAT64, p->cp.minmapsize);
+  p->input->wcs=gal_wcs_read(p->inputname, p->cp.hdu, 0, 0, &p->input->nwcs);
 
 
   /* 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 0381f0a..eecbb47 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -1032,7 +1032,9 @@ ui_prepare_canvas(struct mkprofparams *p)
           /* Read the image. */
           p->out=gal_fits_img_read_to_type(p->backname, p->backhdu,
                                            GAL_TYPE_FLOAT32,
-                                           p->cp.minmapsize, 0, 0);
+                                           p->cp.minmapsize);
+          p->out->wcs=gal_wcs_read(p->backname, p->backhdu, 0, 0,
+                                   &p->out->nwcs);
 
           /* Put the WCS structure and number of dimensions in the
              MakeProfiles's main structure for generality. The WCS
diff --git a/bin/noisechisel/ui.c b/bin/noisechisel/ui.c
index e639090..87cd718 100644
--- a/bin/noisechisel/ui.c
+++ b/bin/noisechisel/ui.c
@@ -587,8 +587,9 @@ ui_preparations(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, 0, 0);
+                                       GAL_TYPE_FLOAT32, p->cp.minmapsize);
+  p->input->wcs = gal_wcs_read(p->inputname, p->cp.hdu, 0, 0,
+                               &p->input->nwcs);
   if(p->input->name==NULL)
     gal_checkset_allocate_copy("INPUT", &p->input->name);
 
@@ -606,8 +607,7 @@ ui_preparations(struct noisechiselparams *p)
     {
       /* Read the input convolved image. */
       p->conv = gal_fits_img_read_to_type(p->convolvedname, p->convolvedhdu,
-                                          GAL_TYPE_FLOAT32, p->cp.minmapsize,
-                                          0, 0);
+                                          GAL_TYPE_FLOAT32, p->cp.minmapsize);
 
       /* Make sure the convolved image is the same size as the input. */
       if( gal_data_dsize_is_different(p->input, p->conv) )
diff --git a/bin/statistics/ui.c b/bin/statistics/ui.c
index bed2975..36c8810 100644
--- a/bin/statistics/ui.c
+++ b/bin/statistics/ui.c
@@ -797,7 +797,9 @@ 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, 0, 0);
+      p->input=gal_fits_img_read(p->inputname, cp->hdu, cp->minmapsize);
+      p->input->wcs=gal_wcs_read(p->inputname, cp->hdu, 0, 0,
+                                 &p->input->nwcs);
     }
   else
     {
diff --git a/bin/warp/ui.c b/bin/warp/ui.c
index 89a5e6c..adea832 100644
--- a/bin/warp/ui.c
+++ b/bin/warp/ui.c
@@ -338,8 +338,9 @@ 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->hstartwcs, p->hendwcs);
+                                         GAL_TYPE_FLOAT64, p->cp.minmapsize);
+      p->input->wcs=gal_wcs_read(p->inputname, p->cp.hdu, p->hstartwcs,
+                                 p->hendwcs, &p->input->nwcs);
       if(p->input->wcs)
         {
           p->pixelscale=gal_wcs_pixel_scale(p->input->wcs);
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index efdc2ab..e553a12 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -554,11 +554,12 @@ Gnuastro library
 * Library data container::      General data container in Gnuastro.
 * Dimensions::                  Dealing with coordinates and dimensions.
 * Linked lists::                Various types of linked lists.
+* Array input output::          Reading and writing images or cubes.
+* Table input output::          Reading and writing table columns.
 * FITS files::                  Working with FITS data.
-* World Coordinate System::     Dealing with the world coordinate system.
 * TIFF files::                  Functions for using TIFF files.
 * Text files::                  Functions to work on Text files.
-* Table input output::          Reading and writing table columns.
+* World Coordinate System::     Dealing with the world coordinate system.
 * Arithmetic on datasets::      Arithmetic operations on a dataset.
 * Tessellation library::        Functions for working on tiles.
 * Bounding box::                Finding the bounding box.
@@ -19099,11 +19100,12 @@ documentation will correspond to your installed 
version.
 * Library data container::      General data container in Gnuastro.
 * Dimensions::                  Dealing with coordinates and dimensions.
 * Linked lists::                Various types of linked lists.
+* Array input output::          Reading and writing images or cubes.
+* Table input output::          Reading and writing table columns.
 * FITS files::                  Working with FITS data.
-* World Coordinate System::     Dealing with the world coordinate system.
 * TIFF files::                  Functions for using TIFF files.
 * Text files::                  Functions to work on Text files.
-* Table input output::          Reading and writing table columns.
+* World Coordinate System::     Dealing with the world coordinate system.
 * Arithmetic on datasets::      Arithmetic operations on a dataset.
 * Tessellation library::        Functions for working on tiles.
 * Bounding box::                Finding the bounding box.
@@ -20278,7 +20280,9 @@ The functions in this section describes Gnuastro's 
facilities to copy a
 given dataset into another. The new dataset can have a different type
 (including a string), it can be already allocated (in which case only the
 values will be written into it). In all these cases, if the input dataset
-is a tile, only the data within the tile are copied.
+is a tile or a list, only the data within the given tile, or the given node
+in a list, are copied. If the input is a list, the @code{next} pointer will
+also be copied to the output, see @ref{List of gal_data_t}.
 
 In many of the functions here, it is possible to copy the dataset to a new
 numeric data type (see @ref{Numeric data types}. In such cases, Gnuastro's
@@ -20288,22 +20292,28 @@ fit into the output type.
 
 @deftypefun {gal_data_t *} gal_data_copy (gal_data_t @code{*in})
 Return a new dataset that is a copy of @code{in}, all of @code{in}'s
-meta-data will also copied into the output, except for @code{block}.
+meta-data will also copied into the output, except for @code{block}. If the
+dataset is a tile/list, only the given tile/node will be copied, the
address@hidden pointer will also be copied however.
 @end deftypefun
 
 @deftypefun {gal_data_t *} gal_data_copy_to_new_type (gal_data_t @code{*in}, 
uint8_t @code{newtype})
 Return a copy of the dataset @code{in}, converted to @code{newtype}, see
 @ref{Library data types} for Gnuastro library's type identifiers. The
 returned dataset will have all meta-data except their type and @code{block}
-equal to the input's metadata.
+equal to the input's metadata. If the dataset is a tile/list, only the
+given tile/node will be copied, the @code{next} pointer will also be copied
+however.
 @end deftypefun
 
 @deftypefun {gal_data_t *} gal_data_copy_to_new_type_free (gal_data_t 
@code{*in}, uint8_t @code{newtype})
 Return a copy of the dataset @code{in} that is converted to @code{newtype}
 and free the input dataset. See @ref{Library data types} for Gnuastro
 library's type identifiers. The returned dataset will have all meta-data,
-except their type, equal to the input's metadata. This function is similar
-to @code{gal_data_copy_to_new_type}, except that it will free the input
+except their type, equal to the input's metadata (including
address@hidden). Note that if the input is a tile within a larger block, it
+will not be freed. This function is similar to
address@hidden, except that it will free the input
 dataset.
 @end deftypefun
 
@@ -20461,7 +20471,7 @@ This macro works fully within its own 
@address@hidden@}} block and except for the
 within this macro's block start with @code{gdn_}.
 @end deffn
 
address@hidden Linked lists, FITS files, Dimensions, Gnuastro library
address@hidden Linked lists, Array input output, Dimensions, Gnuastro library
 @subsection Linked lists (@file{list.h})
 
 @cindex Array
@@ -21220,9 +21230,9 @@ In 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, 0, 0);
+tmp = gal_fits_img_read("file1.fits", "1", minmapsize);
 gal_list_data_add( &list, tmp );
-tmp = gal_fits_img_read("file2.fits", "1", minmapsize, 0, 0);
+tmp = gal_fits_img_read("file2.fits", "1", minmapsize);
 gal_list_data_add( &list, tmp );
 @end example
 @end deftypefun
@@ -21252,7 +21262,234 @@ Free all the datasets in @code{list} along with all 
the allocated spaces in
 each.
 @end deftypefun
 
address@hidden FITS files, World Coordinate System, Linked lists, Gnuastro 
library
+
+
+
+
address@hidden Array input output, Table input output, Linked lists, Gnuastro 
library
address@hidden Array input output
+
+Getting arrays (commonly images or cubes) from a file into your program or
+writing them after the processing into an output file are some of the most
+common operations. The functions in this section are designed for such
+operations with the known file types. The functions here are thus just
+wrappers around funcitons of lower-level file type functions of this
+library, for example @ref{FITS files} or @ref{TIFF files}. If the file type
+of the input/output file is already known, you can use the functions in
+those sections respectively.
+
address@hidden gal_data_t gal_array_read (char @code{*filename}, char 
@code{*extension}, size_t @code{minmapsize})
+Read the array within the given extension (@code{extension}) of
address@hidden If the array is larger than @code{minmapsize} bytes, then
+it won't be read into RAM, but a file on the HDD/SSD (no difference for the
+programmer). @code{extension} will be ignored for files that don't support
+them (for example JPEG or text). For FITS files, @code{extension} can be a
+number or a string (name of the extension), but for TIFF files, it has to
+be number. In both cases, counting starts from zero.
+
+For multi-channel formats (like RGB images in JPEG or TIFF), this function
+will return a @ref{List of gal_data_t}: one data structure per
+channel. Thus if you just want a single array (and want to check if the
+user hasn't given a multi-channel input), you can check the @code{next}
+pointer of the returned @code{gal_data_t}.
address@hidden deftypefun
+
address@hidden void gal_array_read_to_type (char @code{*filename}, char 
@code{*extension}, uint8_t @code{type}, size_t @code{minmapsize})
+Similar to @code{gal_array_read}, but the output data structure(s) will
+have a numeric data type of @code{type}, see @ref{Numeric data types}.
address@hidden deftypefun
+
+
+
address@hidden Table input output, FITS files, Array input output, Gnuastro 
library
address@hidden Table input output (@file{table.h})
+
+Tables are a collection of one dimensional datasets that are packed
+together into one file. They are the single most common format to store
+high-level (processed) information, hence they play a very important role
+in Gnuastro. For a more thorough introduction, please see
address@hidden Gnuastro's Table program, and all the other programs that can
+read from and write into tables, use the functions of this section for
+reading and writing their input/output tables. For a simple demonstration
+of using the constructs introduced here, see @ref{Library demo - reading
+and writing table columns}.
+
+Currently only plain text (see @ref{Gnuastro text table format}) and FITS
+(ASCII and binary) tables are supported by Gnuastro. However, the low-level
+table infra-structure is written such that accommodating other formats is
+also possible and in future releases more formats will hopefully be
+supported. Please don't hesitate to suggest your favorite format so it can
+be implemented when possible.
+
address@hidden  Macro GAL_TABLE_DEF_WIDTH_STR
address@hidden Macro GAL_TABLE_DEF_WIDTH_INT
address@hidden Macro GAL_TABLE_DEF_WIDTH_LINT
address@hidden Macro GAL_TABLE_DEF_WIDTH_FLT
address@hidden Macro GAL_TABLE_DEF_WIDTH_DBL
address@hidden Macro GAL_TABLE_DEF_PRECISION_INT
address@hidden Macro GAL_TABLE_DEF_PRECISION_FLT
address@hidden Macro GAL_TABLE_DEF_PRECISION_DBL
address@hidden @code{printf}
+The default width and precision for generic types to use in writing numeric
+types into a text file (plain text and FITS ASCII tables). When the dataset
+doesn't have any pre-set width and precision (see @code{disp_width} and
address@hidden in @ref{Generic data container}) these will be
+directly used in C's @code{printf} command to write the number as a string.
address@hidden deffn
+
address@hidden  Macro GAL_TABLE_DISPLAY_FMT_STRING
address@hidden Macro GAL_TABLE_DISPLAY_FMT_DECIMAL
address@hidden Macro GAL_TABLE_DISPLAY_FMT_UDECIMAL
address@hidden Macro GAL_TABLE_DISPLAY_FMT_OCTAL
address@hidden Macro GAL_TABLE_DISPLAY_FMT_HEX
address@hidden Macro GAL_TABLE_DISPLAY_FMT_FLOAT
address@hidden Macro GAL_TABLE_DISPLAY_FMT_EXP
address@hidden Macro GAL_TABLE_DISPLAY_FMT_GENERAL
+The display format used in C's @code{printf} to display data of different
+types. The @code{_STRING} and @code{_DECIMAL} are unique for printing
+strings and signed integers, they are mainly here for
+completeness. However, unsigned integers and floating points can be
+displayed in multiple formats:
+
address@hidden @asis
address@hidden Unsigned integer
+For unsigned integers, it is possible to choose from @code{_UDECIMAL}
+(unsigned decimal), @code{_OCTAL} (octal notation, for example @code{125}
+in decimal will be displayed as @code{175}), and @code{_HEX} (hexadecimal
+notation, for example @code{125} in decimal will be displayed as
address@hidden).
+
address@hidden Floating point
+For floating point, it is possible to display the number in @code{_FLOAT}
+(floating point, for example @code{1500.345}), @code{_EXP} (exponential,
+for example @code{1.500345e+03}), or @code{_GENERAL} which is the best of
+the two for the given number.
address@hidden table
address@hidden deffn
+
address@hidden  Macro GAL_TABLE_FORMAT_INVALID
address@hidden Macro GAL_TABLE_FORMAT_TXT
address@hidden Macro GAL_TABLE_FORMAT_AFITS
address@hidden Macro GAL_TABLE_FORMAT_BFITS
+All the current acceptable table formats to Gnuastro. The @code{AFITS} and
address@hidden represent FITS ASCII tables and FITS Binary tables. You can
+use these anywhere you see the @code{tableformat} variable.
address@hidden deffn
+
address@hidden  Macro GAL_TABLE_SEARCH_INVALID
address@hidden Macro GAL_TABLE_SEARCH_NAME
address@hidden Macro GAL_TABLE_SEARCH_UNIT
address@hidden Macro GAL_TABLE_SEARCH_COMMENT
+When the desired column is not a number, these values determine if the
+string to match, or regular expression to search, be in the @emph{name},
address@hidden or @emph{comments} of the column meta data. These values
+should be used for the @code{searchin} variables of the functions.
address@hidden deffn
+
address@hidden {gal_data_t *} gal_table_info (char @code{*filename}, char 
@code{*hdu}, size_t @code{*numcols}, size_t @code{*numrows}, int 
@code{*tableformat})
+Store the information of each column in a table (either as a text file or
+as a FITS table) into an array of data structures with @code{numcols}
+structures (one data structure for each column). The number of rows is
+stored in the space that @code{numrows} points to. The format of the table
+(e.g., ascii text file, or FITS binary or ASCII table) will be put in
address@hidden (macros defined above). If the filename is not a FITS
+file, then @code{hdu} will not be used (can be @code{NULL}).
+
+Note that other than the character strings (column name, units and
+comments), nothing in the data structure(s) will be allocated by this
+function for the actual data (e.g., the `array' or `dsize' elements). This
+function is just for column information (meta-data), not column contents.
address@hidden deftypefun
+
address@hidden void gal_table_print_info (gal_data_t @code{*allcols}, size_t 
@code{numcols}, size_t @code{numrows})
+This program will print the column information for all the columns (output
+of @code{gal_table_info}). The output is in the same format as this command
+with Gnuastro Table program (see @ref{Table}):
address@hidden
+$ asttable --info table.fits
address@hidden example
address@hidden deftypefun
+
address@hidden {gal_data_t *} gal_table_read (char @code{*filename}, char 
@code{*hdu}, gal_list_str_t @code{*cols}, int @code{searchin}, int 
@code{ignorecase}, int @code{minmapsize}, size_t @code{colmatch})
+Read the specified columns in a text file (named @code{filename}) into a
+linked list of data structures. If the file is FITS, then @code{hdu} will
+also be used, otherwise, @code{hdu} is ignored.
+
address@hidden AWK
address@hidden GNU AWK
+The information to search for columns should be specified by the
address@hidden list of strings (see @ref{List of strings}). The string in each
+node of the list may be a number, an exact match to a column name, or a
+regular expression (in GNU AWK format) enclosed in @code{/ /}. The
address@hidden value must be one of the macros defined above. If
address@hidden is NULL, then this function will read the full table.
+
+The output is an individually allocated list of datasets (see @ref{List of
+gal_data_t}) with the same order of the @code{cols} list. Note that one
+column node in the @code{cols} list might give multiple columns (for
+example from regular expressions), in this case, the order of output
+columns that correspond to that one input, are in order of the table (which
+column was read first). So the first requested column is the first popped
+data structure and so on.
+
+if @code{colmatch!=NULL}, it is assumed to be an array that has at least the
+same number of elements as nodes in the @code{cols} list. The number of
+columns that matched each input column will be stored in each element.
address@hidden deftypefun
+
address@hidden Git
address@hidden void gal_table_comments_add_intro (gal_list_str_t 
@code{**comments}, char @code{*program_string}, time_t @code{*rawtime})
+Add some basic information to the list of @code{comments}. This basic
+information includes the following information
address@hidden
address@hidden
+If the program is run in a Git version controlled directory, Git's
+description is printed (see description under @code{COMMIT} in @ref{Output
+headers}).
address@hidden
+The calendar time that is stored in @code{rawtime} (@code{time_t} is C's
+calendar time format defined in @file{time.h}). You can calculate the time
+in this format with the following expressions:
address@hidden
+time_t rawtime;
+time(&rawtime);
address@hidden example
address@hidden
+The name of your program in @code{program_string}. If it is @code{NULL},
+this line is ignored.
address@hidden itemize
address@hidden deftypefun
+
address@hidden void gal_table_write (gal_data_t @code{*cols}, gal_list_str_t 
@code{*comments}, int @code{tableformat}, char @code{*filename}, char 
@code{*extname})
+Write the @code{cols} list of datasets into a table in @code{filename} (see
address@hidden of gal_data_t}). The format of the table can be determined with
address@hidden that accepts the macros defined above. If
address@hidden is not @code{NULL}, then the list of comments will also be
+printed into the output table. When the output table is a plain text file,
+each node's string will be printed after a @code{#} (so it can be
+considered as a comment) and in FITS table they will follow a
address@hidden keyword. If @file{filename} is a FITS file, the table
+extension that will be written will have the name @code{extname}.
+
+If a file named @file{filename} already exists, the operation depends on
+the type of output. When @file{filename} is a FITS file, the table will be
+added as a new extension after all existing ones. If @file{filename} is a
+plain text file, this function will abort with an error.
address@hidden deftypefun
+
address@hidden void gal_table_write_log (gal_data_t @code{*logll}, char 
@code{*program_string}, time_t @code{*rawtime}, gal_list_str_t 
@code{*comments}, char @code{*filename}, int @code{quiet})
+Write the @code{logll} list of datasets into a table in @code{filename}
+(see @ref{List of gal_data_t}). This function is just a wrapper around
address@hidden and @code{gal_table_write} (see
+above). If @code{quiet} is non-zero, this function will print a message
+saying that the @code{filename} has been created.
address@hidden deftypefun
+
+
+
+
+
address@hidden FITS files, TIFF files, Table input output, Gnuastro library
 @subsection FITS files (@file{fits.h})
 
 @cindex FITS
@@ -21659,7 +21896,7 @@ then if the image has a name and units, the respective 
string will be put
 in these pointers.
 @end deftypefun
 
address@hidden {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})
address@hidden {gal_data_t *} gal_fits_img_read (char @code{*filename}, char 
@code{*hdu}, 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}) and
 return it. If the necessary space is larger than @code{minmapsize}, then
@@ -21667,14 +21904,18 @@ 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}.
+Note that this function only reads the main data within the requested FITS
+extension, the WCS will not be read into the returned dataset. To read the
+WCS, you can use @code{gal_wcs_read} function as shown below. Afterwards,
+the @code{gal_data_free} function will free both the dataset and any WCS
+structure (if there are any).
address@hidden
+data=gal_fits_img_read(filename, hdu, -1);
+data->wcs=gal_wcs_read(filename, hdu, 0, 0, &data->wcs->nwcs);
address@hidden example
 @end deftypefun
 
address@hidden {gal_data_t *} gal_fits_img_read_to_type (char 
@code{*inputname}, char @code{*inhdu}, uint8_t @code{type}, size_t 
@code{minmapsize}, )
address@hidden {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.
@@ -21820,205 +22061,57 @@ formats, see @ref{Table input output}.
 
 
 
address@hidden TIFF files, Text files, FITS files, Gnuastro library
address@hidden TIFF files
 
+Outside of astronomy, the TIFF standard is arguably the most commonly used
+format to store high-precision data/images. Unlike FITS however, the TIFF
+standard only supports images (not tables), but like FITS, it has support
+for all standard data types (see @ref{Numeric data types}) which is the
+primary reason other fields use it.
 
+Another similarity of the TIFF and FITS standards is that TIFF supports
+multiple images in one file. The TIFF standard calls each one of these
+images (and their accompanying meta-data) a `directory' (roughly equivalent
+to the FITS extensions). Unlike FITS however, the directories can only be
+identified by their number (counting from zero), recall that in FITS you
+can also use the extension name to identify it.
 
+The functions described here allow easy reading (and later writing) of TIFF
+files within Gnuastro or for users of Gnuastro's libraries. Currently only
+reading is supported, but if you are interested, please get in touch with
+us.
 
address@hidden {int} gal_tiff_name_is_tiff (char @code{*name})
+Return @code{1} if @code{name} has a TIFF suffix. This can be used to make
+sure that a given input file is TIFF. See @code{gal_tiff_suffix_is_tiff}
+for a list of recognized suffixes.
address@hidden deftypefun
 
address@hidden World Coordinate System, TIFF files, FITS files, Gnuastro library
address@hidden World Coordinate System (@file{wcs.h})
address@hidden {int} gal_tiff_suffix_is_tiff (char @code{*name})
+Return @code{1} if @code{suffix} is a recognized TIFF suffix. The
+recognized suffixes are @file{tif}, @file{tiff}, @file{TIFF} and
address@hidden
address@hidden deftypefun
 
-The FITS standard defines the world coordinate system (WCS) as a mechanism
-to associate physical values to positions within a dataset. For example, it
-can be used to convert pixel coordinates in an image to celestial
-coordinates like the right ascension and declination. The functions in this
-section are mainly just wrappers over CFITSIO, WCSLIB and GSL library
-functions to help in common applications.
address@hidden {size_t} gal_tiff_dir_string_read (char @code{*string})
+Return the number within @code{string} as a @code{size_t} number to
+identify a TIFF directory. Note that the directories start counting from
+zero.
address@hidden deftypefun
 
address@hidden {gal_data_t *} gal_tiff_read (char @code{*filename}, size_t 
@code{dir}, size_t @code{minmapsize})
+Read the @code{dir} directory within the TIFF file @code{filename} and
+return the contents of that TIFF directory as @code{gal_data_t}. If the
+directory's image contains multiple channels, the output will be a list
+(see @ref{List of gal_data_t}).
address@hidden deftypefun
 
address@hidden {struct wcsprm *} gal_wcs_read_fitsptr (fitsfile @code{*fptr}, 
size_t @code{hstartwcs}, size_t @code{hendwcs}, int @code{*nwcs})
address@hidden thread-safe}] Return the WCSLIB @code{wcsprm} structure that
-is read from the CFITSIO @code{fptr} pointer to an opened FITS file. Also
-put the number of coordinate representations found into the space that
address@hidden points to. To read the WCS structure directly from a filename,
-see @code{gal_wcs_read} below. After processing has finished, you can free
-the returned structure with WCSLIB's @code{wcsvfree} keyword:
-
address@hidden
-status = wcsvfree(&nwcs,&wcs);
address@hidden example
-
-If you don't want to search the full FITS header for WCS-related FITS
-keywords (for example due to conflicting keywords), but only a specific
-range of the header keywords you can use the @code{hstartwcs} and
address@hidden arguments to specify the keyword number range (counting from
-zero). If @code{hendwcs} is larger than @code{hstartwcs}, then only
-keywords in the given range will be checked. Hence, to ignore this feature
-(and search the full FITS header), give both these arguments the same
-value.
-
-If the WCS information couldn't be read from the FITS file, this function
-will return a @code{NULL} pointer and put a zero in @code{nwcs}. A WCSLIB
-error message will also be printed in @code{stderr} if there was an error.
-
-This function is just a wrapper over WCSLIB's @code{wcspih} function which
-is not thread-safe. Therefore, be sure to not call this function
-simultaneously (over multiple threads).
address@hidden deftypefun
-
address@hidden {struct wcsprm *} gal_wcs_read (char @code{*filename}, char 
@code{*hdu}, size_t @code{hstartwcs}, size_t @code{hendwcs}, int @code{*nwcs})
address@hidden thread-safe}] Return the WCSLIB structure that is read from
-the HDU/extension @code{hdu} of the file @code{filename}. Also put the
-number of coordinate representations found into the space that @code{nwcs}
-points to. Please see @code{gal_wcs_read_fitsptr} for more.
address@hidden deftypefun
-
address@hidden {struct wcsprm *} gal_wcs_copy (struct wcsprm @code{*wcs})
-Return a fully allocated (independent) copy of @code{wcs}.
address@hidden deftypefun
-
address@hidden void gal_wcs_on_tile (gal_data_t @code{*tile})
-Create a WCSLIB @code{wcsprm} structure for @code{tile} using WCS
-parameters of the tile's allocated block dataset, see @ref{Tessellation
-library} for the definition of tiles. If @code{tile} already has a WCS
-structure, this function won't do anything.
-
-In many cases, tiles are created for internal/low-level processing. Hence
-for performance reasons, when creating the tiles they don't have any WCS
-structure. When needed, this function can be used to add a WCS structure to
-each tile tile by copying the WCS structure of its block and correcting the
-reference point's coordinates within the tile.
address@hidden deftypefun
-
address@hidden {double *} gal_wcs_warp_matrix (struct wcsprm @code{*wcs})
-Return the Warping matrix of the given WCS structure as an array of double
-precision floating points. This will be the final matrix, irrespective of
-the type of storage in the WCS structure. Recall that the FITS standard has
-several methods to store the matrix. The output is an allocated square
-matrix with each side equal to the number of dimensions.
address@hidden deftypefun
-
address@hidden void gal_wcs_decompose_pc_cdelt (struct wcsprm @code{*wcs})
-Decompose the @code{PCi_j} and @code{CDELTi} elements of
address@hidden According to the FITS standard, in the @code{PCi_j} WCS
-formalism, the rotation matrix elements @mymath{m_{ij}} are encoded in the
address@hidden keywords and the scale factors are encoded in the
address@hidden keywords. There is also another formalism (the @code{CDi_j}
-formalism) which merges the two into one matrix.
-
-However, WCSLIB's internal operations are apparently done in the
address@hidden formalism. So its outputs are also all in that format by
-default. When the input is a @code{CDi_j}, WCSLIB will still read the
-matrix directly into the @code{PCi_j} matrix and the @code{CDELTi} values
-are set to @code{1} (one). This function is designed to correct such
-issues: after it is finished, the @code{CDELTi} values in @code{wcs} will
-correspond to the pixel scale, and the @code{PCi_j} will correction show
-the rotation.
address@hidden deftypefun
-
address@hidden double gal_wcs_angular_distance_deg (double @code{r1}, double 
@code{d1}, double @code{r2}, double @code{d2})
-Return the angular distance (in degrees) between a point located at
-(@code{r1}, @code{d1}) to (@code{r2}, @code{d2}). All input coordinates are
-in degrees. The distance (along a great circle) on a sphere between two
-points is calculated with the equation below.
-
address@hidden {\cos(d)=\sin(d_1)\sin(d_2)+\cos(d_1)\cos(d_2)\cos(r_1-r_2)}
-
-However, since the the pixel scales are usually very small numbers, this
-function won't use that direct formula. It will be use the
address@hidden://en.wikipedia.org/wiki/Haversine_formula, Haversine formula}
-which is better considering floating point errors:
-
address@hidden(d)\over 2}=\sin^2\left( {d_1-d_2\over 2} 
\right)+\cos(d_1)\cos(d_2)\sin^2\left( {r_1-r_2\over 2} \right)}
address@hidden deftypefun
-
address@hidden {double *} gal_wcs_pixel_scale (struct wcsprm @code{*wcs})
-Return the pixel scale for each dimension of @code{wcs} in degrees. The
-output is an array of double precision floating point type with one element
-for each dimension.
address@hidden deftypefun
-
address@hidden double gal_wcs_pixel_area_arcsec2 (struct wcsprm @code{*wcs})
-Return the pixel area of @code{wcs} in arcsecond squared. If the input WCS
-structure is not two dimensional and the units (@code{CUNIT} keywords) are
-not @code{deg} (for degrees), then this function will return a NaN.
address@hidden deftypefun
-
address@hidden {gal_data_t *} gal_wcs_world_to_img (gal_data_t @code{*coords}, 
struct wcsprm @code{*wcs}, int @code{inplace})
-Convert the linked list of world coordinates in @code{coords} to a linked
-list of image coordinates given the input WCS structure. @code{coords} must
-be a linked list of data structures of float64 (`double') type,
address@hidden lists} and @ref{List of gal_data_t}. The top (first
-popped/read) node of the linked list must be the first WCS coordinate (RA
-in an image usually) and etc. Similarly, the top node of the output will be
-the first image coordinate (in the FITS standard).
 
-If @code{inplace} is zero, then the output will be a newly allocated list
-and the input list will be untouched. However, if @code{inplace} is
-non-zero, the output values will be written into the input's already
-allocated array and the returned pointer will be the same pointer to
address@hidden (in other words, you can ignore the returned value). Note
-that in the latter case, only the values will be changed, things like units
-or name (if present) will be untouched.
address@hidden deftypefun
-
address@hidden {gal_data_t *} gal_wcs_img_to_world (gal_data_t @code{*coords}, 
struct wcsprm @code{*wcs}, int @code{inplace})
-Convert the linked list of image coordinates in @code{coords} to a linked
-list of world coordinates given the input WCS structure. See the
-description of @code{gal_wcs_world_to_img} for more details.
address@hidden deftypefun
-
-
-
address@hidden TIFF files, Text files, World Coordinate System, Gnuastro library
address@hidden TIFF files
-
-Outside of astronomy, the TIFF standard is arguably the most commonly used
-format to store high-precision data/images. Unlike FITS however, the TIFF
-standard only supports images (not tables), but like FITS, it has support
-for all standard data types (see @ref{Numeric data types}) which is the
-primary reason other fields use it.
-
-Another similarity of the TIFF and FITS standards is that TIFF supports
-multiple images in one file. The TIFF standard calls each one of these
-images (and their accompanying meta-data) a `directory' (roughly equivalent
-to the FITS extensions). Unlike FITS however, the directories can only be
-identified by their number (counting from zero), recall that in FITS you
-can also use the extension name to identify it.
-
-The functions described here allow easy reading (and later writing) of TIFF
-files within Gnuastro or for users of Gnuastro's libraries. Currently only
-reading is supported, but if you are interested, please get in touch with
-us.
-
address@hidden {int} gal_tiff_name_is_tiff (char @code{*name})
-Return @code{1} if @code{name} has a TIFF suffix. This can be used to make
-sure that a given input file is TIFF. See @code{gal_tiff_suffix_is_tiff}
-for a list of recognized suffixes.
address@hidden deftypefun
-
address@hidden {int} gal_tiff_suffix_is_tiff (char @code{*name})
-Return @code{1} if @code{suffix} is a recognized TIFF suffix. The
-recognized suffixes are @file{tif}, @file{tiff}, @file{TIFF} and
address@hidden
address@hidden deftypefun
-
address@hidden {size_t} gal_tiff_dir_string_read (char @code{*string})
-Return the number within @code{string} as a @code{size_t} number to
-identify a TIFF directory. Note that the directories start counting from
-zero.
address@hidden deftypefun
-
address@hidden {gal_data_t *} gal_tiff_read (char @code{*filename}, size_t 
@code{dir}, size_t @code{minmapsize})
-Read the @code{dir} directory within the TIFF file @code{filename} and
-return the contents of that TIFF directory as @code{gal_data_t}. If the
-directory's image contains multiple channels, the output will be a list
-(see @ref{List of gal_data_t}).
address@hidden deftypefun
 
 
 
address@hidden Text files, Table input output, TIFF files, Gnuastro library
address@hidden Text files, World Coordinate System, TIFF files, Gnuastro library
 @subsection Text files (@file{txt.h})
 
 FITS files are the primary data container in astronomy. FITS indeed as many
@@ -22125,191 +22218,157 @@ formats, see @ref{Table input output}.
 @end deftypefun
 
 
address@hidden Table input output, Arithmetic on datasets, Text files, Gnuastro 
library
address@hidden Table input output (@file{table.h})
 
-Tables are a collection of one dimensional datasets that are packed
-together into one file. They are the single most common format to store
-high-level (processed) information, hence they play a very important role
-in Gnuastro. For a more thorough introduction, please see
address@hidden Gnuastro's Table program, and all the other programs that can
-read from and write into tables, use the functions of this section for
-reading and writing their input/output tables. For a simple demonstration
-of using the constructs introduced here, see @ref{Library demo - reading
-and writing table columns}.
 
-Currently only plain text (see @ref{Gnuastro text table format}) and FITS
-(ASCII and binary) tables are supported by Gnuastro. However, the low-level
-table infra-structure is written such that accommodating other formats is
-also possible and in future releases more formats will hopefully be
-supported. Please don't hesitate to suggest your favorite format so it can
-be implemented when possible.
 
address@hidden  Macro GAL_TABLE_DEF_WIDTH_STR
address@hidden Macro GAL_TABLE_DEF_WIDTH_INT
address@hidden Macro GAL_TABLE_DEF_WIDTH_LINT
address@hidden Macro GAL_TABLE_DEF_WIDTH_FLT
address@hidden Macro GAL_TABLE_DEF_WIDTH_DBL
address@hidden Macro GAL_TABLE_DEF_PRECISION_INT
address@hidden Macro GAL_TABLE_DEF_PRECISION_FLT
address@hidden Macro GAL_TABLE_DEF_PRECISION_DBL
address@hidden @code{printf}
-The default width and precision for generic types to use in writing numeric
-types into a text file (plain text and FITS ASCII tables). When the dataset
-doesn't have any pre-set width and precision (see @code{disp_width} and
address@hidden in @ref{Generic data container}) these will be
-directly used in C's @code{printf} command to write the number as a string.
address@hidden deffn
address@hidden World Coordinate System, Arithmetic on datasets, Text files, 
Gnuastro library
address@hidden World Coordinate System (@file{wcs.h})
 
address@hidden  Macro GAL_TABLE_DISPLAY_FMT_STRING
address@hidden Macro GAL_TABLE_DISPLAY_FMT_DECIMAL
address@hidden Macro GAL_TABLE_DISPLAY_FMT_UDECIMAL
address@hidden Macro GAL_TABLE_DISPLAY_FMT_OCTAL
address@hidden Macro GAL_TABLE_DISPLAY_FMT_HEX
address@hidden Macro GAL_TABLE_DISPLAY_FMT_FLOAT
address@hidden Macro GAL_TABLE_DISPLAY_FMT_EXP
address@hidden Macro GAL_TABLE_DISPLAY_FMT_GENERAL
-The display format used in C's @code{printf} to display data of different
-types. The @code{_STRING} and @code{_DECIMAL} are unique for printing
-strings and signed integers, they are mainly here for
-completeness. However, unsigned integers and floating points can be
-displayed in multiple formats:
+The FITS standard defines the world coordinate system (WCS) as a mechanism
+to associate physical values to positions within a dataset. For example, it
+can be used to convert pixel coordinates in an image to celestial
+coordinates like the right ascension and declination. The functions in this
+section are mainly just wrappers over CFITSIO, WCSLIB and GSL library
+functions to help in common applications.
 
address@hidden @asis
address@hidden Unsigned integer
-For unsigned integers, it is possible to choose from @code{_UDECIMAL}
-(unsigned decimal), @code{_OCTAL} (octal notation, for example @code{125}
-in decimal will be displayed as @code{175}), and @code{_HEX} (hexadecimal
-notation, for example @code{125} in decimal will be displayed as
address@hidden).
 
address@hidden Floating point
-For floating point, it is possible to display the number in @code{_FLOAT}
-(floating point, for example @code{1500.345}), @code{_EXP} (exponential,
-for example @code{1.500345e+03}), or @code{_GENERAL} which is the best of
-the two for the given number.
address@hidden table
address@hidden deffn
address@hidden {struct wcsprm *} gal_wcs_read_fitsptr (fitsfile @code{*fptr}, 
size_t @code{hstartwcs}, size_t @code{hendwcs}, int @code{*nwcs})
address@hidden thread-safe}] Return the WCSLIB @code{wcsprm} structure that
+is read from the CFITSIO @code{fptr} pointer to an opened FITS file. Also
+put the number of coordinate representations found into the space that
address@hidden points to. To read the WCS structure directly from a filename,
+see @code{gal_wcs_read} below. After processing has finished, you can free
+the returned structure with WCSLIB's @code{wcsvfree} keyword:
 
address@hidden  Macro GAL_TABLE_FORMAT_INVALID
address@hidden Macro GAL_TABLE_FORMAT_TXT
address@hidden Macro GAL_TABLE_FORMAT_AFITS
address@hidden Macro GAL_TABLE_FORMAT_BFITS
-All the current acceptable table formats to Gnuastro. The @code{AFITS} and
address@hidden represent FITS ASCII tables and FITS Binary tables. You can
-use these anywhere you see the @code{tableformat} variable.
address@hidden deffn
address@hidden
+status = wcsvfree(&nwcs,&wcs);
address@hidden example
 
address@hidden  Macro GAL_TABLE_SEARCH_INVALID
address@hidden Macro GAL_TABLE_SEARCH_NAME
address@hidden Macro GAL_TABLE_SEARCH_UNIT
address@hidden Macro GAL_TABLE_SEARCH_COMMENT
-When the desired column is not a number, these values determine if the
-string to match, or regular expression to search, be in the @emph{name},
address@hidden or @emph{comments} of the column meta data. These values
-should be used for the @code{searchin} variables of the functions.
address@hidden deffn
+If you don't want to search the full FITS header for WCS-related FITS
+keywords (for example due to conflicting keywords), but only a specific
+range of the header keywords you can use the @code{hstartwcs} and
address@hidden arguments to specify the keyword number range (counting from
+zero). If @code{hendwcs} is larger than @code{hstartwcs}, then only
+keywords in the given range will be checked. Hence, to ignore this feature
+(and search the full FITS header), give both these arguments the same
+value.
 
address@hidden {gal_data_t *} gal_table_info (char @code{*filename}, char 
@code{*hdu}, size_t @code{*numcols}, size_t @code{*numrows}, int 
@code{*tableformat})
-Store the information of each column in a table (either as a text file or
-as a FITS table) into an array of data structures with @code{numcols}
-structures (one data structure for each column). The number of rows is
-stored in the space that @code{numrows} points to. The format of the table
-(e.g., ascii text file, or FITS binary or ASCII table) will be put in
address@hidden (macros defined above). If the filename is not a FITS
-file, then @code{hdu} will not be used (can be @code{NULL}).
+If the WCS information couldn't be read from the FITS file, this function
+will return a @code{NULL} pointer and put a zero in @code{nwcs}. A WCSLIB
+error message will also be printed in @code{stderr} if there was an error.
 
-Note that other than the character strings (column name, units and
-comments), nothing in the data structure(s) will be allocated by this
-function for the actual data (e.g., the `array' or `dsize' elements). This
-function is just for column information (meta-data), not column contents.
+This function is just a wrapper over WCSLIB's @code{wcspih} function which
+is not thread-safe. Therefore, be sure to not call this function
+simultaneously (over multiple threads).
 @end deftypefun
 
address@hidden void gal_table_print_info (gal_data_t @code{*allcols}, size_t 
@code{numcols}, size_t @code{numrows})
-This program will print the column information for all the columns (output
-of @code{gal_table_info}). The output is in the same format as this command
-with Gnuastro Table program (see @ref{Table}):
address@hidden
-$ asttable --info table.fits
address@hidden example
address@hidden {struct wcsprm *} gal_wcs_read (char @code{*filename}, char 
@code{*hdu}, size_t @code{hstartwcs}, size_t @code{hendwcs}, int @code{*nwcs})
address@hidden thread-safe}] Return the WCSLIB structure that is read from
+the HDU/extension @code{hdu} of the file @code{filename}. Also put the
+number of coordinate representations found into the space that @code{nwcs}
+points to. Please see @code{gal_wcs_read_fitsptr} for more.
 @end deftypefun
 
address@hidden {gal_data_t *} gal_table_read (char @code{*filename}, char 
@code{*hdu}, gal_list_str_t @code{*cols}, int @code{searchin}, int 
@code{ignorecase}, int @code{minmapsize}, size_t @code{colmatch})
-Read the specified columns in a text file (named @code{filename}) into a
-linked list of data structures. If the file is FITS, then @code{hdu} will
-also be used, otherwise, @code{hdu} is ignored.
address@hidden {struct wcsprm *} gal_wcs_copy (struct wcsprm @code{*wcs})
+Return a fully allocated (independent) copy of @code{wcs}.
address@hidden deftypefun
 
address@hidden AWK
address@hidden GNU AWK
-The information to search for columns should be specified by the
address@hidden list of strings (see @ref{List of strings}). The string in each
-node of the list may be a number, an exact match to a column name, or a
-regular expression (in GNU AWK format) enclosed in @code{/ /}. The
address@hidden value must be one of the macros defined above. If
address@hidden is NULL, then this function will read the full table.
address@hidden void gal_wcs_on_tile (gal_data_t @code{*tile})
+Create a WCSLIB @code{wcsprm} structure for @code{tile} using WCS
+parameters of the tile's allocated block dataset, see @ref{Tessellation
+library} for the definition of tiles. If @code{tile} already has a WCS
+structure, this function won't do anything.
 
-The output is an individually allocated list of datasets (see @ref{List of
-gal_data_t}) with the same order of the @code{cols} list. Note that one
-column node in the @code{cols} list might give multiple columns (for
-example from regular expressions), in this case, the order of output
-columns that correspond to that one input, are in order of the table (which
-column was read first). So the first requested column is the first popped
-data structure and so on.
+In many cases, tiles are created for internal/low-level processing. Hence
+for performance reasons, when creating the tiles they don't have any WCS
+structure. When needed, this function can be used to add a WCS structure to
+each tile tile by copying the WCS structure of its block and correcting the
+reference point's coordinates within the tile.
address@hidden deftypefun
 
-if @code{colmatch!=NULL}, it is assumed to be an array that has at least the
-same number of elements as nodes in the @code{cols} list. The number of
-columns that matched each input column will be stored in each element.
address@hidden {double *} gal_wcs_warp_matrix (struct wcsprm @code{*wcs})
+Return the Warping matrix of the given WCS structure as an array of double
+precision floating points. This will be the final matrix, irrespective of
+the type of storage in the WCS structure. Recall that the FITS standard has
+several methods to store the matrix. The output is an allocated square
+matrix with each side equal to the number of dimensions.
 @end deftypefun
 
address@hidden Git
address@hidden void gal_table_comments_add_intro (gal_list_str_t 
@code{**comments}, char @code{*program_string}, time_t @code{*rawtime})
-Add some basic information to the list of @code{comments}. This basic
-information includes the following information
address@hidden
address@hidden
-If the program is run in a Git version controlled directory, Git's
-description is printed (see description under @code{COMMIT} in @ref{Output
-headers}).
address@hidden
-The calendar time that is stored in @code{rawtime} (@code{time_t} is C's
-calendar time format defined in @file{time.h}). You can calculate the time
-in this format with the following expressions:
address@hidden
-time_t rawtime;
-time(&rawtime);
address@hidden example
address@hidden
-The name of your program in @code{program_string}. If it is @code{NULL},
-this line is ignored.
address@hidden itemize
address@hidden void gal_wcs_decompose_pc_cdelt (struct wcsprm @code{*wcs})
+Decompose the @code{PCi_j} and @code{CDELTi} elements of
address@hidden According to the FITS standard, in the @code{PCi_j} WCS
+formalism, the rotation matrix elements @mymath{m_{ij}} are encoded in the
address@hidden keywords and the scale factors are encoded in the
address@hidden keywords. There is also another formalism (the @code{CDi_j}
+formalism) which merges the two into one matrix.
+
+However, WCSLIB's internal operations are apparently done in the
address@hidden formalism. So its outputs are also all in that format by
+default. When the input is a @code{CDi_j}, WCSLIB will still read the
+matrix directly into the @code{PCi_j} matrix and the @code{CDELTi} values
+are set to @code{1} (one). This function is designed to correct such
+issues: after it is finished, the @code{CDELTi} values in @code{wcs} will
+correspond to the pixel scale, and the @code{PCi_j} will correction show
+the rotation.
 @end deftypefun
 
address@hidden void gal_table_write (gal_data_t @code{*cols}, gal_list_str_t 
@code{*comments}, int @code{tableformat}, char @code{*filename}, char 
@code{*extname})
-Write the @code{cols} list of datasets into a table in @code{filename} (see
address@hidden of gal_data_t}). The format of the table can be determined with
address@hidden that accepts the macros defined above. If
address@hidden is not @code{NULL}, then the list of comments will also be
-printed into the output table. When the output table is a plain text file,
-each node's string will be printed after a @code{#} (so it can be
-considered as a comment) and in FITS table they will follow a
address@hidden keyword. If @file{filename} is a FITS file, the table
-extension that will be written will have the name @code{extname}.
address@hidden double gal_wcs_angular_distance_deg (double @code{r1}, double 
@code{d1}, double @code{r2}, double @code{d2})
+Return the angular distance (in degrees) between a point located at
+(@code{r1}, @code{d1}) to (@code{r2}, @code{d2}). All input coordinates are
+in degrees. The distance (along a great circle) on a sphere between two
+points is calculated with the equation below.
 
-If a file named @file{filename} already exists, the operation depends on
-the type of output. When @file{filename} is a FITS file, the table will be
-added as a new extension after all existing ones. If @file{filename} is a
-plain text file, this function will abort with an error.
address@hidden {\cos(d)=\sin(d_1)\sin(d_2)+\cos(d_1)\cos(d_2)\cos(r_1-r_2)}
+
+However, since the the pixel scales are usually very small numbers, this
+function won't use that direct formula. It will be use the
address@hidden://en.wikipedia.org/wiki/Haversine_formula, Haversine formula}
+which is better considering floating point errors:
+
address@hidden(d)\over 2}=\sin^2\left( {d_1-d_2\over 2} 
\right)+\cos(d_1)\cos(d_2)\sin^2\left( {r_1-r_2\over 2} \right)}
 @end deftypefun
 
address@hidden void gal_table_write_log (gal_data_t @code{*logll}, char 
@code{*program_string}, time_t @code{*rawtime}, gal_list_str_t 
@code{*comments}, char @code{*filename}, int @code{quiet})
-Write the @code{logll} list of datasets into a table in @code{filename}
-(see @ref{List of gal_data_t}). This function is just a wrapper around
address@hidden and @code{gal_table_write} (see
-above). If @code{quiet} is non-zero, this function will print a message
-saying that the @code{filename} has been created.
address@hidden {double *} gal_wcs_pixel_scale (struct wcsprm @code{*wcs})
+Return the pixel scale for each dimension of @code{wcs} in degrees. The
+output is an array of double precision floating point type with one element
+for each dimension.
address@hidden deftypefun
+
address@hidden double gal_wcs_pixel_area_arcsec2 (struct wcsprm @code{*wcs})
+Return the pixel area of @code{wcs} in arcsecond squared. If the input WCS
+structure is not two dimensional and the units (@code{CUNIT} keywords) are
+not @code{deg} (for degrees), then this function will return a NaN.
 @end deftypefun
 
address@hidden Arithmetic on datasets, Tessellation library, Table input 
output, Gnuastro library
address@hidden {gal_data_t *} gal_wcs_world_to_img (gal_data_t @code{*coords}, 
struct wcsprm @code{*wcs}, int @code{inplace})
+Convert the linked list of world coordinates in @code{coords} to a linked
+list of image coordinates given the input WCS structure. @code{coords} must
+be a linked list of data structures of float64 (`double') type,
address@hidden lists} and @ref{List of gal_data_t}. The top (first
+popped/read) node of the linked list must be the first WCS coordinate (RA
+in an image usually) and etc. Similarly, the top node of the output will be
+the first image coordinate (in the FITS standard).
+
+If @code{inplace} is zero, then the output will be a newly allocated list
+and the input list will be untouched. However, if @code{inplace} is
+non-zero, the output values will be written into the input's already
+allocated array and the returned pointer will be the same pointer to
address@hidden (in other words, you can ignore the returned value). Note
+that in the latter case, only the values will be changed, things like units
+or name (if present) will be untouched.
address@hidden deftypefun
+
address@hidden {gal_data_t *} gal_wcs_img_to_world (gal_data_t @code{*coords}, 
struct wcsprm @code{*wcs}, int @code{inplace})
+Convert the linked list of image coordinates in @code{coords} to a linked
+list of world coordinates given the input WCS structure. See the
+description of @code{gal_wcs_world_to_img} for more details.
address@hidden deftypefun
+
+
+
+
+
address@hidden Arithmetic on datasets, Tessellation library, World Coordinate 
System, Gnuastro library
 @subsection Arithmetic on datasets (@file{arithmetic.h})
 
 When the dataset's type and other information are already known, any
@@ -23068,7 +23127,7 @@ char *filename="input.fits", *hdu="1";
 ...
 
 /* Read the input dataset. */
-input=gal_fits_img_read(filename, hdu, -1, 0, 0);
+input=gal_fits_img_read(filename, hdu, -1);
 
 /* Do a sanity check and preparations. */
 gal_tile_full_sanity_check(filename, hdu, input, &tl);
@@ -24253,8 +24312,7 @@ main(void)
 
 
   /* Read `img.fits' (HDU: 1) as a float32 array. */
-  image=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32, -1,
-                                  0, 0);
+  image=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32, -1);
 
 
   /* Use the allocated space as a single precision floating
@@ -24303,8 +24361,7 @@ 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,
-                                              0, 0);
+                                              GAL_TYPE_FLOAT32, -1);
 
   /* To avoid the `void *' pointer and have `dinc'. */
   array=input->array;
@@ -24444,8 +24501,7 @@ main(void)
   /* Read the image into memory as a float32 data type. We are using
    * `-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, 0, 0);
+  p.image=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32, -1);
 
 
   /* Print some basic information before the actual contents: */
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 1226a88..9917a3a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -56,10 +56,11 @@ libgnuastro_la_SOURCES = arithmetic.c arithmetic-and.c 
arithmetic-bitand.c \
   arithmetic-bitxor.c arithmetic-divide.c arithmetic-eq.c arithmetic-ge.c  \
   arithmetic-gt.c arithmetic-le.c arithmetic-lt.c arithmetic-minus.c       \
   arithmetic-modulo.c arithmetic-multiply.c arithmetic-ne.c                \
-  arithmetic-or.c arithmetic-plus.c binary.c blank.c box.c checkset.c      \
-  convolve.c cosmology.c data.c fits.c git.c interpolate.c list.c match.c  \
-  options.c permutation.c polygon.c qsort.c dimension.c statistics.c       \
-  table.c tableintern.c threads.c tiff.c tile.c timing.c txt.c type.c wcs.c
+  arithmetic-or.c arithmetic-plus.c array.c binary.c blank.c box.c         \
+  checkset.c convolve.c cosmology.c data.c fits.c git.c interpolate.c      \
+  list.c match.c options.c permutation.c polygon.c qsort.c dimension.c     \
+  statistics.c table.c tableintern.c threads.c tiff.c tile.c timing.c      \
+  txt.c type.c wcs.c
 
 
 
@@ -69,15 +70,16 @@ libgnuastro_la_SOURCES = arithmetic.c arithmetic-and.c 
arithmetic-bitand.c \
 # in the $(headersdir) directory. Some of the header files don't need to be
 # installed.
 headersdir=$(top_srcdir)/lib/gnuastro
-pkginclude_HEADERS = gnuastro/config.h $(headersdir)/arithmetic.h         \
-  $(headersdir)/binary.h $(headersdir)/blank.h $(headersdir)/box.h        \
-  $(headersdir)/convolve.h $(headersdir)/cosmology.h $(headersdir)/data.h \
-  $(headersdir)/dimension.h $(headersdir)/fits.h $(headersdir)/git.h      \
-  $(headersdir)/interpolate.h $(headersdir)/list.h $(headersdir)/match.h  \
-  $(headersdir)/permutation.h $(headersdir)/polygon.h                     \
-  $(headersdir)/qsort.h $(headersdir)/statistics.h $(headersdir)/table.h  \
-  $(headersdir)/threads.h $(headersdir)/tiff.h $(headersdir)/tile.h       \
-  $(headersdir)/txt.h $(headersdir)/type.h $(headersdir)/wcs.h
+pkginclude_HEADERS = gnuastro/config.h $(headersdir)/arithmetic.h          \
+  $(headersdir)/array.h $(headersdir)/binary.h $(headersdir)/blank.h       \
+  $(headersdir)/box.h $(headersdir)/convolve.h $(headersdir)/cosmology.h   \
+  $(headersdir)/data.h $(headersdir)/dimension.h $(headersdir)/fits.h      \
+  $(headersdir)/git.h $(headersdir)/interpolate.h $(headersdir)/list.h     \
+  $(headersdir)/match.h $(headersdir)/permutation.h                        \
+  $(headersdir)/polygon.h $(headersdir)/qsort.h $(headersdir)/statistics.h \
+  $(headersdir)/table.h $(headersdir)/threads.h $(headersdir)/tiff.h       \
+  $(headersdir)/tile.h $(headersdir)/txt.h $(headersdir)/type.h            \
+  $(headersdir)/wcs.h
 
 
 
diff --git a/lib/array.c b/lib/array.c
new file mode 100644
index 0000000..502c7fa
--- /dev/null
+++ b/lib/array.c
@@ -0,0 +1,97 @@
+/*********************************************************************
+array -- Functions for I/O on arrays (images or cubes)
+This is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+     Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2018, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+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 <gnuastro/txt.h>
+#include <gnuastro/fits.h>
+#include <gnuastro/tiff.h>
+#include <gnuastro/array.h>
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************/
+/*****************        High-level functions        ****************/
+/*********************************************************************/
+/* Read (all the possibly existing) color channels within each
+   extension/dir of the given file. */
+gal_data_t *
+gal_array_read(char *filename, char *extension, size_t minmapsize)
+{
+  size_t ext;
+
+  /* Based on the filename,  */
+  if( gal_fits_name_is_fits(filename) )
+    return gal_fits_img_read(filename, extension, minmapsize);
+  else if ( gal_tiff_name_is_tiff(filename) )
+    {
+      ext=gal_tiff_dir_string_read(extension);
+      return gal_tiff_read(filename, ext, minmapsize);
+    }
+  else
+    return gal_txt_image_read(filename, minmapsize);
+
+  /* Control should not get to here, but just to avoid compiler warnings,
+     we'll return a NULL. */
+  error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to solve the "
+        "problem. Control must not reach the end of this function", __func__,
+        PACKAGE_BUGREPORT);
+  return NULL;
+}
+
+
+
+
+
+/* Read the contents of the given file/extension to a specific type. */
+gal_data_t *
+gal_array_read_to_type(char *filename, char *extension, uint8_t type,
+                       size_t minmapsize)
+{
+  gal_data_t *out=NULL;
+  gal_data_t *next, *in=gal_array_read(filename, extension, minmapsize);
+
+  /* Go over all the channels. */
+  while(in)
+    {
+      next=in->next;
+      in->next=NULL;
+      gal_list_data_add(&out, gal_data_copy_to_new_type_free(in, type));
+      in=next;
+    }
+
+  /* Invert the reverse list and return. */
+  gal_list_data_reverse(&out);
+  return out;
+}
diff --git a/lib/fits.c b/lib/fits.c
index aadd92e..0cf1010 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -1506,8 +1506,7 @@ 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,
-                  size_t hstartwcs, size_t hendwcs)
+gal_fits_img_read(char *filename, char *hdu, size_t minmapsize)
 {
   void *blank;
   long *fpixel;
@@ -1563,10 +1562,6 @@ 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);
@@ -1585,13 +1580,12 @@ 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 hstartwcs,
-                          size_t hendwcs)
+                          size_t minmapsize)
 {
   gal_data_t *in, *converted;
 
   /* Read the specified input image HDU. */
-  in=gal_fits_img_read(inputname, hdu, minmapsize, hstartwcs, hendwcs);
+  in=gal_fits_img_read(inputname, hdu, minmapsize);
 
   /* If the input had another type, convert it to float. */
   if(in->type!=type)
@@ -1620,7 +1614,7 @@ gal_fits_img_read_kernel(char *filename, char *hdu, 
size_t minmapsize)
 
   /* 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, 0, 0);
+                                   minmapsize);
   if(kernel->wcs) { wcsfree(kernel->wcs); kernel->wcs=NULL; }
 
   /* Check if the size along each dimension of the kernel is an odd
diff --git a/lib/gnuastro/tiff.h b/lib/gnuastro/array.h
similarity index 80%
copy from lib/gnuastro/tiff.h
copy to lib/gnuastro/array.h
index 443dac8..8b7d728 100644
--- a/lib/gnuastro/tiff.h
+++ b/lib/gnuastro/array.h
@@ -1,11 +1,11 @@
 /*********************************************************************
-tiff -- functions to read and write TIFF files.
+array - Functions to read/write arrays from/to files.
 This is part of GNU Astronomy Utilities (Gnuastro) package.
 
 Original author:
      Mohammad Akhlaghi <address@hidden>
 Contributing author(s):
-Copyright (C) 2015-2018, Free Software Foundation, Inc.
+Copyright (C) 2018, Free Software Foundation, Inc.
 
 Gnuastro is free software: you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -20,14 +20,12 @@ General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
 **********************************************************************/
-#ifndef __GAL_TIFF_H__
-#define __GAL_TIFF_H__
-
+#ifndef __GAL_ARRAY_H__
+#define __GAL_ARRAY_H__
 
 /* Include other headers if necessary here. Note that other header files
    must be included before the C++ preparations below */
-#include <gnuastro/list.h>
-
+#include <gnuastro/data.h>
 
 
 /* C++ Preparations */
@@ -54,19 +52,12 @@ __BEGIN_C_DECLS  /* From C++ preparations */
 
 
 /* Functions */
-int
-gal_tiff_name_is_tiff(char *name);
-
-int
-gal_tiff_suffix_is_tiff(char *name);
-
-size_t
-gal_tiff_dir_string_read(char *string);
-
 gal_data_t *
-gal_tiff_read(char *filename, size_t dir, size_t minmapsize);
-
+gal_array_read(char *filename, char *extension, size_t minmapsize);
 
+gal_data_t *
+gal_array_read_to_type(char *filename, char *extension, uint8_t type,
+                       size_t minmapsize);
 
 
 __END_C_DECLS    /* From C++ preparations */
diff --git a/lib/gnuastro/fits.h b/lib/gnuastro/fits.h
index 058ef12..370355f 100644
--- a/lib/gnuastro/fits.h
+++ b/lib/gnuastro/fits.h
@@ -210,13 +210,11 @@ 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,
-                  size_t hstartwcs, size_t hendwcs);
+gal_fits_img_read(char *filename, char *hdu, size_t minmapsize);
 
 gal_data_t *
 gal_fits_img_read_to_type(char *inputname, char *hdu, uint8_t type,
-                          size_t minmapsize, size_t hstartwcs,
-                          size_t hendwcs);
+                          size_t minmapsize);
 
 gal_data_t *
 gal_fits_img_read_kernel(char *filename, char *hdu, size_t minmapsize);
diff --git a/lib/gnuastro/tiff.h b/lib/gnuastro/tiff.h
index 443dac8..2e2b008 100644
--- a/lib/gnuastro/tiff.h
+++ b/lib/gnuastro/tiff.h
@@ -5,7 +5,7 @@ This is part of GNU Astronomy Utilities (Gnuastro) package.
 Original author:
      Mohammad Akhlaghi <address@hidden>
 Contributing author(s):
-Copyright (C) 2015-2018, Free Software Foundation, Inc.
+Copyright (C) 2018, Free Software Foundation, Inc.
 
 Gnuastro is free software: you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
diff --git a/lib/tiff.c b/lib/tiff.c
index acfc8ba..023c223 100644
--- a/lib/tiff.c
+++ b/lib/tiff.c
@@ -5,7 +5,7 @@ This is part of GNU Astronomy Utilities (Gnuastro) package.
 Original author:
      Mohammad Akhlaghi <address@hidden>
 Contributing author(s):
-Copyright (C) 2015-2018, Free Software Foundation, Inc.
+Copyright (C) 2018, Free Software Foundation, Inc.
 
 Gnuastro is free software: you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
diff --git a/tests/buildprog/simpleio.c b/tests/buildprog/simpleio.c
index 7354ba7..11f6597 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, 0, 0);
+  image=gal_fits_img_read(argv[1], argv[2], -1);
 
   /* Let the user know. */
   printf("%s (hdu %s) is read into memory.\n", argv[1], argv[2]);
diff --git a/tests/lib/multithread.c b/tests/lib/multithread.c
index 65cd5a6..42f632c 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,0,0);
+  p.image=gal_fits_img_read_to_type(filename, hdu, GAL_TYPE_FLOAT32, -1);
 
 
   /* Print some basic information before the actual contents: */



reply via email to

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