LALPulsar  6.1.0.1-fe68b98
FITSFileIO.h File Reference

Prototypes

Open/Close FITS File, and Write History Information to Primary FITS Header-Data Unit

These functions open a FITS file file_name for writing or reading, and close a FITS file represented by file.

The current header-data unit (HDU) may be changed, either by seeking a named HDU or by returning to the primary (first) HDU. History information may also be written to the primary HDU.

void XLALFITSFileClose (FITSFile *file)
 
FITSFileXLALFITSFileOpenWrite (const CHAR *file_name)
 
FITSFileXLALFITSFileOpenRead (const CHAR *file_name)
 
int XLALFITSFileSeekPrimaryHDU (FITSFile *file)
 
int XLALFITSFileSeekNamedHDU (FITSFile *file, const CHAR *name)
 
int XLALFITSFileWriteHistory (FITSFile *file, const CHAR *format,...) _LAL_GCC_PRINTF_FORMAT_(2
 
int int XLALFITSFileWriteVCSInfo (FITSFile *file, const LALVCSInfoList vcs_list)
 
int XLALFITSFileWriteUVarCmdLine (FITSFile *file)
 
Query FITS Header-Data Unit

These function perform various queries of the current FITS header-data unit (HDU):

int XLALFITSHeaderQueryKeyExists (FITSFile *file, const CHAR *key, BOOLEAN *exists)
 
Write/Read Key-Value Pairs to/from FITS Header-Data Unit

These functions write/read key-value pairs (key, value) to/from a FITS header-data unit (HDU).

Scalar BOOLEAN, UINT2, UINT4, UINT8, INT2, INT4, INT8, REAL4, REAL8, COMPLEX8, and COMPLEX16 values, strings, string vectors (LALStringVector) and GPS times (LIGOTimeGPS) can be written and read. A comment string describing the value is required when writing to an HDU, and an arbitrary formatted comment string can also be written. Units for numeric header values may be specified in square brackets after the header key, e.g. "freq [Hz]".

There are some usage restrictions:

  • When writing to or reading from the primary HDU, these functions can be used as soon as the FITS file is opened.
  • When writing to an extension HDU containing an array or table, these functions can only be used after data has been written to the array or table.
  • When reading from an extension HDU containing an array or table, these functions can only be used after the array or table is opened for reading.
int XLALFITSHeaderWriteComment (FITSFile *file, const CHAR *format,...) _LAL_GCC_PRINTF_FORMAT_(2
 
int int XLALFITSHeaderWriteBOOLEAN (FITSFile *file, const CHAR *key, const BOOLEAN value, const CHAR *comment)
 
int XLALFITSHeaderReadBOOLEAN (FITSFile *file, const CHAR *key, BOOLEAN *value)
 
int XLALFITSHeaderWriteUINT2 (FITSFile *file, const CHAR *key, const UINT2 value, const CHAR *comment)
 
int XLALFITSHeaderReadUINT2 (FITSFile *file, const CHAR *key, UINT2 *value)
 
int XLALFITSHeaderWriteUINT4 (FITSFile *file, const CHAR *key, const UINT4 value, const CHAR *comment)
 
int XLALFITSHeaderReadUINT4 (FITSFile *file, const CHAR *key, UINT4 *value)
 
int XLALFITSHeaderWriteUINT8 (FITSFile *file, const CHAR *key, const UINT8 value, const CHAR *comment)
 
int XLALFITSHeaderReadUINT8 (FITSFile *file, const CHAR *key, UINT8 *value)
 
int XLALFITSHeaderWriteINT2 (FITSFile *file, const CHAR *key, const INT2 value, const CHAR *comment)
 
int XLALFITSHeaderReadINT2 (FITSFile *file, const CHAR *key, INT2 *value)
 
int XLALFITSHeaderWriteINT4 (FITSFile *file, const CHAR *key, const INT4 value, const CHAR *comment)
 
int XLALFITSHeaderReadINT4 (FITSFile *file, const CHAR *key, INT4 *value)
 
int XLALFITSHeaderWriteINT8 (FITSFile *file, const CHAR *key, const INT8 value, const CHAR *comment)
 
int XLALFITSHeaderReadINT8 (FITSFile *file, const CHAR *key, INT8 *value)
 
int XLALFITSHeaderWriteREAL4 (FITSFile *file, const CHAR *key, const REAL4 value, const CHAR *comment)
 
int XLALFITSHeaderReadREAL4 (FITSFile *file, const CHAR *key, REAL4 *value)
 
int XLALFITSHeaderWriteREAL8 (FITSFile *file, const CHAR *key, const REAL8 value, const CHAR *comment)
 
int XLALFITSHeaderReadREAL8 (FITSFile *file, const CHAR *key, REAL8 *value)
 
int XLALFITSHeaderWriteCOMPLEX8 (FITSFile *file, const CHAR *key, const COMPLEX8 value, const CHAR *comment)
 
int XLALFITSHeaderReadCOMPLEX8 (FITSFile *file, const CHAR *key, COMPLEX8 *value)
 
int XLALFITSHeaderWriteCOMPLEX16 (FITSFile *file, const CHAR *key, const COMPLEX16 value, const CHAR *comment)
 
int XLALFITSHeaderReadCOMPLEX16 (FITSFile *file, const CHAR *key, COMPLEX16 *value)
 
int XLALFITSHeaderWriteString (FITSFile *file, const CHAR *key, const CHAR *value, const CHAR *comment)
 
int XLALFITSHeaderReadString (FITSFile *file, const CHAR *key, CHAR **value)
 
int XLALFITSHeaderWriteStringVector (FITSFile *file, const CHAR *key, const LALStringVector *values, const CHAR *comment)
 
int XLALFITSHeaderReadStringVector (FITSFile *file, const CHAR *key, LALStringVector **values)
 
int XLALFITSHeaderWriteGPSTime (FITSFile *file, const CHAR *key, const LIGOTimeGPS *value, const CHAR *comment)
 
int XLALFITSHeaderReadGPSTime (FITSFile *file, const CHAR *key, LIGOTimeGPS *value)
 
Write/Read Array to/from FITS File

These function write/read arbitrary-dimensional array to/from a FITS image extension data unit.

A call to XLALFITSArrayOpenWrite() or XLALFITSArrayOpenRead() is required first to write/read the dimension count ndim and sizes dims[]; the functions XLALFITSArrayOpenWriteN() and XLALFITSArrayOpenReadN() are convenience functions for 1- and 2-dimensional arrays. The functions XLALFITSArrayWriteTYPE() and XLALFITSArrayReadTYPE() are then used to write scalar UINT2, UINT4, UINT8, INT2, INT4, INT8, REAL4, and REAL8 values to the array element indexed by idx. For the convenience the functions XLALFITSArrayWriteGSLMatrix() and XLALFITSArrayReadGSLMatrix() exist for writing/reading elements to/from a gsl_matrix.

int XLALFITSArrayOpenWrite (FITSFile *file, const CHAR *name, const size_t ndim, const size_t dims[], const CHAR *comment)
 
int XLALFITSArrayOpenRead (FITSFile *file, const CHAR *name, size_t *ndim, size_t dims[])
 
int XLALFITSArrayOpenWrite1 (FITSFile *file, const CHAR *name, const size_t dim0, const CHAR *comment)
 
int XLALFITSArrayOpenRead1 (FITSFile *file, const CHAR *name, size_t *dim0)
 
int XLALFITSArrayOpenWrite2 (FITSFile *file, const CHAR *name, const size_t dim0, const size_t dim1, const CHAR *comment)
 
int XLALFITSArrayOpenRead2 (FITSFile *file, const CHAR *name, size_t *dim0, size_t *dim1)
 
int XLALFITSArrayWriteUINT2 (FITSFile *file, const size_t idx[], const UINT2 elem)
 
int XLALFITSArrayReadUINT2 (FITSFile *file, const size_t idx[], UINT2 *elem)
 
int XLALFITSArrayWriteUINT4 (FITSFile *file, const size_t idx[], const UINT4 elem)
 
int XLALFITSArrayReadUINT4 (FITSFile *file, const size_t idx[], UINT4 *elem)
 
int XLALFITSArrayWriteUINT8 (FITSFile *file, const size_t idx[], const UINT8 elem)
 
int XLALFITSArrayReadUINT8 (FITSFile *file, const size_t idx[], UINT8 *elem)
 
int XLALFITSArrayWriteINT2 (FITSFile *file, const size_t idx[], const INT2 elem)
 
int XLALFITSArrayReadINT2 (FITSFile *file, const size_t idx[], INT2 *elem)
 
int XLALFITSArrayWriteINT4 (FITSFile *file, const size_t idx[], const INT4 elem)
 
int XLALFITSArrayReadINT4 (FITSFile *file, const size_t idx[], INT4 *elem)
 
int XLALFITSArrayWriteINT8 (FITSFile *file, const size_t idx[], const INT8 elem)
 
int XLALFITSArrayReadINT8 (FITSFile *file, const size_t idx[], INT8 *elem)
 
int XLALFITSArrayWriteREAL4 (FITSFile *file, const size_t idx[], const REAL4 elem)
 
int XLALFITSArrayReadREAL4 (FITSFile *file, const size_t idx[], REAL4 *elem)
 
int XLALFITSArrayWriteREAL8 (FITSFile *file, const size_t idx[], const REAL8 elem)
 
int XLALFITSArrayReadREAL8 (FITSFile *file, const size_t idx[], REAL8 *elem)
 
int XLALFITSArrayWriteGSLMatrix (FITSFile *file, const size_t idx[], const gsl_matrix *elems)
 
int XLALFITSArrayReadGSLMatrix (FITSFile *file, const size_t idx[], gsl_matrix **elems)
 

Go to the source code of this file.

General Definitions

#define FFIO_MAX   999
 Maximum possible number of FITS array dimensions, and FITS table columns. More...
 
typedef struct tagFITSFile FITSFile
 Representation of a FITS file. More...
 

Write/Read Table to/from FITS File

These functions write/read arbitrary tables to/from a FITS binary table extension data unit.

A call to XLALFITSTableOpenWrite() or XLALFITSTableOpenRead() is required first; the latter returns the number of rows in the table nrows, if needed. The table columns must then be specified using the XLAL_FITS_TABLE_COLUMN_...() macros:

First, XLAL_FITS_TABLE_COLUMN_BEGIN(record_type) is called, where record_type is the name of a C structure that will store the values of the columns written to or read from the table. For example:

typedef struct { INT4 index; CHAR name[32]; REAL4 x; } Row
const char * name
Definition: SearchTiming.c:93
#define XLAL_FITS_TABLE_COLUMN_BEGIN(record_type)
Definition: FITSFileIO.h:239
char CHAR
int32_t INT4
float REAL4

Next, XLAL_FITS_TABLE_COLUMN_ADD(file, type, field) is called, where file is the FITS file, type is the C type of the field in record_type, and field is the C structure field. For array fields, including fixed-length strings, XLAL_FITS_TABLE_COLUMN_ADD_ARRAY(file, type, field) should be used instead. An alternative name for the FITS table column can be specified using XLAL_FITS_TABLE_COLUMN_ADD_NAMED(file, type, field, col_name). For example:

#define XLAL_FITS_TABLE_COLUMN_ADD_NAMED(file, type, field, col_name)
Definition: FITSFileIO.h:246
#define XLAL_FITS_TABLE_COLUMN_ADD_ARRAY(file, type, field)
Definition: FITSFileIO.h:249
#define XLAL_FITS_TABLE_COLUMN_ADD(file, type, field)
Definition: FITSFileIO.h:243

The XLAL_FITS_TABLE_COLUMN_PTR_ARRAY_...() macros are for pointers to C arrays, and the XLAL_FITS_TABLE_COLUMN_PTR_STRUCT_...() macros are for more complicated C structures which contain pointers to other C structures. Units for numeric columns may be specified in square brackets after the column name, e.g. "freq [Hz]".

Finally, XLALFITSTableWriteRow() or XLALFITSTableReadRow() are called to write/read table rows; the latter returns the number of rows remaining in the table rem_nrows, if needed.

#define XLAL_FITS_TABLE_COLUMN_BEGIN(record_type)
 
#define XLAL_FITS_TABLE_COLUMN_ADD(file, type, field)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_NAMED(file, type, field, col_name)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_ARRAY(file, type, field)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_ARRAY_NAMED(file, type, field, col_name)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_ARRAY2(file, type, field)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_ARRAY2_NAMED(file, type, field, col_name)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_PTR_ARRAY(file, type, length, field)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_PTR_ARRAY_NAMED(file, type, length, field, col_name)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_PTR_ARRAY2(file, type, length, field)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_PTR_ARRAY2_NAMED(file, type, length, field, col_name)
 
#define XLAL_FITS_TABLE_COLUMN_PTR_STRUCT_BEGIN(field, ptr_record_type, length)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_PTR_STRUCT_NAMED(file, index, type, field, col_name)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_PTR_STRUCT_ARRAY_NAMED(file, index, type, field, col_name)
 
#define XLAL_FITS_TABLE_COLUMN_ADD_PTR_STRUCT_ARRAY2_NAMED(file, index, type, field, col_name)
 
int XLALFITSTableOpenWrite (FITSFile *file, const CHAR *name, const CHAR *comment)
 
int XLALFITSTableOpenRead (FITSFile *file, const CHAR *name, UINT8 *nrows)
 
int XLALFITSTableWriteRow (FITSFile *file, const void *record)
 
int XLALFITSTableReadRow (FITSFile *file, void *record, UINT8 *rem_nrows)