Agora  1.2.0
Agora project
hdf5_lib.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2018-2022
3  RENEW OPEN SOURCE LICENSE: http://renew-wireless.org/license
4 
5 ----------------------------------------------------------------------
6  API to read and write hdf5 file
7 ---------------------------------------------------------------------
8 */
9 
10 #ifndef AGORA_HDF5LIB_H_
11 #define AGORA_HDF5LIB_H_
12 
13 #include <algorithm>
14 #include <array>
15 #include <complex>
16 #include <map>
17 #include <memory>
18 
19 #include "H5Cpp.h"
20 
21 namespace Agora_recorder {
22 static constexpr size_t kDsDimsNum = 5;
23 
24 class Hdf5Lib {
25  public:
26  Hdf5Lib(H5std_string hdf5_name, H5std_string group_name);
27  ~Hdf5Lib();
28 
29  void CreateDataset(const std::string& dataset_name,
30  const std::array<hsize_t, kDsDimsNum>& chunk_dims,
31  const std::array<hsize_t, kDsDimsNum>& init_dims,
32  const ssize_t extend_dimension = 0,
33  const H5::PredType& type = H5::PredType::STD_I16BE);
34  void FinalizeDataset(const std::string& dataset_name);
35 
36  void ExtendDataset(const std::string& dataset_name,
37  const std::array<hsize_t, kDsDimsNum>& extended_dims);
38  herr_t WriteDataset(const std::string& dataset_name,
39  const std::array<hsize_t, kDsDimsNum>& start,
40  const std::array<hsize_t, kDsDimsNum>& count,
41  const short* wrt_data);
42 
43  herr_t WriteDataset(const std::string& dataset_name,
44  const std::array<hsize_t, kDsDimsNum>& start,
45  const std::array<hsize_t, kDsDimsNum>& count,
46  const float* wrt_data);
47 
48  void WriteAttribute(const char name[], double val);
49  void WriteAttribute(const char name[], const std::vector<double>& val);
50  void WriteAttribute(const char name[],
51  const std::vector<std::complex<int16_t>>& val);
52  void WriteAttribute(const char name[],
53  const std::vector<std::complex<float>>& val);
54  void WriteAttribute(const char name[], size_t val);
55  void WriteAttribute(const char name[], int val);
56  void WriteAttribute(const char name[], const std::vector<size_t>& val);
57  void WriteAttribute(const char name[], const std::string& val);
58  void WriteAttribute(const char name[], const std::vector<std::string>& val);
59 
60  private:
61  H5std_string hdf5_name_;
62  H5std_string group_name_;
63  std::unique_ptr<H5::H5File> file_;
64  std::unique_ptr<H5::Group> group_;
65 
67  std::map<std::string, size_t> ds_name_id_;
68  std::vector<std::unique_ptr<H5::DataSet>> datasets_;
69 };
70 }; // namespace Agora_recorder
71 #endif // AGORA_HDF5LIB_H_
size
end IFFT Reshape the symbol vector into two different spatial streams size
Definition: generate_data.m:73
hdf5_lib.h
Agora_recorder::Hdf5Lib::~Hdf5Lib
~Hdf5Lib()
Definition: hdf5_lib.cc:31
Agora_recorder::Hdf5Lib
Definition: hdf5_lib.h:24
Agora_recorder::kDExtendDimIdx
static constexpr size_t kDExtendDimIdx
Definition: hdf5_lib.cc:19
AGORA_LOG_ERROR
#define AGORA_LOG_ERROR(...)
Definition: logger.h:39
Agora_recorder
Definition: hdf5_lib.cc:17
count
count
Definition: inspect_agora_results.m:96
Agora_recorder::Hdf5Lib::group_
std::unique_ptr< H5::Group > group_
Definition: hdf5_lib.h:64
AGORA_LOG_TRACE
#define AGORA_LOG_TRACE(...)
Definition: logger.h:92
Agora_recorder::Hdf5Lib::hdf5_name_
H5std_string hdf5_name_
Definition: hdf5_lib.h:61
Agora_recorder::Hdf5Lib::ExtendDataset
void ExtendDataset(const std::string &dataset_name, const std::array< hsize_t, kDsDimsNum > &extended_dims)
Definition: hdf5_lib.cc:109
i
for i
Definition: generate_data.m:107
Agora_recorder::Hdf5Lib::WriteDataset
herr_t WriteDataset(const std::string &dataset_name, const std::array< hsize_t, kDsDimsNum > &start, const std::array< hsize_t, kDsDimsNum > &count, const short *wrt_data)
Definition: hdf5_lib.cc:135
Agora_recorder::Hdf5Lib::file_
std::unique_ptr< H5::H5File > file_
Definition: hdf5_lib.h:63
start
end start
Definition: inspect_agora_results.m:95
Agora_recorder::Hdf5Lib::Hdf5Lib
Hdf5Lib(H5std_string hdf5_name, H5std_string group_name)
Definition: hdf5_lib.cc:21
Agora_recorder::kPrintDataSetInfo
static constexpr bool kPrintDataSetInfo
Definition: hdf5_lib.cc:18
Agora_recorder::Hdf5Lib::group_name_
H5std_string group_name_
Definition: hdf5_lib.h:62
Agora_recorder::Hdf5Lib::FinalizeDataset
void FinalizeDataset(const std::string &dataset_name)
Definition: hdf5_lib.cc:101
Agora_recorder::Hdf5Lib::CreateDataset
void CreateDataset(const std::string &dataset_name, const std::array< hsize_t, kDsDimsNum > &chunk_dims, const std::array< hsize_t, kDsDimsNum > &init_dims, const ssize_t extend_dimension=0, const H5::PredType &type=H5::PredType::STD_I16BE)
Definition: hdf5_lib.cc:50
AGORA_LOG_INFO
#define AGORA_LOG_INFO(...)
Definition: logger.h:62
std
Definition: json.hpp:5213
AGORA_LOG_WARN
#define AGORA_LOG_WARN(...)
Definition: logger.h:53
Agora_recorder::Hdf5Lib::ds_name_id_
std::map< std::string, size_t > ds_name_id_
Datset lookup table.
Definition: hdf5_lib.h:67
Agora_recorder::kDsDimsNum
static constexpr size_t kDsDimsNum
Definition: hdf5_lib.h:22
Agora_recorder::Hdf5Lib::WriteAttribute
void WriteAttribute(const char name[], double val)
Definition: hdf5_lib.cc:242
Agora_recorder::Hdf5Lib::datasets_
std::vector< std::unique_ptr< H5::DataSet > > datasets_
Definition: hdf5_lib.h:68
fmt::v8::detail::type
type
Definition: core.h:1131