GNU Astronomy Utilities


Next: , Previous: , Up: FITS files   [Contents][Index]


10.3.8.2 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 Library data types (type.h) and are usable for all kinds of datasets (images, table columns and etc) as part of Gnuastro’s Generic data container (gal_data_t). However, following the FITS standard, CFITSIO has different identifiers for images and tables. Following CFITSIO’s own convention, we will use bitpix for image type identifiers and 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 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 correspondence between CFITSIO and Gnuastro’s types.

Function:
uint8_t
gal_fits_bitpix_to_type (int bitpix)

Return the Gnuastro type identifier that corresponds to CFITSIO’s bitpix on this system.

Function:
int
gal_fits_type_to_bitpix (uint8_t type)

Return the CFITSIO bitpix value that corresponds to Gnuastro’s type.

Function:
char
gal_fits_type_to_bin_tform (uint8_t type)

Return the FITS standard binary table TFORM character that corresponds to Gnuastro’s type.

Function:
int
gal_fits_type_to_datatype (uint8_t type)

Return the CFITSIO datatype that corresponds to Gnuastro’s type on this machine.

Function:
uint8_t
gal_fits_datatype_to_type (int datatype, int is_table_column)

Return Gnuastro’s type identifier that corresponds to the CFITSIO datatype. Note that when dealing with CFITSIO’s 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 is_table_column.


Next: , Previous: , Up: FITS files   [Contents][Index]