15 #include <highfive/H5Easy.hpp>
16 #include <highfive/H5File.hpp>
18 #include <xtensor/xadapt.hpp>
19 #include <xtensor/xarray.hpp>
24 using DMatrix = xt::xarray<double, xt::layout_type::row_major>;
34 const std::string & attribute_name){
36 if (!ds.attrExists(
"DETECTOR"))
37 throw std::runtime_error(
"Attribute " + attribute_name +
" does not exist");
40 H5::Attribute attr = ds.openAttribute(attribute_name);
41 H5::StrType stype = attr.getStrType();
42 attr.read(stype, attr_str);
55 const std::string & path,
56 const std::string & attribute_name){
57 H5::H5File file(filename, H5F_ACC_RDONLY);
58 H5::DataSet ds = file.openDataSet(path);
82 return {{
"WAVELENGTH", HighFive::AtomicType<double>{} },
83 {
"THROUGHPUT", HighFive::AtomicType<double>{}} };
94 const std::string& filter_name){
96 std::string dataset_path (
"/filters/" + filter_name);
97 H5::H5File file(library_filename, H5F_ACC_RDONLY);
98 H5::DataSet ds = file.openDataSet(dataset_path);
104 H5Easy::File hf_file(library_filename, H5Easy::File::ReadOnly);
105 HighFive::DataSet hf_ds = hf_file.getDataSet(dataset_path);
106 std::vector<filter_t> data;
110 std::vector<double> transmission;
111 for (
auto & d : data) {
113 transmission.push_back(d.transmission);
116 std::vector<std::size_t> shape = {
wavelength.size() };
118 DMatrix xt_transmit = xt::adapt(transmission, shape);
139 std::vector<std::string> content;
145 std::vector<std::string>
find (
const std::string & name,
146 bool case_sensitive=
true);
158 this->source = filename;
161 H5Easy::File hf_file(filename, H5Easy::File::ReadOnly);
162 this->content = hf_file.getGroup(
"filters").listObjectNames();
171 return this->content;
192 const std::string & name,
bool case_sensitive){
194 std::vector<std::string> result;
196 if (case_sensitive) {
198 if (lib_name.find(name) != std::string::npos)
199 result.push_back(lib_name);
202 std::string name_lower =
tolower(name);
204 if (
tolower(lib_name).
find(name) != std::string::npos)
205 result.push_back(lib_name);
229 os <<
"HDF5Library: " << l.
get_source() <<
"\n"
230 <<
" Contains " << l.
get_content().size() <<
" registered filters."