ifw-daq  1.0.0
IFW Data Acquisition modules
Classes | Typedefs | Functions
daq::fits Namespace Reference

Classes

struct  BasicKeyword
 A type safe version of FormattedKeyword that consist of the three basic components of a FITS keyword keyword record: name, value and optional comment. More...
 
struct  BasicKeywordBase
 Non template base class that is purely used to avoid type-deduction issues of ValueType. More...
 
class  CfitsioError
 Represents errors from cfitsio. More...
 
struct  EsoKeywordTraits
 
struct  ValueKeywordTraits
 

Typedefs

using UniqueFitsFile = std::unique_ptr< fitsfile, void(*)(fitsfile *) noexcept >
 Defines unique ownership type to cfitsio fitsfile. More...
 
using ValueKeyword = BasicKeyword< ValueKeywordTraits >
 Standard FITS value keyword. More...
 
using EsoKeyword = BasicKeyword< EsoKeywordTraits >
 ESO hiearchical keyword. More...
 
using KeywordVariant = std::variant< ValueKeyword, EsoKeyword >
 The different variants of keywords that are supported. More...
 
using KeywordVector = std::vector< KeywordVariant >
 Vector of keywords. More...
 

Functions

void DefaultClose (fitsfile *ptr) noexcept
 Default close function that is used by UniqueFitsFile as a deleter. More...
 
void InitPrimaryHduNoImage (fitsfile *ptr)
 Initializes an empty FITS file with a primary HDU. More...
 
UniqueFitsFile CreateEmpty (char const *filename)
 Creates empty FITS file using fits_create_file and returns a pointer with a deleter that will close the file. More...
 
std::vector< KeywordVariantParseJsonKeywords (char const *keywords)
 Parse and return FITS keywords. More...
 
std::vector< KeywordVariantParseJsonKeywords (nlohmann::json const &keywords)
 Parse and return FITS keywords. More...
 
constexpr bool operator< (ValueKeyword const &, EsoKeyword const &) noexcept
 EsoKeyword is sorted after ValueKeyword. More...
 
constexpr bool operator< (EsoKeyword const &, ValueKeyword const &) noexcept
 EsoKeyword is sorted after ValueKeyword. More...
 
template<class Trait >
std::ostream & operator<< (std::ostream &os, BasicKeyword< Trait > const &kw)
 
template<class Trait >
std::ostream & operator<< (std::ostream &os, BasicKeywordBase::ValueType const &kw)
 
std::ostream & operator<< (std::ostream &os, KeywordVariant const &kw)
 Ostream formatting of keywords. More...
 
bool NameEquals (KeywordVariant const &lhs, KeywordVariant const &rhs) noexcept
 Compare keyword names of keyword of the same type. More...
 
void UpdateKeywords (KeywordVector &to, KeywordVector const &from)
 Updates a with keywords from b. More...
 
template std::ostream & operator<<<EsoKeywordTraits > (std::ostream &os, BasicKeyword< EsoKeywordTraits > const &kw)
 
template std::ostream & operator<<<ValueKeywordTraits > (std::ostream &os, BasicKeyword< ValueKeywordTraits > const &kw)
 

Class Documentation

◆ daq::fits::EsoKeywordTraits

struct daq::fits::EsoKeywordTraits

Definition at line 85 of file keyword.hpp.

◆ daq::fits::ValueKeywordTraits

struct daq::fits::ValueKeywordTraits

Definition at line 84 of file keyword.hpp.

Typedef Documentation

◆ EsoKeyword

ESO hiearchical keyword.

Definition at line 99 of file keyword.hpp.

◆ KeywordVariant

using daq::fits::KeywordVariant = typedef std::variant<ValueKeyword, EsoKeyword>

The different variants of keywords that are supported.

Definition at line 131 of file keyword.hpp.

◆ KeywordVector

using daq::fits::KeywordVector = typedef std::vector<KeywordVariant>

Vector of keywords.

Definition at line 138 of file keyword.hpp.

◆ UniqueFitsFile

using daq::fits::UniqueFitsFile = typedef std::unique_ptr<fitsfile, void (*)(fitsfile*) noexcept>

Defines unique ownership type to cfitsio fitsfile.

Definition at line 46 of file cfitsio.hpp.

◆ ValueKeyword

Standard FITS value keyword.

Definition at line 92 of file keyword.hpp.

Function Documentation

◆ CreateEmpty()

UniqueFitsFile daq::fits::CreateEmpty ( char const *  filename)

Creates empty FITS file using fits_create_file and returns a pointer with a deleter that will close the file.

Definition at line 79 of file cfitsio.cpp.

◆ DefaultClose()

void daq::fits::DefaultClose ( fitsfile *  ptr)
noexcept

Default close function that is used by UniqueFitsFile as a deleter.

Definition at line 23 of file cfitsio.cpp.

◆ InitPrimaryHduNoImage()

void daq::fits::InitPrimaryHduNoImage ( fitsfile *  ptr)

Initializes an empty FITS file with a primary HDU.

Mandatory keywords are set and primary HDU added if necessary.

Mandatory keywords are initialized as:

  • SIMPLE = T
  • BITPIX = 8
  • NAXIS = 0
Precondition
ptr != nullptr
Parameters
ptrValid FITS file.
Exceptions
CfitsioErroron error.

Definition at line 35 of file cfitsio.cpp.

◆ NameEquals()

bool daq::fits::NameEquals ( KeywordVariant const &  lhs,
KeywordVariant const &  rhs 
)
noexcept

Compare keyword names of keyword of the same type.

Comparing names only is useful to e.g. look up keyword by name, to modify it.

Parameters
lhsvalue to compare
rhsvalue to compare
Returns
true iff lhs and rhs are the same type and their name property compares equal.

Definition at line 73 of file keyword.cpp.

◆ operator<() [1/2]

constexpr bool daq::fits::operator< ( EsoKeyword const &  ,
ValueKeyword const &   
)
constexprnoexcept

EsoKeyword is sorted after ValueKeyword.

Definition at line 115 of file keyword.hpp.

◆ operator<() [2/2]

constexpr bool daq::fits::operator< ( ValueKeyword const &  ,
EsoKeyword const &   
)
constexprnoexcept

EsoKeyword is sorted after ValueKeyword.

Definition at line 106 of file keyword.hpp.

◆ operator<<() [1/3]

template<class Trait >
std::ostream & daq::fits::operator<< ( std::ostream &  os,
BasicKeyword< Trait > const &  kw 
)

Definition at line 101 of file keyword.cpp.

◆ operator<<() [2/3]

template<class Trait >
std::ostream & daq::fits::operator<< ( std::ostream &  os,
BasicKeywordBase::ValueType const &  kw 
)

Definition at line 84 of file keyword.cpp.

◆ operator<<() [3/3]

std::ostream & daq::fits::operator<< ( std::ostream &  os,
KeywordVariant const &  kw 
)

Ostream formatting of keywords.

Definition at line 111 of file keyword.cpp.

◆ operator<<<EsoKeywordTraits >()

template std::ostream& daq::fits::operator<<<EsoKeywordTraits > ( std::ostream &  os,
BasicKeyword< EsoKeywordTraits > const &  kw 
)

◆ operator<<<ValueKeywordTraits >()

template std::ostream& daq::fits::operator<<<ValueKeywordTraits > ( std::ostream &  os,
BasicKeyword< ValueKeywordTraits > const &  kw 
)

◆ ParseJsonKeywords() [1/2]

std::vector< KeywordVariant > daq::fits::ParseJsonKeywords ( char const *  keywords)

Parse and return FITS keywords.

Example string:

auto keywords = R"([
{
"type":"valueKeyword",
"name":"OBJECT",
"value":"OBJECT,SKY"
},
...
]");
auto res = ParseJsonKeywords(keywords);
Parameters
keywordsJSON encoded string of keywords
Exceptions
std::invalid_argumenton schema validation error.
nlohmann::json::exceptionon JSON parsing error.

Definition at line 73 of file json.cpp.

◆ ParseJsonKeywords() [2/2]

std::vector< KeywordVariant > daq::fits::ParseJsonKeywords ( nlohmann::json const &  keywords)

Parse and return FITS keywords.

Parameters
keywordsJSON object containing FITS keywords.
Exceptions
std::invalid_argumenton schema validation error.

Definition at line 79 of file json.cpp.

◆ UpdateKeywords()

void daq::fits::UpdateKeywords ( KeywordVector to,
KeywordVector const &  from 
)

Updates a with keywords from b.

New keywords are inserted at the end. Existing keywords will be updated with new value if keyword type and name is the same.

Parameters
toKeywords to update to.
fromKeywords to update from.

Definition at line 120 of file keyword.cpp.