Getting arrays (commonly images or cubes) from a file into your program or writing them after the processing into an output file are some of the most common operations. The functions in this section are designed for such operations with the known file types. The functions here are thus just wrappers around functions of lower-level file type functions of this library, for example, FITS files (fits.h) or TIFF files (tiff.h). If the file type of the input/output file is already known, you can use the functions in those sections respectively.
int
(char *filename
)
¶Return 1 if the given file name corresponds to one of the recognized file types for reading arrays.
int
(char *filename
)
¶Return 1 if the given file name corresponds to one of the recognized file types for reading arrays which may contain multiple extensions (for example FITS or TIFF) formats.
int
(char *filename
)
¶Similar to gal_array_name_recognized
, but for FITS files, it will also check the contents of the file if the recognized file name suffix is not found.
See the description of gal_fits_file_recognized
for more (FITS Macros, errors and filenames).
gal_data_t
(char *filename
, char *extension
, gal_list_str_t *lines
, size_t minmapsize
, int quietmmap
)
¶Read the array within the given extension (extension
) of
filename
, or the lines
list (see below). If the array is
larger than minmapsize
bytes, then it will not be read into RAM, but a
file on the HDD/SSD (no difference for the programmer). Messages about the
memory-mapped file can be disabled with quietmmap
.
extension
will be ignored for files that do not support them (for
example JPEG or text). For FITS files, extension
can be a number or
a string (name of the extension), but for TIFF files, it has to be
number. In both cases, counting starts from zero.
For multi-channel formats (like RGB images in JPEG or TIFF), this function
will return a List of gal_data_t
: one data structure per
channel. Thus if you just want a single array (and want to check if the
user has not given a multi-channel input), you can check the next
pointer of the returned gal_data_t
.
lines
is a list of strings with each node representing one line
(including the new-line character), see List of strings. It will
mostly be the output of gal_txt_stdin_read
, which is used to read
the program’s input as separate lines from the standard input (see
Text files (txt.h)). Note that filename
and lines
are mutually
exclusive and one of them must be NULL
.
void
(char *filename
, char *extension
, gal_list_str_t *lines
, uint8_t type
, size_t minmapsize
, int quietmmap
)
¶Similar to gal_array_read
, but the output data structure(s) will
have a numeric data type of type
, see Numeric data types.
void
(char *filename
, char *extension
, gal_list_str_t *lines
, size_t minmapsize
, int quietmmap
)
¶Read the dataset within filename
(extension/hdu/dir
extension
) and make sure it is only a single channel. This is just a
simple wrapper around gal_array_read
that checks if there was more
than one dataset and aborts with an informative error if there is more than
one channel in the dataset.
Formats like JPEG or TIFF support multiple channels per input, but it may happen that your program only works on a single dataset. This function can be a convenient way to make sure that the data that comes into your program is only one channel.
void
(char *filename
, char *extension
, gal_list_str_t *lines
, uint8_t type
, size_t minmapsize
, int quietmmap
)
¶Similar to gal_array_read_one_ch
, but the output data structure will
has a numeric data type of type
, see Numeric data types.
GNU Astronomy Utilities 0.20 manual, April 2023.