ifw  0.0.1-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Functions | Variables
dit::fits Namespace Reference

Classes

class  FitsReport
 Class to handle information for one FITS file check run. More...
 

Typedefs

using CfitsioType = int32_t
 

Functions

CfitsioType DidToCfitsioType (ctd::defines::DataType did_type)
 Convert an ELT ICS data type to the corresponding cfitsio data type. More...
 
void HandleCfitsioError (const std::string &operation, const int cfitsio_status)
 Throw an exception, extracting the relevant info from cfitsio, if status != 0. More...
 
std::string GenerateKey (const std::string &key, const std::string &hierarch_prefix=FITS_KEY_ESO_HIERARCH)
 Generates an ESO hierarchical keyword. More...
 
void Verify (const std::string &filename, std::string &target_filename, dit::fits::FitsReport &report)
 Function to carry out a verification check on a FITS file. More...
 
void Verify (const std::string &filename, std::string &target_filename, const dit::did::Did &dictionary, dit::fits::FitsReport &report)
 Function to carry out a verification check on a FITS file. Dictionary taken into account. More...
 
void CreateFile (CCfits::FITS **fits_handle, const std::string &filename, const dit::did::Did &dictionary, const int32_t bitpix, const std::list< 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. More...
 
void MoveToHdu (CCfits::FITS &fits_handle, const int16_t hdu_nb)
 Move to the given HDU. More...
 
bool KeyInHdu (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). More...
 
void AddDoubleKey (CCfits::FITS &fits_handle, const 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. More...
 
void PrepForAddingKey (CCfits::FITS &fits_handle, const dit::did::Did &dictionary, const std::string &key, const int16_t hdu_nb, dit::did::Record &did_record, std::string &target_key, bool &key_in_hdu, CfitsioType &cfitsio_type, dit::did::FormatSpecifier &format_specifier)
 Used to prepare for adding a keyword card in a FITS file (mostly internal usage). More...
 
void ExtractHeaders (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). More...
 
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. More...
 
void OpenFitsFile (CCfits::FITS **fits_handle, const std::string &filename, std::string &target_filename, CCfits::RWmode mode=CCfits::Read)
 Open an existing FITS file. More...
 
template<class TYPE >
void AddKey (CCfits::FITS &fits_handle, const dit::did::Did &dictionary, const std::string &key, const TYPE &value, const int16_t hdu_nb)
 Template function to add a keyword card in an existing FITS file. More...
 

Variables

const std::string FITS_KEY_ESO_HIERARCH = "HIERARCH ESO"
 
const int16_t ALL_HEADERS = SHRT_MAX
 

Typedef Documentation

typedef int32_t dit::fits::CfitsioType

Function Documentation

void dit::fits::AddDoubleKey ( CCfits::FITS &  fits_handle,
const 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.
template<class TYPE >
void dit::fits::AddKey ( CCfits::FITS &  fits_handle,
const dit::did::Did dictionary,
const std::string &  key,
const TYPE &  value,
const int16_t  hdu_nb 
)

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 "dit::fits::AddDoubleKey()".

Todo:
: Call AddDoubleKey() directly here.
Todo:
: Call AddDoubleKey() directly here.
Todo:
: Call AddDoubleKey() directly here.
Todo:
: Call AddDoubleKey() directly here.
Todo:
: Call AddDoubleKey() directly here.
void dit::fits::CreateFile ( CCfits::FITS **  fits_handle,
const std::string &  filename,
const dit::did::Did dictionary,
const int32_t  bitpix,
const std::list< 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.
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).

Files given by their basename, will be created in "$DATAROOT/resource/image".

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.
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).

Files given by their basename, will be created in "$DATAROOT/resource/image".

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.
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).

Files given by their basename, will be created in "$DATAROOT/resource/image".

Todo:
: Handle nb_of_hdr_blocks, data_size.
Todo:
: Handle nb_of_hdr_blocks, data_size.
Todo:
: Handle nb_of_hdr_blocks, data_size.
CfitsioType dit::fits::DidToCfitsioType ( ctd::defines::DataType  did_type)

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

Parameters
did_type
Returns
cfitsio data type.
void dit::fits::ExtractHeaders ( 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.
void 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).
std::string 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.

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

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

bool dit::fits::KeyInHdu ( 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.
void dit::fits::MoveToHdu ( 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).
void dit::fits::OpenFitsFile ( 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.
void dit::fits::PrepForAddingKey ( CCfits::FITS &  fits_handle,
const dit::did::Did dictionary,
const std::string &  key,
const int16_t  hdu_nb,
dit::did::Record did_record,
std::string &  target_key,
bool &  key_in_hdu,
CfitsioType &  cfitsio_type,
dit::did::FormatSpecifier format_specifier 
)

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).
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.
cfitsio_typeThe cfitsio data type for the key.
format_specifierObject with information about the format of the value.

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

void dit::fits::Verify ( const std::string &  filename,
std::string &  target_filename,
dit::fits::FitsReport report 
)

Function to carry out a verification check on a FITS file.

Parameters
filenameBasename of file to check.
target_filenameFilename of the FITS file checked.
reportReport object with the results from the check.

This is a basic verification check, not involving a ICS dictionary.

Todo:
Not yet implemented.
Parameters
filenameBasename of file to check.
target_filenameFilename of the FITS file checked.
reportReport object with the results from the check.

This is a basic verification check, not involving a ICS dictionary.

Todo:
Not yet implemented.
Parameters
filenameBasename of file to check.
target_filenameFilename of the FITS file checked.
reportReport object with the results from the check.

This is a basic verification check, not involving a ICS dictionary.

Todo:
Not yet implemented.
void dit::fits::Verify ( const std::string &  filename,
std::string &  target_filename,
const dit::did::Did dictionary,
dit::fits::FitsReport report 
)

Function to carry out a verification check on a FITS file. Dictionary taken into account.

Parameters
filenameBasename of file to check.
target_filenameComplete filename of file checked.
dictionaryICS dictionary with keyword definitions.
reportReport object with the results from the check.

Variable Documentation

const int16_t dit::fits::ALL_HEADERS = SHRT_MAX
const std::string dit::fits::FITS_KEY_ESO_HIERARCH = "HIERARCH ESO"