[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 06833a9e: Book: Minor edits and clarifications
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 06833a9e: Book: Minor edits and clarifications |
Date: |
Thu, 13 Jul 2023 14:37:36 -0400 (EDT) |
branch: master
commit 06833a9ea783b65f580707fbc13457a967e8675f
Author: Faezeh Bidjarchian <fbidjarchian@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Book: Minor edits and clarifications
Until now, the default operation of Convolve was not highlighted under each
option which disables one steps (for example '--nokernelflip' did not
mention that by default the kernel is flipped by default). There were also
some typos and non-clear statements in the comments of some library
functions.
With this commit, a link to the section describing the operation of
Convolve has been added under those options. Furthermore, the typos and
clarifying points have been implemented in the comments within the library
source code.
---
bin/arithmetic/arithmetic.c | 2 +-
doc/gnuastro.texi | 23 ++++-----
lib/arithmetic.c | 11 ++---
lib/eps.c | 2 +-
lib/fit.c | 8 ++--
lib/fits.c | 114 ++++++++++++++++++++++----------------------
lib/options.c | 82 +++++++++++++++----------------
7 files changed, 122 insertions(+), 120 deletions(-)
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 0d75c481..1de51e9e 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -108,7 +108,7 @@ pop_number_of_operands(struct arithmeticparams *p, int op,
char *token_string,
or quantile estimation can be negative). */
if( ((float *)(tmp->array))[0]<=0.0 )
error(EXIT_FAILURE, 0, "the %s popped operand of the '%s' "
- "operator cannot be negative", cstring, token_string);
+ "operator cannot be zero or negative", cstring, token_string);
/* Increment the counter string. */
cstring=c?"third":"second";
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 0fe795b6..a60a98ff 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -20,7 +20,6 @@
@c So dashes and underscores can be used in HTMLs
@allowcodebreaks true
-
@c So function output type is printed on first line
@deftypefnnewline on
@@ -21074,16 +21073,16 @@ Formally, any pixel that is outside of the image in
the equation above will be c
When the kernel is symmetric about its center the blurred image has the same
orientation as the original image.
However, if the kernel is not symmetric, the image will be affected in the
opposite manner, this is a natural consequence of the definition of spatial
filtering.
In order to avoid this we can rotate the kernel about its center by 180
degrees so the convolved output can have the same original orientation (this is
done by default in the Convolve program).
-Technically speaking, only if the kernel is flipped the process is known
@emph{Convolution}.
+Technically speaking, only if the kernel is flipped the process is known as
@emph{Convolution}.
If it is not it is known as @emph{Correlation}.
-To be a weighted average, the sum of the weights (the pixels in the kernel)
have to be unity.
+To be a weighted average, the sum of the weights (the pixels in the kernel)
has to be unity.
This will have the consequence that the convolved image of an object and
unconvolved object will have the same brightness (see @ref{Brightness flux
magnitude}), which is natural, because convolution should not eat up the object
photons, it only disperses them.
-The convolution of each pixel is independent of the others pixels, and in some
cases it may be necessary to convolve different parts of an image separately
(for example, when you have different amplifiers on the CCD).
+The convolution of each pixel is independent of the other pixels, and in some
cases, it may be necessary to convolve different parts of an image separately
(for example, when you have different amplifiers on the CCD).
Therefore, to speed up spatial convolution, Gnuastro first defines a
tessellation over the input; assigning each group of pixels to ``tiles''.
It then does the convolution in parallel on each tile.
-For more on how Gnuastro's program create the tile grid (tessellation), see
@ref{Tessellation}.
+For more on how Gnuastro's programs create the tile grid (tessellation), see
@ref{Tessellation}.
@@ -21093,7 +21092,7 @@ For more on how Gnuastro's program create the tile grid
(tessellation), see @ref
In purely `linear' spatial filtering (convolution), there are problems with
the edges of the input image.
Here we will explain the problem in the spatial domain.
For a discussion of this problem from the frequency domain perspective, see
@ref{Edges in the frequency domain}.
-The problem originates from the fact that on the edges, in
practice@footnote{Because we assumed the overlapping pixels outside the input
image have a value of zero.}, the sum of the weights we use on the actual image
pixels is not unity.
+The problem originates from the fact that on the edges, in practice, the sum
of the weights we use on the actual image pixels is not unity@footnote{Because
we assumed the overlapping pixels outside the input image have a value of
zero.}.
For example, as discussed above, a profile in the center of an image will have
the same brightness before and after convolution.
However, for partially imaged profile on the edge of the image, the brightness
(sum of its pixel fluxes within the image, see @ref{Brightness flux magnitude})
will not be equal, some of the flux is going to be `eaten' by the edges.
@@ -21896,11 +21895,13 @@ Column containing the 1D kernel.
When the input dataset is a 1-dimensional column, and the host table has more
than one column, use this option to specify which column should be used.
@item --nokernelflip
-Do not flip the kernel after reading it the spatial domain convolution.
+Do not flip the kernel after reading; only for spatial domain convolution.
This can be useful if the flipping has already been applied to the kernel.
+By default, the input kernel is flipped to avoid the output getting flipped;
see @ref{Convolution process}.
-@item --nokernelnormx
+@item --nokernelnorm
Do not normalize the kernel after reading it, such that the sum of its pixels
is unity.
+As described in @ref{Convolution process}, the kernel is normalized by default.
@item -d STR
@itemx --domain=STR
@@ -21951,7 +21952,7 @@ Therefore in the final step (when cropping the central
parts of the image), we a
@end enumerate
@item --noedgecorrection
-Do not correct the edge effect in spatial domain convolution.
+Do not correct the edge effect in spatial domain convolution (this correction
is done in spatial domain convolution by default).
For a full discussion, please see @ref{Edges in the spatial domain}.
@item -m INT
@@ -35642,8 +35643,8 @@ Here is one short/simple example of initializing and
adding elements to a string
@example
gal_list_str_t *strlist=NULL;
-gal_list_str_add(&strlist, "bottom of list.");
-gal_list_str_add(&strlist, "second last element of list.");
+gal_list_str_add(&strlist, "bottom of list.", 1);
+gal_list_str_add(&strlist, "second last element of list.", 1);
@end example
@end deftypefun
diff --git a/lib/arithmetic.c b/lib/arithmetic.c
index 586b8e1d..69682ebb 100644
--- a/lib/arithmetic.c
+++ b/lib/arithmetic.c
@@ -1129,7 +1129,7 @@ arithmetic_size(int operator, int flags, gal_data_t *in,
gal_data_t *arg)
/* Stitch multiple operands along a given dimension. */
static gal_data_t *
-arithmetic_to_1d(int operator, int flags, gal_data_t *input)
+arithmetic_to_1d(int flags, gal_data_t *input)
{
size_t i;
@@ -1223,8 +1223,7 @@ arithmetic_stitch_sanity_check(gal_data_t *list,
gal_data_t *fdim)
/* Stitch multiple operands along a given dimension. */
static gal_data_t *
-arithmetic_stitch(int operator, int flags, gal_data_t *list,
- gal_data_t *fdim)
+arithmetic_stitch(int flags, gal_data_t *list, gal_data_t *fdim)
{
void *oarr;
gal_data_t *tmp, *out;
@@ -1276,7 +1275,7 @@ arithmetic_stitch(int operator, int flags, gal_data_t
*list,
break;
/* Horizontal stitching (first FITS axis is the horizontal
- axis) */
+ axis). */
case 1:
/* Copy row-by-row. */
@@ -3824,13 +3823,13 @@ gal_arithmetic(int operator, size_t numthreads, int
flags, ...)
case GAL_ARITHMETIC_OP_TRIM:
d1 = va_arg(va, gal_data_t *);
out = ( operator==GAL_ARITHMETIC_OP_TO1D
- ? arithmetic_to_1d(operator, flags, d1)
+ ? arithmetic_to_1d(flags, d1)
: gal_blank_trim(d1, flags & GAL_ARITHMETIC_FLAG_FREE) );
break;
case GAL_ARITHMETIC_OP_STITCH:
d1 = va_arg(va, gal_data_t *);
d2 = va_arg(va, gal_data_t *);
- out=arithmetic_stitch(operator, flags, d1, d2);
+ out=arithmetic_stitch(flags, d1, d2);
break;
/* Conversion operators. */
diff --git a/lib/eps.c b/lib/eps.c
index 5e5619cd..76f8adfd 100644
--- a/lib/eps.c
+++ b/lib/eps.c
@@ -167,7 +167,7 @@ eps_convert_to_bitstream(gal_data_t *in, size_t *numbytes,
uint8_t bitone)
{
/* Allocate the array. Note that we currently don't have an
allocation system for bits, so we'll allocate space in bytes, then
- convert */
+ convert the type to 'GAL_TYPE_BIT'. */
gal_list_data_add_alloc(&out, NULL, GAL_TYPE_UINT8, 1, numbytes,
NULL, 0, -1, 1, NULL, NULL, NULL);
out->type=GAL_TYPE_BIT;
diff --git a/lib/fit.c b/lib/fit.c
index 6bc18025..cdf5b5e0 100644
--- a/lib/fit.c
+++ b/lib/fit.c
@@ -107,7 +107,7 @@ gal_fit_name_from_id(uint8_t fitid)
int
gal_fit_name_robust_to_id(char *name)
{
- /* In case 'name' is NULL, then return the invalid type. */
+ /* In case 'name' is NULL, then return the invalid type. */
if(name==NULL) return GAL_FIT_ROBUST_INVALID;
/* Match the name. */
@@ -501,8 +501,8 @@ gal_fit_1d_polynomial_base(gal_data_t *xin, gal_data_t *yin,
any space, we can just use the allocated space within the
'gal_data_t'. We can't set the pointers now because we aren't sure
they have 'double' type yet. */
- gsl_vector yvec={yin->size, 1, NULL, NULL, 0}; /* Both have same size, */
- gsl_vector wvec={yin->size, 1, NULL, NULL, 0}; /* but ywht may be NULL!*/
+ gsl_vector yvec={yin->size, 1, NULL, NULL, 0}; /* Both have same size. */
+ gsl_vector wvec={yin->size, 1, NULL, NULL, 0}; /* 'ywht' may be NULL! */
gsl_vector *y=&yvec, *w=&wvec; /* These have to be after the two above.*/
/* Basic sanity checks. */
@@ -624,7 +624,7 @@ gal_fit_1d_polynomial_robust(gal_data_t *xin, gal_data_t
*yin,
-/* Estimate values from a polynomial fit.*/
+/* Estimate values from a polynomial fit. */
gal_data_t *
gal_fit_1d_polynomial_estimate(gal_data_t *fit, gal_data_t *xin)
{
diff --git a/lib/fits.c b/lib/fits.c
index 97708841..8f0a93d7 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -114,7 +114,7 @@ gal_fits_io_error(int status, char *message)
/* IMPORTANT NOTE: if other compression suffixes are add to this function,
include them in 'gal_checkset_automatic_output', so the compression
suffix can be skipped when the user doesn't specify an output
- filename.*/
+ filename. */
int
gal_fits_name_is_fits(char *name)
{
@@ -143,7 +143,7 @@ gal_fits_name_is_fits(char *name)
/* IMPORTANT NOTE: if other compression suffixes are added to this function,
include them in 'gal_checkset_automatic_output', so the compression
suffix can be skipped when the user doesn't specify an output
- filename.*/
+ filename. */
int
gal_fits_suffix_is_fits(char *suffix)
{
@@ -325,7 +325,7 @@ gal_fits_type_to_bitpix(uint8_t type)
/* The values to the TFORM header keywords of FITS binary tables are single
letter capital letters, but that is useless in identifying the data type
of the column. So this function will do the conversion based on the
- CFITSIO manual.*/
+ CFITSIO manual. */
char
gal_fits_type_to_bin_tform(uint8_t type)
{
@@ -385,7 +385,7 @@ gal_fits_type_to_datatype(uint8_t type)
/* Types that depend on the host system. The C standard says that the
'short', 'int' and 'long' types are ATLEAST 2, 2, 4 bytes, so to be
- safe, we will check all of them for the 32-bit types.*/
+ safe, we will check all of them for the 32-bit types. */
case GAL_TYPE_UINT16:
w=2;
if ( sizeof(short) == w ) return TUSHORT;
@@ -401,7 +401,7 @@ gal_fits_type_to_datatype(uint8_t type)
/* On 32-bit systems, the length of 'int' and 'long' are both
32-bits. But CFITSIO's LONG type is preferred because it is designed
to be 32-bit. Its 'INT' type is not clearly defined and caused
- problems when reading keywords.*/
+ problems when reading keywords. */
case GAL_TYPE_UINT32:
w=4;
if ( sizeof(long) == w ) return TULONG;
@@ -557,7 +557,7 @@ gal_fits_datatype_to_type(int datatype, int is_table_column)
/* When there is a BZERO or TZERO and BSCALE or TSCALE keywords, then the
type that must be used to store the actual values of the pixels may be
different from the type from BITPIX. This function does the necessary
- corrections.*/
+ corrections. */
static void
fits_type_correct(int *type, double bscale, char *bzero_str)
{
@@ -780,7 +780,7 @@ gal_fits_hdu_format(char *filename, char *hdu, char
*hdu_option_name)
if (fits_get_hdu_type(fptr, &hdutype, &status) )
gal_fits_io_error(status, NULL);
- /* Clean up and return.. */
+ /* Clean up and return. */
if( fits_close_file(fptr, &status) )
gal_fits_io_error(status, NULL);
return hdutype;
@@ -882,7 +882,7 @@ gal_fits_hdu_open(char *filename, char *hdu, int iomode,
int exitonerror,
}
break;
- /* Generic error below is fine for this case */
+ /* Generic error below is fine for this case. */
case BAD_HDU_NUM:
break;
@@ -1128,7 +1128,7 @@ gal_fits_key_date_to_struct_tm(char *fitsdate, struct tm
*tp)
/* https://www.w3.org/TR/NOTE-datetime */
/* In case we have sub-seconds in the string, we need to remove it
- because 'strptime' doesn't recognize sub-second resolution.*/
+ because 'strptime' doesn't recognize sub-second resolution. */
case '.':
/* Allocate space (by copying the remaining full string and adding
a '\0' where necessary. */
@@ -1196,7 +1196,8 @@ gal_fits_key_date_to_struct_tm(char *fitsdate, struct tm
*tp)
useful to avoid calendar issues like number of days in a different
months or leap years and etc. The remainder of the format string
(sub-seconds) will be put into the two pointer arguments: 'subsec' is in
- double-precision floating point format and */
+ double-precision floating point format but it will only get a value when
+ 'subsecstr!=NULL'. */
size_t
gal_fits_key_date_to_seconds(char *fitsdate, char **subsecstr,
double *subsec)
@@ -1351,7 +1352,7 @@ gal_fits_key_read_from_ptr(fitsfile *fptr, gal_data_t
*keysll,
/* When the type is a string, 'tmp->array' is an array of pointers
to a separately allocated piece of memory. So we have to
allocate that space here. If its not a string, then the
- allocated space above is enough to keep the value.*/
+ allocated space above is enough to keep the value. */
switch(tmp->type)
{
case GAL_TYPE_STRING:
@@ -1375,7 +1376,7 @@ gal_fits_key_read_from_ptr(fitsfile *fptr, gal_data_t
*keysll,
"tmp->array") );
}
- /* Allocate space for the keyword comment if necessary.*/
+ /* Allocate space for the keyword comment if necessary. */
if(readcomment)
{
errno=0;
@@ -1392,7 +1393,7 @@ gal_fits_key_read_from_ptr(fitsfile *fptr, gal_data_t
*keysll,
the 'FLEN_COMMENT' length for units too (theoretically, the unit
might take the full remaining area in the keyword). Also note
that the unit is only optional, so it needs a separate CFITSIO
- function call which is done here.*/
+ function call which is done here. */
if(readunit)
{
/* Allocate space for the unit and read it in. */
@@ -1547,7 +1548,7 @@ gal_fits_key_list_add_end(gal_fits_list_key_t **list,
uint8_t type,
newnode->ufree=ufree;
/* Set the next pointer. */
- if(*list) /* List is already full, add this node to the end */
+ if(*list) /* List is already full, add this node to the end. */
{
/* After this line, tmp points to the last node. */
tmp=*list; while(tmp->next!=NULL) tmp=tmp->next;
@@ -1609,7 +1610,7 @@ gal_fits_key_list_title_add_end(gal_fits_list_key_t
**list, char *title,
newnode->tfree=tfree;
/* Set the next pointer. */
- if(*list) /* List is already full, add this node to the end */
+ if(*list) /* List is already full, add this node to the end. */
{
/* After this line, tmp points to the last node. */
tmp=*list; while(tmp->next!=NULL) tmp=tmp->next;
@@ -1627,7 +1628,7 @@ gal_fits_key_list_title_add_end(gal_fits_list_key_t
**list, char *title,
-/* Only set this key to be a full comment */
+/* Only set this key to be a full comment. */
void
gal_fits_key_list_fullcomment_add(gal_fits_list_key_t **list,
char *fullcomment, int fcfree)
@@ -1673,7 +1674,7 @@ gal_fits_key_list_fullcomment_add_end(gal_fits_list_key_t
**list,
newnode->fcfree=fcfree;
/* Set the next pointer. */
- if(*list) /* List is already full, add this node to the end */
+ if(*list) /* List is already full, add this node to the end. */
{
/* After this line, tmp points to the last node. */
tmp=*list; while(tmp->next!=NULL) tmp=tmp->next;
@@ -1742,7 +1743,7 @@ gal_fits_key_write_title_in_ptr(char *title, fitsfile
*fptr)
titlerec[79]='\0';
cp=blankrec; do *cp=' '; while(++cp<cpf);
- /* Print the blank lines before the title */
+ /* Print the blank lines before the title. */
if(fits_write_record(fptr, blankrec, &status))
gal_fits_io_error(status, NULL);
@@ -1772,7 +1773,7 @@ gal_fits_key_write_filename(char *keynamebase, char
*filename,
/* When you give string arguments, CFITSIO puts them within two ''s,
so the actual length available is two less. It seems this length
also didn't include the null character, so, ultimately you have
- to take three from it.*/
+ to take three from it. */
maxlength=FLEN_VALUE-3;
/* Parse the filename and see when it is necessary to break it. */
@@ -1817,7 +1818,7 @@ gal_fits_key_write_filename(char *keynamebase, char
*filename,
{
/* Find the last place in the copied array that contains a
'/' and put j on the next character (so it can be turned
- into a null character.*/
+ into a null character. */
for(j=maxlength-2;j>0;--j)
if(value[j]=='/')
{
@@ -1847,7 +1848,7 @@ gal_fits_key_write_filename(char *keynamebase, char
*filename,
__func__, filename, maxlength);
}
- /* Convert the last useful character and save the file name.*/
+ /* Convert the last useful character and save the file name. */
if(top1end0)
gal_fits_key_list_add(list, GAL_TYPE_STRING, keyname, 1,
value, 1, NULL, 0, NULL, 0);
@@ -1948,7 +1949,7 @@ fits_bug_wrapper_cdelt_zero(fitsfile *fptr, struct wcsprm
*wcs, char *keystr)
-/* Write the WCS header string into a FITS files*/
+/* Write the WCS header string into a FITS files. */
void
gal_fits_key_write_wcsstr(fitsfile *fptr, struct wcsprm *wcs,
char *wcsstr, int nkeyrec)
@@ -1974,7 +1975,7 @@ gal_fits_key_write_wcsstr(fitsfile *fptr, struct wcsprm
*wcs,
that WCSLIB adds a blank line and a 'COMMENT' keyword saying its
own version. But Gnuastro writes the version of WCSLIB as a
separate keyword along with all other important software, so it is
- redundant and just makes the keywrods hard to read by eye.*/
+ redundant and just makes the keywrods hard to read by eye. */
if( keystart[0]!=' ' && strncmp(keystart, "COMMENT", 7) )
{
fits_write_record(fptr, keystart, &status);
@@ -2029,10 +2030,10 @@ gal_fits_key_write(gal_fits_list_key_t **keylist, char
*title,
fitsfile *fptr=gal_fits_hdu_open(filename, hdu, READWRITE, 1,
hdu_option_name);
- /* Write the title */
+ /* Write the title. */
gal_fits_key_write_title_in_ptr(title, fptr);
- /* Write the keywords into the */
+ /* Write the keywords into the FITS file pointer ('fptr'). */
gal_fits_key_write_in_ptr(keylist, fptr);
/* Close the input FITS file. */
@@ -2079,7 +2080,7 @@ gal_fits_key_write_in_ptr_nan_check(gal_fits_list_key_t
*tmp)
: ((double *)(out))[0] ) );
}
- /* Return the allocated array.*/
+ /* Return the allocated array. */
return out;
}
@@ -2149,7 +2150,7 @@ gal_fits_key_write_in_ptr(gal_fits_list_key_t **keylist,
fitsfile *fptr)
}
/* Keep the pointer to the next keyword and free the allocated
- space for this keyword.*/
+ space for this keyword. */
ttmp=tmp->next;
free(tmp);
tmp=ttmp;
@@ -2197,7 +2198,7 @@ gal_fits_key_write_version_in_ptr(gal_fits_list_key_t
**keylist,
/* Before WCSLIB 5.0, the wcslib_version function was not
defined. Sometime in the future were everyone has moved to more
recent versions of WCSLIB, we can remove this macro and its check
- in configure.ac.*/
+ in configure.ac. */
#if GAL_CONFIG_HAVE_WCSLIB_VERSION == 1
int wcslibvers[3];
char wcslibversion[20];
@@ -2235,7 +2236,7 @@ gal_fits_key_write_version_in_ptr(gal_fits_list_key_t
**keylist,
/* Write all the information: */
fits_write_date(fptr, &status);
- /* Write the version of CFITSIO */
+ /* Write the version of CFITSIO. */
fits_update_key(fptr, TSTRING, "CFITSIO", cfitsioversion,
"CFITSIO version.", &status);
@@ -2265,7 +2266,7 @@ gal_fits_key_write_version_in_ptr(gal_fits_list_key_t
**keylist,
free(gitdescribe);
}
- /* Report any error if a problem came up */
+ /* Report any error if a problem came up. */
gal_fits_io_error(status, NULL);
}
@@ -2313,7 +2314,7 @@ gal_fits_key_write_config(gal_fits_list_key_t **keylist,
char *title,
/* From an input list of FITS files and a HDU, select those that have a
- certain value(s) in a certain keyword.*/
+ certain value(s) in a certain keyword. */
gal_list_str_t *
gal_fits_with_keyvalue(gal_list_str_t *files, char *hdu, char *name,
gal_list_str_t *values, char *hdu_option_name)
@@ -2371,7 +2372,7 @@ gal_fits_with_keyvalue(gal_list_str_t *files, char *hdu,
char *name,
/* From an input list of FITS files and a HDU, select those that have a
- certain value(s) in a certain keyword.*/
+ certain value(s) in a certain keyword. */
gal_list_str_t *
gal_fits_unique_keyvalues(gal_list_str_t *files, char *hdu, char *name,
char *hdu_option_name)
@@ -2627,7 +2628,7 @@ gal_fits_img_read(char *filename, char *hdu, size_t
minmapsize,
gal_fits_io_error(status, NULL);
- /* Return the filled data structure */
+ /* Return the filled data structure. */
return img;
}
@@ -2692,7 +2693,7 @@ gal_fits_img_read_kernel(char *filename, char *hdu,
size_t minmapsize,
"doesn't have an odd number of pixels", __func__, filename, hdu);
/* If there are any NaN pixels, set them to zero and normalize it. A
- blank pixel in a kernel is going to make a completely blank output.*/
+ blank pixel in a kernel is going to make a completely blank output. */
fp=(f=kernel->array)+kernel->size;
do
{
@@ -2714,7 +2715,7 @@ gal_fits_img_read_kernel(char *filename, char *hdu,
size_t minmapsize,
f[ kernel->size - i - 1 ]=tmp;
}
- /* Return the kernel*/
+ /* Return the kernel. */
return kernel;
}
@@ -2756,7 +2757,7 @@ gal_fits_img_write_to_ptr(gal_data_t *input, char
*filename)
"naxes");
- /* Open the file for writing */
+ /* Open the file for writing. */
fptr=gal_fits_open_to_write(filename);
@@ -2813,7 +2814,7 @@ gal_fits_img_write_to_ptr(gal_data_t *input, char
*filename)
}
else
{
- /* Set the datatype */
+ /* Set the datatype. */
datatype=gal_fits_type_to_datatype(block->type);
/* Create the FITS file. */
@@ -2845,7 +2846,7 @@ gal_fits_img_write_to_ptr(gal_data_t *input, char
*filename)
case GAL_TYPE_FLOAT32:
case GAL_TYPE_FLOAT64:
/* Do nothing! Since there are much fewer floating point types
- (that don't need any BLANK keyword), we are checking them.*/
+ (that don't need any BLANK keyword), we are checking them. */
break;
default:
@@ -2872,12 +2873,13 @@ gal_fits_img_write_to_ptr(gal_data_t *input, char
*filename)
fits_write_comment(fptr, towrite->comment, &status);
- /* If a WCS structure is present, write it in */
+ /* If a WCS structure is present, write it in the FITS file pointer
+ ('fptr'). */
if(towrite->wcs)
gal_wcs_write_in_fitsptr(fptr, towrite->wcs);
- /* Report any errors if we had any */
+ /* If there were any errors, report them and return.*/
free(naxes);
gal_fits_io_error(status, NULL);
if(towrite!=input) gal_data_free(towrite);
@@ -2943,7 +2945,7 @@ gal_fits_img_write_to_type(gal_data_t *data, char
*filename,
- 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. */
+ in each thread. */
void
gal_fits_img_write_corr_wcs_str(gal_data_t *input, char *filename,
char *wcsstr, int nkeyrec, double *crpix,
@@ -3008,7 +3010,7 @@ gal_fits_img_write_corr_wcs_str(gal_data_t *input, char
*filename,
/********** Table ************/
/**************************************************************/
/* Get the size of a table HDU. CFITSIO doesn't use size_t, also we want to
- check status here.*/
+ check status here. */
void
gal_fits_tab_size(fitsfile *fitsptr, size_t *nrows, size_t *ncols)
{
@@ -3079,7 +3081,7 @@ set_display_format(char *tdisp, gal_data_t *data, char
*filename, char *hdu,
int isanint=0;
char *tailptr;
- /* First, set the general display format */
+ /* First, set the general display format. */
switch(tdisp[0])
{
case 'A':
@@ -3158,7 +3160,7 @@ set_display_format(char *tdisp, gal_data_t *data, char
*filename, char *hdu,
'TSCALn' and 'TZEROn' to scale the signed types to an unsigned type. It
does this internally, but since we need to define our data type and
allocate space for it before actually reading the array, it is necessary
- to do this setting here. */
+ to do this setting here. */
static void
fits_correct_bin_table_int_types(gal_data_t *allcols, int tfields,
int *tscal, long long *tzero)
@@ -3208,7 +3210,7 @@ gal_fits_tab_info(char *filename, char *hdu, size_t
*numcols,
size_t *numrows, int *tableformat, char *hdu_option_name)
{
long repeat;
- int tfields; /* The maximum number of fields in FITS is 999 */
+ int tfields; /* The maximum number of fields in FITS is 999. */
char *tailptr;
fitsfile *fptr;
size_t i, index;
@@ -3266,7 +3268,7 @@ gal_fits_tab_info(char *filename, char *hdu, size_t
*numcols,
single quotes around the value string, one before and one
after. 'gal_fits_key_clean_str_value' will remove these single
quotes and any possible trailing space within the allocated
- space.*/
+ space. */
if(value[0]=='\'') gal_fits_key_clean_str_value(value);
@@ -3277,14 +3279,14 @@ gal_fits_tab_info(char *filename, char *hdu, size_t
*numcols,
number exists before the defined capital letter, it defaults to 1,
but if a number exists (for example '5D'), then the repeat is 5
(there are actually five values in each column). Note that
- value[0] is a single quote.*/
+ value[0] is a single quote. */
if(strncmp(keyname, "TFORM", 5)==0)
{
/* See which column this information was for and add it, if the
index is larger than the number of columns, then ignore
the . The FITS standard says there should be no extra TFORM
keywords beyond the number of columns, but we don't want to be
- that strict here.*/
+ that strict here. */
index = strtoul(&keyname[5], &tailptr, 10) - 1;
if(index<tfields) /* Counting from zero was corrected above. */
{
@@ -3307,14 +3309,14 @@ gal_fits_tab_info(char *filename, char *hdu, size_t
*numcols,
/* Set the repeat flag if necessary (recall that by
default 'allcols[index].minmapsize' will be zero! So
we need this flag to confirm that the zero there is
- meaningful.*/
+ meaningful. */
if(repeat==0)
allcols[index].flag
|= GAL_TABLEINTERN_FLAG_TFORM_REPEAT_IS_ZERO;
}
/* Write the "repeat" element into 'allcols->minmapsize',
- also activate the repeat flag within the dataset.*/
+ also activate the repeat flag within the dataset. */
allcols[index].minmapsize = repeat;
/* Write the type into the data structure. */
@@ -3381,7 +3383,7 @@ gal_fits_tab_info(char *filename, char *hdu, size_t
*numcols,
quotation marks, CFITSIO puts them in itsself, so if we don't
remove them here, we might have duplicates later, its easier to
just remove them to have a simple string that might be used else
- where too (without the single quotes).*/
+ where too (without the single quotes). */
else if(strncmp(keyname, "TTYPE", 5)==0)
{
index = strtoul(&keyname[5], &tailptr, 10) - 1;
@@ -3399,7 +3401,7 @@ gal_fits_tab_info(char *filename, char *hdu, size_t
*numcols,
}
- /* COLUMN COMMENTS */
+ /* COLUMN COMMENTS. */
else if(strncmp(keyname, "TCOMM", 5)==0)
{
index = strtoul(&keyname[5], &tailptr, 10) - 1;
@@ -3441,7 +3443,7 @@ gal_fits_tab_info(char *filename, char *hdu, size_t
*numcols,
}
- /* COLUMN DISPLAY FORMAT */
+ /* COLUMN DISPLAY FORMAT. */
else if(strncmp(keyname, "TDISP", 5)==0)
{
index = strtoul(&keyname[5], &tailptr, 10) - 1;
@@ -4015,7 +4017,7 @@ fits_table_prepare_arrays(gal_data_t *cols, size_t
numcols,
/* For vector columns, we need to give the number of elements
in the vector. Note that a vector column with dsize[1]==1
is just a single-valued column and shouldn't be treated
- like a vector.*/
+ like a vector. */
if( col->ndim==1 || (col->ndim==2 && col->dsize[1]==1) )
{
if( asprintf(&tform[i], "%c", fmt[0])<0 )
@@ -4105,7 +4107,7 @@ fits_write_tnull_tcomm(fitsfile *fptr, gal_data_t *col,
int tableformat,
int status=0;
char *c, *keyname, *bcomment;
- /* Write the NULL value */
+ /* Write the NULL value. */
switch(tableformat)
{
case GAL_TABLE_FORMAT_AFITS:
@@ -4377,7 +4379,7 @@ gal_fits_tab_write(gal_data_t *cols, gal_list_str_t
*comments,
/* Clean up and close the FITS file. Note that each element in the
'ttype' and 'tunit' arrays just points to the respective string in the
column data structure, the space for each element of the array wasn't
- allocated.*/
+ allocated. */
for(i=0;i<numcols;++i) {free(tform[i]); free(ttype[i]); free(tunit[i]);}
free(tform); free(ttype); free(tunit);
fits_close_file(fptr, &status);
diff --git a/lib/options.c b/lib/options.c
index 05730855..b0ca4f4c 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -230,7 +230,7 @@ gal_options_check_version(struct argp_option *option, char
*arg,
PACKAGE_BUGREPORT);
else if( strcmp(arg, PACKAGE_VERSION) )
{
- /* Print an error message and abort. */
+ /* Print an error message and abort. */
error_at_line(EXIT_FAILURE, 0, filename, lineno, "version "
"mis-match: you are running GNU Astronomy "
"Utilities (Gnuastro) version '%s'. However, "
@@ -450,7 +450,7 @@ gal_options_read_type(struct argp_option *option, char *arg,
arg, option->name);
/* For no un-used variable warning. This function doesn't need the
- pointer.*/
+ pointer. */
return junk=NULL;
}
}
@@ -530,7 +530,7 @@ gal_options_read_searchin(struct argp_option *option, char
*arg,
arg, option->name);
/* For no un-used variable warning. This function doesn't need the
- pointer.*/
+ pointer. */
return junk=NULL;
}
}
@@ -580,7 +580,7 @@ gal_options_read_wcslinearmatrix(struct argp_option
*option, char *arg,
*(uint8_t *)(option->value)=value;
/* For no un-used variable warning. This function doesn't need the
- pointer.*/
+ pointer. */
return junk=NULL;
}
}
@@ -617,7 +617,7 @@ gal_options_read_tableformat(struct argp_option *option,
char *arg,
"'fits-binary').\n\n", arg, option->name);
/* For no un-used variable warning. This function doesn't need the
- pointer.*/
+ pointer. */
return junk=NULL;
}
}
@@ -742,7 +742,7 @@ gal_options_read_sexagesimal(size_t dim, char *str, char
**tailptr,
/* If the loop above ended in a comma, then it stops and its time
to check if this is actually a sexagesimal string or not. If we
have reached the end of the string, and there was only two
- colons, then this is indeed a colon-based sexagesimal string.*/
+ colons, then this is indeed a colon-based sexagesimal string. */
if( (*cc=='\0' || *cc==',')
&& coloncounter>=2 )
iscolon=1;
@@ -753,12 +753,12 @@ gal_options_read_sexagesimal(size_t dim, char *str, char
**tailptr,
string. */
if(iscolon==0) return NAN;
- /* Everything is good, continue */
+ /* Everything is good, continue. */
if(dim==0) isra=1; else isdec=1;
break;
}
- /* Make sure the string could be identified properly */
+ /* Make sure the string could be identified properly. */
if( (isra==0 && isdec==0) || (ishd==0 && iscolon==0) )
{
if(abort)
@@ -939,7 +939,7 @@ gal_options_parse_list_of_numbers(char *string, char
*filename,
/* If the last number wasn't finished by a ',', add the read value to the
- list */
+ list. */
if( !isnan(numerator) )
{
++num;
@@ -1004,7 +1004,7 @@ gal_options_parse_list_of_strings(char *string, char
*filename,
{ for(d=c+2; *d!='\0'; ++d) {*(d-1)=*d;} *(d-1)='\0'; }
}
- /* Start separating the tokens */
+ /* Start separating the tokens. */
token=strtok(cp, delimiters);
gal_list_str_add(&list, token, 1);
while(token!=NULL)
@@ -1039,7 +1039,7 @@ gal_options_parse_list_of_strings(char *string, char
*filename,
/* Clean up and return. Note that we don't want to free the values in the
list, the elements in 'out->array' point to them and will later use
- them.*/
+ them. */
free(cp);
gal_list_str_free(list, 0);
return out;
@@ -1084,7 +1084,7 @@ options_print_liststr_as_csv(void *inval)
/* NOTE: output is REVERSED (since the option parsing automatically
- reverses STRLLs at its end).. */
+ reverses STRLLs at its end). */
gal_list_str_t *
gal_options_parse_csv_strings_to_list(char *string, char *filename,
size_t lineno)
@@ -1131,7 +1131,7 @@ gal_options_parse_csv_strings_to_list(char *string, char
*filename,
{
*c='\0';
gal_list_str_add(&list, str, 1);
- str=NULL; /* Mark that the next character is the start */
+ str=NULL; /* Mark that the next character is the start. */
}
break;
@@ -1189,7 +1189,7 @@ gal_options_parse_csv_strings_append(struct argp_option
*option, char *arg,
gal_list_str_last(alist)->next=olist;
*(gal_list_str_t **)(option->value)=alist;
- /* Return a NULL pointer */
+ /* Return a NULL pointer. */
return NULL;
}
}
@@ -1244,7 +1244,7 @@ gal_options_parse_csv_strings_to_data(char *string, char
*filename,
/* Clean up and return. Note that we don't want to free the space of
- each string becuse it has been passed */
+ each string becuse it has been passed. */
gal_list_str_free(list, 0);
return out;
}
@@ -1300,7 +1300,7 @@ gal_options_parse_csv_strings(struct argp_option *option,
char *arg,
else sstr[nc-1]='\0';
/* Copy the string into a dynamically allocated space, because it
- will be freed later.*/
+ will be freed later. */
gal_checkset_allocate_copy(sstr, &str);
return str;
}
@@ -1427,7 +1427,7 @@ gal_options_parse_sizes_reverse(struct argp_option
*option, char *arg,
sstr[nc-1]='\0';
/* Copy the string into a dynamically allocated space, because it
- will be freed later.*/
+ will be freed later. */
gal_checkset_allocate_copy(sstr, &str);
return str;
}
@@ -1465,14 +1465,14 @@ gal_options_parse_sizes_reverse(struct argp_option
*option, char *arg,
}
/* Write the values into an allocated size_t array and finish it with
- a '-1' so the total number can be found later.*/
+ a '-1' so the total number can be found later. */
num=values->size;
array=gal_pointer_allocate(GAL_TYPE_SIZE_T, num+1, 0, __func__,
"array");
for(i=0;i<num;++i) array[num-1-i]=v[i];
array[num] = GAL_BLANK_SIZE_T;
- /* Put the array of size_t into the option, clean up and return.*/
+ /* Put the array of size_t into the option, clean up and return. */
*(size_t **)(option->value) = array;
gal_data_free(values);
return NULL;
@@ -1500,7 +1500,7 @@ gal_options_parse_csv_float64(struct argp_option *option,
char *arg,
values = *(gal_data_t **)(option->value);
darray=values->array;
- /* Write each string into the output string */
+ /* Write each string into the output string. */
nc=0;
for(i=0;i<values->size;++i)
{
@@ -1515,7 +1515,7 @@ gal_options_parse_csv_float64(struct argp_option *option,
char *arg,
sstr[nc-1]='\0';
/* Copy the string into a dynamically allocated space, because it
- will be freed later.*/
+ will be freed later. */
gal_checkset_allocate_copy(sstr, &str);
return str;
}
@@ -1681,7 +1681,7 @@ gal_options_parse_name_and_values(struct argp_option
*option, char *arg,
sstr[nc-1]='\0';
/* Copy the string into a dynamically allocated space, because it
- will be freed later.*/
+ will be freed later. */
gal_checkset_allocate_copy(sstr, &str);
return str;
}
@@ -1692,7 +1692,7 @@ gal_options_parse_name_and_values(struct argp_option
*option, char *arg,
error_at_line(EXIT_FAILURE, 0, filename, lineno, "no value "
"given to '--%s'", option->name);
- /* Parse until the comma or the end of the string.*/
+ /* Parse until the comma or the end of the string. */
c=arg; while(*c!='\0' && *c!=',') ++c;
values = (*c=='\0') ? NULL : c+1;
@@ -1848,7 +1848,7 @@ gal_options_parse_colon_sep_csv_raw(char *instring, char
*filename,
but not when they are before a : or ,. So we need to remove
all white spaces. White spaces are usually put beside each
other, so if one is encountered, go along the string until
- the white space characters finish. */
+ the white space characters finish. */
if(isspace(*pt))
++pt;
else
@@ -1891,7 +1891,7 @@ gal_options_parse_colon_sep_csv_raw(char *instring, char
*filename,
/* Add the read coordinate to the list of coordinates. */
gal_list_f64_add(&vertices, read);
- /* The job here is done, start from tailptr */
+ /* The job here is done, start from tailptr. */
pt=tailptr;
}
}
@@ -1910,7 +1910,7 @@ gal_options_parse_colon_sep_csv_raw(char *instring, char
*filename,
/* Parse strings that are given to a function in this format
- 'num1,num2:num3,n4:num5,num6' */
+ 'num1,num2:num3,n4:num5,num6'. */
void *
gal_options_parse_colon_sep_csv(struct argp_option *option, char *arg,
char *filename, size_t lineno, void *junk)
@@ -1949,7 +1949,7 @@ gal_options_parse_colon_sep_csv(struct argp_option
*option, char *arg,
sstr[nc-1]='\0';
/* Copy the string into a dynamically allocated space, because it
- will be freed later.*/
+ will be freed later. */
gal_checkset_allocate_copy(sstr, &str);
return str;
}
@@ -2331,7 +2331,7 @@ gal_options_set_from_key(int key, char *arg, struct
argp_option *options,
/* Go through all the options and find the one that should keep this
value, then put its value into the appropriate key. Note that the
options array finishs with an all zero element, so we don't need to
- know the number before hand.*/
+ know the number before hand. */
for(i=0;1;++i)
{
/* Check if the key corresponds to this option. */
@@ -2480,7 +2480,7 @@ gal_options_check_stdin(char *inputname, long
stdintimeout, char *name)
/************ Configuration files ***************/
/**********************************************************************/
-/* Read the option and the argument from the line and return.*/
+/* Read the option and the argument from the line and return. */
static void
options_read_name_arg(char *line, char *filename, size_t lineno,
char **name, char **arg)
@@ -2496,7 +2496,7 @@ options_read_name_arg(char *line, char *filename, size_t
lineno,
switch(*line)
{
case ' ': case '=': case '\t': case '\v': case '\n': case '\r':
- if(inword) /* Only considered in a word, not in a quote*/
+ if(inword) /* Only considered in a word, not in a quote. */
{
inword=0;
*line='\0';
@@ -2573,7 +2573,7 @@ options_set_from_name(char *name, char *arg, struct
argp_option *options,
/* Go through all the options and find the one that should keep this
value, then put its value into the appropriate key. Note that the
options array finishs with an all zero element, so we don't need to
- know the number before hand.*/
+ know the number before hand. */
for(i=0;1;++i)
{
/* Check if the key corresponds to this option. */
@@ -2664,7 +2664,7 @@ options_parse_file(char *filename, struct
gal_options_common_params *cp,
fp=fopen(filename, "r");
if(fp==NULL)
{
- /* Print a warning */
+ /* Print a warning. */
if(warning && cp->quiet==0)
error(EXIT_SUCCESS, errno, "%s", filename);
return;
@@ -2699,7 +2699,7 @@ options_parse_file(char *filename, struct
gal_options_common_params *cp,
found there, 'options_set_from_name' will return 1. So the
condition will succeed and we will start looking into the
common options, if it isn't found there either, then report an
- error.*/
+ error. */
if( options_set_from_name(name, arg, cp->poptions, cp,
filename, lineno) )
if( options_set_from_name(name, arg, cp->coptions, cp,
@@ -2896,7 +2896,7 @@ gal_options_read_low_level_checks(struct
gal_options_common_params *cp)
-/* Read all configuration files and set common options */
+/* Read all configuration files and set common options. */
void
gal_options_read_config_set(struct gal_options_common_params *cp)
{
@@ -2905,7 +2905,7 @@ gal_options_read_config_set(struct
gal_options_common_params *cp)
/* Reverse the order of all linked list type options so the popping order
is the same as the user's input order. We need to do this here because
- when printing those options, their order matters.*/
+ when printing those options, their order matters. */
options_reverse_lists_check_mandatory(cp, cp->poptions);
options_reverse_lists_check_mandatory(cp, cp->coptions);
@@ -3115,12 +3115,12 @@ options_print_doc(FILE *fp, const char *doc, int
nvwidth)
else
{
/* If the break is in the middle of a word, then pull set it before
- the word starts.*/
+ the word starts. */
cwidth=width; while( doc[cwidth]!=' ' ) --cwidth;
fprintf(fp, "# %.*s\n", cwidth, doc);
i=cwidth;
- /* Go over the rest of the line */
+ /* Go over the rest of the line. */
while(i<len)
{
/* Remove any possible space before the first word. */
@@ -3154,7 +3154,7 @@ options_print_all_in_group(struct argp_option *options,
int groupint,
&& options[i].set /* Has been given a value. */
&& option_is_printable(&options[i]) ) /* Is relevant for printing.*/
{
- /* Linked lists */
+ /* Linked lists. */
if(gal_type_is_list(options[i].type))
for(tmp=*(gal_list_str_t **)(options[i].value);
tmp!=NULL; tmp=tmp->next)
@@ -3211,7 +3211,7 @@ options_print_all(struct gal_options_common_params *cp,
char *dirname,
/* Remove the file if it already exists. */
gal_checkset_writable_remove(filename, NULL, 0, 0);
- /* Open the file for writing */
+ /* Open the file for writing. */
errno=0;
fp=fopen(filename, "w");
if(fp==NULL)
@@ -3243,7 +3243,7 @@ options_print_all(struct gal_options_common_params *cp,
char *dirname,
the (possible) other groups are in the program specific options. We
will only be dealing with the 'topics' linked list in this function
and the strings in 'poption' are statically allocated, so its fine to
- not waste CPU cycles allocating and freeing.*/
+ not waste CPU cycles allocating and freeing. */
for(i=0; !gal_options_is_last(&coptions[i]); ++i)
if(coptions[i].name==NULL && coptions[i].key==0 && coptions[i].doc)
{
@@ -3298,7 +3298,7 @@ options_print_all(struct gal_options_common_params *cp,
char *dirname,
free(filename);
}
- /* Exit the program successfully */
+ /* Exit the program successfully. */
exit(EXIT_SUCCESS);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 06833a9e: Book: Minor edits and clarifications,
Mohammad Akhlaghi <=