ifw-core 7.0.0
 
Loading...
Searching...
No Matches
ifw::core::dit::fits Namespace Reference

Classes

struct  FormatSpec
 

Typedefs

using CfitsioType = int32_t
 

Functions

log4cplus::Logger & Logger ()
 
void HandleCfitsioError (const std::string &operation, const int cfitsio_status)
 Throw an exception, extracting the relevant info from cfitsio, if status != 0.
 
int DidToCfitsioType (const ifw::core::dit::did::DataType did_type)
 Convert an ELT ICS data type to the corresponding cfitsio data type.
 
std::string GenerateKey (const std::string &key, const std::string &hierarch_prefix=FITS_KEY_ESO_HIERARCH)
 Generates an ESO hierarchical keyword.
 
void CreateFile (std::shared_ptr< CCfits::FITS > &fits_handle, const std::string &filename, const ifw::core::dit::did::Did &dictionary, const int32_t bitpix, const std::vector< int32_t > &naxes, std::string &target_filename, const bool remove_if_exists=false, const uint16_t nb_of_hdr_blocks=1)
 Create a new FITS file.
 
void MoveToHdu (std::shared_ptr< CCfits::FITS > &fits_handle, const int16_t hdu_nb)
 Move to the given HDU.
 
bool KeyInHdu (std::shared_ptr< CCfits::FITS > &fits_handle, const int16_t hdu_nb, const std::string &key)
 Check if a given key is contained in the referenced HDU (primary HDU = 1).
 
int ReadIntKey (std::shared_ptr< CCfits::FITS > &fits_handle, const std::string &key)
 
void AddDoubleKey (std::shared_ptr< CCfits::FITS > &fits_handle, const ifw::core::dit::did::Did &dictionary, const std::string &key, const double value, const uint16_t hdu_nb)
 Add a double type key in an existing FITS file.
 
void PrepForAddingKey (std::shared_ptr< CCfits::FITS > &fits_handle, const ifw::core::dit::did::Did &dictionary, const std::string &key, const int16_t hdu_nb, ifw::core::dit::did::Record &did_record, std::string &target_key, bool &key_in_hdu)
 Used to prepare for adding a keyword card in a FITS file (mostly internal usage).
 
void ExtractHeaders (std::shared_ptr< CCfits::FITS > &fits_handle, std::string &hdr_buf, const int16_t hdr_ref=ALL_HEADERS)
 Extract the keyword cards in one or more HDU's in an ASCII format (newline terminated).
 
void ExtractHeaders (const std::string &filename, std::string &target_filename, std::string &hdr_buf, const int16_t hdr_ref=ALL_HEADERS)
 Extract all or a specific header from a FITS file.
 
void OpenFitsFile (std::shared_ptr< CCfits::FITS > &fits_handle, const std::string &filename, std::string &target_filename, CCfits::RWmode mode=CCfits::Read)
 Open an existing FITS file.
 
void StoreImage (std::shared_ptr< CCfits::FITS > &fits_handle, const ifw::fnd::fits::BitPix bitpix, const uint32_t image_size, const void *image_buffer, const int16_t hdu_nb, const int16_t naxis3)
 
void addHdu (std::shared_ptr< CCfits::FITS > &fits_handle, const std::string extension_name, const ifw::fnd::fits::BitPix bitpix, const std::vector< int32_t > &naxes)
 
template<class TYPE>
void AddKey (std::shared_ptr< CCfits::FITS > &fits_handle, const ifw::core::dit::did::Did &dictionary, const std::string &key, const TYPE &value, const int16_t hdu_nb=CUR_HDU)
 Template function to add a keyword card in an existing FITS file.
 
template<class TYPE>
void UpdateKey (std::shared_ptr< CCfits::FITS > &fits_handle, const ifw::core::dit::did::Did &dictionary, const std::string &key, const TYPE &value, const int16_t hdu_nb=CUR_HDU)
 

Variables

const int CUR_HDU = -1
 
const int APPEND = -2
 
const std::string FITS_KEY_ESO_HIERARCH = "HIERARCH ESO"
 
const int16_t ALL_HEADERS = SHRT_MAX
 
const int BITS_PER_PIXEL = 8
 

Typedef Documentation

◆ CfitsioType

Function Documentation

◆ AddDoubleKey()

void ifw::core::dit::fits::AddDoubleKey ( std::shared_ptr< CCfits::FITS > & fits_handle,
const ifw::core::dit::did::Did & dictionary,
const std::string & key,
const double value,
const uint16_t hdu_nb )

Add a double type key in an existing FITS file.

Parameters
fits_handleCCfits object associated to the FITS file.
dictionaryDictionary obejct containing information about keys to be added.
hdu_nbHDU in which to add the key (primary header = 1).
valueDouble value to be added.
keyKey to be added.

◆ addHdu()

void ifw::core::dit::fits::addHdu ( std::shared_ptr< CCfits::FITS > & fits_handle,
const std::string extension_name,
const ifw::fnd::fits::BitPix bitpix,
const std::vector< int32_t > & naxes )

Add a HDU to an existing file

Parameters
fits_handleCCfits handle object associated with existing FITS file.
bitpixbitpix of the image pixels.
naxesdimension of each axis.
Returns
0 if successful, -1 otherwise

◆ AddKey()

template<class TYPE>
void ifw::core::dit::fits::AddKey ( std::shared_ptr< CCfits::FITS > & fits_handle,
const ifw::core::dit::did::Did & dictionary,
const std::string & key,
const TYPE & value,
const int16_t hdu_nb = CUR_HDU )

Template function to add a keyword card in an existing FITS file.

Parameters
fits_handleCCfits object associated to a FITS file.
dictionaryDictionary obejct containing information about keys to be added.
keyKey to be added, e.g. "INS OPTI1 ID".
valueValue to be added.
hdu_nbTarget HDU number (primary header = 1).

Note: For Double type keys, use "ifw::core::dit::fits::AddDoubleKey()".

◆ CreateFile()

void ifw::core::dit::fits::CreateFile ( std::shared_ptr< CCfits::FITS > & fits_handle,
const std::string & filename,
const ifw::core::dit::did::Did & dictionary,
const int32_t bitpix,
const std::vector< int32_t > & naxes,
std::string & target_filename,
const bool remove_if_exists = false,
const uint16_t nb_of_hdr_blocks = 1 )

Create a new FITS file.

Parameters
fits_handleThe CCfits handle for the new file. Will be allocated by the function.
filenameBasename for target file.
dictionaryDictionary containing the definition of the keys to be created.
bitpixNumber of bits per pixel
naxesdimension of each axis
target_filenameThe resulting final target filename.
remove_if_existsIf true, remove a file if already exsting with the target filename.
nb_of_hdr_blocksNumber of header blocks to reserve (
Todo
not implemented).
Parameters
data_sizeSize in bytes to allocate for the data (
Todo
not implemented).

FITS files should normally be created in "$DATAROOT/<subsystem>/<instance id>". If a filename is given without the path, the default target path will be "$DATAROOT/<filename>". It will be checked if the filename given has extension ".fits". If not, it will be added i the target name. If a filename with path is given, which contains environment variables or "~", the name will be resolved.

◆ DidToCfitsioType()

int ifw::core::dit::fits::DidToCfitsioType ( const ifw::core::dit::did::DataType did_type)

Convert an ELT ICS data type to the corresponding cfitsio data type.

Parameters
did_type
Returns
cfitsio data type.

◆ ExtractHeaders() [1/2]

void ifw::core::dit::fits::ExtractHeaders ( const std::string & filename,
std::string & target_filename,
std::string & hdr_buf,
const int16_t hdr_ref = ALL_HEADERS )

Extract all or a specific header from a FITS file.

Parameters
filenameBasename of the file.
target_filenameComplete name of target file.
hdr_bufBuffer with the newline terminated FITS keyword cards from the requested HDU's.
hdr_refHDU to extract, or all (primary HDU = 1).
Returns
Buffer with the ASCII dump of the requested header(s).

◆ ExtractHeaders() [2/2]

void ifw::core::dit::fits::ExtractHeaders ( std::shared_ptr< CCfits::FITS > & fits_handle,
std::string & hdr_buf,
const int16_t hdr_ref = ALL_HEADERS )

Extract the keyword cards in one or more HDU's in an ASCII format (newline terminated).

Parameters
fits_handleCCfits handle object associated with existing FITS file.
hdr_bufBuffer which will contain the ASCII dump of the requested headers.
hdr_refSingle HDU or all for which to extract the keyword cards.

◆ GenerateKey()

std::string ifw::core::dit::fits::GenerateKey ( const std::string & key,
const std::string & hierarch_prefix = FITS_KEY_ESO_HIERARCH )

Generates an ESO hierarchical keyword.

Parameters
keyInput key to be checked and possibly converted.
Returns
ESO hierachical key or input key unchanged.

For hierarchical keys, these shall be given as follows: "<cat> [<subsystem>] <parameter>".

A primary key is returned unmodified.

◆ HandleCfitsioError()

void ifw::core::dit::fits::HandleCfitsioError ( const std::string & operation,
const int cfitsio_status )

Throw an exception, extracting the relevant info from cfitsio, if status != 0.

◆ KeyInHdu()

bool ifw::core::dit::fits::KeyInHdu ( std::shared_ptr< CCfits::FITS > & fits_handle,
const int16_t hdu_nb,
const std::string & key )

Check if a given key is contained in the referenced HDU (primary HDU = 1).

Parameters
fits_handleThe CCfits object.
hdu_nbHDU to check.
keyName of the key, e.g. "INS FILT1 NAME".
Returns
True if key found in the referenced HDU.

◆ Logger()

log4cplus::Logger & ifw::core::dit::fits::Logger ( )

◆ MoveToHdu()

void ifw::core::dit::fits::MoveToHdu ( std::shared_ptr< CCfits::FITS > & fits_handle,
const int16_t hdu_nb )

Move to the given HDU.

Parameters
fits_handleCCfits fits handle.
hdu_nbHDU number requested (primary header = 1).

◆ OpenFitsFile()

void ifw::core::dit::fits::OpenFitsFile ( std::shared_ptr< CCfits::FITS > & fits_handle,
const std::string & filename,
std::string & target_filename,
CCfits::RWmode mode = CCfits::Read )

Open an existing FITS file.

Parameters
fits_handleCCfits fits handle object. Will be allocated by the function.
filenameBasename of FITS file to open.
target_filenameComplete name of file opened.
modeCCfits::Read or CCfits::Write.

◆ PrepForAddingKey()

void ifw::core::dit::fits::PrepForAddingKey ( std::shared_ptr< CCfits::FITS > & fits_handle,
const ifw::core::dit::did::Did & dictionary,
const std::string & key,
const int16_t hdu_nb,
ifw::core::dit::did::Record & did_record,
std::string & target_key,
bool & key_in_hdu )

Used to prepare for adding a keyword card in a FITS file (mostly internal usage).

Parameters
dictionaryDictionary object defining the keys in the FITS file.
fits_handleThe CCfits object.
keyKey to be added.
hdu_nbHDU number where the shall be added (primary header = 1, CUR_HDU = current HDU).
did_recordCopy of the dictionary record for the key.
target_keyThe final target keyname, e.g. "HIERARCH ESO INS1 FILT2 NAME".
key_in_hduTrue if key already defined in the given HDU.

Note, the function does actually not add the key in the file.

◆ ReadIntKey()

int ifw::core::dit::fits::ReadIntKey ( std::shared_ptr< CCfits::FITS > & fits_handle,
const std::string & key )

◆ StoreImage()

void ifw::core::dit::fits::StoreImage ( std::shared_ptr< CCfits::FITS > & fits_handle,
const ifw::fnd::fits::BitPix bitpix,
const uint32_t image_size,
const void * image_buffer,
const int16_t hdu_nb = ifw::core::dit::fits::CUR_HDU,
const int16_t naxis3 = 0 )

Store the image pixels provided into a specific HDU. Cubes are supported.

Parameters
fits_handleCCfits handle object associated with existing FITS file.
bitpixFITS std BITPIX data type of the image pixels.
image_sizesize in bytes of an image.
image_bufferimage content.
hdu_nbindex (starting from one) of the hdu where to store the data.
naxis3frame index in case of a cube.

◆ UpdateKey()

template<class TYPE>
void ifw::core::dit::fits::UpdateKey ( std::shared_ptr< CCfits::FITS > & fits_handle,
const ifw::core::dit::did::Did & dictionary,
const std::string & key,
const TYPE & value,
const int16_t hdu_nb = CUR_HDU )

Update an existing key. See also AddKey().

Variable Documentation

◆ ALL_HEADERS

const int16_t ifw::core::dit::fits::ALL_HEADERS = SHRT_MAX

◆ APPEND

const int ifw::core::dit::fits::APPEND = -2

◆ BITS_PER_PIXEL

const int ifw::core::dit::fits::BITS_PER_PIXEL = 8

◆ CUR_HDU

const int ifw::core::dit::fits::CUR_HDU = -1

◆ FITS_KEY_ESO_HIERARCH

const std::string ifw::core::dit::fits::FITS_KEY_ESO_HIERARCH = "HIERARCH ESO"