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.
Return 1 if the given file name corresponds to one of the recognized file types for reading arrays.
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.
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).
Read the array within the given extension (
filename, or the
lines list (see below). If the array is
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
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
pointer of the returned
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
lines are mutually
exclusive and one of them must be
gal_array_read, but the output data structure(s) will
have a numeric data type of
type, see Numeric data types.
Read the dataset within
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.