Main Page   Compound List   File List   Compound Members   File Members  

mfitsio.h File Reference

#include "mex.h"
#include "matrix.h"
#include <fitsio.h>

Go to the source code of this file.

Compounds

struct  mfitsio_header
 This structure stores an entire extracted header. More...

struct  mfitsio_info
 This structure stores information about a FITS data array or a MATLAB image. More...

struct  mfitsio_record
 This structure holds keyword information extracted from a FITS file header. More...


Defines

#define MFITSIO_WARN   mexWarnMsgTxt
 Macro specifies which function to execute when a warning is reported. More...

#define MFITSIO_ERR   mexErrMsgTxt
 Macro specifies which function to execute when an error is reported. More...

#define MFITSIO_PRINTF   mexPrintf
 Macro specifies which function to execute when writing standard text. More...

#define MFITSIO_FREE   free
 Macro specifies which function to execute when freeing memory. More...

#define MFITSIO_MALLOC   malloc
 Macro specifies which function to execute when allocating memory using the malloc invocation syntax. More...

#define MFITSIO_CALLOC   calloc
 Macro specifies which function to execute when allocating memory using the calloc invocation syntax. More...

#define MFITSIO_READONLY   READONLY
 Macro specifies which status flag should be used for functions which only read to a FITS image. More...

#define MFITSIO_READWRITE   READWRITE
 Macro specifies which status flag should be used for functions which only read and write to a FITS image. More...


Functions

void mfitsio_free_record (mfitsio_record *record)
 Deallocates a mfitsio_record structure. More...

void mfitsio_free_header (mfitsio_header *header)
 Deallocates a mfitsio_header structure. More...

void mfitsio_free_info (mfitsio_info *info)
 Deallocates a mfitsio_info structure. More...

mfitsio_recordmfitsio_parse_card (const char *cardtext)
 Parses a fits header "card". More...

mfitsio_headermfitsio_read_header (const char *filename)
 Reads a header from a fits file. More...

mxArray * mfitsio_adapt_frecord (const mfitsio_record *record)
 Adapts a mfitsio_record structure into a MATLAB variable. More...

mxArray * mfitsio_adapt_fheader (const mfitsio_header *record)
 Adapts a mfitsio_header structure into a MATLAB struct array. More...

mfitsio_infomfitsio_read_info (const char *filename)
 The dimensions and bitpix are acquired from the FITS file header. More...

mxArray * mfitsio_read_image (const char *filename, const mfitsio_info *info)
 Read a FITS image and store the result in a MATLAB array. More...

mxArray * mfitsio_read_image_impl (const char *filename, const mfitsio_info *info, long *fpixels, long *lpixels, long *lnaxes, long *inc)
 Read a FITS image and store the result in a MATLAB array. More...

void mfitsio_write_image (const char *filename, const mxArray *header, mxArray *img)
 Write a MATLAB array/image to a FITS file. More...

void mfitsio_write_image_impl (const char *filename, const mxArray *header, mxArray *img, long *fpixels, long *lpixels, long *lnaxes, long *inc, mfitsio_info *info)
 Write a MATLAB array/image to a FITS file. More...

void mfitsio_write_header (const char *filename, const mxArray *header)
 Write header information stored in a MATLAB struct array to a FITS file. More...

void mfitsio_delete_keyword (const char *filename, const char *keyword)
 Delete a record from a header in a FITS file. More...

mfitsio_infomfitsio_calc_info (const mxArray *img)
 Calculate bitpix and dimension information from a MATLAB image. More...

void mfitsio_write_info (fitsfile *fptr, const mfitsio_info *info)
 Write bitpix and dimension information to a FITS header. More...

int mfitsio_is_scalar (const mxArray *array)
 Determine whether the MATLAB array is singleton. More...

int mfitsio_forbidden (const char *s)
 This function determines whether modifying a certain header keyword is allowed. More...

mxArray * mfitsio_get_mfield (const mxArray *array, int index, const char *field_name)
 A wrapper function for mxGetField. More...

double mfitsio_get_mscalar (const mxArray *array)
 A wrapper function for mxGetScalar. More...

void mfitsio_check_coordinate (const mxArray *crd1, const mxArray *crd2, const int naxis, const int *naxes)
 Checks for validity of starting and ending pixel coordinates. More...

void mfitsio_check_size_info (const mxArray *crd1)
 Checks for validity of size information. More...

long * mfitsio_convert_dbl2long (const double *dbl, const int size)
 Converts a double array to a long array. More...

long * mfitsio_convert_int2long (const int *in, const int size)
 Converts an int array to a long array. More...

long * mfitsio_create_ones_vector (const int size)
 Creates a one vector of a particular size. More...

int * mfitsio_get_region_size (const long *crd1, const long *crd2, const int naxis)
 Computes the size of a region defined by two coordinates. More...

mxArray * mfitsio_get_lpixels (const mxArray *spixels, const mxArray *img, int naxis)
 Computes the ending pixel value based on the starting pixel. More...

void mfitsio_write_image_execute (fitsfile *file, mxArray *img, long group, long naxis, long *naxes, long *fpixel, long *lpixel, int *status)
 Close the FITS file. More...

mxArray * mfitsio_read_image_execute (const mfitsio_info *info, int *diff, fitsfile *fptr, int group, int naxis, long *lnaxes, long *fpixel, long *lpixel, long *inc, int *anynul, int *status)
 Return the resultant image. More...


Define Documentation

#define MFITSIO_CALLOC   calloc
 

Macro specifies which function to execute when allocating memory using the calloc invocation syntax.

Definition at line 51 of file mfitsio.h.

Referenced by mfitsio_adapt_fheader, and mfitsio_write_header.

#define MFITSIO_ERR   mexErrMsgTxt
 

Macro specifies which function to execute when an error is reported.

Definition at line 37 of file mfitsio.h.

Referenced by mfitsio_adapt_fheader, mfitsio_calc_info, mfitsio_check_coordinate, mfitsio_check_size_info, mfitsio_delete_keyword, mfitsio_get_mfield, mfitsio_read_header, mfitsio_read_image_execute, mfitsio_read_image_impl, mfitsio_read_info, mfitsio_write_header, mfitsio_write_image_execute, mfitsio_write_image_impl, and mfitsio_write_info.

#define MFITSIO_FREE   free
 

Macro specifies which function to execute when freeing memory.

Definition at line 43 of file mfitsio.h.

Referenced by mexFunction, mfitsio_free_header, mfitsio_free_info, mfitsio_free_record, mfitsio_read_header, mfitsio_read_image, mfitsio_read_image_impl, mfitsio_read_info, and mfitsio_write_image.

#define MFITSIO_MALLOC   malloc
 

Macro specifies which function to execute when allocating memory using the malloc invocation syntax.

Definition at line 47 of file mfitsio.h.

Referenced by mfitsio_adapt_fheader, mfitsio_adapt_frecord, mfitsio_calc_info, mfitsio_convert_dbl2long, mfitsio_convert_int2long, mfitsio_create_ones_vector, mfitsio_get_region_size, mfitsio_logical_m2f, mfitsio_parse_card, mfitsio_read_header, mfitsio_read_image, mfitsio_read_info, and mfitsio_write_image.

#define MFITSIO_PRINTF   mexPrintf
 

Macro specifies which function to execute when writing standard text.

Definition at line 40 of file mfitsio.h.

Referenced by mfitsio_calc_info, mfitsio_check_coordinate, mfitsio_check_size_info, mfitsio_delete_keyword, mfitsio_get_mfield, mfitsio_read_header, mfitsio_read_image_execute, mfitsio_read_image_impl, mfitsio_read_info, mfitsio_write_header, mfitsio_write_image_execute, mfitsio_write_image_impl, and mfitsio_write_info.

#define MFITSIO_READONLY   READONLY
 

Macro specifies which status flag should be used for functions which only read to a FITS image.

Definition at line 56 of file mfitsio.h.

Referenced by mfitsio_read_header, mfitsio_read_image_impl, and mfitsio_read_info.

#define MFITSIO_READWRITE   READWRITE
 

Macro specifies which status flag should be used for functions which only read and write to a FITS image.

Definition at line 61 of file mfitsio.h.

Referenced by mfitsio_delete_keyword, mfitsio_write_header, and mfitsio_write_image_impl.

#define MFITSIO_WARN   mexWarnMsgTxt
 

Macro specifies which function to execute when a warning is reported.

Definition at line 34 of file mfitsio.h.

Referenced by mfitsio_write_header.


Function Documentation

mxArray* mfitsio_adapt_fheader const mfitsio_header   header
 

Adapts a mfitsio_header structure into a MATLAB struct array.

Parameters:
header  The header to adapt.
Returns:
A MATLAB struct object corresponding to the parsed mfitsio_header.

Definition at line 445 of file mfitsio.c.

Referenced by mexFunction.

mxArray* mfitsio_adapt_frecord const mfitsio_record   record
 

Adapts a mfitsio_record structure into a MATLAB variable.

The syntax of the text of the value determines the type of the MATLAB variable.

Parameters:
record  The record to adapt.
Returns:
A MATLAB variable.

Definition at line 328 of file mfitsio.c.

mfitsio_info* mfitsio_calc_info const mxArray *    img
 

Calculate bitpix and dimension information from a MATLAB image.

Parameters:
img  The MATLAB array where the image is stored.
Returns:
A mfitsio_info struct containing the bitpix and dimension information.

Definition at line 1190 of file mfitsio.c.

Referenced by mfitsio_write_image.

void mfitsio_check_coordinate const mxArray *    crd1,
const mxArray *    crd2,
const int    naxis,
const int *    naxes
 

Checks for validity of starting and ending pixel coordinates.

In particular, pixels must be within the range defined by the NAXES keywords and a region along a particular axis profile must not begin at the ending coordinate.

Parameters:
crd1  The starting coordinate.
crd2  The ending coordinate.
naxis  The number of axes.
naxes  The size of each axis.

Definition at line 1380 of file mfitsio.c.

Referenced by mexFunction.

void mfitsio_check_size_info const mxArray *    size_unit
 

Checks for validity of size information.

The NAXIS and NAXES information must be non-negative.

Parameters:
size_unit  The size unit as a row vector.

Definition at line 1456 of file mfitsio.c.

long* mfitsio_convert_dbl2long const double *    dbl,
const int    size
 

Converts a double array to a long array.

Parameters:
dbl  The array to convert.
size  The size of the array to convert.
Returns:
The converted array.

Definition at line 1493 of file mfitsio.c.

Referenced by mexFunction.

long* mfitsio_convert_int2long const int *    in,
const int    size
 

Converts an int array to a long array.

Parameters:
in  The array to convert.
size  The size of the array to convert.
Returns:
The converted array.

Definition at line 1511 of file mfitsio.c.

Referenced by mexFunction.

long* mfitsio_create_ones_vector const int    size
 

Creates a one vector of a particular size.

Parameters:
size  The size of the ones array to create.
Returns:
The converted array.

Definition at line 1528 of file mfitsio.c.

Referenced by mexFunction.

void mfitsio_delete_keyword const char *    filename,
const char *    keyword
 

Delete a record from a header in a FITS file.

Parameters:
filename  The filename of the FITS file.
keyword  The keyword of the record to delete.

Definition at line 905 of file mfitsio.c.

Referenced by mexFunction.

int mfitsio_forbidden const char *    s
 

This function determines whether modifying a certain header keyword is allowed.

The reason for checking is that we do not want users modifying NAXIS, BITPIX, and other important headers as they can be calculated from a MATLAB image. Thus, the situation where the dimension and bitpix keywords differ from the stored image is avoided.

Parameters:
array  The MATLAB variable to check for singleton dimensions.
Returns:
True is the array is a scalar.

Definition at line 1297 of file mfitsio.c.

Referenced by mfitsio_delete_keyword, and mfitsio_write_header.

void mfitsio_free_header mfitsio_header   header
 

Deallocates a mfitsio_header structure.

Parameters:
header  The record you wish to deallocate.

Definition at line 67 of file mfitsio.c.

Referenced by mexFunction.

void mfitsio_free_info mfitsio_info   info
 

Deallocates a mfitsio_info structure.

Parameters:
info  The info you wish to deallocate.

Definition at line 84 of file mfitsio.c.

Referenced by mexFunction, and mfitsio_write_image.

void mfitsio_free_record mfitsio_record   record
 

Deallocates a mfitsio_record structure.

Parameters:
record  The record you wish to deallocate.

Definition at line 54 of file mfitsio.c.

Referenced by mfitsio_free_header.

mxArray* mfitsio_get_lpixels const mxArray *    spixels,
const mxArray *    img,
int    naxis
 

Computes the ending pixel value based on the starting pixel.

Parameters:
spixels  The starting pixel.
img  The image.
naxis  The number of axes.
Returns:
The size of the region as an array.

Definition at line 1568 of file mfitsio.c.

Referenced by mexFunction.

mxArray* mfitsio_get_mfield const mxArray *    array,
int    index,
const char *    field_name
 

A wrapper function for mxGetField.

Whenever a field cannot be retrieved, an error is reported and execution aborts.

Parameters:
array  The MATLAB struct array.
index  The index for the record.
field_name  The key for the record.
Returns:
The value of the field requested.

Definition at line 1334 of file mfitsio.c.

double mfitsio_get_mscalar const mxArray *    array
 

A wrapper function for mxGetScalar.

Whenever a scalar cannot be retrieved, zero is returned.

Parameters:
array  The MATLAB struct array.
index  The index for the record.
field_name  The key for the record.
Returns:
The numeric value as a double.

Definition at line 1364 of file mfitsio.c.

Referenced by mfitsio_get_mscalar, and mfitsio_write_header.

int* mfitsio_get_region_size const long *    crd1,
const long *    crd2,
const int    naxis
 

Computes the size of a region defined by two coordinates.

Parameters:
crd1  The starting coordinate.
crd2  The ending coordinate.
naxis  The number of axes.
Returns:
The size of the region as an array.

Definition at line 1547 of file mfitsio.c.

Referenced by mfitsio_read_image_impl.

int mfitsio_is_scalar const mxArray *    array
 

Determine whether the MATLAB array is singleton.

Parameters:
array  The MATLAB variable to check for singleton dimensions.
Returns:
True is the array is a scalar.

Definition at line 1260 of file mfitsio.c.

Referenced by mfitsio_write_header.

mfitsio_record* mfitsio_parse_card const char *    cardtext
 

Parses a fits header "card".

Comments are ignored. A mfitsio_record structure is returned. When this structure is no longer needed, it should be deallocated.

Parameters:
cardtext  The text of the fits header card.
Returns:
A mfitsio_record structure containing the key and value which was parsed from the card. NULL is returned if the field is to be ignored or if the card is a comment line.

Definition at line 104 of file mfitsio.c.

Referenced by mfitsio_read_header.

mfitsio_header* mfitsio_read_header const char *    filename
 

Reads a header from a fits file.

Before the result of this function can be used by MATLAB, the header must be adapted to a MATLAB struct array using mfitsio_adapt_fheader function.

Parameters:
filename  The filename of the fits file to read.
Returns:
A mfitsio_header structure acquired by reading the header in the fits file.

Definition at line 223 of file mfitsio.c.

Referenced by mexFunction.

mxArray* mfitsio_read_image const char *    filename,
const mfitsio_info   info
 

Read a FITS image and store the result in a MATLAB array.

Parameters:
filename  The filename of the FITS image.
info  The dimensions and bitpix of the image.
Returns:
A mfitsio_info struct containing the information.

Definition at line 572 of file mfitsio.c.

Referenced by mexFunction.

mxArray* mfitsio_read_image_execute const mfitsio_info   info,
int *    diff,
fitsfile *    fptr,
int    group,
int    naxis,
long *    lnaxes,
long *    fpixel,
long *    lpixel,
long *    inc,
int *    anynul,
int *    status
 

Return the resultant image.

Definition at line 646 of file mfitsio.c.

Referenced by mfitsio_read_image_impl.

mxArray* mfitsio_read_image_impl const char *    filename,
const mfitsio_info   info,
long *    fpixels,
long *    lpixels,
long *    lnaxes,
long *    inc
 

Read a FITS image and store the result in a MATLAB array.

Parameters:
filename  The filename of the FITS image.
info  The dimensions and bitpix of the image.
Returns:
A mfitsio_info struct containing the information.

Definition at line 607 of file mfitsio.c.

Referenced by mexFunction, and mfitsio_read_image.

mfitsio_info* mfitsio_read_info const char *    filename
 

The dimensions and bitpix are acquired from the FITS file header.

Parameters:
filename  The filename of the FITS file.
Returns:
A mfitsio_info struct containing the information.

Definition at line 503 of file mfitsio.c.

Referenced by mexFunction.

void mfitsio_write_header const char *    filename,
const mxArray *    header
 

Write header information stored in a MATLAB struct array to a FITS file.

Parameters:
filename  The filename of the FITS file.
header  The MATLAB struct array containing the information.

Definition at line 951 of file mfitsio.c.

Referenced by mexFunction, and mfitsio_write_image_impl.

void mfitsio_write_image const char *    filename,
const mxArray *    header,
mxArray *    img
 

Write a MATLAB array/image to a FITS file.

Parameters:
filename  The filename of the FITS file.
info  The MATLAB struct array representing the keywords to store.
img  The MATLAB array/image to store in the FITS file.

Definition at line 704 of file mfitsio.c.

Referenced by mexFunction.

void mfitsio_write_image_execute fitsfile *    file,
mxArray *    img,
long    group,
long    naxis,
long *    naxes,
long *    fpixel,
long *    lpixel,
int *    status
 

Close the FITS file.

Definition at line 825 of file mfitsio.c.

Referenced by mfitsio_write_image_impl.

void mfitsio_write_image_impl const char *    filename,
const mxArray *    header,
mxArray *    img,
long *    fpixels,
long *    lpixels,
long *    lnaxes,
long *    inc,
mfitsio_info   info
 

Write a MATLAB array/image to a FITS file.

Parameters:
filename  The filename of the FITS file.
info  The MATLAB struct array representing the keywords to store.
img  The MATLAB array/image to store in the FITS file.
fpixels  The starting pixel coordinates.
lpixels  The ending pixel coordinates.
lnaxes  The

Definition at line 751 of file mfitsio.c.

Referenced by mexFunction, and mfitsio_write_image.

void mfitsio_write_info fitsfile *    fptr,
const mfitsio_info   info
 

Write bitpix and dimension information to a FITS header.

Parameters:
filename  The filename of the FITS file.
info  The mfitsio_info struct containing the dimension and bitpix information.

Definition at line 1145 of file mfitsio.c.



Operated by University of California for the National Nuclear Security Administration of the US Department of Energy. Copyright © 2002-2003 UC | Disclaimer/Privacy
This website has been approved for unlimited release with associated LA-UR number LA-UR-03-0949.