mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages

FITS file utilities and wrappers.

Functions

template<typename dataT >
void mx::fits::headersToValues (std::vector< dataT > &v, std::vector< fitsHeader > &heads, const std::string &keyw)
 Convert the values in a std::vector of fits headers into a std::vector of values.
 
template<typename dataT >
std::vector< dataT > mx::fits::headersToValues (std::vector< fitsHeader > &heads, const std::string &keyw)
 Convert the values in a std::vector of fits headers into a std::vector of values.
 
void mx::fits::fitsHeaderGitStatus (fitsHeader &head, const std::string &repoName, const char *sha1, int modified)
 Write the status of a Git repository to HISTORY in a FITS header.
 

Function Documentation

◆ fits_write_key()

template<typename typeT >
int mx::fits::fits_write_key ( fitsfile *  fptr,
char *  keyword,
void *  value,
char *  comment 
)

Write a header card to a file.

This is a templatized wrapper for the cfitsio routine fits_write_key.

Template Parameters
typeTis the type of the value
Parameters
fptris a pointer to an open fits file
keywordis a c-string containing the keyword
valueis a pointer to the memory location of the value
commentis a c-string, possibly NULL, containing a comment string
Return values
intcontaining the status returned by the cfitsio routine.

Definition at line 349 of file fitsUtils.hpp.

References mx::fits::fits_write_key().

Referenced by mx::fits::fits_write_key(), and mx::fits::fits_write_key< bool >().

◆ fits_write_key< bool >()

template<>
int mx::fits::fits_write_key< bool > ( fitsfile *  fptr,
char *  keyword,
void *  value,
char *  comment 
)

Specialization to handle the case bool.

This gets converted to unsigned char.

Definition at line 123 of file fitsUtils.cpp.

References mx::fits::fits_write_key().

◆ fitsBITPIX()

template<typename scalarT >
constexpr int mx::fits::fitsBITPIX ( )
constexpr

Return the cfitsio BITPIX value for a given data type.

Template Parameters
scalarTis the type
Return values
int> 0 if a constant is defined in cfitsio corresponding to the native type
-1if not a defined type in cfitsio

◆ fitsErrText()

void mx::fits::fitsErrText ( std::string &  explan,
const std::string &  filename,
int  fstatus 
)

Generate a rich error meesage from a FITS status code.

Parameters
[out]explanthe explanatory message
[in]filenamethe FITS file's name which generated the problem
[in]fstatusthe cfitstio status code

Definition at line 169 of file fitsUtils.cpp.

References mx::ioutils::convertToString().

Referenced by mx::fits::fitsFile< dataT >::close(), mx::fits::fitsFile< dataT >::open(), mx::fits::fitsFile< dataT >::read(), mx::fits::fitsFile< dataT >::read(), mx::fits::fitsFile< dataT >::read(), mx::fits::fitsFile< dataT >::readHeader(), and mx::fits::fitsFile< dataT >::write().

◆ fitsHeaderGitStatus()

void mx::fits::fitsHeaderGitStatus ( fitsHeader head,
const std::string &  repoName,
const char *  sha1,
int  modified 
)

Write the status of a Git repository to HISTORY in a FITS header.

Parameters
[in,out]headthe HISTORY cards will be appended to this header
[in]repoNamethe name of the repository
[in]sha1is the SHA-1 hash string of the repository
[in]modifiedwhether or not the repository has been modified after the commit referred to by sha1

Definition at line 259 of file fitsHeader.cpp.

References mx::fits::fitsHeader::append().

Referenced by mx::improc::HCIobservation< _realT >::outputPSFSub(), and mx::improc::HCIobservation< _realT >::writeFinim().

◆ fitsPopulateCard()

void mx::fits::fitsPopulateCard ( char  headStr[81],
char *  keyword,
char *  value,
char *  comment 
)

Populate a fits header card with the value string copied verbatim.

Parameters
headStris a c-string which must be 81 characters in length, including the '
'
keywordis the keyword name
valueis the value string
commentis the comment string

Definition at line 63 of file fitsUtils.cpp.

◆ fitsStripApost()

int mx::fits::fitsStripApost ( std::string &  s)

Strip the apostrophes from a FITS value string.

The argument is modified if the first and/or last non-whitespace character is '

Parameters
sis the string from which to strip apostrophes
Return values
intcontaining the number of stripped apostrophes

Definition at line 34 of file fitsUtils.cpp.

◆ fitsType()

template<typename scalarT >
constexpr int mx::fits::fitsType ( )
constexpr

Return the cfitsio constant for a given data type.

Template Parameters
scalarTis the type
Returns
a constant defined in cfitsio corresponding to the native type
-1 if not a define type in cfitsio

Definition at line 104 of file fitsUtils.hpp.

◆ headersToValues() [1/2]

template<typename dataT >
void mx::fits::headersToValues ( std::vector< dataT > &  v,
std::vector< fitsHeader > &  heads,
const std::string &  keyw 
)

Convert the values in a std::vector of fits headers into a std::vector of values.

Resizes the vector of the appropriate type.

Template Parameters
dataTis the type of the header value
Parameters
[out]vwill contain the converted values
[in]headscontains the headers
[in]keywcontains the keyword designating which value to convert

Definition at line 311 of file fitsHeader.hpp.

Referenced by mx::fits::headersToValues().

◆ headersToValues() [2/2]

template<typename dataT >
std::vector< dataT > mx::fits::headersToValues ( std::vector< fitsHeader > &  heads,
const std::string &  keyw 
)

Convert the values in a std::vector of fits headers into a std::vector of values.

Creates a vector of the appropriate type and size.

Template Parameters
dataTis the type of the header value
Parameters
[in]headscontains the headers
[in]keywcontains the keyword designating which value to convert
Return values
std::vector<dataT>containing the converted values

Definition at line 332 of file fitsHeader.hpp.

References mx::fits::headersToValues().