ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
keywordRule.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_dpm_libmerge
4  * @copyright ESO - European Southern Observatory
5  */
7 
8 #include <algorithm>
9 #include <daq/fits/keyword.hpp>
10 
11 namespace daq::dpm {
12 
14  DefaultRule default_rule) const {
15  /*
16  Class Value Keywords
17  TYP_STRUC_KEY 10 SIMPLE, BITPIX, NAXIS, NAXISn, EXTEND, BLOCKED,
18  GROUPS, PCOUNT, GCOUNT, END
19  XTENSION, TFIELDS, TTYPEn, TBCOLn, TFORMn, THEAP,
20  and the first 4 COMMENT keywords in the primary array
21  that define the FITS format.
22  TYP_CMPRS_KEY 20 The keywords used in the compressed image or table
23  format, including ZIMAGE, ZCMPTYPE, ZNAMEn, ZVALn,
24  ZTILEn, ZBITPIX, ZNAXISn, ZSCALE, ZZERO, ZBLANK
25  TYP_SCAL_KEY 30 BSCALE, BZERO, TSCALn, TZEROn
26  TYP_NULL_KEY 40 BLANK, TNULLn
27  TYP_DIM_KEY 50 TDIMn
28  TYP_RANG_KEY 60 TLMINn, TLMAXn, TDMINn, TDMAXn, DATAMIN, DATAMAX
29  TYP_UNIT_KEY 70 BUNIT, TUNITn
30  TYP_DISP_KEY 80 TDISPn
31  TYP_HDUID_KEY 90 EXTNAME, EXTVER, EXTLEVEL, HDUNAME, HDUVER, HDULEVEL
32  TYP_CKSUM_KEY 100 CHECKSUM, DATASUM
33  TYP_WCS_KEY 110 WCS keywords defined in the the WCS papers, including:
34  CTYPEn, CUNITn, CRVALn, CRPIXn, CROTAn, CDELTn
35  CDj_is, PVj_ms, LONPOLEs, LATPOLEs
36  TCTYPn, TCTYns, TCUNIn, TCUNns, TCRVLn, TCRVns, TCRPXn,
37  TCRPks, TCDn_k, TCn_ks, TPVn_m, TPn_ms, TCDLTn, TCROTn
38  jCTYPn, jCTYns, jCUNIn, jCUNns, jCRVLn, jCRVns, iCRPXn,
39  iCRPns, jiCDn, jiCDns, jPVn_m, jPn_ms, jCDLTn, jCROTn
40  (i,j,m,n are integers, s is any letter)
41  TYP_REFSYS_KEY 120 EQUINOXs, EPOCH, MJD-OBSs, RADECSYS, RADESYSs, DATE-OBS
42  TYP_COMM_KEY 130 COMMENT, HISTORY, (blank keyword)
43  TYP_CONT_KEY 140 CONTINUE
44  TYP_USER_KEY 150 all other keywords
45  */
46  fits::KeywordVector result;
47  result.reserve(keywords.size());
48  if (default_rule == DefaultRule::All) {
49  result = keywords;
50  } else {
51  // note: Start by keeping only USER keys
52  std::copy_if(keywords.begin(),
53  keywords.end(),
54  std::back_inserter(result),
55  [](fits::KeywordVariant const& kw_var) -> bool {
56  // Exclude all but user types
57  return std::visit(
58  [](auto const& kw) {
59  return fits::GetKeywordClass(kw.GetName().name) ==
60  fits::KeywordClass::User;
61  },
62  kw_var);
63  });
64  }
65 
66  for (auto const& rule : m_rules) {
67  auto kws = rule(result);
68  result.swap(kws);
69  }
70  return result;
71 }
72 
73 } // namespace daq::dpm
daq::fits::KeywordVariant
std::variant< ValueKeyword, EsoKeyword, LiteralKeyword > KeywordVariant
The different variants of keywords that are supported.
Definition: keyword.hpp:400
daq::dpm::KeywordRuleProcessor::DefaultRule
DefaultRule
Definition: keywordRule.hpp:20
keywordRule.hpp
keyword.hpp
Contains data structure for FITS keywords.
daq::dpm::StandardKeywordRuleProcessor::Process
virtual fits::KeywordVector Process(fits::KeywordVector const &keywords, DefaultRule default_rule) const override
Definition: keywordRule.cpp:13
daq::dpm
Definition: testDpSpec.cpp:16
daq::dpm::KeywordRuleProcessor::DefaultRule::All
@ All
Default rule is to keep all keywords (useful for in-place merge)
daq::fits::KeywordVector
std::vector< KeywordVariant > KeywordVector
Vector of keywords.
Definition: keyword.hpp:414