6 #include <isce3/core/Constants.h>
7 #include <isce3/except/Error.h>
10 #include <type_traits>
20 const hsize_t chunkSizeX = 128;
21 const hsize_t chunkSizeY = 128;
24 const int STRLENGTH = 50;
37 std::vector<std::string> outList;
38 std::string searchStr;
39 std::string searchType;
48 IDataSet(
const H5::DataSet& dset) : H5::DataSet(dset) {};
49 IDataSet(
const hid_t
id) : H5::DataSet(
id) {};
61 int getRank(
const std::string& v =
"");
80 std::string
toGDAL()
const;
85 template<
typename T>
inline void read(T& v,
const std::string& att =
"");
88 void read(std::string& v,
const std::string& att =
"");
91 template<
typename T>
inline void read(T* buf,
const std::string& att);
95 inline void read(std::vector<T>& buf,
const std::string& att);
99 inline void read(std::valarray<T>& buf,
const std::string& att);
128 inline void read(T* buf,
const int* startIn =
nullptr,
129 const int* countIn =
nullptr,
130 const int* strideIn =
nullptr);
135 inline void read(T* buf,
const std::vector<std::slice>* slicesIn);
139 template<
typename T>
inline void read(T* buf,
const std::gslice* gsliceIn);
142 template<
typename T>
inline void read(std::vector<T>& buf);
146 inline void read(std::vector<T>& buf,
const std::vector<int>* startIn,
147 const std::vector<int>* countIn,
148 const std::vector<int>* strideIn);
152 inline void read(std::vector<T>& buf,
153 const std::vector<std::slice>* slicesIn);
158 inline void read(std::vector<T>& buf,
const std::gslice* gsliceIn);
161 template<
typename T>
inline void read(std::valarray<T>& buf);
165 inline void read(std::valarray<T>& buf,
const std::valarray<int>* startIn,
166 const std::valarray<int>* countIn,
167 const std::valarray<int>* strideIn);
172 inline void read(std::valarray<T>& buf,
173 const std::vector<std::slice>* slicesIn);
178 inline void read(std::valarray<T>& buf,
const std::gslice* gsliceIn);
183 template<
typename T>
inline void write(
const std::vector<T>& buf);
187 template<
typename T,
size_t S>
188 inline void write(
const std::vector<T>& buf,
189 const std::array<int, S>& startIn,
190 const std::array<int, S>& countIn,
191 const std::array<int, S>& strideIn);
196 inline void write(
const std::vector<T>& buf,
197 const std::vector<std::slice>* slicesIn);
202 inline void write(
const std::vector<T>& buf,
const std::gslice* gsliceIn);
205 template<
typename T>
inline void write(
const std::valarray<T>& buf);
209 template<
typename T,
size_t S>
210 inline void write(
const std::valarray<T>& buf,
211 const std::array<int, S>& startIn,
212 const std::array<int, S>& countIn,
213 const std::array<int, S>& strideIn);
218 inline void write(
const std::valarray<T>& buf,
219 const std::vector<std::slice>* slicesIn);
224 inline void write(
const std::valarray<T>& buf,
const std::gslice* gsliceIn);
227 template<
typename T>
inline void write(
const T* buf,
const size_t sz);
231 template<
typename T,
size_t S>
232 inline void write(
const T* buf,
const std::array<int, S>& startIn,
233 const std::array<int, S>& countIn,
234 const std::array<int, S>& strideIn);
239 inline void write(
const T* buf,
const std::vector<std::slice>* slicesIn);
244 inline void write(
const T* buf,
const std::gslice* gsliceIn);
253 const std::vector<T>& values);
258 const std::valarray<T>& values);
262 template<
typename T,
typename T2,
size_t S>
264 const std::array<T2, S>& dims,
265 const std::vector<T>& values);
269 template<
typename T,
typename T2,
size_t S>
271 const std::array<T2, S>& dims,
272 const std::valarray<T>& values);
276 template<
typename T,
typename T2,
size_t S>
278 const std::array<T2, S>& dims,
const T* buffer);
282 H5::DataSpace
getDataSpace(
const int* startIn,
const int* countIn,
283 const int* strideIn);
286 H5::DataSpace
getDataSpace(
const std::vector<std::slice>* sliceIn);
289 H5::DataSpace
getDataSpace(
const std::gslice* gsliceIn);
292 H5::DataSpace
getDataSpace(
const size_t xidx,
const size_t yidx,
293 const size_t iowidth,
const size_t iolength,
297 template<
typename T>
void read(T* buffer,
const H5::DataSpace& dspace);
299 void read(std::string* buffer,
const H5::DataSpace& dspace);
300 void read(std::string* buf,
const std::string& att);
303 void createAttribute(
const std::string& name,
const H5::DataType& datatype,
304 const H5::DataSpace& dataspace,
const T* buffer);
307 void write(
const T* buf,
const H5::DataSpace& filespace);
312 void IDataSet::write(
const std::string* buf,
const H5::DataSpace& dspace);
315 const H5::DataType& datatype,
316 const H5::DataSpace& dataspace,
317 const std::string* buffer);
322 IGroup() : H5::Group() {};
323 IGroup(
const H5::Group& group) : H5::Group(group) {};
324 IGroup(hid_t group) : H5::Group(group) {};
326 std::vector<std::string> getAttrs();
329 std::vector<std::string>
find(
const std::string name,
330 const std::string start =
".",
331 const std::string type =
"BOTH",
332 const std::string path =
"FULL");
344 template<
typename T>
inline void read(T& v,
const std::string& att);
347 void read(std::string& v,
const std::string& att);
350 template<
typename T>
inline void read(T* buf,
const std::string& att);
353 void read(std::string* buf,
const std::string& att);
357 inline void read(std::vector<T>& buf,
const std::string& att);
361 inline void read(std::valarray<T>& buf,
const std::string& att);
382 const std::vector<T>& data);
387 const std::valarray<T>& data);
395 template<
typename T,
typename T2,
size_t S>
397 const std::vector<T>& data,
398 const std::array<T2, S>& dims);
401 template<
typename T,
typename T2,
size_t S>
403 const std::valarray<T>& data,
404 const std::array<T2, S>& dims);
407 template<
typename T,
typename T2,
size_t S>
409 const std::array<T2, S>& dims);
412 template<
typename T,
typename T2,
size_t S>
414 const std::array<T2, S>& dims,
const int chunk = 0,
415 const int shuffle = 0,
const int deflate = 0);
424 const std::vector<T>& values);
429 const std::valarray<T>& values);
433 template<
typename T,
typename T2,
size_t S>
435 const std::array<T2, S>& dims,
436 const std::vector<T>& values);
440 template<
typename T,
typename T2,
size_t S>
442 const std::array<T2, S>& dims,
443 const std::valarray<T>& values);
447 template<
typename T,
typename T2,
size_t S>
449 const std::array<T2, S>& dims,
const T* buffer);
453 void createAttribute(
const std::string& name,
const H5::DataType& datatype,
454 const H5::DataSpace& dataspace,
const T* buffer);
459 const H5::DataType& datatype,
460 const H5::DataSpace& dataspace,
461 const std::string* buffer);
474 IH5File(
const H5std_string& name,
const char mode =
'r');
476 void openFile(
const H5std_string& name);
485 std::vector<std::string>
find(
const std::string name,
486 const std::string start =
"/",
487 const std::string type =
"BOTH",
488 const std::string path =
"FULL");
491 inline std::string
filename()
const {
return getFileName(); }
500 #define ISCE_IO_IH5_ICC
502 #undef ISCE_IO_IH5_ICC
H5::DataSpace getDataSpace(const std::string &name)
Return the H5::DataSpace of the given attribute.
Definition: IH5.cpp:831
IGroup openGroup(const H5std_string &name)
Open a given group.
Definition: IH5.cpp:1021
std::vector< std::string > find(const std::string name, const std::string start=".", const std::string type="BOTH", const std::string path="FULL")
Search function for given name in the group.
Definition: IH5.cpp:804
std::vector< int > getDimensions(const std::string &v="")
Get the size of each dimension of the dataset or given attribute.
Definition: IH5.cpp:162
IDataSet openDataSet(const H5std_string &name)
Open a given dataset.
Definition: IH5.cpp:854
void createAttribute(const std::string &name, const T &data)
Creating and writing a scalar as an attribute.
Definition: IH5.icc:1238
void read(T &v, const std::string &att="")
Reading scalar (non string) dataset or attributes.
Definition: IH5.icc:130
int getNumElements(const std::string &v="")
Get the total number of elements contained in dataset or given attribute.
Definition: IH5.cpp:150
std::string getPathname()
Return the path of the group from the file root.
Definition: IH5.cpp:814
void createAttribute(const std::string &name, const T &data)
Creating and writing a scalar as an attribute.
Definition: IH5.icc:824
int getRank(const std::string &v="")
Get the number of dimension of dataset or given attribute.
Definition: IH5.cpp:140
IGroup createGroup(const H5std_string &name)
Create a group.
Definition: IH5.cpp:1029
std::vector< std::string > getAttrs()
Get a list of attributes attached to dataset.
Definition: IH5.cpp:242
std::string toGDAL() const
Generate GDALDataset Representation.
Definition: IH5.cpp:340
void write(const std::vector< T > &buf)
Writing std::vector data into a dataset.
Definition: IH5.icc:512
Our derived dataset structure that includes utility functions.
Definition: IH5.h:44
int getNumElements(const std::string &name)
Return the number of elements in the given attribute.
Definition: IH5.cpp:843
IGroup createGroup(const H5std_string &name)
Create a group within this group.
Definition: IH5.cpp:932
IDataSet openDataSet(const H5std_string &name)
Open a given dataset.
Definition: IH5.cpp:1013
std::string getTypeClassStr(const std::string &v="")
Get the H5 data type of the dataset or given attribute.
Definition: IH5.cpp:198
std::vector< int > getChunkSize()
Get the storage chunk size of the dataset.
Definition: IH5.cpp:266
std::vector< std::string > find(const std::string name, const std::string start="/", const std::string type="BOTH", const std::string path="FULL")
Searching for given name in file.
Definition: IH5.cpp:1065
H5::DataSpace getDataSpace(const std::string &v="")
Get a HDF5 DataSpace object corresponding to dataset or given attribute.
Definition: IH5.cpp:117
int getNumBits(const std::string &v="")
Get the number of bit used to store each dataset element.
Definition: IH5.cpp:305
void read(T &v, const std::string &att)
Reading scalar attribute given by name.
Definition: IH5.icc:852
IGroup openGroup(const H5std_string &name)
Open a given group.
Definition: IH5.cpp:862
IDataSet createDataSet(const std::string &name, const std::string &data)
Create a string scalar dataset and simultaneously write the data.
Definition: IH5.cpp:957
std::string filename() const
Get filename of HDF5 file.
Definition: IH5.h:491