gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 1fe38d8: FITS library functions now fully docu


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 1fe38d8: FITS library functions now fully documented
Date: Sun, 30 Apr 2017 18:06:41 -0400 (EDT)

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

    FITS library functions now fully documented
    
    The FITS library functions have now been documented in the manual. Some
    simple corrections in the function/argument names were also made to make
    them more consistent. For example where `type' doesn't refer to a numeric
    datatype it was changed to `format'.
---
 bin/crop/crop.c               |   6 +-
 bin/crop/onecrop.c            |   9 +-
 bin/crop/ui.c                 |   2 +-
 bin/fits/keywords.c           |   4 +-
 bin/fits/main.h               |   8 +-
 bin/fits/ui.c                 |  10 +-
 bin/mknoise/mknoise.c         |  32 +-
 bin/noisechisel/noisechisel.c |  48 +--
 bin/statistics/ui.c           |   2 +-
 bin/warp/warp.c               |   9 +-
 doc/gnuastro.texi             | 885 ++++++++++++++++++++++++------------------
 lib/fits.c                    | 214 +++++-----
 lib/gnuastro/fits.h           |  71 ++--
 lib/gnuastro/tile.h           |   2 +-
 lib/tile.c                    |   2 +-
 lib/wcs.c                     |   2 +-
 16 files changed, 704 insertions(+), 602 deletions(-)

diff --git a/bin/crop/crop.c b/bin/crop/crop.c
index 1e8f02a..fbebda5 100644
--- a/bin/crop/crop.c
+++ b/bin/crop/crop.c
@@ -201,7 +201,7 @@ imgmodecrop(void *inparam)
   /* The whole catalog is from one image, so you can get the
      information here:*/
   img=&p->imgs[crp->in_ind];
-  crp->infits=gal_fits_hdu_open_type(img->name, p->cp.hdu, 0);
+  crp->infits=gal_fits_hdu_open_format(img->name, p->cp.hdu, 0);
 
   /* Go over all the outputs that are assigned to this thread: */
   for(i=0; crp->indexs[i]!=GAL_BLANK_SIZE_T; ++i)
@@ -292,8 +292,8 @@ wcsmodecrop(void *inparam)
         if(radecoverlap(crp))
           {
             /* Open the input FITS file. */
-            crp->infits=gal_fits_hdu_open_type(p->imgs[crp->in_ind].name,
-                                               p->cp.hdu, 0);
+            crp->infits=gal_fits_hdu_open_format(p->imgs[crp->in_ind].name,
+                                                 p->cp.hdu, 0);
 
             /* If a name isn't set yet, set it. */
             if(crp->name==NULL) cropname(crp);
diff --git a/bin/crop/onecrop.c b/bin/crop/onecrop.c
index ad1e2e4..735d011 100644
--- a/bin/crop/onecrop.c
+++ b/bin/crop/onecrop.c
@@ -694,7 +694,7 @@ onecrop(struct onecropparams *crp)
   int status=0, anynul=0;
   char basename[FLEN_KEYWORD];
   fitsfile *ifp=crp->infits, *ofp;
-  struct gal_fits_key_ll *headers=NULL;
+  gal_fits_list_key_t *headers=NULL;
   long fpixel_o[2], lpixel_o[2], inc[2]={1,1};
   char region[FLEN_VALUE], regionkey[FLEN_KEYWORD];
   long naxes[]={img->dsize[1], img->dsize[0]}, fpixel_i[2] , lpixel_i[2];
@@ -766,10 +766,9 @@ onecrop(struct onecropparams *crp)
       sprintf(regionkey, "%sPIX", basename);
       sprintf(region, "%ld:%ld,%ld:%ld", fpixel_i[0], lpixel_i[0],
               fpixel_i[1], lpixel_i[1]);
-      gal_fits_key_add_to_ll_end(&headers, GAL_TYPE_STRING, regionkey,
-                                 0, region, 0,
-                                 "Range of pixels used for this output.", 0,
-                                 NULL);
+      gal_fits_key_list_add_end(&headers, GAL_TYPE_STRING, regionkey,
+                                0, region, 0, "Range of pixels used for "
+                                "this output.", 0, NULL);
       gal_fits_key_write(ofp, &headers);
 
       /* Free the allocated array. */
diff --git a/bin/crop/ui.c b/bin/crop/ui.c
index f5371fa..1fb3d0b 100644
--- a/bin/crop/ui.c
+++ b/bin/crop/ui.c
@@ -675,7 +675,7 @@ ui_preparations(struct cropparams *p)
       status=0;
       img=&p->imgs[--input_counter];
       img->name=gal_list_str_pop(&p->inputs);
-      tmpfits=gal_fits_hdu_open_type(img->name, p->cp.hdu, 0);
+      tmpfits=gal_fits_hdu_open_format(img->name, p->cp.hdu, 0);
       gal_fits_img_info(tmpfits, &p->type, &img->ndim, &img->dsize);
       gal_wcs_read_from_fitsptr(tmpfits, &img->nwcs, &img->wcs,
                                 p->hstartwcs, p->hendwcs);
diff --git a/bin/fits/keywords.c b/bin/fits/keywords.c
index 36944e6..2a2ce62 100644
--- a/bin/fits/keywords.c
+++ b/bin/fits/keywords.c
@@ -125,10 +125,10 @@ keywords_rename_keys(struct fitsparams *p, fitsfile 
**fptr, int *r)
 
 static void
 keywords_write_update(struct fitsparams *p, fitsfile **fptr,
-                    struct gal_fits_key_ll *keyll, int u1w2)
+                      gal_fits_list_key_t *keyll, int u1w2)
 {
   int status=0;
-  struct gal_fits_key_ll *tmp;
+  gal_fits_list_key_t *tmp;
 
   /* Open the FITS file if it hasn't been opened yet. */
   keywords_open(p, fptr, READWRITE);
diff --git a/bin/fits/main.h b/bin/fits/main.h
index 851479b..46bae7d 100644
--- a/bin/fits/main.h
+++ b/bin/fits/main.h
@@ -70,10 +70,10 @@ struct fitsparams
   uint8_t     quitonerror;     /* Quit if an error occurs.        */
 
   /* Internal: */
-  int                            mode;  /* Operating on HDUs or keywords.  */
-  struct gal_fits_key_ll  *write_keys;  /* Keys to write in the header.    */
-  struct gal_fits_key_ll *update_keys;  /* Keys to update in the header.   */
-  time_t                      rawtime;  /* Starting time of the program.   */
+  int                         mode;  /* Operating on HDUs or keywords.  */
+  gal_fits_list_key_t  *write_keys;  /* Keys to write in the header.    */
+  gal_fits_list_key_t *update_keys;  /* Keys to update in the header.   */
+  time_t                   rawtime;  /* Starting time of the program.   */
 };
 
 #endif
diff --git a/bin/fits/ui.c b/bin/fits/ui.c
index f232e81..5873071 100644
--- a/bin/fits/ui.c
+++ b/bin/fits/ui.c
@@ -305,10 +305,10 @@ ui_check_options_and_arguments(struct fitsparams *p)
 /*****************       Preparations      ********************/
 /**************************************************************/
 /* The `--update' and `--write' options take multiple values for each
-   keyword, so here, we tokenize them and put them into a `gal_fits_key_ll'
-   list. */
+   keyword, so here, we tokenize them and put them into a
+   `gal_fits_list_key_t' list. */
 static void
-ui_fill_fits_headerll(gal_list_str_t *input, struct gal_fits_key_ll **output)
+ui_fill_fits_headerll(gal_list_str_t *input, gal_fits_list_key_t **output)
 {
   long l, *lp;
   void *fvalue;
@@ -417,8 +417,8 @@ ui_fill_fits_headerll(gal_list_str_t *input, struct 
gal_fits_key_ll **output)
         }
 
 
-      gal_fits_key_add_to_ll(output, type, keyname, 0,
-                             fvalue, vfree, comment, 0, unit);
+      gal_fits_key_list_add(output, type, keyname, 0, fvalue, vfree,
+                            comment, 0, unit);
       free(original);
     }
 }
diff --git a/bin/mknoise/mknoise.c b/bin/mknoise/mknoise.c
index 78d9bb5..e17b8ad 100644
--- a/bin/mknoise/mknoise.c
+++ b/bin/mknoise/mknoise.c
@@ -55,7 +55,7 @@ void
 convertsaveoutput(struct mknoiseparams *p)
 {
   char keyname1[FLEN_KEYWORD];
-  struct gal_fits_key_ll *headers=NULL;
+  gal_fits_list_key_t *headers=NULL;
   char keyname2[FLEN_KEYWORD], keyname3[FLEN_KEYWORD];
   char keyname4[FLEN_KEYWORD], keyname5[FLEN_KEYWORD];
 
@@ -63,26 +63,24 @@ convertsaveoutput(struct mknoiseparams *p)
   /* Add the proper information to the header of the output: */
   gal_fits_key_write_filename("INF", p->inputname, &headers);
   strcpy(keyname1, "BCKGRND");
-  gal_fits_key_add_to_ll_end(&headers, GAL_TYPE_FLOAT64, keyname1, 0,
-                             &p->background_mag, 0, "Background "
-                             "value (in magnitude) for noise.",
-                             0, NULL);
+  gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname1, 0,
+                            &p->background_mag, 0, "Background "
+                            "value (in magnitude) for noise.",
+                            0, NULL);
   strcpy(keyname2, "BZRPNT");
-  gal_fits_key_add_to_ll_end(&headers, GAL_TYPE_FLOAT64, keyname2, 0,
-                             &p->zeropoint, 0,
-                             "Zeropoint magnitude of image.", 0, NULL);
+  gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname2, 0,
+                            &p->zeropoint, 0, "Zeropoint magnitude of image.",
+                            0, NULL);
   strcpy(keyname3, "STDADD");
-  gal_fits_key_add_to_ll_end(&headers, GAL_TYPE_FLOAT64, keyname3, 0,
-                             &p->stdadd, 0,
-                             "Instrumental noise in units of flux.", 0, NULL);
+  gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname3, 0,
+                            &p->stdadd, 0, "Instrumental noise in units of "
+                            "flux.", 0, NULL);
   strcpy(keyname4, "RNGTYPE");
-  gal_fits_key_add_to_ll_end(&headers, GAL_TYPE_STRING, keyname4, 0,
-                             p->rng_type, 0,
-                             "Random number generator (by GSL) type.",
-                             0, NULL);
+  gal_fits_key_list_add_end(&headers, GAL_TYPE_STRING, keyname4, 0,
+                            p->rng_type, 0, "Random number generator (by "
+                            "GSL) type.",  0, NULL);
   strcpy(keyname5, "RNGSEED");
-  gal_fits_key_add_to_ll_end(&headers, GAL_TYPE_INT64, keyname5, 0,
-                             &p->rng_seed,
+  gal_fits_key_list_add_end(&headers, GAL_TYPE_INT64, keyname5, 0, 
&p->rng_seed,
                              0, "Random number generator (by GSL) seed.",
                              0, NULL);
 
diff --git a/bin/noisechisel/noisechisel.c b/bin/noisechisel/noisechisel.c
index f92125f..51e0f8d 100644
--- a/bin/noisechisel/noisechisel.c
+++ b/bin/noisechisel/noisechisel.c
@@ -188,7 +188,7 @@ noisechisel_output_copy_input(struct noisechiselparams *p)
 static void
 noisechisel_output(struct noisechiselparams *p)
 {
-  struct gal_fits_key_ll *keys=NULL;
+  gal_fits_list_key_t *keys=NULL;
 
   /* Copy the input image into the first extension. */
   noisechisel_output_copy_input(p);
@@ -196,14 +196,14 @@ noisechisel_output(struct noisechiselparams *p)
 
   /* Write the object labels and useful information into it's header. */
   if(p->onlydetection==0)
-    gal_fits_key_add_to_ll(&keys, GAL_TYPE_STRING, "WCLUMPS", 0, "yes", 0,
-                           "Generate catalog with clumps?", 0, "bool");
-  gal_fits_key_add_to_ll(&keys, GAL_TYPE_SIZE_T, "NUMLABS", 0,
-                         &p->numobjects, 0, "Total number of labels "
-                         "(inclusive)", 0, "counter");
-  gal_fits_key_add_to_ll(&keys, GAL_TYPE_FLOAT32, "DETSN", 0, &p->detsnthresh,
-                         0, "Minimum S/N of true pseudo-detections", 0,
-                         "ratio");
+    gal_fits_key_list_add(&keys, GAL_TYPE_STRING, "WCLUMPS", 0, "yes", 0,
+                          "Generate catalog with clumps?", 0, "bool");
+  gal_fits_key_list_add(&keys, GAL_TYPE_SIZE_T, "NUMLABS", 0,
+                        &p->numobjects, 0, "Total number of labels "
+                        "(inclusive)", 0, "counter");
+  gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "DETSN", 0, &p->detsnthresh,
+                        0, "Minimum S/N of true pseudo-detections", 0,
+                        "ratio");
   p->olabel->name = p->onlydetection ? "DETECTIONS" : "OBJECTS";
   gal_fits_img_write(p->olabel, p->cp.output, keys, PROGRAM_STRING);
   p->olabel->name=NULL;
@@ -217,12 +217,12 @@ noisechisel_output(struct noisechiselparams *p)
   if(p->onlydetection==0)
     {
       p->clabel->name="CLUMPS";
-      gal_fits_key_add_to_ll(&keys, GAL_TYPE_SIZE_T, "NUMLABS", 0,
-                             &p->numclumps, 0, "Total number of clumps", 0,
-                             "counter");
-      gal_fits_key_add_to_ll(&keys, GAL_TYPE_FLOAT32, "CLUMPSN", 0,
-                             &p->clumpsnthresh, 0,
-                             "Minimum S/N of true clumps", 0, "ratio");
+      gal_fits_key_list_add(&keys, GAL_TYPE_SIZE_T, "NUMLABS", 0,
+                            &p->numclumps, 0, "Total number of clumps", 0,
+                            "counter");
+      gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "CLUMPSN", 0,
+                            &p->clumpsnthresh, 0, "Minimum S/N of true clumps",
+                            0, "ratio");
       gal_fits_img_write(p->clabel, p->cp.output, keys, PROGRAM_STRING);
       p->clabel->name=NULL;
       keys=NULL;
@@ -239,15 +239,15 @@ noisechisel_output(struct noisechiselparams *p)
 
   /* Write the Sky standard deviation into the output. */
   p->std->name="SKY_STD";
-  gal_fits_key_add_to_ll(&keys, GAL_TYPE_FLOAT32, "MAXSTD", 0,
-                         &p->maxstd, 0, "Maximum raw tile standard deviation",
-                         0, p->input->unit);
-  gal_fits_key_add_to_ll(&keys, GAL_TYPE_FLOAT32, "MINSTD", 0,
-                         &p->minstd, 0, "Minimum raw tile standard deviation",
-                         0, p->input->unit);
-  gal_fits_key_add_to_ll(&keys, GAL_TYPE_FLOAT32, "MEDSTD", 0,
-                         &p->medstd, 0, "Median raw tile standard deviation",
-                         0, p->input->unit);
+  gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "MAXSTD", 0, &p->maxstd, 0,
+                        "Maximum raw tile standard deviation", 0,
+                        p->input->unit);
+  gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "MINSTD", 0, &p->minstd, 0,
+                        "Minimum raw tile standard deviation", 0,
+                        p->input->unit);
+  gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "MEDSTD", 0, &p->medstd, 0,
+                        "Median raw tile standard deviation", 0,
+                        p->input->unit);
   gal_tile_full_values_write(p->std, &p->cp.tl, p->cp.output, keys,
                              PROGRAM_STRING);
   p->std->name=NULL;
diff --git a/bin/statistics/ui.c b/bin/statistics/ui.c
index 662717a..05df0e8 100644
--- a/bin/statistics/ui.c
+++ b/bin/statistics/ui.c
@@ -522,7 +522,7 @@ ui_check_options_and_arguments(struct statisticsparams *p)
                   "acceptable by CFITSIO");
 
           /* If its a table, make sure a column is also specified. */
-          p->hdu_type=gal_fits_hdu_type(p->inputname, p->cp.hdu);
+          p->hdu_type=gal_fits_hdu_format(p->inputname, p->cp.hdu);
           if(p->hdu_type==IMAGE_HDU)
             {
               if(p->column)
diff --git a/bin/warp/warp.c b/bin/warp/warp.c
index ba9eaf7..ff53451 100644
--- a/bin/warp/warp.c
+++ b/bin/warp/warp.c
@@ -415,7 +415,7 @@ correct_wcs_save_output(struct warpparams *p)
   double *m=p->matrix->array, diff;
   char keyword[9*FLEN_KEYWORD];
   struct wcsprm *wcs=p->output->wcs;
-  struct gal_fits_key_ll *headers=NULL;
+  gal_fits_list_key_t *headers=NULL;
   double tpc[4], tcrpix[3], *pixelscale;
   double *crpix=wcs->crpix, *pc=wcs->pc;
   double tinv[4]={p->inverse[0]/p->inverse[8], p->inverse[1]/p->inverse[8],
@@ -444,10 +444,9 @@ correct_wcs_save_output(struct warpparams *p)
   for(i=0;i<9;++i)
     {
       sprintf(&keyword[i*FLEN_KEYWORD], "WMTX%zu_%zu", i/3+1, i%3+1);
-      gal_fits_key_add_to_ll_end(&headers, GAL_TYPE_FLOAT64,
-                                 &keyword[i*FLEN_KEYWORD], 0,
-                                 &m[i], 0, "Warp matrix element value", 0,
-                                 NULL);
+      gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64,
+                                &keyword[i*FLEN_KEYWORD], 0, &m[i], 0,
+                                "Warp matrix element value", 0, NULL);
     }
 
   /* Due to floating point errors extremely small values of PC matrix can
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index a232cd9..a2b1ac8 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -425,8 +425,8 @@ Data analysis
 Statistics
 
 * Histogram and Cumulative Frequency Plot::  Basic definitions.
-* Sigma clipping::              Definition of @mymath{\sigma}-clipping
-* Sky value::
+* Sigma clipping::              Definition of @mymath{\sigma}-clipping.
+* Sky value::                   Definition and derivation of the Sky value.
 * Invoking aststatistics::      Arguments and options to Statistics.
 
 Sky value
@@ -532,12 +532,12 @@ Gnuastro library
 * Library blank values::        Blank values and functions to deal with them.
 * Library data container::      General data container in Gnuastro.
 * Linked lists::                Various types of linked lists.
+* FITS files::                  Working with FITS data.
+* Text files::                  Functions to work on Text files.
 * Table input output::          Reading and writing table columns.
 * Arithmetic on datasets::      Arithmetic operations on a dataset.
 * Tessellation library::        Functions for working on tiles.
 * Bounding box::                Finding the bounding box.
-* FITS files::                  Working with FITS data.
-* Text files::                  Functions to work on Text files.
 * Git wrappers::                Wrappers for functions in libgit2.
 * Polygons::                    Working with the vertices of a polygon.
 * Qsort functions::             Helper functions for Qsort.
@@ -552,7 +552,7 @@ Data container (@file{data.h})
 * Arrays of datasets::          Functions to help with array of datasets.
 * Copying datasets::            Functions to copy a dataset to a new one.
 
-Linked lists (@file{linkedlist.h})
+Linked lists (@file{list.h})
 
 * List of strings::             Simply linked list of strings.
 * List of int32_t::             Simply linked list of int32_ts.
@@ -566,8 +566,12 @@ Linked lists (@file{linkedlist.h})
 
 FITS files (@file{fits.h})
 
-* FITS macros and data structures::  Gnuastro FITS related macros and 
structures.
-* FITS functions::              Functions to work on FITS data.
+* FITS macros errors filenames::  General macros, errors and checking FITS 
names
+* CFITSIO and Gnuastro types::  Conversion between FITS and Gnuastro types.
+* FITS HDUs::                   Opening and getting information about HDUs.
+* FITS header keywords::        Reading and writing FITS header keywords.
+* FITS arrays::                 Reading and writing FITS images/arrays.
+* FITS tables::                 Reading and writing FITS tables.
 
 Multithreaded programming (@file{threads.h})
 
@@ -10986,8 +10990,8 @@ Statistics program is designed for such situations.
 
 @menu
 * Histogram and Cumulative Frequency Plot::  Basic definitions.
-* Sigma clipping::              Definition of @mymath{\sigma}-clipping
-* Sky value::
+* Sigma clipping::              Definition of @mymath{\sigma}-clipping.
+* Sky value::                   Definition and derivation of the Sky value.
 * Invoking aststatistics::      Arguments and options to Statistics.
 @end menu
 
@@ -16014,8 +16018,8 @@ their fixed values. So when a header specifies macros 
you can do your
 programming without worrying about the actual values.  The standard C types
 (for example @code{int}, or @code{float}) are very low-level and basic. We
 can collect multiple C types into a @emph{structure} for a higher-level way
-to keep and pass-along data. See @ref{FITS macros and data structures} for
-some examples of macros and data structures.
+to keep and pass-along data. See @ref{Generic data container} for some
+examples of macros and data structures.
 
 The contents in the header need to be @emph{include}d into the caller's
 source code with a special pre-processor command: @code{#include
@@ -16555,12 +16559,12 @@ documentation will correspond to your installed 
version.
 * Library blank values::        Blank values and functions to deal with them.
 * Library data container::      General data container in Gnuastro.
 * Linked lists::                Various types of linked lists.
+* FITS files::                  Working with FITS data.
+* Text files::                  Functions to work on Text files.
 * Table input output::          Reading and writing table columns.
 * Arithmetic on datasets::      Arithmetic operations on a dataset.
 * Tessellation library::        Functions for working on tiles.
 * Bounding box::                Finding the bounding box.
-* FITS files::                  Working with FITS data.
-* Text files::                  Functions to work on Text files.
 * Git wrappers::                Wrappers for functions in libgit2.
 * Polygons::                    Working with the vertices of a polygon.
 * Qsort functions::             Helper functions for Qsort.
@@ -17638,8 +17642,8 @@ single-element dataset.
 @end deftypefun
 
 
address@hidden Linked lists, Table input output, Library data container, 
Gnuastro library
address@hidden Linked lists (@file{linkedlist.h})
address@hidden Linked lists, FITS files, Library data container, Gnuastro 
library
address@hidden Linked lists (@file{list.h})
 
 @cindex Array
 @cindex Linked list
@@ -18426,482 +18430,589 @@ Free all the datasets in @code{list} along with all 
the allocated spaces in
 each.
 @end deftypefun
 
address@hidden FITS files, Text files, Linked lists, Gnuastro library
address@hidden FITS files (@file{fits.h})
 
address@hidden Table input output, Arithmetic on datasets, Linked lists, 
Gnuastro library
address@hidden Table input output (@file{table.h})
address@hidden FITS
address@hidden CFITSIO
+The FITS format is the most common format to store data (images and tables)
+in astronomy. The CFITSIO library already provides a very good low-level
+collection of functions for manipulating FITS data. The low-level nature of
+CFITSIO is defined for versatility and portability. As a result, even a
+simple a basic operation, like reading an image or table column into
+memory, will require a special sequence of CFITSIO function calls which can
+be inconvenient and buggy to manage in separate locations. Therefore
+Gnuastro library provides wrappers for CFITSIO functions to make it much
+easier to read/write/modify FITS file data, header keywords and
+extensions. Hence, if you feel these functions don't exactly do what you
+want, we strongly recommend reading the CFITSIO manual to use its great
+features directly.
 
-Functions to read columns from/to tables.
+All the functions and macros introduced in this section are declared in
address@hidden/fits.h}.  When you include this header, you are also
+including CFITSIO's @file{fitsio.h} header. So you don't need to explicitly
+include @file{fitsio.h} anymore and can freely use any of its macros or
+functions in your code along with those discussed here.
 
address@hidden Arithmetic on datasets, Tessellation library, Table input 
output, Gnuastro library
address@hidden Arithmetic on datasets (@file{arithmetic.h})
 
address@hidden Tessellation library, Bounding box, Arithmetic on datasets, 
Gnuastro library
address@hidden Tessellation library (@file{tile.h})
address@hidden
+* FITS macros errors filenames::  General macros, errors and checking FITS 
names
+* CFITSIO and Gnuastro types::  Conversion between FITS and Gnuastro types.
+* FITS HDUs::                   Opening and getting information about HDUs.
+* FITS header keywords::        Reading and writing FITS header keywords.
+* FITS arrays::                 Reading and writing FITS images/arrays.
+* FITS tables::                 Reading and writing FITS tables.
address@hidden menu
 
address@hidden FITS macros errors filenames, CFITSIO and Gnuastro types, FITS 
files, FITS files
address@hidden FITS Macros, errors and filenames
 
address@hidden Bounding box, FITS files, Tessellation library, Gnuastro library
address@hidden Bounding box (@file{box.h})
+Some general constructs provided by Gnuastro's FITS handling functions are
+discussed here. In particular there are several useful functions about FITS
+file names.
 
-Functions related to reporting a the bounding box of certain inputs are
-declared in @file{gnuastro/box.h}. All coordinates in this header are in
-the FITS format (first axis is the horizontal and the second axis is
-vertical).
address@hidden Macro GAL_FITS_MAX_NDIM
+The maximum number of dimensions a dataset can have in FITS format,
+according to the FITS standard this is 999.
address@hidden deffn
 
address@hidden void gal_box_ellipse_in_box (double @code{A}, double @code{B}, 
double @code{theta_rad}, long @code{*width})
-Any ellipse can be enclosed into a rectangular box. The purpose of this
-function is to give the height and width of that box. @code{A} is the
-ellipse major axis, @code{B} is the minor axis, @code{theta_rad} is the
-position angle in radians. The @code{width} array will contain the output
-size in long integer type. @code{width[0]}, and @code{width[1]} are the
-number of pixels along the first and second FITS axis.
address@hidden void gal_fits_io_error (int @code{status}, char @code{*message})
+If @code{status} is non-zero, this function will print the CFITSIO error
+message corresponding to status, print @code{message} (optional) in the
+next line and abort the program. If @code{message==NULL}, it will print a
+default string after the CFITSIO error.
 @end deftypefun
 
address@hidden void gal_box_border_from_center (double @code{xc}, double 
@code{yc}, long @code{*width}, long @code{*fpixel}, long @code{*lpixel})
-Given the center (@code{xc} and @code{yc}) and width (two element array) of a
-box, return the coordinates of the first @code{fpixel} and last @code{lpixel}
-pixels (both are two element arrays.
address@hidden int gal_fits_name_is_fits (char @code{*name})
+If the @code{name} is an acceptable CFITSIO FITS filename return @code{1}
+(one), otherwise return @code{0} (zero). The currently acceptable FITS
+suffixes are @file{.fits}, @file{.fits.gz}, @file{.fits.Z}, @file{.imh},
address@hidden IMH is the IRAF format which is acceptable to CFITSIO.
 @end deftypefun
 
address@hidden int gal_box_overlap (long @code{*naxes}, long @code{*fpixel_i}, 
long @code{*lpixel_i}, long @code{*fpixel_o}, long @code{*lpixel_o})
-We have an image of size @code{naxes} and want to get the overlap of the
-image with a box. This function will return 1 if there is an overlap and 0
-if there isn't. The input and output box are specified by their first and
-last pixels. When there is an overlap, the coordinates of the first and
-last pixels of the overlap will be put in @code{fpixel_o} and
address@hidden
address@hidden int gal_fits_suffix_is_fits (char @code{*suffix})
+Similar to @code{gal_fits_name_is_fits}, but only for the suffix. The
+suffix doesn't have to start with address@hidden': this function will return
address@hidden (one) for both @code{fits} and @code{.fits}.
 @end deftypefun
 
address@hidden FITS files, Text files, Bounding box, Gnuastro library
address@hidden FITS files (@file{fits.h})
address@hidden {char *} gal_fits_name_save_as_string (char @code{*filename}, 
char @code{*hdu})
+If the name is a FITS name, then put a @code{(hdu: ...)} after it and
+return the string. If it isn't a FITS file, just print the name. Note that
+the space is allocated. This function is useful when you want to report a
+random file to the user which may be FITS or not (for a FITS file, simply
+the filename is not enough, the HDU is also necessary).
address@hidden deftypefun
 
address@hidden FITS
address@hidden CFITSIO
-The FITS format is the most common format to store data (images and tables)
-in astronomy. The CFITSIO library already provides a very good low-level
-set of functions for manipulating FITS data. Some CFITSIO operations (with
-well-defined inputs and outputs) are commonly needed in a special
-order. Therefore Gnuastro comes with the macros, data structures and
-functions introduced in this section. These functions are actually wrappers
-around CFITSIO functions for a higher-level (easier) access to FITS
-data. So if you feel these functions don't exactly do what you want, we
-strongly recommend reading the CFITSIO manual to use it directly.
 
-All the functions and macros introduced in this section are declared in
address@hidden/fits.h}.  When you include this header, you are also
-including CFITSIO's @file{fitsio.h} header. So you don't need to explicitly
-include @file{fitsio.h} anymore and can freely use any of its macros or
-functions in your code along with those discussed here. @ref{FITS macros
-and data structures} defines the macros and data structures that can be
-used in functions for a unified format. This subsection finished with
address@hidden functions}, which introduce the different Gnuastro functions
-available.
address@hidden CFITSIO and Gnuastro types, FITS HDUs, FITS macros errors 
filenames, FITS files
address@hidden CFITSIO and Gnuastro types
+
+Both Gnuastro and CFITSIO have special identifiers for each type that they
+accept. Gnuastro's type identifiers are fully described in @ref{Library
+data types} and are usable for all kinds of datasets (images, table columns
+and etc) as part of Gnuastro's @ref{Generic data container}. However,
+following the FITS standard, CFITSIO has different identifiers for images
+and tables. Following CFITSIO's own convention, we will use @code{bitpix}
+for image type identifiers and @code{datatype} for its internal identifiers
+(and mainly used in tables). The functions introduced in this section can
+be used to convert between CFITSIO and Gnuastro's type identifiers.
+
+One important issue to consider is that CFITSIO's types are not fixed width
+(for example @code{long} may be 32-bits or 64-bits on different
+systems). However, Gnuastro's types are defined by their width. These
+functions will use information on the host system to do the proper
+conversion, so it strongly recommended to use these functions for
+portability of your code and not to assume a fixed correspondance between
+CFITSIO and Gnuastro's types.
+
address@hidden uint8_t gal_fits_bitpix_to_type (int @code{bitpix})
+Return the Gnuastro type identifier that corresponds to CFITSIO's
address@hidden on this system.
address@hidden deftypefun
 
address@hidden
-* FITS macros and data structures::  Gnuastro FITS related macros and 
structures.
-* FITS functions::              Functions to work on FITS data.
address@hidden menu
address@hidden int gal_fits_type_to_bitpix (uint8_t @code{type})
+Return the CFITSIO @code{bitpix} value that corresponds to Gnuastro's
address@hidden
address@hidden deftypefun
 
address@hidden char gal_fits_type_to_bin_tform (uint8_t @code{type})
+Return the FITS standard binary table @code{TFORM} character that
+corresponds to Gnuastro's @code{type}.
address@hidden deftypefun
 
address@hidden FITS macros and data structures, FITS functions, FITS files, 
FITS files
address@hidden FITS macros and data structures
-
-To facilitate handling of fixed/standard values and store, or pass multiple
-related variables in your programs, Gnuastro defines the following FITS
-related macros and data structures, see @ref{Headers} for a more detailed
-discussion.
-
address@hidden  Macro GAL_FITS_STRING_BLANK
address@hidden Macro GAL_FITS_BYTE_BLANK
address@hidden Macro GAL_FITS_LOGICAL_BLANK
address@hidden Macro GAL_FITS_SHORT_BLANK
address@hidden Macro GAL_FITS_LONG_BLANK
address@hidden Macro GAL_FITS_LLONG_BLANK
address@hidden Macro GAL_FITS_FLOAT_BLANK
address@hidden Macro GAL_FITS_DOUBLE_BLANK
address@hidden Macro GAL_FITS_INT_BLANK
address@hidden Macro GAL_FITS_SBYTE_BLANK
address@hidden Macro GAL_FITS_UINT_BLANK
address@hidden Macro GAL_FITS_USHORT_BLANK
address@hidden Macro GAL_FITS_ULONG_BLANK
address@hidden Blank pixel
-These macros keep Gnuastro's blank value constant for all the recognized
-datatypes in CFITSIO (see @ref{Blank pixels} for a discussion on blank
-values). The values for the different types are mostly the lowest or
-highest possible value for that type (for unsigned types and 8-bit types,
-the maximum is used). So you can safely ignore the actual value and simply
-use these values to check.
address@hidden int gal_fits_type_to_datatype (uint8_t @code{type})
+Return the CFITSIO @code{datatype} that corresponds to Gnuastro's
address@hidden on this machine.
address@hidden deftypefun
 
address@hidden NaN
address@hidden isnan
address@hidden IEEE NaN
-The @code{float} and @code{double} types use the IEEE NaN values and for
-string it is a @code{NULL} pointer. By definition, a NaN value fails in
-every condition check, so a NaN value is not equal to itself and the check
address@hidden will fail even if the value in
address@hidden is NaN. Therefore, to check for blank values in floating
-point types be careful to use C's @code{isnan} function.
address@hidden deffn
address@hidden uint8_t gal_fits_datatype_to_type (int @code{datatype}, int 
@code{is_table_column})
+Return Gnuastro's type identifier that corresponds to the CFITSIO
address@hidden Note that when dealing with CFITSIO's @code{TLONG}, the
+fixed width type differs between tables and images. So if the corresponding
+dataset is a table column, put a non-zero value into
address@hidden
address@hidden deftypefun
 
address@hidden FITS HDUs, FITS header keywords, CFITSIO and Gnuastro types, 
FITS files
address@hidden FITS HDUs
 
address@hidden Structure gal_fits_key
-Structure for reading FITS header keywords. This structure will keep the
-name and value of one keyword. The value will be stored in the element
-corresponding to the type of the value. When multiple keywords must be
-read, you can define an array of this structure, for example the following
-declaration will allocate an array of five keywords to be read.
+A FITS file can contain multiple HDUs/extensions. The functions in this
+section can be used to get basic information about the extensions or open
+them. Note that @code{fitsfile} is defined in CFITSIO's @code{fitsio.h}
+which is automatically included by Gnuastro's @file{gnuastro/fits.h}.
 
address@hidden
-struct gal_fits_key keys[5];
address@hidden example
address@hidden {fitsfile *} gal_fits_open_to_write (char @code{*filename})
+If @file{filename} exists, open it and return the @code{fitsfile} pointer
+that corresponds to it. If @file{filename} doesn't exist, the file will be
+created which contains a blank first extension and the pointer to its next
+extension will be returned.
address@hidden deftypefun
 
-The names of the keywords can then be stored separately in the array and
-this expression will store the values in each element.
address@hidden size_t gal_fits_hdu_num (char @code{*filename})
+Return the number of HDUs/extensions in @file{filename}.
address@hidden deftypefun
 
address@hidden
-gal_fits_read_keywords("filename.fits", hdu, gal_fits_key, 5);
address@hidden example
address@hidden int gal_fits_hdu_format (char @code{*filename}, char @code{*hdu})
+Return the format of the HDU as one of CFITSIO's recognized macros:
address@hidden, @code{ASCII_TBL}, or @code{BINARY_TBL}.
address@hidden deftypefun
 
-The FITS standard defines a maximum length for the value of keyword, so the
-space for the @code{str} element is statically allocated
-(@code{FLEN_VALUE}, which is defined in CFITSIO). So if the string value is
-necessary where @code{gal_fits_key} is no longer available, then you have
-to allocate space dynamically and copy the string there.
address@hidden deftp
address@hidden {fitsfile *} gal_fits_hdu_open (char @code{*filename}, char 
@code{*hdu}, int @code{iomode})
+Open the HDU/extension @code{hdu} from @file{filename} and return a pointer
+to CFITSIO's @code{fitsfile}. @code{iomode} determines how the FITS file
+will be opened using CFITSIO's macros: @code{READONLY} or @code{READWRITE}.
+
+The string in @code{hdu} will be appended to @file{filename} in square
+brackets so CFITSIO only opens this extension. You can use any formatting
+for the @code{hdu} that is acceptable to CFITSIO. See the description under
address@hidden in @ref{Input output options} for more.
address@hidden deftypefun
+
address@hidden {fitsfile *} gal_fits_hdu_open_format (char @code{*filename}, 
char @code{*hdu}, int @code{img0_tab1})
+Open (in read-only format) the @code{hdu} HDU/extension of @file{filename}
+as an image or table. When @code{img0_tab1} is @code{0}(zero) but the HDU
+is a table, this function will abort with an error. It will also abort with
+an error when @code{img0_tab1} is @code{1} (one), but the HDU is an
+image.
+
+A FITS HDU may contain both tables or images. When your program needs one
+of these formats, you can call this function so if the user provided the
+wrong HDU/file, it will abort and inform the user that the file/HDU is has
+the wrong format.
address@hidden deftypefun
 
address@hidden
-struct gal_fits_key
address@hidden
-  int            status;        /* CFITSIO status.        */
-  char         *keyname;        /* Name of keyword.       */
-  int          datatype;        /* Type of keyword value. */
-  char  str[FLEN_VALUE];        /* String value.          */
-  unsigned char       u;        /* Byte value.            */
-  short               s;        /* Short integer value.   */
-  long                l;        /* Long integer value.    */
-  LONGLONG            L;        /* Long Long value.       */
-  float               f;        /* Float value.           */
-  double              d;        /* Double value.          */
address@hidden;
address@hidden example
 
 
 
address@hidden Structure gal_fits_key_ll
address@hidden FITS header keywords, FITS arrays, FITS HDUs, FITS files
address@hidden FITS header keywords
+
+Each FITS extension/HDU contains a raw dataset which can either be a table
+or an image along with some header keywords. The keywords can be used to
+store meta-data about the actual dataset. The functions in this section
+describe Gnuastro's high-level functions for reading and writing FITS
+keywords. Similar to all Gnuastro's FITS-related functions, these functions
+are all wrappers for CFITSIO's low-level functions.
+
+The necessary meta-data (header keywords) for a particular dataset are
+commonly numerous, it is much more efficient to list them in one variable
+and call the reading/writing functions once. Hence the functions in this
+section use linked lists, a thorough introduction to them is given in
address@hidden lists}. To reading FITS keywords, these functions use a list of
+Gnuastro's generic dataset format that is discussed in @ref{List of
+gal_data_t}. To write FITS keywords we define the
address@hidden node that is defined below.
+
address@hidden {Type (C @code{struct})} gal_fits_list_key_t
 @cindex Linked list
 @cindex last-in-first-out
 @cindex first-in-first-out
-Structure for writing FITS keywords. This structure is used for one
-keyword. However, with the @code{next} element, it can link to another
-keyword thus creating a linked list to add any number of keywords easily
-and at any step during your program. Adding new keywords doesn't have to be
-done manually, the @code{gal_fits_add_to_key_ll} and
address@hidden will add new keywords for you to the
-start or end of the list to make a last-in-first-out or first-in-last-out
-list. See @ref{Linked lists} for more on the nature of linked lists and
-more similar structures.
address@hidden deftp
+Structure for writing FITS keywords. This structure is used for one keyword
+and you don't need to set all elements. With the @code{next} element, you
+can link it to another keyword thus creating a linked list to add any
+number of keywords easily and at any step during your program (see
address@hidden lists} for an introduction on lists). See the functions below
+for adding elements to the list.
 
 @example
-struct gal_fits_key_ll
+typedef struct gal_fits_list_key_t
 @{
-  int                    kfree;   /* ==1, free keyword name.   */
-  int                    vfree;   /* ==1, free keyword value.  */
-  int                    cfree;   /* ==1, free comment.        */
-  int                 datatype;   /* Keyword value datatype.   */
-  char                *keyname;   /* Keyword Name.             */
-  void                  *value;   /* Keyword value.            */
-  char                *comment;   /* Keyword comment.          */
-  char                   *unit;   /* Keyword unit.             */
-  struct gal_fits_key_ll *next;   /* Pointer next keyword.     */
address@hidden;
+  int                        kfree;   /* ==1, free name.      */
+  int                        vfree;   /* ==1, free value.     */
+  int                        cfree;   /* ==1, free comment.   */
+  uint8_t                     type;   /* Keyword value type.  */
+  char                    *keyname;   /* Keyword Name.        */
+  void                      *value;   /* Keyword value.       */
+  char                    *comment;   /* Keyword comment.     */
+  char                       *unit;   /* Keyword unit.        */
+  struct gal_fits_list_key_t *next;   /* Next keyword.        */
address@hidden gal_fits_list_key_t;
address@hidden example
address@hidden deftp
+
address@hidden void gal_fits_key_clean_str_value (char @code{*string})
+Remove the sigle quotes and possible extra spaces around the keyword values
+that CFITSIO returns when reading a string keyword. CFITSIO doesn't remove
+the two single quotes around the string value of a keyword. Hence the
+strings it reads are like: @code{'value '}, or
address@hidden'some_very_long_value'}. To use the value during your processing, 
it
+is commonly necessary to remove the single quotes (and possible extra
+spaces). This function will do this within the allocated space of the
+string.
address@hidden deftypefun
+
address@hidden void gal_fits_key_read_from_ptr (fitsfile @code{*fptr}, 
gal_data_t @code{*keysll}, int @code{readcomment}, int @code{readunit})
+
+Read the list of keyword values from a FITS pointer. The input should be a
+linked list of Gnuastro's generic data container
+(@code{gal_data_t}). Before calling this function, you just have to set the
address@hidden and desired @code{type} values of each node in the list to the
+keyword you want it to keep the value of. The given @code{name} value will
+be directly passed to CFITSIO to read the desired keyword name. This
+function will allocate space to keep the value. If @code{readcomment} and
address@hidden are non-zero, this function will also try to read the
+possible comments and units of the keyword.
+
+Here is one example of using this function:
+
address@hidden
+/* Allocate an array of datasets. */
+gal_data_t *keysll=gal_data_array_calloc(N);
+
+/* Use the array as a list.*/
+for(i=0;i<N-2;++i) keysll[i].next=keysll[i+1];
+
+/* Fill the datasets with a `name' and a `type'. */
+keysll[0].name="NAME1";     keysll[0].type=GAL_TYPE_INT32;
+keysll[1].name="NAME2";     keysll[1].type=GAL_TYPE_STRING;
+...
+...
+
+/* Call this function. */
+gal_fits_key_read_from_ptr(fptr, keysll, 0, 0);
+
+/* Use the values as you like... */
+
+/* Free all the allocated spaces. */
+gal_data_array_free(keysll, N, 1);
 @end example
 
+If the @code{array} pointer of each keyword's dataset is not @code{NULL},
+then it is assumed that the space to keep the value has already been
+allocated. If it is @code{NULL}, space will be allocated for the value by
+this function.
 
+Strings need special consideration: the reason is that generally,
address@hidden needs to also allow for array of strings (as it supports
+arrays of integers for example). Hence when reading a string value, two
+allocations may be done by this function (one if
address@hidden).
 
address@hidden FITS functions,  , FITS macros and data structures, FITS files
address@hidden FITS functions
+Therefore, when using the values of strings after this function,
address@hidden must be interpretted as @code{char **}: one
+allocation for the pointer, one for the actual characters. If you use
+something like the example, above you don't have to worry about the
+freeing, @code{gal_data_array_free} will free both allocations. So to read
+a string, one easy way would be the following:
 
-Gnuastro provides the following functions to deal with FITS data related
-operations. FITS data can have a variety of types, in particular the
-integer variables named @code{datatype}, @code{bitpix}, and
address@hidden See @ref{FITS macros and data structures} for the structure
-and macro definitions.
address@hidden
+char *str, **strarray;
+strarr = keysll[i].array;
+str    = strarray[0];
address@hidden example
 
address@hidden void gal_fits_io_error (int @code{status}, char @code{*message})
-Report the input or output error as a string and print it along with a
-short statement that an error in CFITSIO occurred. All CFITSIO functions
-will change the value of @code{status} if an error occurs. This function
-will print the CFITSIO error string from the value of @code{status}
-followed by an optional @code{message} that you can add to it. If the value
-of @code{message} is @code{NULL}, then a default message will be printed.
address@hidden deftypefun
+If CFITSIO is unable to read a keyword for any reason the @code{status}
+element of the respective @code{gal_data_t} will be non-zero. If it is
+zero, then the keyword was found and succesfully read. Otherwise, it is a
+CFITSIO status value. You can use CFITSIO's error reporting tools or
address@hidden (see @ref{FITS macros errors filenames}) for
+reporting the reason of the failure. A tip: when the keyword doesn't exist,
+CFITSIO's status value will be @code{KEY_NO_EXIST}.
 
address@hidden int gal_fits_name_is_fits (char @code{*name})
-Return @code{1} if the string pointed by @code{name} is a standard FITS
-filename (or more generally: can be read by CFITSIO) and @code{0} if it
-isn't. See @ref{Arguments} for the standard FITS filenames.
address@hidden deftypefun
+CFITSIO will start searching for the keywords from the last place in the
+header that it searched for a keyword. So it is much more efficient if the
+order that you ask for keywords is based on the order they are stored in
+the header.
 
address@hidden int gal_fits_suffix_is_fits (char @code{*suffix})
-Return @code{1} if the string pointed by @code{suffix} is a standard FITS
-suffix (or more generally: can be read by CFITSIO) and @code{0} if it
-isn't. @code{suffix} can contain a dot or not (for example both
address@hidden and @file{fits} will return @code{1}. See @ref{Arguments} for
-the standard FITS filenames.
 @end deftypefun
 
address@hidden int gal_fits_bitpix_to_datatype (int @code{bitpix})
-Return the datatype corresponding to the given @code{bitpix} (value to the
address@hidden header keyword) in a FITS image.
address@hidden deftypefun
 
address@hidden int gal_fits_tform_to_datatype (char @code{tform})
-Return the datatype corresponding to the given @code{tform} character of a
-FITS table column: value to the @code{TFORM} header keyword for the
-column. Note that in the FITS standard, @code{TFORM} values are characters.
address@hidden void gal_fits_key_read (char @code{*filename}, char @code{*hdu}, 
gal_data_t @code{*keysll}, int @code{readcomment}, int @code{readunit})
+Same as @code{gal_fits_read_keywords_fptr} (see above), but accepts the
+filename and HDU as input instead of an already opened CFITSIO
address@hidden pointer.
 @end deftypefun
 
address@hidden void gal_fits_img_bitpix_size (fitsfile @code{*fptr}, int 
@code{*bitpix}, long @code{*naxes})
-Return the datatype (in FITS @code{BITPIX} format) and image size of a FITS
-HDU specified with the @code{fitsfile} pointer (defined in CFITSIO). So the
-HDU must have been already opened. If the number of dimensions is not 2,
-this function will return an error and abort.
address@hidden deftypefun
 
address@hidden {void *} gal_fits_datatype_blank (int @code{datatype})
-Allocate the necessary space and put the blank value of type
address@hidden in it. Finally, return the pointer to the allocated
-space.
address@hidden deftypefun
address@hidden void gal_fits_key_list_add (gal_fits_list_key_t @code{**list}, 
uint8_t @code{type}, char @code{*keyname}, int @code{kfree}, void 
@code{*value}, int @code{vfree}, char @code{*comment}, int @code{cfree}, char 
@code{*unit})
+Add on keyword to the top of list of header keywords that need to be
+written into a FITS file. In the end, the keywords will have to be freed,
+so it is important to know before hand if they were allocated or not (hence
+the presence of the arguments ending in @code{free}). If the space for the
+respective element is not allocated, set these arguments to @code{0}
+(zero).
 
address@hidden {void *} gal_fits_datatype_alloc (size_t @code{size}, int 
@code{datatype})
-Allocate an array of @code{size} elements of type @code{datatype}.
address@hidden note for strings}: the value should be the pointer to the
+string its-self (@code{char *}), not a pointer to a pointer (@code{char **}).
 @end deftypefun
 
address@hidden size_t gal_fits_datatype_size (int @code{datatype})
-Return the size (in bytes) of the type specified by @code{datatype}.
address@hidden void gal_fits_key_list_add_end (gal_fits_list_key_t 
@code{**list}, uint8_t @code{type}, char @code{*keyname}, int @code{kfree}, 
void @code{*value}, int @code{vfree}, char @code{*comment}, int @code{cfree}, 
char @code{*unit})
+Similar to @code{gal_fits_key_list_add} (see above) but add the keyword to
+the end of the list. Use this function if you want the keywords to be
+written in the same order that you add nodes to the list of keywords.
 @end deftypefun
 
address@hidden void gal_fits_blank_to_value (void @code{*array}, int 
@code{datatype}, size_t @code{size}, void @code{*value})
-Convert the blank values in @code{array} (with @code{size} elements) into
-the value pointed by @code{value}.
address@hidden void gal_fits_key_write_filename (char @code{*keynamebase}, char 
@code{*filename}, gal_fits_list_key_t @code{**list})
+Put @file{filename} into the @code{gal_fits_list_key_t} list (possibly
+broken up into multiple keywords) to later write into a HDU header. The
address@hidden string will be appended with a @code{_N} (N>0) and used
+as the keyword name.
+
+The FITS standard sets a maximum length for the value of a keyword. This
+creates problems with file names (which include directories). Because file
+names/addresses can become very long. Therefore, when @code{filename} is
+longer than the maximum length of a FITS keyword value, this function will
+break it into several keywords (breaking up the string on directory
+separators).
 @end deftypefun
 
address@hidden void gal_fits_change_type (void @code{*in}, int @code{inbitpix}, 
size_t @code{size}, int @code{anyblank}, void @code{**out}, int 
@code{outbitpix})
-Convert the @code{in} array (with @code{inbitpix} type) into an array of
-type @code{outbitpix} that is pointed by @code{out}. Space will be
-allocated for the output array within this function.
address@hidden void gal_fits_key_write_wcsstr (fitsfile @code{*fptr}, char 
@code{*wcsstr}, int @code{nkeyrec})
+Write the WCS header string (produced with WCSLIB's @code{wcshdo} function)
+into the CFITSIO @code{fitsfile} pointer. @code{nkeyrec} is the number of
+FITS header keywords in @code{wcsstr}. This function will put a few blank
+keyword lines along with a comment @code{WCS information} before writing
+each keyword record.
 @end deftypefun
 
address@hidden void gal_fits_num_hdus (char @file{*filename}, int 
@code{*numhdu})
-Find the number of HDUs in @file{filename} and store it in the space
-pointed to by @code{numhdu}.
address@hidden void gal_fits_key_write (fitsfile @code{*fptr}, 
gal_fits_list_key_t @code{**keylist})
+Write the list of keywords in @code{keylist} into the CFITSIO
address@hidden
 @end deftypefun
 
address@hidden void gal_fits_read_hdu (char @code{*filename}, char @code{*hdu}, 
unsigned char @code{img0_tab1}, fitsfile @code{**outfptr})
-Open the HDU @code{hdu} (a string) of the @file{filename} FITS file into
-the @code{outfptr}. See @option{--hdu} option in @ref{Input output options}
-for the accepted HDU formats.
address@hidden void gal_fits_key_write_version (fitsfile @code{*fptr}, 
gal_fits_list_key_t @code{*headers}, char @code{*program_name})
+Write or update (all the) keyword(s) in @code{headers} into the FITS
+pointer, but also the date, name of your program (@code{program_name}),
+along with the versions of CFITSIO, WCSLIB (when available), GSL, Gnuastro,
+and (the possible) commit information into the header as described in
address@hidden headers}.
+
+Since the data processing depends on the versions of the libraries you have
+used, it is strongly recommended to include this information in every FITS
+output. @code{gal_fits_img_write} and @code{gal_fits_tab_write} will
+automatically use this function.
 @end deftypefun
 
address@hidden void gal_fits_read_keywords (char @code{*filename}, char 
@code{*hdu}, struct gal_fits_key @code{*keys}, size_t @code{num})
-Read @code{num} keywords (identified in the @code{keys} array) in the
address@hidden HDU of @file{filename}. See @ref{FITS macros and data
-structures} for the definition of @code{gal_fits_key} and its recommended
-usage with this function.
 
-CFITSIO will look for the next keyword starting from the last keyword
-found. Therefore, it is most efficient to specify the keywords in the same
-order as they appear in the desired HDU.
address@hidden deftypefun
address@hidden FITS arrays, FITS tables, FITS header keywords, FITS files
address@hidden FITS arrays (images)
 
address@hidden void gal_fits_add_to_key_ll (struct gal_fits_key_ll 
@code{**list}, int @code{datatype}, char @code{*keyname}, int @code{kfree}, 
void @code{*value}, int @code{vfree}, char @code{*comment}, int @code{cfree}, 
char @code{*unit})
-Add an element to the top of the @code{gal_fits_key_ll} linked list for
-writing keywords. This structure (or linked list) is used to write FITS
-keywords and is fully described in @ref{FITS macros and data
-structures}. Each variable also has the same name as the structure element
-that is described there.
+Images (or multi-dimensional arrays in general) are one of the common data
+formats that is stored in FITS files. Only one image may be stored in each
+FITS HDU/extension. The functions described here can be used to get the
+information of, read, or write images in FITS files.
 
address@hidden last-in-first-out
-Assuming all the keywords were added with this function, you will have a
-last-in-first-out list: as the the name suggests, the last keyword you add
-to the list will be the first one that gets popped out and thus written in
-the FITS file header.
address@hidden void gal_fits_img_info (fitsfile @code{*fptr}, int @code{*type}, 
size_t @code{*ndim}, size_t @code{**dsize})
+Read the type (see @ref{Library data types}), number of dimensions, and
+size of the array along each dimension of the CFITSIO @code{fitsfile} into
+the @code{type}, @code{ndim}, and @code{dsize} pointers respectively.
 @end deftypefun
 
address@hidden void gal_fits_add_to_key_ll_end (struct gal_fits_key_ll 
@code{**list}, int @code{datatype}, char @code{*keyname}, int @code{kfree}, 
void @code{*value}, int @code{vfree}, char @code{*comment}, int @code{cfree}, 
char @code{*unit})
address@hidden first-in-first-out
-Similar to @code{gal_fits_add_to_key_ll}, except the keyword is added to
-the end of the list, creating a first-in-first-out list. Therefore the
-order the keywords are written to the FITS header is the same as the order
-you have called this function.
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
+don't keep the data in RAM, but in a file on the HDD/SSD. For more on
address@hidden see the description under the same name in @ref{Generic
+data container}.
 @end deftypefun
 
address@hidden void gal_fits_file_name_in_keywords (char @code{*keynamebase}, 
char @code{*filename}, struct gal_fits_key_ll @code{**list})
-Put a filename into the @code{gal_fits_key_ll} list to later write into a
-HDU header. The FITS standard sets a maximum length for the value of a
-keyword. This creates problems with file names (including directories),
-because they can become very long. Therefore, when the filename is longer
-than the maximum length of a FITS keyword value, this function will break
-it into several keywords. The @code{keynamebase} string will be appended
-with a @code{_N} (N>0) and used as the keyword name.
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
address@hidden 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).
 @end deftypefun
 
address@hidden void gal_fits_add_wcs_to_header (fitsfile @code{*fptr}, char 
@code{*wcsheader}, int @code{nkeyrec})
-Add the WCS information into the header of the HDU pointed to by
address@hidden The WCS information must already be converted into a long
-string with the FITS conventions. To help in identifying the WCS
-information, a few blank lines and a title will be added on top.
address@hidden NaN
address@hidden Convolution kernel
address@hidden Kernel, convolution
address@hidden {gal_data_t *} gal_fits_img_read_kernel (char @code{*filename}, 
char @code{*hdu}, size_t @code{minmapsize})
+Read the @code{hdu} of @code{filename} as a convolution kernel. A
+convolution kernel must have an odd size along all dimensions, it must not
+have blank (NaN in floating point types) values and must be flipped around
+the center to make the proper convolution (see @ref{Convolution
+process}). If there are blank values, this function will change the blank
+values to @code{0.0}. If the input image doesn't have the other two
+requirements, this function will abort with an error describing the
+condition to the user. The finally returned dataset will have a
address@hidden type.
 @end deftypefun
 
address@hidden void gal_fits_update_keys (fitsfile @code{*fptr}, struct 
gal_fits_key_ll @code{**keylist})
-Given the an opened FITS HDU (pointed to by @code{fptr}), this function
-will write, or update, all the keywords given in @code{keylist}. See
address@hidden macros and data structures} for more information on the
address@hidden structure or linked list.
address@hidden {fitsfile *} gal_fits_img_write_to_ptr (gal_data_t 
@code{*input}, char @code{*filename})
+Write the @code{input} dataset into a FITS file named @file{filename} and
+return the corresponding CFITSIO @code{fitsfile} pointer. This function
+won't close @code{fitsfile}, so you can still add other extensions to it
+after this function or make other modifications.
 @end deftypefun
 
address@hidden void gal_fits_write_keys_version (fitsfile @code{*fptr}, struct 
gal_fits_key_ll @code{*headers}, char @code{*spack_string})
-Write or update (all the) keyword(s) in @code{headers} into the FITS
-pointer, but also the date, name of your program (@code{spack_string}),
-along with the versions of Gnuastro, CFITSIO, WCSLIB (when available) into
-the header, see @ref{Output headers}.  Since the data processing depends on
-the versions of the libraries you have used, it is strongly recommended to
-include this information in every FITS output. See @ref{FITS macros and
-data structures} for more information on the @code{gal_fits_key_ll}
-structure or linked list.
address@hidden void gal_fits_img_write (gal_data_t @code{*data}, char 
@code{*filename}, gal_fits_list_key_t @code{*headers}, char 
@code{*program_string})
+Write the @code{input} dataset into the FITS file named @file{filename}.
+Also add the @code{headers} keywords to the newly created HDU/extension it
+along with your program's name (@code{program_string}).
 @end deftypefun
 
address@hidden void gal_fits_read_wcs_from_pointer (fitsfile @code{*fptr}, int 
@code{*nwcs}, struct wcsprm @code{**wcs}, size_t @code{hstartwcs}, size_t 
@code{hendwcs})
-Read the WCSLIB WCS structure (@code{wcs}, and @code{nwcs} the number of WCS
-structures) from the FITS pointer @code{fptr}. In some cases, it might be
-necessary to only consider header keywords between a certain range. You can
-define the range of keywords to look for WCS information with the
address@hidden and @code{hendwcs} arguments. The range of header keywords
-will only be considered when the value of @code{hstartwcs} is less than
address@hidden, so if you don't want to limit the range, set both values to
-0. After you have finished using the WCS structure, use
address@hidden(&nwcs,&wcs);} to free it.
address@hidden void gal_fits_img_write_to_type (gal_data_t @code{*data}, char 
@code{*filename}, gal_fits_list_key_t @code{*headers}, char 
@code{*program_string}, int @code{type})
+Convert the @code{input} dataset into @code{type}, then write it into the
+FITS file named @file{filename}. Also add the @code{headers} keywords to
+the newly created HDU/extension along with your program's name
+(@code{program_string}). After the FITS file is written, this function will
+free the copied dataset (with type @code{type}) from memory.
 
address@hidden
address@hidden
address@hidden WCSLIB
address@hidden Thread-saftey
address@hidden is not thread-safe: } WCSLIB's @code{wcspih} function is
-used by to read the FITS keywords into WCSLIB's internal WCS
-structures. Unfortunately this function is not thread-safe. Therefore, be
-sure to call that function (or Gnuastro's
address@hidden and @code{gal_fits_read_wcs}) before
-spinning off threads, see @ref{Multithreaded programming}.
address@hidden cartouche
+This is just a wrapper for the @code{gal_data_copy_to_new_type} and
address@hidden functions.
 @end deftypefun
 
address@hidden void gal_fits_read_wcs (char @code{*filename}, char @code{*hdu}, 
size_t @code{hstartwcs}, size_t @code{hendwcs}, int @code{*nwcs}, struct wcsprm 
@code{**wcs})
-Read the WCSLIB WCS structure (@code{wcs} and @code{nwcs} the number of WCS
-structures) from a FITS file (@code{hdu} in @code{filename}). This is
-basically just a wrapper around the @code{gal_fits_read_wcs_from_pointer}
-function, see that function for more.
address@hidden deftypefun
address@hidden void gal_fits_img_write_corr_wcs_str (gal_data_t @code{*data}, 
char @code{*filename}, char @code{*wcsstr}, int @code{nkeyrec}, double 
@code{*crpix}, gal_fits_list_key_t @code{*headers}, char @code{*program_string})
+Write the @code{input} dataset into @file{filename} using the @code{wcsstr}
+while correcting the @code{CRPIX} values.
 
address@hidden int gal_fits_hdu_to_array (char @code{*filename}, char 
@code{*hdu}, int @code{*bitpix}, void @code{**array}, size_t @code{*s0}, size_t 
@code{*s1})
-Read the FITS image (in the @code{hdu} extension of @code{filename}). The
-image array will be stored in @code{array} and the number of pixels in the
-first and second C axis will be stored in @code{s0} and @code{s1}. The type
-of the array will be kept in @code{bitpix}. See @option{--hdu} in
address@hidden output options} for the acceptable formats of @code{hdu}.
address@hidden deftypefun
+This function is mainly useful when you want to make FITS files in parallel
+(from one main WCS structure, with just differing CRPIX). This can happen
+in the following cases for example:
 
address@hidden void gal_fits_array_to_file (char @code{*filename}, char 
@code{*extname}, int @code{bitpix}, void @code{*array}, size_t @code{s0}, 
size_t @code{s1}, int @code{anyblank}, struct wcsprm @code{*wcs}, struct 
gal_fits_key_ll @code{*headers}, char @code{*spack_string})
-Write the array @code{array} (with sizes @code{s0} and @code{s1}, type
address@hidden, and WCS structure @code{wcs}) into the FITS file
address@hidden and extension name @code{extname}. If the array has any
-blank pixels, then you can set @code{anyblank} to 1. All the headers in
address@hidden will also be written to this extension and
address@hidden is the name of your program (which can include a
-version number), which will be written in the output header.
address@hidden deftypefun
address@hidden
address@hidden
+When a large number of FITS images (with WCS) need to be created in
+parallel, it can be much more efficient to write the header's WCS keywords
+once at first, write them in the FITS file, then just correct the CRPIX
+values.
 
address@hidden void gal_fits_atof_correct_wcs (char @code{*filename}, char 
@code{*hdu}, int @code{bitpix}, void @code{*array}, size_t @code{s0}, size_t 
@code{s1}, char @code{*wcsheader}, int @code{wcsnkeyrec}, double @code{*crpix}, 
char @code{*spack_string})
-This is essentially the same as @code{gal_fits_array_to_file}, but through
-the two element @code{crpix} array, you can change the final @code{CRPIX}
-keywords that will be written in the FITS file.
address@hidden
+WCSLIB's header writing function is not thread safe. So when writing FITS
+images in parallel, we can't write the header keywords in each thread.
address@hidden itemize
 @end deftypefun
 
address@hidden void gal_fits_table_size (fitsfile @code{*fitsptr}, size_t 
@code{*nrows}, size_t @code{*ncols})
-Get the number of rows (@code{nrows}) and columns (@code{ncols}) in a FITS
-table within the @code{fitsptr}.
+
address@hidden FITS tables,  , FITS arrays, FITS files
address@hidden FITS tables
+
+Tables are one of the common formats of data that is stored in FITS
+files. Only one table may be stored in each FITS HDU/extension, but each
+table column must be viewed as a different dataset (with its own name,
+units and numeric data type for example). The only constraint of the column
+datasets in a table is that they must be one-dimensional and have the same
+number of elements as the other columns. The functions described here can
+be used to get the information of, read, or write columns into FITS tables.
+
address@hidden void gal_fits_tab_size (fitsfile @code{*fitsptr}, size_t 
@code{*nrows}, size_t @code{*ncols})
+Read the number of rows and columns in the table within CFITSIO's
address@hidden
 @end deftypefun
 
address@hidden int gal_fits_table_type (fitsfile @code{*fptr})
-Return the type of the table: @code{ASCII_TBL} and @code{BINARY_TBL} for an
-ASCII or binary table. These two macros are defined by CFITSIO.
address@hidden int gal_fits_tab_format (fitsfile @code{*fitsptr})
+Return the format of the FITS table contained in CFITSIO's
address@hidden Recall that FITS tables can be in binary or ASCII
+formats. This function will return @code{GAL_TABLE_FORMAT_AFITS} or
address@hidden (defined in @ref{Table input output}). If the
address@hidden is not a table, this function will abort the program with an
+error message informing the user of the problem.
 @end deftypefun
 
address@hidden void gal_fits_file_or_ext_name (char @code{*inputname}, char 
@code{*inhdu}, int @code{othernameset}, char @code{**othername}, char 
@code{*ohdu}, int @code{ohduset}, char @code{*type})
-This is mainly a function used in Gnuastro programs. Since a FITS image
-can have many extensions, usually related data are stored within one FITS
-file. For example an image, its masked pixels, and the sky standard
-deviation of the noise are various extensions of one FITS file. It would be
-very inconvenient if the same file name would have to be repeated in a call
-to a program for all images that are within one file.
-
-To easily manage things, within Gnuastro, each input variable also has an
-integer variable with the same name, but suffixed with @code{set}. The job
-of this function is to use the name of the main input image and based on
-the other arguments, determine what filename should be used for each
-type. The final argument (@code{type}) is the type of input you want, for
-example, if you were expecting a mask image, you can give the value
address@hidden"mask"} as type. @code{type} is just used to report errors.
address@hidden {gal_data_t *} gal_fits_tab_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 @code{hdu} of @code{filename} into
+an array of data structures with @code{numcols} elements (one data
+structure for each column), see @ref{Arrays of datasets}. The number of
+rows is stored as the @code{size} element of each data structure. The
+format of the table (e.g., FITS binary or ASCII table) will be put in
address@hidden (macros defined in @ref{Table input output}).
+
+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 @code{array} or @code{dsize}
+elements). This function is just for column information.
 @end deftypefun
 
address@hidden void gal_fits_file_to_float (char @code{*inputname}, char 
@code{*maskname}, char @code{*inhdu}, char @code{*mhdu}, float @code{**img}, 
int @code{*inbitpix}, int @code{*anyblank}, size_t @code{*ins0}, size_t 
@code{*ins1})
-Read a FITS image HDU (@code{inhdu} in @file{inputname}) as a @code{float}
-type array. An optional mask image and mask hdu can also be given. Single
-precision floating point types are one of the most common types to store
-data: the observation noise is usually much larger than the extra precision
-(and thus volume in your computer, and slower processing) offered by double
-precision floating point types. With this function, so when you work
-internally with floating points, you can use this function to directly read
-a FITS image array into a floating point array.
address@hidden {gal_data_t *} gal_fits_tab_read (char @code{*filename}, char 
@code{*hdu}, size_t @code{numrows}, gal_data_t @code{*colinfo}, 
gal_list_sizet_t @code{*indexll}, int @code{minmapsize})
+Read the columns given in the list @code{indexll} from a FITS table into a
+linked list of data structures, see @ref{List of size_t} and @ref{List of
+gal_data_t}. If the necessary space for each column is larger than
address@hidden, don't keep it in the RAM, but in a file on memory, see
+the description under the same name in @ref{Generic data container}.
+
+Note that this is a low-level function, so the output data linked list is
+the inverse of the input indexs linked list. It is recommended to use
address@hidden for generic reading of tables, see @ref{Table input
+output}.
 @end deftypefun
 
address@hidden void gal_fits_file_to_double (char @code{*inputname}, char 
@code{*maskname}, char @code{*inhdu}, char @code{*mhdu}, double @code{**img}, 
int @code{*inbitpix}, int @code{*anyblank}, size_t @code{*ins0}, size_t 
@code{*ins1})
-Similar to @code{gal_fits_file_to_float}, but for double precision floating
-point type. In some contexts, the internal operations must be done in
-double precision floating point types, irrespective of the input type and
-this function can be used to directly read a file into an array of this
-type.
address@hidden void gal_fits_tab_write (gal_data_t @code{*cols}, gal_list_str_t 
@code{*comments}, int @code{tableformat}, char @code{*filename}, int 
@code{dontdelete})
+Write the list of datasets in @code{cols} (see @ref{List of gal_data_t}) as
+separate columns in a FITS table in @code{filename}. If @code{filename}
+already exists and @code{dontdelete} is non-zero, then this function will
+abort with an error and will not write over the existing file. The format
+of the table (ASCII or binary) may be specified with the @code{tableformat}
+(see @ref{Table input output}). If @code{comments!=NULL}, each node of the
+list of strings will be written as a @code{COMMENT} keywords in the output
+FITS file (see @ref{List of strings}.
 @end deftypefun
 
address@hidden void gal_fits_file_to_long (char @code{*inputname}, char 
@code{*inhdu}, long @code{**img}, int @code{*inbitpix}, int @code{*anyblank}, 
size_t @code{*ins0}, size_t @code{*ins1})
address@hidden Labeled image
address@hidden Segmentation map
-Similar to @code{gal_fits_file_to_float}, but will read the image specified
-by @file{inputname} (@code{inhdu}) into a long integer type. Long integer
-types are commonly used to store things like segmentation maps or labeled
-images.
+
address@hidden Text files, Table input output, FITS files, Gnuastro library
address@hidden Text files (@file{txt.h})
+
address@hidden Table input output, Arithmetic on datasets, Text files, Gnuastro 
library
address@hidden Table input output (@file{table.h})
+
+Functions to read columns from/to tables.
+
address@hidden Arithmetic on datasets, Tessellation library, Table input 
output, Gnuastro library
address@hidden Arithmetic on datasets (@file{arithmetic.h})
+
address@hidden Tessellation library, Bounding box, Arithmetic on datasets, 
Gnuastro library
address@hidden Tessellation library (@file{tile.h})
+
+
address@hidden Bounding box, Git wrappers, Tessellation library, Gnuastro 
library
address@hidden Bounding box (@file{box.h})
+
+Functions related to reporting a the bounding box of certain inputs are
+declared in @file{gnuastro/box.h}. All coordinates in this header are in
+the FITS format (first axis is the horizontal and the second axis is
+vertical).
+
address@hidden void gal_box_ellipse_in_box (double @code{A}, double @code{B}, 
double @code{theta_rad}, long @code{*width})
+Any ellipse can be enclosed into a rectangular box. The purpose of this
+function is to give the height and width of that box. @code{A} is the
+ellipse major axis, @code{B} is the minor axis, @code{theta_rad} is the
+position angle in radians. The @code{width} array will contain the output
+size in long integer type. @code{width[0]}, and @code{width[1]} are the
+number of pixels along the first and second FITS axis.
 @end deftypefun
 
address@hidden void gal_fits_prep_float_kernel (char @code{*inputname}, char 
@code{*inhdu}, float @code{**outkernel}, size_t @code{*ins0}, size_t 
@code{*ins1})
address@hidden Convolution kernel
address@hidden Kernel: convolution
-Read @file{inputname} (@code{inhdu}) will be read as a floating point array
-to be used as a convolution kernel. Convolution kernels are commonly
-necessary in astronomical image processing, but they need to have certain
-properties: their dimensions have to be an odd number and they must not
-have any blank pixels. In both cases, this function will abort with an
-error notice.
address@hidden void gal_box_border_from_center (double @code{xc}, double 
@code{yc}, long @code{*width}, long @code{*fpixel}, long @code{*lpixel})
+Given the center (@code{xc} and @code{yc}) and width (two element array) of a
+box, return the coordinates of the first @code{fpixel} and last @code{lpixel}
+pixels (both are two element arrays.
 @end deftypefun
 
address@hidden@deftypefun
address@hidden@end deftypefun
address@hidden int gal_box_overlap (long @code{*naxes}, long @code{*fpixel_i}, 
long @code{*lpixel_i}, long @code{*fpixel_o}, long @code{*lpixel_o})
+We have an image of size @code{naxes} and want to get the overlap of the
+image with a box. This function will return 1 if there is an overlap and 0
+if there isn't. The input and output box are specified by their first and
+last pixels. When there is an overlap, the coordinates of the first and
+last pixels of the overlap will be put in @code{fpixel_o} and
address@hidden
address@hidden deftypefun
 
 
address@hidden Text files, Git wrappers, FITS files, Gnuastro library
address@hidden Text files (@file{txt.h})
 
 
address@hidden Git wrappers, Polygons, Text files, Gnuastro library
address@hidden Git wrappers, Polygons, Bounding box, Gnuastro library
 @subsection Git wrappers (@file{git.h})
 
 @cindex Git
diff --git a/lib/fits.c b/lib/fits.c
index bdaac68..87adddf 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -171,7 +171,7 @@ gal_fits_name_save_as_string(char *filename, char *hdu)
 /*************************************************************
  **************           Type codes           ***************
  *************************************************************/
-int
+uint8_t
 gal_fits_bitpix_to_type(int bitpix)
 {
   switch(bitpix)
@@ -355,7 +355,7 @@ gal_fits_type_to_datatype(uint8_t type)
 
 
 
-int
+uint8_t
 gal_fits_datatype_to_type(int datatype, int is_table_column)
 {
   int inttype;
@@ -375,44 +375,44 @@ gal_fits_datatype_to_type(int datatype, int 
is_table_column)
     case TUSHORT:
       switch( sizeof(short) )
         {
-        case 2:           return GAL_TYPE_UINT16; break;
-        case 4:           return GAL_TYPE_UINT32; break;
-        case 8:           return GAL_TYPE_UINT64; break;
+        case 2:           return GAL_TYPE_UINT16;
+        case 4:           return GAL_TYPE_UINT32;
+        case 8:           return GAL_TYPE_UINT64;
         }
       break;
 
     case TSHORT:
       switch( sizeof(short) )
         {
-        case 2:           return GAL_TYPE_INT16;  break;
-        case 4:           return GAL_TYPE_INT32;  break;
-        case 8:           return GAL_TYPE_INT64;  break;
+        case 2:           return GAL_TYPE_INT16;
+        case 4:           return GAL_TYPE_INT32;
+        case 8:           return GAL_TYPE_INT64;
         }
       break;
 
     case TUINT:
       switch( sizeof(int) )
         {
-        case 2:           return GAL_TYPE_UINT16; break;
-        case 4:           return GAL_TYPE_UINT32; break;
-        case 8:           return GAL_TYPE_UINT64; break;
+        case 2:           return GAL_TYPE_UINT16;
+        case 4:           return GAL_TYPE_UINT32;
+        case 8:           return GAL_TYPE_UINT64;
         }
       break;
 
     case TINT:
       switch( sizeof(int) )
         {
-        case 2:           return GAL_TYPE_INT16;  break;
-        case 4:           return GAL_TYPE_INT32;  break;
-        case 8:           return GAL_TYPE_INT64;  break;
+        case 2:           return GAL_TYPE_INT16;
+        case 4:           return GAL_TYPE_INT32;
+        case 8:           return GAL_TYPE_INT64;
         }
       break;
 
     case TULONG:
       switch( sizeof(long) )
         {
-        case 4:           return GAL_TYPE_UINT32; break;
-        case 8:           return GAL_TYPE_UINT64; break;
+        case 4:           return GAL_TYPE_UINT32;
+        case 8:           return GAL_TYPE_UINT64;
         }
       break;
 
@@ -421,8 +421,8 @@ gal_fits_datatype_to_type(int datatype, int is_table_column)
       else
         switch( sizeof(long) )
           {
-          case 4:         return GAL_TYPE_INT32;  break;
-          case 8:         return GAL_TYPE_INT64;  break;
+          case 4:         return GAL_TYPE_INT32;
+          case 8:         return GAL_TYPE_INT64;
           }
       break;
 
@@ -451,7 +451,7 @@ gal_fits_datatype_to_type(int datatype, int is_table_column)
   error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s so we can fix "
         "this. Control must not have reached the end of this function.",
         __func__, PACKAGE_BUGREPORT);
-  return -1;
+  return GAL_TYPE_INVALID;
 }
 
 
@@ -514,11 +514,11 @@ gal_fits_open_to_write(char *filename)
 
 
 
-void
-gal_fits_hdu_num(char *filename, int *numhdu)
+size_t
+gal_fits_hdu_num(char *filename)
 {
-  int status=0;
   fitsfile *fptr;
+  int num, status=0;
 
   /* We don't need to check for an error everytime, because we don't
      make any non CFITSIO usage of the output. It is necessary to
@@ -526,40 +526,13 @@ gal_fits_hdu_num(char *filename, int *numhdu)
      outputs. */
   fits_open_file(&fptr, filename, READONLY, &status);
 
-  fits_get_num_hdus(fptr, numhdu, &status);
+  fits_get_num_hdus(fptr, &num, &status);
 
   fits_close_file(fptr, &status);
 
   gal_fits_io_error(status, NULL);
-}
-
-
-
 
-
-/* Open a given HDU and return the FITS pointer. `iomode' determines how
-   the FITS file will be opened: only to read or to read and write. You
-   should use the macros given by the CFITSIO header:
-
-     READONLY:   read-only.
-     READWRITE:  read and write.         */
-fitsfile *
-gal_fits_hdu_open(char *filename, char *hdu, int iomode)
-{
-  int status=0;
-  char *ffname;
-  fitsfile *fptr;
-
-  /* Add hdu to filename: */
-  asprintf(&ffname, "%s[%s#]", filename, hdu);
-
-  /* Open the FITS file: */
-  if( fits_open_file(&fptr, ffname, iomode, &status) )
-    gal_fits_io_error(status, "reading this FITS file");
-
-  /* Clean up and the pointer. */
-  free(ffname);
-  return fptr;
+  return num;
 }
 
 
@@ -574,7 +547,7 @@ gal_fits_hdu_open(char *filename, char *hdu, int iomode)
        ASCII_TBL:    An ASCII table HDU.
        BINARY_TBL:   BINARY TABLE HDU.       */
 int
-gal_fits_hdu_type(char *filename, char *hdu)
+gal_fits_hdu_format(char *filename, char *hdu)
 {
   fitsfile *fptr;
   int hdutype, status=0;
@@ -596,10 +569,39 @@ gal_fits_hdu_type(char *filename, char *hdu)
 
 
 
+/* Open a given HDU and return the FITS pointer. `iomode' determines how
+   the FITS file will be opened: only to read or to read and write. You
+   should use the macros given by the CFITSIO header:
+
+     READONLY:   read-only.
+     READWRITE:  read and write.         */
+fitsfile *
+gal_fits_hdu_open(char *filename, char *hdu, int iomode)
+{
+  int status=0;
+  char *ffname;
+  fitsfile *fptr;
+
+  /* Add hdu to filename: */
+  asprintf(&ffname, "%s[%s#]", filename, hdu);
+
+  /* Open the FITS file: */
+  if( fits_open_file(&fptr, ffname, iomode, &status) )
+    gal_fits_io_error(status, "reading this FITS file");
+
+  /* Clean up and the pointer. */
+  free(ffname);
+  return fptr;
+}
+
+
+
+
+
 /* Check the desired HDU in a FITS image and also if it has the
    desired type. */
 fitsfile *
-gal_fits_hdu_open_type(char *filename, char *hdu, unsigned char img0_tab1)
+gal_fits_hdu_open_format(char *filename, char *hdu, int img0_tab1)
 {
   fitsfile *fptr;
   int status=0, hdutype;
@@ -661,7 +663,7 @@ gal_fits_hdu_open_type(char *filename, char *hdu, unsigned 
char img0_tab1)
 /* CFITSIO doesn't remove the two single quotes around the string value, so
    the strings it reads are like: 'value ', or 'some_very_long_value'. To
    use the value, it is commonly necessary to remove the single quotes (and
-   possible extra spaces). This function fill modify the string in its own
+   possible extra spaces). This function will modify the string in its own
    allocated space. You can use this to later free the original string (if
    it was allocated). */
 void
@@ -882,11 +884,11 @@ gal_fits_key_read(char *filename, char *hdu, gal_data_t 
*keysll,
    NOTE FOR STRINGS: the value should be the pointer to the string its-self
    (char *), not a pointer to a pointer (char **). */
 void
-gal_fits_key_add_to_ll(struct gal_fits_key_ll **list, uint8_t type,
-                       char *keyname, int kfree, void *value, int vfree,
-                       char *comment, int cfree, char *unit)
+gal_fits_key_list_add(gal_fits_list_key_t **list, uint8_t type,
+                      char *keyname, int kfree, void *value, int vfree,
+                      char *comment, int cfree, char *unit)
 {
-  struct gal_fits_key_ll *newnode;
+  gal_fits_list_key_t *newnode;
 
   /* Allocate space for the new node and fill it in. */
   errno=0;
@@ -911,11 +913,11 @@ gal_fits_key_add_to_ll(struct gal_fits_key_ll **list, 
uint8_t type,
 
 
 void
-gal_fits_key_add_to_ll_end(struct gal_fits_key_ll **list, uint8_t type,
-                           char *keyname, int kfree, void *value, int vfree,
-                           char *comment, int cfree, char *unit)
+gal_fits_key_list_add_end(gal_fits_list_key_t **list, uint8_t type,
+                          char *keyname, int kfree, void *value, int vfree,
+                          char *comment, int cfree, char *unit)
 {
-  struct gal_fits_key_ll *newnode, *tmp;
+  gal_fits_list_key_t *newnode, *tmp;
 
   /* Allocate space for the new node and fill it in. */
   errno=0;
@@ -951,7 +953,7 @@ gal_fits_key_add_to_ll_end(struct gal_fits_key_ll **list, 
uint8_t type,
 
 void
 gal_fits_key_write_filename(char *keynamebase, char *filename,
-                            struct gal_fits_key_ll **list)
+                            gal_fits_list_key_t **list)
 {
   char *keyname, *value;
   size_t numkey=1, maxlength;
@@ -989,8 +991,8 @@ gal_fits_key_write_filename(char *keynamebase, char 
*filename,
          length was copied. */
       if(value[maxlength-1]=='\0')
         {
-          gal_fits_key_add_to_ll_end(list, GAL_TYPE_STRING, keyname, 1,
-                                     value, 1, NULL, 0, NULL);
+          gal_fits_key_list_add_end(list, GAL_TYPE_STRING, keyname, 1,
+                                    value, 1, NULL, 0, NULL);
           break;
         }
       else
@@ -1011,8 +1013,8 @@ gal_fits_key_write_filename(char *keynamebase, char 
*filename,
                   filename, maxlength);
 
           /* Convert the last useful character and save the file name.*/
-          gal_fits_key_add_to_ll_end(list, TSTRING, keyname, 1,
-                                     value, 1, NULL, 0, NULL);
+          gal_fits_key_list_add_end(list, TSTRING, keyname, 1,
+                                    value, 1, NULL, 0, NULL);
           i+=j+1;
         }
     }
@@ -1056,14 +1058,14 @@ gal_fits_key_write_wcsstr(fitsfile *fptr, char *wcsstr, 
int nkeyrec)
 
 
 
-/* Write the keywords in the gal_fits_key_ll linked list to the FITS
-   file. Every keyword that is written is freed, that is why we need
-   the pointer to the linked list (to correct it after we finish). */
+/* Write the keywords in the gal_fits_list_key_t linked list to the FITS
+   file. Every keyword that is written is freed, that is why we need the
+   pointer to the linked list (to correct it after we finish). */
 void
-gal_fits_key_write(fitsfile *fptr, struct gal_fits_key_ll **keylist)
+gal_fits_key_write(fitsfile *fptr, gal_fits_list_key_t **keylist)
 {
   int status=0;
-  struct gal_fits_key_ll *tmp, *ttmp;
+  gal_fits_list_key_t *tmp, *ttmp;
 
   tmp=*keylist;
   while(tmp!=NULL)
@@ -1105,7 +1107,7 @@ gal_fits_key_write(fitsfile *fptr, struct gal_fits_key_ll 
**keylist)
 
 
 void
-gal_fits_key_write_version(fitsfile *fptr, struct gal_fits_key_ll *headers,
+gal_fits_key_write_version(fitsfile *fptr, gal_fits_list_key_t *headers,
                            char *program_name)
 {
   size_t i;
@@ -1260,7 +1262,7 @@ gal_fits_img_read(char *filename, char *hdu, size_t 
minmapsize)
 
 
   /* Check HDU for realistic conditions: */
-  fptr=gal_fits_hdu_open_type(filename, hdu, 0);
+  fptr=gal_fits_hdu_open_format(filename, hdu, 0);
 
 
   /* Get the info and allocate the data structure. */
@@ -1512,7 +1514,7 @@ gal_fits_img_write_to_ptr(gal_data_t *input, char 
*filename)
 
 void
 gal_fits_img_write(gal_data_t *data, char *filename,
-                   struct gal_fits_key_ll *headers, char *program_string)
+                   gal_fits_list_key_t *headers, char *program_string)
 {
   int status=0;
   fitsfile *fptr;
@@ -1534,8 +1536,8 @@ gal_fits_img_write(gal_data_t *data, char *filename,
 
 void
 gal_fits_img_write_to_type(gal_data_t *data, char *filename,
-                           struct gal_fits_key_ll *headers,
-                           char *program_string, int type)
+                           gal_fits_list_key_t *headers, char *program_string,
+                           int type)
 {
   /* If the input dataset is not the correct type, then convert it,
      otherwise, use the input data structure. */
@@ -1567,21 +1569,21 @@ gal_fits_img_write_to_type(gal_data_t *data, char 
*filename,
         writing FITS images in parallel, we can't write the header keywords
         in each thread.   */
 void
-gal_fits_img_write_corr_wcs_str(gal_data_t *data, char *filename,
+gal_fits_img_write_corr_wcs_str(gal_data_t *input, char *filename,
                                 char *wcsstr, int nkeyrec, double *crpix,
-                                struct gal_fits_key_ll *headers,
+                                gal_fits_list_key_t *headers,
                                 char *program_string)
 {
   int status=0;
   fitsfile *fptr;
 
   /* The data should not have any WCS structure for this function. */
-  if(data->wcs)
+  if(input->wcs)
     error(EXIT_FAILURE, 0, "%s: input must not have WCS meta-data",
           __func__);
 
   /* Write the data array into a FITS file and keep it open. */
-  fptr=gal_fits_img_write_to_ptr(data, filename);
+  fptr=gal_fits_img_write_to_ptr(input, filename);
 
   /* Write the WCS headers into the FITS file. */
   gal_fits_key_write_wcsstr(fptr, wcsstr, nkeyrec);
@@ -1652,12 +1654,12 @@ gal_fits_tab_size(fitsfile *fitsptr, size_t *nrows, 
size_t *ncols)
 
 
 int
-gal_fits_tab_type(fitsfile *fptr)
+gal_fits_tab_format(fitsfile *fitsptr)
 {
   int status=0;
   char value[FLEN_VALUE];
 
-  fits_read_key(fptr, TSTRING, "XTENSION", value, NULL, &status);
+  fits_read_key(fitsptr, TSTRING, "XTENSION", value, NULL, &status);
 
   if(status==0)
     {
@@ -1692,9 +1694,7 @@ gal_fits_tab_type(fitsfile *fptr)
    where `T' specifies the general format, `w' is the width to be given to
    this column and `p' is the precision. For integer types, percision is
    actually the minimum number of integers, for floats, it is the number of
-   decimal digits beyond the decimal point.
-
- */
+   decimal digits beyond the decimal point. */
 static void
 set_display_format(char *tdisp, gal_data_t *data, char *filename, char *hdu,
                    char *keyname)
@@ -1826,7 +1826,7 @@ fits_correct_bin_table_int_types(gal_data_t *allcols, int 
tfields,
 /* See the descriptions of `gal_table_info'. */
 gal_data_t *
 gal_fits_tab_info(char *filename, char *hdu, size_t *numcols,
-                  size_t *numrows, int *tabletype)
+                  size_t *numrows, int *tableformat)
 {
   long repeat;
   int tfields;        /* The maximum number of fields in FITS is 999 */
@@ -1840,8 +1840,8 @@ gal_fits_tab_info(char *filename, char *hdu, size_t 
*numcols,
 
 
   /* Open the FITS file and get the basic information. */
-  fptr=gal_fits_hdu_open_type(filename, hdu, 1);
-  *tabletype=gal_fits_tab_type(fptr);
+  fptr=gal_fits_hdu_open_format(filename, hdu, 1);
+  *tableformat=gal_fits_tab_format(fptr);
   gal_fits_tab_size(fptr, numrows, numcols);
 
 
@@ -1901,7 +1901,7 @@ gal_fits_tab_info(char *filename, char *hdu, size_t 
*numcols,
             {
               /* The FITS standard's value to this option for FITS ASCII
                  and binary files differ. */
-              if(*tabletype==GAL_TABLE_FORMAT_AFITS)
+              if(*tableformat==GAL_TABLE_FORMAT_AFITS)
                 fits_ascii_tform(value, &datatype, NULL, NULL, &status);
               else
                 fits_binary_tform(value, &datatype, &repeat, NULL, &status);
@@ -1913,7 +1913,7 @@ gal_fits_tab_info(char *filename, char *hdu, size_t 
*numcols,
                  number of bytes in both cases for printing later. */
               if( allcols[index].type==GAL_TYPE_STRING )
                 {
-                  if(*tabletype==GAL_TABLE_FORMAT_AFITS)
+                  if(*tableformat==GAL_TABLE_FORMAT_AFITS)
                     {
                       repeat=strtol(value+1, &tailptr, 0);
                       if(*tailptr!='\0')
@@ -2033,7 +2033,7 @@ gal_fits_tab_info(char *filename, char *hdu, size_t 
*numcols,
 /* Read the column indexs given in the `indexll' linked list from a FITS
    table into a linked list of data structures, note that this is a
    low-level function, so the output data linked list is the inverse of the
-   input indexs linked list. You can use */
+   input indexs linked list. */
 gal_data_t *
 gal_fits_tab_read(char *filename, char *hdu, size_t numrows,
                   gal_data_t *allcols, gal_list_sizet_t *indexll,
@@ -2049,7 +2049,7 @@ gal_fits_tab_read(char *filename, char *hdu, size_t 
numrows,
   gal_list_sizet_t *ind;
 
   /* Open the FITS file */
-  fptr=gal_fits_hdu_open_type(filename, hdu, 1);
+  fptr=gal_fits_hdu_open_format(filename, hdu, 1);
 
   /* Pop each index and read/store the array. */
   for(ind=indexll; ind!=NULL; ind=ind->next)
@@ -2148,7 +2148,7 @@ fits_string_fixed_alloc_size(gal_data_t *data)
 
 
 static void
-fits_table_prepare_arrays(gal_data_t *cols, size_t numcols, int tabletype,
+fits_table_prepare_arrays(gal_data_t *cols, size_t numcols, int tableformat,
                           char ***outtform, char ***outttype,
                           char ***outtunit)
 {
@@ -2186,7 +2186,7 @@ fits_table_prepare_arrays(gal_data_t *cols, size_t 
numcols, int tabletype,
 
       /* FITS's TFORM depends on the type of FITS table, so work
          differently. */
-      switch(tabletype)
+      switch(tableformat)
         {
         /* FITS ASCII table. */
         case GAL_TABLE_FORMAT_AFITS:
@@ -2252,8 +2252,8 @@ fits_table_prepare_arrays(gal_data_t *cols, size_t 
numcols, int tabletype,
           break;
 
         default:
-          error(EXIT_FAILURE, 0, "%s: tabletype code %d not recognized",
-                __func__, tabletype);
+          error(EXIT_FAILURE, 0, "%s: tableformat code %d not recognized",
+                __func__, tableformat);
         }
 
 
@@ -2271,7 +2271,7 @@ fits_table_prepare_arrays(gal_data_t *cols, size_t 
numcols, int tabletype,
    a binary table, only the non-floating point ones (even if they don't
    have NULL values) must have it. */
 static void
-fits_write_tnull_tcomm(fitsfile *fptr, gal_data_t *col, int tabletype,
+fits_write_tnull_tcomm(fitsfile *fptr, gal_data_t *col, int tableformat,
                        size_t colnum, char *tform)
 {
   void *blank;
@@ -2279,7 +2279,7 @@ fits_write_tnull_tcomm(fitsfile *fptr, gal_data_t *col, 
int tabletype,
   char *c, *keyname, *bcomment;
 
   /* Write the NULL value */
-  switch(tabletype)
+  switch(tableformat)
     {
     case GAL_TABLE_FORMAT_AFITS:
 
@@ -2323,8 +2323,8 @@ fits_write_tnull_tcomm(fitsfile *fptr, gal_data_t *col, 
int tabletype,
       break;
 
     default:
-      error(EXIT_FAILURE, 0, "%s: tabletype code %d not recognized",
-            __func__, tabletype);
+      error(EXIT_FAILURE, 0, "%s: tableformat code %d not recognized",
+            __func__, tableformat);
     }
 
   /* Write the comments if there is any. */
@@ -2348,7 +2348,7 @@ fits_write_tnull_tcomm(fitsfile *fptr, gal_data_t *col, 
int tabletype,
    table.*/
 void
 gal_fits_tab_write(gal_data_t *cols, gal_list_str_t *comments,
-                   int tabletype, char *filename, int dontdelete)
+                   int tableformat, char *filename, int dontdelete)
 {
   void *blank;
   fitsfile *fptr;
@@ -2381,13 +2381,13 @@ gal_fits_tab_write(gal_data_t *cols, gal_list_str_t 
*comments,
 
   /* prepare necessary arrays and if integer type columns have blank
      values, write the TNULLn keywords into the FITS file. */
-  fits_table_prepare_arrays(cols, numcols, tabletype,
+  fits_table_prepare_arrays(cols, numcols, tableformat,
                             &tform, &ttype, &tunit);
 
 
-  /* Make the FITS file pointer. Note that tabletype was checked in
+  /* Make the FITS file pointer. Note that tableformat was checked in
      `fits_table_prepare_arrays'. */
-  tbltype = tabletype==GAL_TABLE_FORMAT_AFITS ? ASCII_TBL : BINARY_TBL;
+  tbltype = tableformat==GAL_TABLE_FORMAT_AFITS ? ASCII_TBL : BINARY_TBL;
   fits_create_tbl(fptr, tbltype, numrows, numcols, ttype, tform, tunit,
                   "table", &status);
   gal_fits_io_error(status, NULL);
@@ -2400,13 +2400,13 @@ gal_fits_tab_write(gal_data_t *cols, gal_list_str_t 
*comments,
     {
       /* Write the blank value into the header and return a pointer to
          it. Otherwise, */
-      fits_write_tnull_tcomm(fptr, col, tabletype, i+1, tform[i]);
+      fits_write_tnull_tcomm(fptr, col, tableformat, i+1, tform[i]);
 
       /* Set the blank pointer if its necessary, note that strings don't
          need a blank pointer in a FITS ASCII table.*/
       blank = ( gal_blank_present(col, 0)
                 ? gal_blank_alloc_write(col->type) : NULL );
-      if(tabletype==GAL_TABLE_FORMAT_AFITS && col->type==GAL_TYPE_STRING)
+      if(tableformat==GAL_TABLE_FORMAT_AFITS && col->type==GAL_TYPE_STRING)
         { if(blank) free(blank); blank=NULL; }
 
       /* Write the full column into the table. */
diff --git a/lib/gnuastro/fits.h b/lib/gnuastro/fits.h
index b044c47..6663099 100644
--- a/lib/gnuastro/fits.h
+++ b/lib/gnuastro/fits.h
@@ -74,18 +74,18 @@ __BEGIN_C_DECLS  /* From C++ preparations */
 
 
 /* To create a linked list of headers. */
-struct gal_fits_key_ll
+typedef struct gal_fits_list_key_t
 {
-  int                    kfree;   /* ==1, free keyword name.   */
-  int                    vfree;   /* ==1, free keyword value.  */
-  int                    cfree;   /* ==1, free comment.        */
-  uint8_t                 type;   /* Keyword value type.       */
-  char                *keyname;   /* Keyword Name.             */
-  void                  *value;   /* Keyword value.            */
-  char                *comment;   /* Keyword comment.          */
-  char                   *unit;   /* Keyword unit.             */
-  struct gal_fits_key_ll *next;   /* Pointer next keyword.     */
-};
+  int                        kfree;   /* ==1, free keyword name.   */
+  int                        vfree;   /* ==1, free keyword value.  */
+  int                        cfree;   /* ==1, free comment.        */
+  uint8_t                     type;   /* Keyword value type.       */
+  char                    *keyname;   /* Keyword Name.             */
+  void                      *value;   /* Keyword value.            */
+  char                    *comment;   /* Keyword comment.          */
+  char                       *unit;   /* Keyword unit.             */
+  struct gal_fits_list_key_t *next;   /* Pointer next keyword.     */
+} gal_fits_list_key_t;
 
 
 
@@ -110,11 +110,6 @@ gal_fits_name_is_fits(char *name);
 int
 gal_fits_suffix_is_fits(char *suffix);
 
-void
-gal_fits_file_or_ext_name(char *inputname, char *inhdu, int othernameset,
-                          char **othername, char *ohdu, int ohduset,
-                          char *type);
-
 char *
 gal_fits_name_save_as_string(char *filename, char *hdu);
 
@@ -123,7 +118,7 @@ gal_fits_name_save_as_string(char *filename, char *hdu);
 /*************************************************************
  **************           Type codes           ***************
  *************************************************************/
-int
+uint8_t
 gal_fits_bitpix_to_type(int bitpix);
 
 int
@@ -135,7 +130,7 @@ gal_fits_type_to_bin_tform(uint8_t type);
 int
 gal_fits_type_to_datatype(uint8_t type);
 
-int
+uint8_t
 gal_fits_datatype_to_type(int datatype, int is_table_column);
 
 
@@ -147,17 +142,17 @@ gal_fits_datatype_to_type(int datatype, int 
is_table_column);
 fitsfile *
 gal_fits_open_to_write(char *filename);
 
-void
-gal_fits_hdu_num(char *filename, int *numhdu);
+size_t
+gal_fits_hdu_num(char *filename);
 
 int
-gal_fits_hdu_type(char *filename, char *hdu);
+gal_fits_hdu_format(char *filename, char *hdu);
 
 fitsfile *
 gal_fits_hdu_open(char *filename, char *hdu, int iomode);
 
 fitsfile *
-gal_fits_hdu_open_type(char *filename, char *hdu, unsigned char img0_tab1);
+gal_fits_hdu_open_format(char *filename, char *hdu, int img0_tab1);
 
 
 
@@ -177,27 +172,27 @@ gal_fits_key_read(char *filename, char *hdu, gal_data_t 
*keysll,
                   int readcomment, int readunit);
 
 void
-gal_fits_key_add_to_ll(struct gal_fits_key_ll **list, uint8_t type,
-                       char *keyname, int kfree, void *value, int vfree,
-                       char *comment, int cfree, char *unit);
+gal_fits_key_list_add(gal_fits_list_key_t **list, uint8_t type,
+                      char *keyname, int kfree, void *value, int vfree,
+                      char *comment, int cfree, char *unit);
 
 void
-gal_fits_key_add_to_ll_end(struct gal_fits_key_ll **list, uint8_t type,
-                           char *keyname, int kfree, void *value, int vfree,
-                           char *comment, int cfree, char *unit);
+gal_fits_key_list_add_end(gal_fits_list_key_t **list, uint8_t type,
+                          char *keyname, int kfree, void *value, int vfree,
+                          char *comment, int cfree, char *unit);
 
 void
 gal_fits_key_write_filename(char *keynamebase, char *filename,
-                            struct gal_fits_key_ll **list);
+                            gal_fits_list_key_t **list);
 
 void
 gal_fits_key_write_wcsstr(fitsfile *fptr, char *wcsstr, int nkeyrec);
 
 void
-gal_fits_key_write(fitsfile *fptr, struct gal_fits_key_ll **keylist);
+gal_fits_key_write(fitsfile *fptr, gal_fits_list_key_t **keylist);
 
 void
-gal_fits_key_write_version(fitsfile *fptr, struct gal_fits_key_ll *headers,
+gal_fits_key_write_version(fitsfile *fptr, gal_fits_list_key_t *headers,
                            char *program_string);
 
 
@@ -225,17 +220,17 @@ gal_fits_img_write_to_ptr(gal_data_t *data, char 
*filename);
 
 void
 gal_fits_img_write(gal_data_t *data, char *filename,
-                   struct gal_fits_key_ll *headers, char *program_string);
+                   gal_fits_list_key_t *headers, char *program_string);
 
 void
 gal_fits_img_write_to_type(gal_data_t *data, char *filename,
-                           struct gal_fits_key_ll *headers,
+                           gal_fits_list_key_t *headers,
                            char *program_string, int type);
 
 void
-gal_fits_img_write_corr_wcs_str(gal_data_t *data, char *filename,
+gal_fits_img_write_corr_wcs_str(gal_data_t *input, char *filename,
                                 char *wcsheader, int nkeyrec, double *crpix,
-                                struct gal_fits_key_ll *headers,
+                                gal_fits_list_key_t *headers,
                                 char *program_string);
 
 
@@ -249,11 +244,11 @@ void
 gal_fits_tab_size(fitsfile *fitsptr, size_t *nrows, size_t *ncols);
 
 int
-gal_fits_tab_type(fitsfile *fptr);
+gal_fits_tab_format(fitsfile *fptr);
 
 gal_data_t *
 gal_fits_tab_info(char *filename, char *hdu, size_t *numcols,
-                    size_t *numrows, int *tabletype);
+                  size_t *numrows, int *tableformat);
 
 gal_data_t *
 gal_fits_tab_read(char *filename, char *hdu, size_t numrows,
@@ -262,7 +257,7 @@ gal_fits_tab_read(char *filename, char *hdu, size_t numrows,
 
 void
 gal_fits_tab_write(gal_data_t *cols, gal_list_str_t *comments,
-                   int tabletype, char *filename, int dontdelete);
+                   int tableformat, char *filename, int dontdelete);
 
 
 
diff --git a/lib/gnuastro/tile.h b/lib/gnuastro/tile.h
index 6f3ef80..ef4d882 100644
--- a/lib/gnuastro/tile.h
+++ b/lib/gnuastro/tile.h
@@ -148,7 +148,7 @@ gal_tile_full_permutation(struct gal_tile_two_layer_params 
*tl);
 void
 gal_tile_full_values_write(gal_data_t *tilevalues,
                            struct gal_tile_two_layer_params *tl,
-                           char *filename, struct gal_fits_key_ll *keys,
+                           char *filename, gal_fits_list_key_t *keys,
                            char *program_string);
 
 gal_data_t *
diff --git a/lib/tile.c b/lib/tile.c
index c274b20..b6f061f 100644
--- a/lib/tile.c
+++ b/lib/tile.c
@@ -1076,7 +1076,7 @@ gal_tile_full_permutation(struct 
gal_tile_two_layer_params *tl)
 void
 gal_tile_full_values_write(gal_data_t *tilevalues,
                            struct gal_tile_two_layer_params *tl,
-                           char *filename, struct gal_fits_key_ll *keys,
+                           char *filename, gal_fits_list_key_t *keys,
                            char *program_string)
 {
   gal_data_t *disp;
diff --git a/lib/wcs.c b/lib/wcs.c
index ae9f5b0..ecf9875 100644
--- a/lib/wcs.c
+++ b/lib/wcs.c
@@ -154,7 +154,7 @@ gal_wcs_read(char *filename, char *hdu, size_t hstartwcs,
   fitsfile *fptr;
 
   /* Check HDU for realistic conditions: */
-  fptr=gal_fits_hdu_open_type(filename, hdu, 0);
+  fptr=gal_fits_hdu_open_format(filename, hdu, 0);
 
   /* Read the WCS information: */
   gal_wcs_read_from_fitsptr(fptr, nwcs, wcs, hstartwcs, hendwcs);



reply via email to

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