gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master e41a18a: Minor edits in code and book


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master e41a18a: Minor edits in code and book
Date: Wed, 26 Sep 2018 14:44:18 -0400 (EDT)

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

    Minor edits in code and book
    
    While doing some work, a few minor corrections were found here and there in
    the code and the book. Here is a summary of the major points:
    
     - In MakeCatalog's `parse_objects', we were incorrectly incrementing the
       pointers by checking the whole dataset size instead of the tile size. On
       a 2D image, this causes no problem, but it can be confusing.
    
     - To let the users know that the Sky was subtracted in MakeCatalog, a
       message is now printed if it isn't in `quiet' mode.
    
     - The old "MakeCatalog output columns" and "MakeCatalog output file"
       sections of the book are now renamed to "MakeCatalog measurements" and
       "MakeCatalog output" to avoid confusion (both having the term "output"
       in them). Both sections were also edited to be more clear.
    
     - `gal_data_copy_to_allocated' also copies (and frees any that might
       already be allocated) string meta-data.
---
 NEWS                      |   1 +
 bin/mkcatalog/mkcatalog.c |  20 ++---
 bin/mkcatalog/parse.c     |  33 +++++----
 bin/mkcatalog/ui.c        |   4 +
 doc/gnuastro.texi         | 181 ++++++++++++++++++++++++++--------------------
 lib/data.c                |   9 +++
 6 files changed, 144 insertions(+), 104 deletions(-)

diff --git a/NEWS b/NEWS
index f0761ef..d6191b1 100644
--- a/NEWS
+++ b/NEWS
@@ -92,6 +92,7 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
     --meanmedqdiff: new name for `--modmedqdiff'. Similar to NoiseChisel.
 
   Library:
+    - gal_data_copy_to_allocated: Also copies string metadata (e.g., name).
     - gal_fits_key_write: filename and hdu instead of FITS pointer.
     - gal_fits_key_write_version: filename and hdu instead of FITS pointer.
     - gal_fits_key_write_filename: write at the top or end of the input list.
diff --git a/bin/mkcatalog/mkcatalog.c b/bin/mkcatalog/mkcatalog.c
index d88d5ca..9bd3b42 100644
--- a/bin/mkcatalog/mkcatalog.c
+++ b/bin/mkcatalog/mkcatalog.c
@@ -616,8 +616,8 @@ mkcatalog_write_outputs(struct mkcatalogparams *p)
   /* Reverse the comments list (so it is printed in the same order here),
      write the objects catalog and free the comments. */
   gal_list_str_reverse(&comments);
-  gal_table_write(p->objectcols, comments, p->cp.tableformat, p->objectsout,
-                  "OBJECTS", 0);
+  gal_table_write(p->objectcols, comments, p->cp.tableformat,
+                  p->objectsout, "OBJECTS", 0);
   gal_list_str_free(comments, 1);
 
 
@@ -627,14 +627,10 @@ mkcatalog_write_outputs(struct mkcatalogparams *p)
       /* Make the comments. */
       comments=mkcatalog_outputs_same_start(p, 1, "Clumps");
 
-      /* Write objects catalog
-         ---------------------
-
-         Reverse the comments list (so it is printed in the same order here),
-         write the objects catalog and free the comments. */
+      /* Reverse the comments and write the catalog. */
       gal_list_str_reverse(&comments);
-      gal_table_write(p->clumpcols, comments, p->cp.tableformat, p->clumpsout,
-                      "CLUMPS", 0);
+      gal_table_write(p->clumpcols, comments, p->cp.tableformat,
+                      p->clumpsout, "CLUMPS", 0);
       gal_list_str_free(comments, 1);
     }
 
@@ -651,14 +647,14 @@ mkcatalog_write_outputs(struct mkcatalogparams *p)
   /* Inform the user */
   if(!p->cp.quiet)
     {
-      if(p->clumpsout==p->objectsout)
-        printf("  - Output catalog: %s\n", p->objectsout);
-      else
+      if(p->clumpsout && strcmp(p->clumpsout,p->objectsout))
         {
           printf("  - Output objects catalog: %s\n", p->objectsout);
           if(p->clumps)
             printf("  - Output clumps catalog: %s\n", p->clumpsout);
         }
+      else
+        printf("  - Catalog written to %s\n", p->objectsout);
     }
 }
 
diff --git a/bin/mkcatalog/parse.c b/bin/mkcatalog/parse.c
index 195239c..f077649 100644
--- a/bin/mkcatalog/parse.c
+++ b/bin/mkcatalog/parse.c
@@ -114,9 +114,10 @@ parse_objects(struct mkcatalog_passparams *pp)
   size_t ndim=p->objects->ndim, *dsize=p->objects->dsize;
 
   double *oi=pp->oi;
+  size_t *tsize=pp->tile->dsize;
   size_t d, increment=0, num_increment=1;
   float st, sval, *V=NULL, *SK=NULL, *ST=NULL;
-  int32_t *O, *OO, *C=NULL, *objects=p->objects->array;
+  int32_t *O, *OO, *C=NULL, *objarr=p->objects->array;
   float *std=p->std?p->std->array:NULL, *sky=p->sky?p->sky->array:NULL;
 
   /* If tile processing isn't necessary, set `tid' to a blank value. */
@@ -157,7 +158,7 @@ parse_objects(struct mkcatalog_passparams *pp)
       if( p->values            ) V  = pp->st_v   + increment;
       if( p->sky && pp->st_sky ) SK = pp->st_sky + increment;
       if( p->std && pp->st_std ) ST = pp->st_std + increment;
-      OO = ( O = pp->st_o + increment ) + pp->tile->dsize[ndim-1];
+      OO = ( O = pp->st_o + increment ) + tsize[ndim-1];
 
       /* Parse the tile. */
       do
@@ -180,7 +181,7 @@ parse_objects(struct mkcatalog_passparams *pp)
               if(c)
                 {
                   /* Convert the index to coordinate. */
-                  gal_dimension_index_to_coord(O-objects, ndim, dsize, c);
+                  gal_dimension_index_to_coord(O-objarr, ndim, dsize, c);
 
                   /* If we need tile-ID, get the tile ID now. */
                   if(tid!=GAL_BLANK_SIZE_T)
@@ -297,7 +298,7 @@ parse_objects(struct mkcatalog_passparams *pp)
       while(++O<OO);
 
       /* Increment to the next contiguous region of this tile. */
-      increment += ( gal_tile_block_increment(p->objects, dsize,
+      increment += ( gal_tile_block_increment(p->objects, tsize,
                                               num_increment++, NULL) );
     }
 
@@ -332,6 +333,7 @@ parse_clumps(struct mkcatalog_passparams *pp)
 
   double *ci, *cir;
   uint8_t *cif=p->ciflag;
+  size_t *tsize=pp->tile->dsize;
   int32_t *O, *OO, *C=NULL, nlab;
   float st, sval, *V=NULL, *SK=NULL, *ST=NULL;
   size_t i, ii, d, increment=0, num_increment=1;
@@ -384,7 +386,7 @@ parse_clumps(struct mkcatalog_passparams *pp)
       if( p->values            ) V  = pp->st_v   + increment;
       if( p->sky && pp->st_sky ) SK = pp->st_sky + increment;
       if( p->std && pp->st_std ) ST = pp->st_std + increment;
-      OO = ( O = pp->st_o + increment ) + pp->tile->dsize[ndim-1];
+      OO = ( O = pp->st_o + increment ) + tsize[ndim-1];
 
       /* Parse the tile */
       do
@@ -561,7 +563,7 @@ parse_clumps(struct mkcatalog_passparams *pp)
       while(++O<OO);
 
       /* Increment to the next contiguous region of this tile. */
-      increment += ( gal_tile_block_increment(p->objects, dsize,
+      increment += ( gal_tile_block_increment(p->objects, tsize,
                                               num_increment++, NULL) );
     }
 
@@ -580,7 +582,6 @@ void
 parse_median(struct mkcatalog_passparams *pp)
 {
   struct mkcatalogparams *p=pp->p;
-  size_t ndim=p->objects->ndim, *dsize=p->objects->dsize;
 
   float *V;
   double *ci;
@@ -588,9 +589,10 @@ parse_median(struct mkcatalog_passparams *pp)
   int32_t *O, *OO, *C=NULL;
   gal_data_t **clumpsmed=NULL;
   size_t i, increment=0, num_increment=1;
-  size_t counter=0, *ccounter=NULL, tsize=pp->oi[OCOL_NUM];
-  gal_data_t *objmed=gal_data_alloc(NULL, p->values->type, 1, &tsize, NULL, 0,
-                                    p->cp.minmapsize, NULL, NULL, NULL);
+  size_t *tsize=pp->tile->dsize, ndim=p->objects->ndim;
+  size_t counter=0, *ccounter=NULL, tmpsize=pp->oi[OCOL_NUM];
+  gal_data_t *objmed=gal_data_alloc(NULL, p->values->type, 1, &tmpsize, NULL,
+                                    0, p->cp.minmapsize, NULL, NULL, NULL);
 
   /* Allocate space for the clump medians. */
   if(p->clumps)
@@ -607,9 +609,10 @@ parse_median(struct mkcatalog_passparams *pp)
                                     __func__, "ccounter");
       for(i=0;i<pp->clumpsinobj;++i)
         {
-          tsize=pp->ci[ i * CCOL_NUMCOLS + CCOL_NUM ];
-          clumpsmed[i]=gal_data_alloc(NULL, p->values->type, 1, &tsize, NULL,
-                                      0, p->cp.minmapsize, NULL, NULL, NULL);
+          tmpsize=pp->ci[ i * CCOL_NUMCOLS + CCOL_NUM ];
+          clumpsmed[i]=gal_data_alloc(NULL, p->values->type, 1, &tmpsize,
+                                      NULL, 0, p->cp.minmapsize, NULL, NULL,
+                                      NULL);
         }
     }
 
@@ -621,7 +624,7 @@ parse_median(struct mkcatalog_passparams *pp)
          along the fastest dimension will be done over the `O' pointer. */
       V = pp->st_v + increment;
       if(p->clumps) C = pp->st_c + increment;
-      OO = ( O = pp->st_o + increment ) + pp->tile->dsize[ndim-1];
+      OO = ( O = pp->st_o + increment ) + tsize[ndim-1];
 
       /* Parse the next contiguous region of this tile. */
       do
@@ -651,7 +654,7 @@ parse_median(struct mkcatalog_passparams *pp)
       while(++O<OO);
 
       /* Increment to the next contiguous region of this tile. */
-      increment += ( gal_tile_block_increment(p->objects, dsize,
+      increment += ( gal_tile_block_increment(p->objects, tsize,
                                               num_increment++, NULL) );
     }
 
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index 91a151b..00df798 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -871,6 +871,10 @@ ui_subtract_sky(struct mkcatalogparams *p)
     error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
           "the problem. For some reason, the size doesn't match", __func__,
           PACKAGE_BUGREPORT);
+
+  /* Inform the user that this operation is done (if necessary). */
+  if(!p->cp.quiet)
+    printf("  - Sky subtracted from input values.\n");
 }
 
 
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index a22694a..e490bac 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -483,8 +483,8 @@ Invoking MakeCatalog
 
 * MakeCatalog inputs and basic settings::  Input files and basic settings.
 * Upper-limit settings::        Settings for upper-limit measurements.
-* MakeCatalog output columns::  Available columns in MakeCatalog's output 
table.
-* MakeCatalog output file::     File names of MakeCatalog's output table.
+* MakeCatalog measurements::    Available measurements in MakeCatalog.
+* MakeCatalog output::          File names of MakeCatalog's output table.
 
 Match
 
@@ -17499,21 +17499,27 @@ it. For example the magnitudes, positions and 
elliptical properties of the
 galaxies that are in the image.
 
 MakeCatalog is Gnuastro's program for localized measurements over a
-dataset. The role of MakeCatalog in a scientific analysis and the benefits
-of this model of data analysis (were detection/segmentation is separated
-from measurement) is discussed in @url{https://arxiv.org/abs/1611.06387v1,
-Akhlaghi [2016]}. We strongly recommend reading this short paper for a
-better understanding of this methodology thus effective usage of
-MakeCatalog, in combination with the other Gnuastro's programs. However,
-that paper cannot undergo any more change, so this manual is the definitive
-guide.
-
-It is important to define your regions of interest @emph{before} running
-MakeCatalog. MakeCatalog is specialized in doing measurements accurately
-and efficiently. Therefore MakeCatalog will not do detection, segmentation,
-or defining apertures on requested positions in your dataset. Following
-Gnuastro's modularity principle, There are separate and highly specialized
-and customizable programs in Gnuastro for these other jobs:
+dataset. In other words, MakeCatalog is Gnuastro's program to convert
+low-level datasets (like images), to high level catalogs. The role of
+MakeCatalog in a scientific analysis and the benefits of its model (where
+detection/segmentation is separated from measurement) is discussed in
address@hidden://arxiv.org/abs/1611.06387v1, Akhlaghi address@hidden
+published paper cannot undergo any more change, so this manual is the
+definitive guide.} and summarized in @ref{Detection and catalog
+production}. We strongly recommend reading this short paper for a better
+understanding of this methodology. Understanding the effective usage of
+MakeCatalog, will thus also help effective use of other (lower-level)
+Gnuastro's programs like @ref{NoiseChisel} or @ref{Segment}.
+
+It is important to define your regions of interest for measurements
address@hidden running MakeCatalog. MakeCatalog is specialized in doing
+measurements accurately and efficiently. Therefore MakeCatalog will not do
+detection, segmentation, or defining apertures on requested positions in
+your dataset. Following Gnuastro's modularity principle, there are separate
+and highly specialized and customizable programs in Gnuastro for these
+other jobs as shown below (for a usage example in a real-world analysis,
+see @ref{General program usage tutorial} and @ref{Detecting large extended
+targets}).
 
 @itemize
 @item
@@ -17530,19 +17536,23 @@ and customizable programs in Gnuastro for these other 
jobs:
 @end itemize
 
 These programs will/can return labeled dataset(s) to be fed into
-MakeCatalog. The labeled dataset must have the same size/dimensions as the
-input, but only with integer valued pixels that have the label/counter for
-the feature the pixel belongs to.
-
-These labels are then directly used to make the necessary measurements. For
-example the flux weighted average position of all the pixels with a label
-of 42 will be considered as the central address@hidden
+MakeCatalog. A labeled dataset for measurement has the same size/dimensions
+as the input, but with integer valued pixels that have the label/counter
+for each sub-set of pixels that must be measured together. For example all
+the pixels covering one galaxy in an image, get the same label.
+
+The requested measurements are then done on similarly labeled pixels. The
+final result is a catalog where each row corresponds to the measurements on
+pixels with a specfic label. For example the flux weighted average position
+of all the pixels with a label of 42 will be written into the 42nd row of
+the output catalog/table's central position address@hidden
 @ref{Measuring elliptical parameters} for a discussion on this and the
-derivation of positional parameters.} of the 42nd row of the output
-catalog. Similarly, the sum of all these pixels will be the 42nd row in the
-brightness column and etc. Pixels with labels equal to or smaller than zero
-will be ignored by MakeCatalog. In other words, the number of rows in
-MakeCatalog's output is already known before running it.
+derivation of positional parameters, which includes the
+center.}. Similarly, the sum of all these pixels will be the 42nd row in
+the brightness column and etc. Pixels with labels equal to, or smaller
+than, zero will be ignored by MakeCatalog. In other words, the number of
+rows in MakeCatalog's output is already known before running it (the
+maximum value of the labeled dataset).
 
 Before getting into the details of running MakeCatalog (in @ref{Invoking
 astmkcatalog}, we'll start with a discussion on the basics of its approach
@@ -17568,23 +17578,26 @@ steps is provided for readily adding your own new 
measurements/columns.
 @node Detection and catalog production, Quantifying measurement limits, 
MakeCatalog, MakeCatalog
 @subsection Detection and catalog production
 
-Most other common tools in low-level astronomical data-analysis (for
+Most existing common tools in low-level astronomical data-analysis (for
 example
 address@hidden@url{https://www.astromatic.net/software/sextractor}})
-merge the two processes of detection and measurement into one. Gnuastro's
-modularized methodology to separating detection from measurements is
-therefore new to many experienced astronomers and deserves a short review
-here. Further discussion on the benefits of this methodology can be seen in
+merge the two processes of detection and measurement (catalog production)
+in one program. However, in light of Gnuastro's modularized approach
+(modeled on the Unix system) detection is separated from measurements and
+catalog production. This modularity is therefore new to many experienced
+astronomers and deserves a short review here. Further discussion on the
+benefits of this methodology can be seen in
 @url{https://arxiv.org/abs/1611.06387v1, Akhlaghi [2016]}.
 
-The raw output of any of the programs mentioned in @ref{MakeCatalog} can be
-directly fed into MakeCatalog to get to a fast catalog. This is good when
-no further customization is necessary and you want a fast/simple
-catalog. But the modular approach taken by Gnuastro has many benefits that
-will become clear as you get more experienced in astronomical data analysis
-and want to be more creative in using your valuable data for the exciting
-scientific project you are working on. In short the reasons for this
-modularity can be classified as below:
+As discussed in the introduction of @ref{MakeCatalog}, detection
+(identifying which pixels to do measurements on) can be done with different
+programs. Their outputs (a labeled dataset) can be directly fed into
+MakeCatalog to do the measurements and write the result as a
+catalog/table. Beyond that, Gnuastro's modular approach has many benefits
+that will become clear as you get more experienced in astronomical data
+analysis and want to be more creative in using your valuable data for the
+exciting scientific project you are working on. In short the reasons for
+this modularity can be classified as below:
 
 @itemize
 
@@ -17603,7 +17616,7 @@ same scale. However, it is imperative that the same 
pixels be used in
 measuring the colors of galaxies.
 
 To solve the problem, NoiseChisel can be run on the reference image to
-generate the labeled detection image. After wards, the labeled image can be
+generate the labeled detection image. Afterwards, the labeled image can be
 warped into the grid of the other color (using @ref{Warp}). MakeCatalog
 will then generate the same catalog for both colors (with the different
 labeled images). It is currently customary to warp the images to the same
@@ -18205,18 +18218,18 @@ including MakeCatalog.
 The various measurements/columns of MakeCatalog are requested as options,
 either on the command-line or in configuration files, see
 @ref{Configuration files}. The full list of available columns is available
-in @ref{MakeCatalog output columns}. Depending on the requested columns,
+in @ref{MakeCatalog measurements}. Depending on the requested columns,
 MakeCatalog needs more than one input dataset, for more details, please see
 @ref{MakeCatalog inputs and basic settings}. The upper-limit measurements
 in particular need several configuration options which are thoroughly
 discussed in @ref{Upper-limit settings}. Finally, in @ref{MakeCatalog
-output file} the output file(s) created by MakeCatalog are discussed.
+output} the output file(s) created by MakeCatalog are discussed.
 
 @menu
 * MakeCatalog inputs and basic settings::  Input files and basic settings.
 * Upper-limit settings::        Settings for upper-limit measurements.
-* MakeCatalog output columns::  Available columns in MakeCatalog's output 
table.
-* MakeCatalog output file::     File names of MakeCatalog's output table.
+* MakeCatalog measurements::    Available measurements in MakeCatalog.
+* MakeCatalog output::          File names of MakeCatalog's output table.
 @end menu
 
 @node MakeCatalog inputs and basic settings, Upper-limit settings, Invoking 
astmkcatalog, Invoking astmkcatalog
@@ -18243,7 +18256,7 @@ error). All such auxiliary input files have to have the 
same size (number
 of pixels in each dimension) as the input labeled image. Their numeric data
 type is irrelevant (they will be converted to 32-bit floating point
 internally). For the full list of available measurements, see
address@hidden output columns}.
address@hidden measurements}.
 
 The ``values'' dataset is used for measurements like brightness/magnitude,
 or flux-weighted positions. If it is a real image, by default it is assumed
@@ -18305,9 +18318,9 @@ options and general setting options are described below.
 @item -l STR
 @itemx --clumpsfile=STR
 The file containing the labeled clumps dataset when @option{--clumpscat} is
-called (see @ref{MakeCatalog output file}). When @option{--clumpscat} is
-called, but this option isn't, MakeCatalog will look into the main input
-file (given as an argument) for the required extension/HDU (value to
+called (see @ref{MakeCatalog output}). When @option{--clumpscat} is called,
+but this option isn't, MakeCatalog will look into the main input file
+(given as an argument) for the required extension/HDU (value to
 @option{--clumpshdu}).
 
 @item --clumpshdu=STR
@@ -18388,7 +18401,7 @@ magnitude}.
 @end table
 
 
address@hidden Upper-limit settings, MakeCatalog output columns, MakeCatalog 
inputs and basic settings, Invoking astmkcatalog
address@hidden Upper-limit settings, MakeCatalog measurements, MakeCatalog 
inputs and basic settings, Invoking astmkcatalog
 @subsubsection Upper-limit settings
 
 The upper-limit magnitude was discussed in @ref{Quantifying measurement
@@ -18528,17 +18541,28 @@ option.
 @end table
 
 
address@hidden MakeCatalog output columns, MakeCatalog output file, Upper-limit 
settings, Invoking astmkcatalog
address@hidden MakeCatalog output columns
address@hidden MakeCatalog measurements, MakeCatalog output, Upper-limit 
settings, Invoking astmkcatalog
address@hidden MakeCatalog measurements
 
 The final group of options particular to MakeCatalog are those that specify
-which columns should be written into the final output table. For each
-column there is an option, if it has been called on the command line or in
-any of the configuration files, it will included as a column in the output
-catalog in the same order (see @ref{Configuration file precedence}). Some
-of the columns apply to both objects and clumps and some are particular to
-only one of them. The latter cases are explicitly marked with [Objects] or
-[Clumps] to specify the catalog they will be placed in.
+which measurements/columns should be written into the final output
+table. The current measurements in MakeCatalog are those which only produce
+one final value for each label (for example its total brightness: a single
+number). All the different label's measurements can be written as one
+column in a final table/catalog that contains other columns for other
+similar single-number measurements.
+
+Command-line options are used to identify which measurements you want in
+the final catalog(s) and in what order. If any of the options below is
+called on the command line or in any of the configuration files, it will be
+included as a column in the output catalog. The order of the columns is in
+the same order as the options were seen by MakeCatalog (see
address@hidden file precedence}). Some of the columns apply to both
+``objects'' and ``clumps'' and some are particular to only one of them (for
+the definition of ``objects'' and ``clumps'', see
address@hidden). Columns/options that are unique to one catalog (only
+objects, or only clumps), are explicitly marked with [Objects] or [Clumps]
+to specify the catalog they will be placed in.
 
 @table @option
 
@@ -18890,10 +18914,11 @@ with the first FITS axis in degrees.
 
 
 
address@hidden MakeCatalog output file,  , MakeCatalog output columns, Invoking 
astmkcatalog
address@hidden MakeCatalog output file
address@hidden MakeCatalog output,  , MakeCatalog measurements, Invoking 
astmkcatalog
address@hidden MakeCatalog output
 
-When complete, MakeCatalog will store its measurements as a table. If an
+After it has completed all the requested measurements (see @ref{MakeCatalog
+measurements}), MakeCatalog will store its measurements in table(s). If an
 output filename is given (see @option{--output} in @ref{Input output
 options}), the format of the table will be deduced from the name. When it
 isn't given, the input name will be appended with a @file{_cat} suffix (see
@@ -18907,8 +18932,9 @@ By default only a single catalog/table will be created 
for ``objects'',
 however, if @option{--clumpscat} is called, a secondary catalog/table will
 also be created. For more on ``objects'' and ``clumps'', see
 @ref{Segment}. In short, if you only have one set of labeled images, you
-don't have to worry about clumps (they are deactivated by default). Here is
-a full description of MakeCatalog's output options:
+don't have to worry about clumps (they are deactivated by default).
+
+The full list of MakeCatalog's output options are elaborated below.
 
 @table @option
 @item -C
@@ -23548,10 +23574,11 @@ not have any zero values (a dimension of length zero 
is not defined).
 @end deftypefun
 
 @deftypefun void gal_data_free_contents (gal_data_t @code{*data})
-Free all the address@hidden pointers in @code{gal_data_t}. If @code{data}
-is actually a tile (@code{data->block!=NULL}, see @ref{Tessellation
-library}), then @code{data->array} is not freed. For a complete description
-of @code{gal_data_t} and its contents, see @ref{Generic data container}.
+Free all the address@hidden pointers in @code{gal_data_t} except for
address@hidden and @code{block}. If @code{data} is actually a tile
+(@code{data->block!=NULL}, see @ref{Tessellation library}), then
address@hidden>array} is not freed. For a complete description of
address@hidden and its contents, see @ref{Generic data container}.
 @end deftypefun
 
 @deftypefun void gal_data_free (gal_data_t @code{*data})
@@ -26401,13 +26428,13 @@ function-like macro that is described below.
 
 @deftypefun {gal_data_t *} gal_tile_series_from_minmax (gal_data_t 
@code{*block}, size_t @code{*minmax}, size_t @code{number})
 Construct a list of tile(s) given coordinates of the minimum and maximum of
-each tile. The minimum and maximums are assumed to be inclusive. The
-returned pointer is an allocated @code{gal_data_t} array that can later be
-freed with @code{gal_data_array_free} (see @ref{Arrays of
-datasets}). Internally, each element of the output array points to the next
-element, so the output may also be treated as a list of datasets (see
address@hidden of gal_data_t}) and passed onto the other functions described in
-this section.
+each tile. The minimum and maximums are assumed to be inclusive and in C
+order (slowest dimension first). The returned pointer is an allocated
address@hidden array that can later be freed with
address@hidden (see @ref{Arrays of datasets}). Internally, each
+element of the output array points to the next element, so the output may
+also be treated as a list of datasets (see @ref{List of gal_data_t}) and
+passed onto the other functions described in this section.
 
 The array keeping the minimum and maximum coordinates for each tile must
 have the following format. So in total @code{minmax} must have
diff --git a/lib/data.c b/lib/data.c
index 45b4762..475de3f 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -777,12 +777,21 @@ gal_data_copy_to_allocated(gal_data_t *in, gal_data_t 
*out)
           "of dimensions, the dimensions are %zu and %zu respectively",
           __func__, out->ndim, in->ndim);
 
+  /* Free possibly allocated meta-data strings. */
+  if(out->name)    free(out->name);
+  if(out->unit)    free(out->unit);
+  if(out->comment) free(out->comment);
+
   /* Write the basic meta-data. */
   out->flag           = in->flag;
   out->next           = in->next;
   out->status         = in->status;
   out->disp_width     = in->disp_width;
   out->disp_precision = in->disp_precision;
+  gal_checkset_allocate_copy(in->name,    &out->name);
+  gal_checkset_allocate_copy(in->unit,    &out->unit);
+  gal_checkset_allocate_copy(in->comment, &out->comment);
+
 
   /* Do the copying. */
   switch(out->type)



reply via email to

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