mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
mx::fits::fitsFile< dataT, verboseT > Class Template Reference

template<typename dataT, class verboseT = verbose::d>
class mx::fits::fitsFile< dataT, verboseT >

Class to manage interactions with a FITS file.

This class wraps the functionality of cfitsio.

Template Parameters
dataTis the datatype to use for in-memory storage of the image. This does not have to match the data type stored on disk for reading, but will be the type used for writing.

Definition at line 52 of file fitsFile.hpp.

#include <ioutils/fits/fitsFile.hpp>

Inherited by mx::unitTest::fitsTest::fitsFileTest::fitsFile_test< dataT >.

Public Member Functions

 fitsFile ()
 Default constructor.
 
 fitsFile (error_t &errc)
 Default constructor with error code.
 
 fitsFile (const std::string &fname, error_t &errc)
 Constructor with file name and error code.
 
 fitsFile (const std::string &fname, bool doopen=true)
 Constructor with file name, and option to open.
 
 fitsFile (const std::string &fname, bool doopen, error_t &errc)
 Constructor with file name, option to open, and error code.
 
 ~fitsFile ()
 Destructor.
 
std::string fileName ()
 Get the current value of m_fileName.
 
error_t fileName (const std::string &fname, bool doopen=true)
 Set the file path, and optionally open the file.
 
int naxis ()
 Get the current value of m_naxis.
 
long naxes (int dim)
 Get the current value of m_naxes for the specified dimension.
 
error_t open ()
 Open the file and gets its dimensions.
 
error_t open (const std::string &fname)
 Open the file, first setting the file path.
 
error_t close ()
 Close the file.
 
int getDimensions (error_t &errc)
 Get the number of dimensions (i.e. m_naxis)
 
long getSize (error_t &errc)
 Get the total size.
 
long getSize (size_t axis, error_t &errc)
 Get the size of a specific dimension.
 
Reading Eigen Arrays

These methods read FITS data into array types with an Eigen-like interface.

template<typename arrT >
error_t read (arrT &data)
 Read the contents of the FITS file into an Eigen array type (not a simple pointer).
 
template<typename arrT >
error_t read (arrT &data, fitsHeader< verboseT > &head)
 Read the contents of the FITS file into an Eigen array type (not a simple pointer).
 
template<typename arrT >
error_t read (arrT &data, const std::string &fname)
 Read the contents of the FITS file into an Eigen array type (not a simple pointer).
 
template<typename arrT >
error_t read (arrT &data, fitsHeader< verboseT > &head, const std::string &fname)
 Read the contents of the FITS file into an Eigen array type (not a simple pointer).
 
template<typename cubeT >
error_t read (cubeT &cube, const std::vector< std::string > &flist, std::vector< fitsHeader< verboseT > > *heads=0)
 Read data from a vector list of files into an image cube.
 
template<typename cubeT >
error_t read (cubeT &cube, std::vector< fitsHeader< verboseT > > &heads, const std::vector< std::string > &flist)
 Read data from a vector of files into an image cube with individual headers.
 
Reading Headers
error_t readHeader (fitsHeader< verboseT > &head)
 Read the header from the fits file.
 
error_t readHeader (fitsHeader< verboseT > &head, const std::string &fname)
 Read the header from the fits file.
 
error_t readHeader (std::vector< fitsHeader< verboseT > > &heads, const std::vector< std::string > &flist)
 Read the headers from a list of FITS files.
 
Writing Basic Arrays

These methods write basic arrays specified by a pointer to FITS.

error_t write (const dataT *im, int d1, int d2, int d3, fitsHeader< verboseT > *head)
 Write the contents of a raw array to the FITS file.
 
error_t write (const dataT *im, int d1, int d2, int d3)
 Write the contents of a raw array to the FITS file.
 
error_t write (const dataT *im, int d1, int d2, int d3, fitsHeader< verboseT > &head)
 Write the contents of a raw array to the FITS file.
 
error_t write (const std::string &fname, const dataT *im, int d1, int d2, int d3)
 Write the contents of a raw array to the FITS file.
 
error_t write (const std::string &fname, const dataT *im, int d1, int d2, int d3, fitsHeader< verboseT > &head)
 Write the contents of a raw array to the FITS file.
 
Writing Eigen Arrays

These methods write array types with an Eigen-like interface.

template<typename arrT >
error_t write (const std::string &fname, const arrT &im)
 Write the contents of an Eigen-type array to a FITS file.
 
template<typename arrT >
error_t write (const std::string &fname, const arrT &im, fitsHeader< verboseT > &head)
 Write the contents of an Eigen-type array to a FITS file.
 
Reading Subsets

It is often desirable to read only a subset of an image or images into memory. These methods allow you to specify this.

void setReadSize ()
 Set to read all the pixels in the file.
 
void setReadSize (long x0, long y0, long xpix, long ypix)
 Set to read only a subset of the pixels in the file.
 
void setCubeReadSize ()
 Set to read all frames from a cube.
 
void setCubeReadSize (long z0, long zframes)
 Set the number of frames to read from a cube.
 

Protected Member Functions

void construct ()
 One time initialization common to all constructors.
 

Protected Attributes

std::string m_fileName
 The path to the file.
 
fitsfile * m_fptr { nullptr }
 The cfitsio data structure.
 
int m_naxis { 0 }
 The dimensions of the image (1D, 2D, or 3D)
 
long m_naxes [3]
 The size of each dimension.
 
bool m_isOpen { false }
 Flag indicating whether the file is open or not.
 
dataT m_nulval { 0 }
 The value to replace null values with.
 
int m_anynul { 0 }
 Records whether any null values were replaced.
 
int m_noComment { 0 }
 Flag to control whether the comment string is read.
 
long m_x0 { -1 }
 The starting x-pixel to read from.
 
long m_y0 { -1 }
 The starting y-pixel to read from.
 
long m_xpix { -1 }
 The number of x-pixels to read.
 
long m_ypix { -1 }
 The number of y-pixels to read.
 
long m_z0 { -1 }
 The starting frame to read from a cube.
 
long m_zframes { -1 }
 The number of frames to read from a cube.
 

Reading Basic Arrays

These methods read FITS data into basic or raw arrays specified by a pointer.

error_t calcPixarrs (pixarrT &pixarr)
 Fill in the read-size arrays for reading a subset (always used)
 
error_t read (dataT *data)
 Read the contents of the FITS file into an array.
 
error_t read (dataT *data, fitsHeader< verboseT > &head)
 Read the contents of the FITS file into an array.
 
error_t read (dataT *data, const std::string &fname)
 Read the contents of the FITS file into an array.
 
error_t read (dataT *data, fitsHeader< verboseT > &head, const std::string &fname)
 Read the contents of the FITS file into an array and read the header.
 
error_t read (dataT *im, const std::vector< std::string > &flist)
 Read data from a vector list of files into an image cube.
 
error_t read (dataT *im, std::vector< fitsHeader< verboseT > > &heads, const std::vector< std::string > &flist)
 Read data from a vector of files into an image cube with individual headers.
 

Constructor & Destructor Documentation

◆ fitsFile() [1/5]

template<typename dataT , class verboseT >
mx::fits::fitsFile< dataT, verboseT >::fitsFile ( )

Default constructor.

Definition at line 681 of file fitsFile.hpp.

◆ fitsFile() [2/5]

template<typename dataT , class verboseT >
mx::fits::fitsFile< dataT, verboseT >::fitsFile ( error_t errc)

Default constructor with error code.

Parameters
[out]errcerror_t code indicating success or error

Definition at line 686 of file fitsFile.hpp.

References mx::noerror.

◆ fitsFile() [3/5]

template<typename dataT , class verboseT >
mx::fits::fitsFile< dataT, verboseT >::fitsFile ( const std::string &  fname,
error_t errc 
)

Constructor with file name and error code.

The file is not opened.

Parameters
[in]fnameFile name to set on construction
[out]errcerror_t code indicating success or error

Definition at line 692 of file fitsFile.hpp.

◆ fitsFile() [4/5]

template<typename dataT , class verboseT >
mx::fits::fitsFile< dataT, verboseT >::fitsFile ( const std::string &  fname,
bool  doopen = true 
)

Constructor with file name, and option to open.

Parameters
[in]fnameFile name to set on construction
[in]doopen[optional] If true, then the file is opened (the default).

Definition at line 699 of file fitsFile.hpp.

◆ fitsFile() [5/5]

template<typename dataT , class verboseT >
mx::fits::fitsFile< dataT, verboseT >::fitsFile ( const std::string &  fname,
bool  doopen,
error_t errc 
)

Constructor with file name, option to open, and error code.

Parameters
fnameFile name to set on construction
doopenIf true, then the file is opened (the default).
[out]errcerror_t code indicating success or error

Definition at line 707 of file fitsFile.hpp.

◆ ~fitsFile()

template<typename dataT , class verboseT >
mx::fits::fitsFile< dataT, verboseT >::~fitsFile ( )

Destructor.

Definition at line 715 of file fitsFile.hpp.

Member Function Documentation

◆ calcPixarrs()

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::calcPixarrs ( pixarrT &  pixarr)
protected

Fill in the read-size arrays for reading a subset (always used)

Parameters
[out]pixarrPopulated with the allocated read-size arrays

Definition at line 915 of file fitsFile.hpp.

References mx::noerror, and mx::paramnotset.

Referenced by mx::unitTest::fitsTest::fitsFileTest::TEST_CASE().

◆ close()

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::close ( )

Close the file.

Returns
mx::error_t::noerror on success
mx::error_t::fits_* codes from cfitsio functions

Definition at line 821 of file fitsFile.hpp.

References mx::fits_status2error_t(), and mx::noerror.

◆ construct()

template<typename dataT , class verboseT = verbose::d>
void mx::fits::fitsFile< dataT, verboseT >::construct ( )
protected

One time initialization common to all constructors.

◆ fileName() [1/2]

template<typename dataT , class verboseT >
std::string mx::fits::fitsFile< dataT, verboseT >::fileName ( )

Get the current value of m_fileName.

Returns
the current value of m_fileName.

Definition at line 725 of file fitsFile.hpp.

◆ fileName() [2/2]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::fileName ( const std::string &  fname,
bool  doopen = true 
)

Set the file path, and optionally open the file.

Returns
mx::error_t::noerror on success
mx::error_t codes from close or open
Parameters
fnameThe new file name.
doopenIf true, then the file is opened (the default).

Definition at line 731 of file fitsFile.hpp.

References mxlib_error_check, and mx::noerror.

◆ getDimensions()

template<typename dataT , class verboseT >
int mx::fits::fitsFile< dataT, verboseT >::getDimensions ( error_t errc)

Get the number of dimensions (i.e. m_naxis)

Definition at line 844 of file fitsFile.hpp.

References mx::invalidconfig.

◆ getSize() [1/2]

template<typename dataT , class verboseT >
long mx::fits::fitsFile< dataT, verboseT >::getSize ( error_t errc)

Get the total size.

Definition at line 856 of file fitsFile.hpp.

References mx::invalidconfig, and mx::noerror.

◆ getSize() [2/2]

template<typename dataT , class verboseT >
long mx::fits::fitsFile< dataT, verboseT >::getSize ( size_t  axis,
error_t errc 
)

Get the size of a specific dimension.

Definition at line 884 of file fitsFile.hpp.

References mx::invalidarg, mx::invalidconfig, and mx::noerror.

◆ naxes()

template<typename dataT , class verboseT >
long mx::fits::fitsFile< dataT, verboseT >::naxes ( int  dim)

Get the current value of m_naxes for the specified dimension.

Returns
the current value of m_naxes for the specified dimension. -1 if no such dimension
Parameters
[in]dimthe dimension

Definition at line 755 of file fitsFile.hpp.

Referenced by mx::unitTest::fitsTest::fitsFileTest::TEST_CASE().

◆ naxis()

template<typename dataT , class verboseT >
int mx::fits::fitsFile< dataT, verboseT >::naxis ( )

Get the current value of m_naxis.

Returns
the current value of m_naxis

Definition at line 749 of file fitsFile.hpp.

Referenced by mx::unitTest::fitsTest::fitsFileTest::TEST_CASE().

◆ open() [1/2]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::open ( )

Open the file and gets its dimensions.

File name needs to already have been set. If the file has already been opened, this returns immediately with no re-open.

Returns
mx::error_t::noerror on success
mx::invalidconfig if m_filename is empty.
mx::error_t::bad_alloc on an allocation error
mx::error_t::std_exception on other errors during allocations
mx::error_t::exception on unexpected errors during allocations
mx::error_t::allocerr if allocation fails without an exception
mx::error_t::fits_* codes from cfitsio functions

Definition at line 766 of file fitsFile.hpp.

References mx::allocerr, mx::fits_status2error_t(), mx::invalidconfig, and mx::noerror.

◆ open() [2/2]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::open ( const std::string &  fname)

Open the file, first setting the file path.

Returns
mx::error_t::noerror on success
mx::invalidconfig if m_filename is empty.
mx::error_t::bad_alloc on an allocation error
mx::error_t::std_exception on other errors during allocations
mx::error_t::exception on unexpected errors during allocations
mx::error_t::allocerr if allocation fails without an exception
mx::error_t::fits_* codes from cfitsio functions
Parameters
fnameThe name of the file to open.

Definition at line 815 of file fitsFile.hpp.

References mxlib_error_return.

◆ read() [1/12]

template<typename dataT , class verboseT >
template<typename arrT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( arrT &  data)

Read the contents of the FITS file into an Eigen array type (not a simple pointer).

The type arrT can be any type with the following members defined:

  • resize(int, int) (allocates memory)
  • data() (returns a pointer to the underlying array)
  • typedef arrT::Scalar (is the data type, does not have to be dataT)
Template Parameters
arrTis the type of array, see requirements above.
Returns
0 on success
-1 on error
Todo:
this can probably be made part of one read function (or call read(data *)) with a call to resize with SFINAE
Parameters
[out]datais the array, which will be resized as necessary using its resize(int, int) member

Definition at line 1205 of file fitsFile.hpp.

References mx::fits_status2error_t(), mxlib_error_check, and mx::noerror.

◆ read() [2/12]

template<typename dataT , class verboseT >
template<typename arrT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( arrT &  data,
const std::string &  fname 
)

Read the contents of the FITS file into an Eigen array type (not a simple pointer).

The type arrT can be any type with the following members defined:

  • resize(int, int) (allocates memory)
  • data() (returns a pointer to the underlying array)
  • typedef arrT::Scalar (is the data type, does not have to be dataT)
Template Parameters
arrTis the type of array, see requirements above.
Returns
0 on success
-1 on error
Parameters
[out]datais the array, which will be resized as necessary using its resize(int, int) member
[in]fnameis the file path, which is passed to fileName

Definition at line 1278 of file fitsFile.hpp.

References mx::noerror.

◆ read() [3/12]

template<typename dataT , class verboseT >
template<typename arrT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( arrT &  data,
fitsHeader< verboseT > &  head 
)

Read the contents of the FITS file into an Eigen array type (not a simple pointer).

The type arrT can be any type with the following members defined:

  • resize(int, int) (allocates memory)
  • data() (returns a pointer to the underlying array)
  • typedef arrT::Scalar (is the data type, does not have to be dataT)
Template Parameters
arrTis the type of array, see requirements above.
Returns
0 on success
-1 on error
Parameters
[out]datais the array, which will be resized as necessary using its resize(int, int) member
[out]headis a fitsHeader object which is passed to readHeader

Definition at line 1258 of file fitsFile.hpp.

References mx::noerror.

◆ read() [4/12]

template<typename dataT , class verboseT >
template<typename arrT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( arrT &  data,
fitsHeader< verboseT > &  head,
const std::string &  fname 
)

Read the contents of the FITS file into an Eigen array type (not a simple pointer).

The type arrT can be any type with the following members defined:

  • resize(int, int) (allocates memory)
  • data() (returns a pointer to the underlying array)
  • typedef arrT::Scalar (is the data type, does not have to be dataT)
Template Parameters
arrTis the type of array, see requirements above.
Returns
0 on success
-1 on error
Parameters
[out]datathe array, which will be resized as necessary using its resize(int, int) member
[out]heada fitsHeader object which is passed to readHeader
[in]fnamethe file path, which is passed to fileName

Definition at line 1297 of file fitsFile.hpp.

References mx::noerror.

◆ read() [5/12]

template<typename dataT , class verboseT >
template<typename cubeT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( cubeT &  cube,
const std::vector< std::string > &  flist,
std::vector< fitsHeader< verboseT > > *  heads = 0 
)

Read data from a vector list of files into an image cube.

The type cubeT can be any type with the following members defined:

  • resize(int, int, int) (allocates memory)
  • data() (returns a pointer to the underlying array)
  • typedef cubeT::Scalar (is the data type, does not have to be dataT)
Note
The images must all be the same size, or all be as large or larger than the subset specified.
Template Parameters
cubeTis the type of array, see requirements above.
Returns
0 on success
-1 on error
Parameters
[out]cubeA cube which will be resized using its resize(int, int, int) member.
[in]flistThe list of files to read.
[out]heads[optional] A vector of fits headers, allocated to contain one per image.

Definition at line 1323 of file fitsFile.hpp.

References mx::fits_status2error_t(), mx::invalidarg, and mx::noerror.

◆ read() [6/12]

template<typename dataT , class verboseT >
template<typename cubeT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( cubeT &  cube,
std::vector< fitsHeader< verboseT > > &  heads,
const std::vector< std::string > &  flist 
)

Read data from a vector of files into an image cube with individual headers.

The type cubeT can be any type with the following members defined:

  • resize(int, int, int) (allocates memory)
  • data() (returns a pointer to the underlying array)
  • typedef cubeT::Scalar (is the data type, does not have to be dataT)
Template Parameters
cubeTis the type of array, see requirements above.
Returns
0 on success
-1 on error
Parameters
[out]cubeA cube which will be resized using its resize(int, int, int) member.
[out]headsThe vector of fits headers, allocated to contain one per image.
[in]flistThe list of files to read.

Definition at line 1419 of file fitsFile.hpp.

References mxlib_error_return.

◆ read() [7/12]

◆ read() [8/12]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( dataT *  data,
const std::string &  fname 
)

Read the contents of the FITS file into an array.

The array pointed to by data must have been allocated.

Returns
0 on success
-1 on error
Parameters
[out]datais an allocated arrray large enough to hold the entire image
[in]fnameis the file path, which is passed to fileName

Definition at line 1035 of file fitsFile.hpp.

References mxlib_error_check, and mxlib_error_return.

◆ read() [9/12]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( dataT *  data,
fitsHeader< verboseT > &  head 
)

Read the contents of the FITS file into an array.

The array pointed to by data must have been allocated.

Returns
0 on success
-1 on error
Parameters
[out]dataan allocated arrray large enough to hold the entire image
[out]heada fitsHeader object which is passed to readHeader

Definition at line 1027 of file fitsFile.hpp.

References mxlib_error_check, and mxlib_error_return.

◆ read() [10/12]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( dataT *  data,
fitsHeader< verboseT > &  head,
const std::string &  fname 
)

Read the contents of the FITS file into an array and read the header.

The array pointed to by data must have been allocated.

Returns
0 on success
-1 on error
Parameters
[out]dataan allocated arrray large enough to hold the entire image
[out]heada fitsHeader object which is passed to readHeader
[in]fnamethe file path, which is passed to fileName

Definition at line 1043 of file fitsFile.hpp.

References mxlib_error_check, and mxlib_error_return.

◆ read() [11/12]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( dataT *  im,
const std::vector< std::string > &  flist 
)

Read data from a vector list of files into an image cube.

Parameters
[out]imAn allocated array large enough to hold all the images
[in]flistThe list of files to read.

Definition at line 1053 of file fitsFile.hpp.

References mx::invalidarg, mxlib_error_check, and mx::noerror.

◆ read() [12/12]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::read ( dataT *  im,
std::vector< fitsHeader< verboseT > > &  heads,
const std::vector< std::string > &  flist 
)

Read data from a vector of files into an image cube with individual headers.

Parameters
[out]imAn allocated array large enough to hold all the images
heads[in/out] The vector of fits headers, allocated to contain one per image.
[in]flistThe list of files to read.

Definition at line 1080 of file fitsFile.hpp.

References mx::invalidarg, mxlib_error_check, and mx::noerror.

◆ readHeader() [1/3]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::readHeader ( fitsHeader< verboseT > &  head)

Read the header from the fits file.

If head is not empty, then only the keywords already in head are updated. Otherwise the complete header is read.

Returns
0 on success
-1 on error
Parameters
[out]heada fitsHeader object

Definition at line 1427 of file fitsFile.hpp.

References mx::fits::fitsHeader< verboseT >::append(), mx::fits::fitsHeader< verboseT >::begin(), mx::fits::fitsHeader< verboseT >::end(), mx::fits::fitsHeader< verboseT >::erase(), mx::fits_status2error_t(), mxlib_error_check, mx::noerror, and mx::fits::fitsHeader< verboseT >::size().

Referenced by mx::unitTest::fitsTest::fitsFileTest::TEST_CASE().

◆ readHeader() [2/3]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::readHeader ( fitsHeader< verboseT > &  head,
const std::string &  fname 
)

Read the header from the fits file.

If head is not empty, then only the keywords already in head are updated. Otherwise the complete header is read.

Returns
0 on success
-1 on error
Parameters
[out]heada fitsHeader object
[in]fnamethe file path, which is passed to fileName

Definition at line 1553 of file fitsFile.hpp.

References mxlib_error_check, and mx::noerror.

◆ readHeader() [3/3]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::readHeader ( std::vector< fitsHeader< verboseT > > &  heads,
const std::vector< std::string > &  flist 
)

Read the headers from a list of FITS files.

In each case, if the header is not empty then only the keywords already in head are updated. Otherwise the complete header is read.

Returns
0 on success
-1 on error
Parameters
flistA vector of fitsHeader objects to read into. [in] A list of files, each of which is passed to fileName

Definition at line 1562 of file fitsFile.hpp.

References mx::invalidarg, mxlib_error_check, and mx::noerror.

◆ setCubeReadSize() [1/2]

template<typename dataT , class verboseT >
void mx::fits::fitsFile< dataT, verboseT >::setCubeReadSize ( )

Set to read all frames from a cube.

Definition at line 1745 of file fitsFile.hpp.

Referenced by mx::unitTest::fitsTest::fitsFileTest::TEST_CASE().

◆ setCubeReadSize() [2/2]

template<typename dataT , class verboseT >
void mx::fits::fitsFile< dataT, verboseT >::setCubeReadSize ( long  z0,
long  zframes 
)

Set the number of frames to read from a cube.

Parameters
z0is the starting frame to read
zframesis the number of frames to read

Definition at line 1752 of file fitsFile.hpp.

◆ setReadSize() [1/2]

template<typename dataT , class verboseT >
void mx::fits::fitsFile< dataT, verboseT >::setReadSize ( )

Set to read all the pixels in the file.

Definition at line 1727 of file fitsFile.hpp.

Referenced by mx::unitTest::fitsTest::fitsFileTest::TEST_CASE().

◆ setReadSize() [2/2]

template<typename dataT , class verboseT >
void mx::fits::fitsFile< dataT, verboseT >::setReadSize ( long  x0,
long  y0,
long  xpix,
long  ypix 
)

Set to read only a subset of the pixels in the file.

Parameters
x0is the starting x-pixel to read
y0is the starting y-pixel to read
xpixis the number of x-pixels to read
ypixis the number of y-pixels to read

Definition at line 1736 of file fitsFile.hpp.

◆ write() [1/7]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::write ( const dataT *  im,
int  d1,
int  d2,
int  d3 
)

Write the contents of a raw array to the FITS file.

Returns
0 on success
-1 on error
Parameters
[in]imis the array
[in]d1is the first dimension
[in]d2is the second dimension
[in]d3is the third dimenesion (minimum value is 1)

Definition at line 1680 of file fitsFile.hpp.

References mxlib_error_return.

◆ write() [2/7]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::write ( const dataT *  im,
int  d1,
int  d2,
int  d3,
fitsHeader< verboseT > &  head 
)

Write the contents of a raw array to the FITS file.

Note: the type of the array must match dataT

Returns
0 on success
-1 on error
Parameters
[in]imis the array
[in]d1is the first dimension
[in]d2is the second dimension
[in]d3is the third dimenesion (minimum value is 1)
[in]headis the header

Definition at line 1686 of file fitsFile.hpp.

References mxlib_error_return.

◆ write() [3/7]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::write ( const dataT *  im,
int  d1,
int  d2,
int  d3,
fitsHeader< verboseT > *  head 
)

◆ write() [4/7]

template<typename dataT , class verboseT >
template<typename arrT >
error_t mx::fits::fitsFile< dataT, verboseT >::write ( const std::string &  fname,
const arrT &  im 
)

Write the contents of an Eigen-type array to a FITS file.

The type arrT can be any type with the following members defined:

  • data() (returns a pointer to the underlying array)
  • rows() (returrns the number of rows)
  • cols() (returns the number of columns)
  • may have planes() defined

Note: as with all write methods, the Scalar type of the array must match dataT

Template Parameters
arrTis the type of array, see requirements above.
Returns
0 on success
-1 on error
Parameters
[in]fnameis the name of the file.
[in]imis the array

Definition at line 1710 of file fitsFile.hpp.

References mxlib_error_return.

◆ write() [5/7]

template<typename dataT , class verboseT >
template<typename arrT >
error_t mx::fits::fitsFile< dataT, verboseT >::write ( const std::string &  fname,
const arrT &  im,
fitsHeader< verboseT > &  head 
)

Write the contents of an Eigen-type array to a FITS file.

The type arrT can be any type with the following members defined:

  • data() (returns a pointer to the underlying array)
  • rows() (returrns the number of rows)
  • cols() (returns the number of columns)
  • may have planes() defined.

Note: as with all write methods, the Scalar type of the array must match dataT

Template Parameters
arrTis the type of array, see requirements above.
Returns
0 on success
-1 on error
Parameters
[in]fnameis the file path, which is passed to fileName
[in]imis the array
[in]headis a fitsHeader object which is passed to readHeader

Definition at line 1719 of file fitsFile.hpp.

◆ write() [6/7]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::write ( const std::string &  fname,
const dataT *  im,
int  d1,
int  d2,
int  d3 
)

Write the contents of a raw array to the FITS file.

Returns
0 on success
-1 on error
Parameters
[in]fnameis the name of the file.
[in]imis the array
[in]d1is the first dimension
[in]d2is the second dimension
[in]d3is the third dimenesion (minimum value is 1)

Definition at line 1692 of file fitsFile.hpp.

References mxlib_error_check, and mxlib_error_return.

◆ write() [7/7]

template<typename dataT , class verboseT >
error_t mx::fits::fitsFile< dataT, verboseT >::write ( const std::string &  fname,
const dataT *  im,
int  d1,
int  d2,
int  d3,
fitsHeader< verboseT > &  head 
)

Write the contents of a raw array to the FITS file.

Returns
0 on success
-1 on error
Parameters
[in]fnameis the name of the file.
[in]imis the array
[in]d1is the first dimension
[in]d2is the second dimension
[in]d3is the third dimenesion (minimum value is 1)
[in]headis the header

Definition at line 1700 of file fitsFile.hpp.

References mxlib_error_check, and mxlib_error_return.

Member Data Documentation

◆ m_anynul

template<typename dataT , class verboseT = verbose::d>
int mx::fits::fitsFile< dataT, verboseT >::m_anynul { 0 }
protected

Records whether any null values were replaced.

Definition at line 80 of file fitsFile.hpp.

◆ m_fileName

template<typename dataT , class verboseT = verbose::d>
std::string mx::fits::fitsFile< dataT, verboseT >::m_fileName
protected

The path to the file.

Definition at line 62 of file fitsFile.hpp.

◆ m_fptr

template<typename dataT , class verboseT = verbose::d>
fitsfile* mx::fits::fitsFile< dataT, verboseT >::m_fptr { nullptr }
protected

The cfitsio data structure.

Definition at line 65 of file fitsFile.hpp.

◆ m_isOpen

template<typename dataT , class verboseT = verbose::d>
bool mx::fits::fitsFile< dataT, verboseT >::m_isOpen { false }
protected

Flag indicating whether the file is open or not.

Definition at line 74 of file fitsFile.hpp.

◆ m_naxes

template<typename dataT , class verboseT = verbose::d>
long mx::fits::fitsFile< dataT, verboseT >::m_naxes[3]
protected

The size of each dimension.

Definition at line 71 of file fitsFile.hpp.

◆ m_naxis

template<typename dataT , class verboseT = verbose::d>
int mx::fits::fitsFile< dataT, verboseT >::m_naxis { 0 }
protected

The dimensions of the image (1D, 2D, or 3D)

Definition at line 68 of file fitsFile.hpp.

◆ m_noComment

template<typename dataT , class verboseT = verbose::d>
int mx::fits::fitsFile< dataT, verboseT >::m_noComment { 0 }
protected

Flag to control whether the comment string is read.

Definition at line 83 of file fitsFile.hpp.

◆ m_nulval

template<typename dataT , class verboseT = verbose::d>
dataT mx::fits::fitsFile< dataT, verboseT >::m_nulval { 0 }
protected

The value to replace null values with.

Definition at line 77 of file fitsFile.hpp.

◆ m_x0

template<typename dataT , class verboseT = verbose::d>
long mx::fits::fitsFile< dataT, verboseT >::m_x0 { -1 }
protected

The starting x-pixel to read from.

Definition at line 86 of file fitsFile.hpp.

◆ m_xpix

template<typename dataT , class verboseT = verbose::d>
long mx::fits::fitsFile< dataT, verboseT >::m_xpix { -1 }
protected

The number of x-pixels to read.

Definition at line 92 of file fitsFile.hpp.

◆ m_y0

template<typename dataT , class verboseT = verbose::d>
long mx::fits::fitsFile< dataT, verboseT >::m_y0 { -1 }
protected

The starting y-pixel to read from.

Definition at line 89 of file fitsFile.hpp.

◆ m_ypix

template<typename dataT , class verboseT = verbose::d>
long mx::fits::fitsFile< dataT, verboseT >::m_ypix { -1 }
protected

The number of y-pixels to read.

Definition at line 95 of file fitsFile.hpp.

◆ m_z0

template<typename dataT , class verboseT = verbose::d>
long mx::fits::fitsFile< dataT, verboseT >::m_z0 { -1 }
protected

The starting frame to read from a cube.

Definition at line 98 of file fitsFile.hpp.

◆ m_zframes

template<typename dataT , class verboseT = verbose::d>
long mx::fits::fitsFile< dataT, verboseT >::m_zframes { -1 }
protected

The number of frames to read from a cube.

Definition at line 101 of file fitsFile.hpp.


The documentation for this class was generated from the following file: