h5geo 0.4.0
C++17 and python API to work with geo-data (seismic, wells, maps, other in process) based on HDF5. Aimed at geoscientists and developers.
Loading...
Searching...
No Matches
h5core.h
1#ifndef H5CORE_H
2#define H5CORE_H
3
4#ifndef H5GT_USE_EIGEN
5#define H5GT_USE_EIGEN // should be defined before including h5gt
6#endif
7
8#include "h5geo_export.h"
9#include "private/h5enum.h"
10#include "private/h5easyhull.h"
11#include "private/h5interpolation.h"
12#include "private/h5polyfit.h"
13#include "private/h5sort.h"
14
15#include <map>
16#include <type_traits>
17#include <string>
18#include <vector>
19#include <regex>
20#include <optional>
21#include <limits.h>
22#include <stdint.h>
23
24#include <Eigen/Dense>
25
26#ifndef H5GT_USE_EIGEN
27#define H5GT_USE_EIGEN // should be defined before including h5gt
28#endif
29
30#include <h5gt/H5File.hpp>
31#include <h5gt/H5Group.hpp>
32#include <h5gt/H5DataSet.hpp>
33#include <h5gt/H5DataSpace.hpp>
34#include <h5gt/H5Attribute.hpp>
35
36class H5Seis;
37
38#if CHAR_BIT != 8
39#error "unsupported char size"
40#endif
41
42enum {
43 O32_LITTLE_ENDIAN = 0x03020100ul,
44 O32_BIG_ENDIAN = 0x00010203ul,
45 O32_PDP_ENDIAN = 0x01000302ul, /* DEC PDP-11 (aka ENDIAN_LITTLE_WORD) */
46 O32_HONEYWELL_ENDIAN = 0x02030001ul /* Honeywell 316 (aka ENDIAN_BIG_WORD) */
47};
48
49static const union {
50 unsigned char bytes[4];
51 uint32_t value;
52} o32_host_order = { { 0, 1, 2, 3 } };
53
54#define O32_HOST_ORDER (o32_host_order.value)
55
56namespace h5geo
57{
58
60template<typename Object, typename T,
61 typename std::enable_if<
62 std::is_same<Object, h5gt::File>::value ||
63 std::is_same<Object, h5gt::Group>::value>::type* = nullptr>
65 Object& node,
66 const std::string& datasetPath,
67 T* M,
68 size_t nH5Rows,
69 size_t nH5Cols,
70 const std::string& unitsFrom = "",
71 const std::string& unitsTo = "");
72
74template<typename Object, typename D,
75 typename std::enable_if<
76 (std::is_same<Object, h5gt::File>::value ||
77 std::is_same<Object, h5gt::Group>::value) &&
78 std::is_arithmetic<typename D::Scalar>::value>::type* = nullptr>
80 Object& node,
81 const std::string& datasetPath,
82 Eigen::DenseBase<D>& M,
83 const std::string& unitsFrom = "",
84 const std::string& unitsTo = "");
85
87template<typename Object, typename T,
88 typename std::enable_if<
89 (std::is_same<Object, h5gt::File>::value ||
90 std::is_same<Object, h5gt::Group>::value) &&
91 std::is_arithmetic<T>::value>::type* = nullptr>
93 Object& node,
94 const std::string& datasetPath,
95 std::vector<T>& v,
96 const std::string& unitsFrom = "",
97 const std::string& unitsTo = "");
98
100template<typename Object, typename T,
101 typename std::enable_if<
102 (std::is_same<Object, h5gt::File>::value ||
103 std::is_same<Object, h5gt::Group>::value) &&
104 std::is_arithmetic<T>::value>::type* = nullptr>
106 Object& node,
107 const std::string& datasetPath,
108 T& v,
109 const std::string& unitsFrom = "",
110 const std::string& unitsTo = "");
111
113template<typename Object, typename T,
114 typename std::enable_if<
115 std::is_same<Object, h5gt::File>::value ||
116 std::is_same<Object, h5gt::Group>::value>::type* = nullptr>
118 Object& node,
119 const std::string& datasetPath,
120 T* M,
121 size_t nH5Rows,
122 size_t nH5Cols,
123 const std::string& unitsFrom = "",
124 const std::string& unitsTo = "");
125
127template<typename Object, typename D,
128 typename std::enable_if<
129 (std::is_same<Object, h5gt::File>::value ||
130 std::is_same<Object, h5gt::Group>::value) &&
131 std::is_arithmetic<typename D::Scalar>::value>::type* = nullptr>
133 Object& node,
134 const std::string& datasetPath,
135 Eigen::DenseBase<D>& M,
136 const std::string& unitsFrom = "",
137 const std::string& unitsTo = "");
138
140template<typename Object, typename T,
141 typename std::enable_if<
142 (std::is_same<Object, h5gt::File>::value ||
143 std::is_same<Object, h5gt::Group>::value) &&
144 std::is_arithmetic<T>::value>::type* = nullptr>
146 Object& node,
147 const std::string& datasetPath,
148 std::vector<T>& v,
149 const std::string& unitsFrom = "",
150 const std::string& unitsTo = "");
151
153template<typename Object, typename T,
154 typename std::enable_if<
155 (std::is_same<Object, h5gt::File>::value ||
156 std::is_same<Object, h5gt::Group>::value) &&
157 std::is_arithmetic<T>::value>::type* = nullptr>
159 Object& node,
160 const std::string& datasetPath,
161 T& v,
162 const std::string& unitsFrom = "",
163 const std::string& unitsTo = "");
164
166template <typename Object, typename T,
167 typename std::enable_if<
168 std::is_same<Object, h5gt::File>::value ||
169 std::is_same<Object, h5gt::Group>::value>::type* = nullptr>
170bool _readDataset(
171 Object& node,
172 const std::string& datasetPath,
173 T* M,
174 size_t nElem,
175 const std::string& unitsFrom = "",
176 const std::string& unitsTo = "");
177
179template<typename Object, typename D,
180 typename std::enable_if<
181 (std::is_same<Object, h5gt::File>::value ||
182 std::is_same<Object, h5gt::Group>::value ||
183 std::is_same<Object, h5gt::DataSet>::value) &&
184 std::is_arithmetic<typename D::Scalar>::value>::type* = nullptr>
185bool readDataset(
186 Object& node,
187 const std::string& datasetPath,
188 Eigen::DenseBase<D>& M,
189 const std::string& unitsFrom = "",
190 const std::string& unitsTo = "");
191
193template<typename Object,
194 typename std::enable_if<
195 std::is_same<Object, h5gt::File>::value ||
196 std::is_same<Object, h5gt::Group>::value ||
197 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
198Eigen::MatrixXf readFloatEigenMtxDataset(
199 Object& node,
200 const std::string& datasetPath,
201 const std::string& unitsFrom = "",
202 const std::string& unitsTo = "");
203
205template<typename Object,
206 typename std::enable_if<
207 std::is_same<Object, h5gt::File>::value ||
208 std::is_same<Object, h5gt::Group>::value ||
209 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
210Eigen::MatrixXd readDoubleEigenMtxDataset(
211 Object& node,
212 const std::string& datasetPath,
213 const std::string& unitsFrom = "",
214 const std::string& unitsTo = "");
215
217template <typename Object, typename T,
218 typename std::enable_if<
219 std::is_same<Object, h5gt::File>::value ||
220 std::is_same<Object, h5gt::Group>::value ||
221 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
222bool _readAttribute(
223 Object& holder,
224 const std::string& attrName,
225 T* v,
226 size_t nElem,
227 const std::string& unitsFrom = "",
228 const std::string& unitsTo = "");
229
231template<typename Object, typename D,
232 typename std::enable_if<
233 (std::is_same<Object, h5gt::File>::value ||
234 std::is_same<Object, h5gt::Group>::value ||
235 std::is_same<Object, h5gt::DataSet>::value) &&
236 std::is_arithmetic<typename D::Scalar>::value>::type* = nullptr>
237bool readAttribute(
238 Object& holder,
239 const std::string& attrName,
240 Eigen::DenseBase<D>& v,
241 const std::string& unitsFrom = "",
242 const std::string& unitsTo = "");
243
245template <typename Object, typename T,
246 typename std::enable_if<
247 (std::is_same<Object, h5gt::File>::value ||
248 std::is_same<Object, h5gt::Group>::value ||
249 std::is_same<Object, h5gt::DataSet>::value) &&
250 std::is_arithmetic<T>::value>::type* = nullptr>
251bool readAttribute(
252 Object& holder,
253 const std::string& attrName,
254 std::vector<T>& v,
255 const std::string& unitsFrom = "",
256 const std::string& unitsTo = "");
257
259template <typename Object, typename T,
260 typename std::enable_if<
261 (std::is_same<Object, h5gt::File>::value ||
262 std::is_same<Object, h5gt::Group>::value ||
263 std::is_same<Object, h5gt::DataSet>::value) &&
264 std::is_arithmetic<T>::value>::type* = nullptr>
265bool readAttribute(
266 Object& holder,
267 const std::string& attrName,
268 T& v,
269 const std::string& unitsFrom = "",
270 const std::string& unitsTo = "");
271
273template <typename Object, typename T,
274 typename std::enable_if<
275 std::is_same<Object, h5gt::File>::value ||
276 std::is_same<Object, h5gt::Group>::value||
277 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
279 Object& holder,
280 const std::string& attrName,
281 T* v,
282 size_t nElem,
283 const std::string& unitsFrom = "",
284 const std::string& unitsTo = "");
285
287template<typename Object,
288 typename std::enable_if<
289 std::is_same<Object, h5gt::File>::value ||
290 std::is_same<Object, h5gt::Group>::value ||
291 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
293 Object& holder,
294 const std::string& attrName,
295 const std::string& str);
296
298template<typename Object, typename D,
299 typename std::enable_if<
300 (std::is_same<Object, h5gt::File>::value ||
301 std::is_same<Object, h5gt::Group>::value ||
302 std::is_same<Object, h5gt::DataSet>::value) &&
303 std::is_arithmetic<typename D::Scalar>::value>::type* = nullptr>
305 Object& holder,
306 const std::string& attrName,
307 Eigen::DenseBase<D>& v,
308 const std::string& unitsFrom = "",
309 const std::string& unitsTo = "");
310
312template <typename Object, typename T,
313 typename std::enable_if<
314 (std::is_same<Object, h5gt::File>::value ||
315 std::is_same<Object, h5gt::Group>::value ||
316 std::is_same<Object, h5gt::DataSet>::value) &&
317 std::is_arithmetic<T>::value>::type* = nullptr>
319 Object& holder,
320 const std::string& attrName,
321 std::vector<T>& v,
322 const std::string& unitsFrom = "",
323 const std::string& unitsTo = "");
324
326template <typename Object, typename T,
327 typename std::enable_if<
328 (std::is_same<Object, h5gt::File>::value ||
329 std::is_same<Object, h5gt::Group>::value ||
330 std::is_same<Object, h5gt::DataSet>::value) &&
331 std::is_arithmetic<T>::value>::type* = nullptr>
333 Object& holder,
334 const std::string& attrName,
335 T& v,
336 const std::string& unitsFrom = "",
337 const std::string& unitsTo = "");
338
340template <typename Object, typename T,
341 typename std::enable_if<
342 std::is_same<Object, h5gt::File>::value ||
343 std::is_same<Object, h5gt::Group>::value||
344 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
346 Object& holder,
347 const std::string& attrName,
348 T* v,
349 size_t nElem);
350
352template <typename Object, typename T,
353 typename std::enable_if<
354 (std::is_same<Object, h5gt::File>::value ||
355 std::is_same<Object, h5gt::Group>::value ||
356 std::is_same<Object, h5gt::DataSet>::value) &&
357 std::is_enum<T>::value>::type* = nullptr>
359 Object& holder,
360 const std::string& attrName,
361 T& v);
362
364template <typename Object, typename T,
365 typename std::enable_if<
366 (std::is_same<Object, h5gt::File>::value ||
367 std::is_same<Object, h5gt::Group>::value ||
368 std::is_same<Object, h5gt::DataSet>::value) &&
369 std::is_enum<T>::value>::type* = nullptr>
371 Object& holder,
372 const std::string& attrName,
373 std::vector<T>& v);
374
376template <typename Object, typename T,
377 typename std::enable_if<
378 std::is_same<Object, h5gt::File>::value ||
379 std::is_same<Object, h5gt::Group>::value ||
380 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
381inline bool _readEnumAttribute(
382 Object& holder,
383 const std::string& attrName,
384 T *v,
385 size_t nElem);
386
388template<typename Object, typename T,
389 typename std::enable_if<
390 (std::is_same<Object, h5gt::File>::value ||
391 std::is_same<Object, h5gt::Group>::value ||
392 std::is_same<Object, h5gt::DataSet>::value) &&
393 std::is_enum<T>::value>::type* = nullptr>
394T readEnumAttribute(Object& object, const std::string& attrName);
395
397template<typename Object, typename T,
398 typename std::enable_if<
399 (std::is_same<Object, h5gt::File>::value ||
400 std::is_same<Object, h5gt::Group>::value ||
401 std::is_same<Object, h5gt::DataSet>::value) &&
402 std::is_enum<T>::value>::type* = nullptr>
403std::vector<T> readEnumVecAttribute(Object& object, const std::string& attrName);
404
406template<typename Object,
407 typename std::enable_if<
408 std::is_same<Object, h5gt::File>::value ||
409 std::is_same<Object, h5gt::Group>::value ||
410 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
411std::string readStringAttribute(Object& object, const std::string& attrName);
412
414template<typename Object,
415 typename std::enable_if<
416 std::is_same<Object, h5gt::File>::value ||
417 std::is_same<Object, h5gt::Group>::value ||
418 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
420 Object& object, const std::string& attrName,
421 const std::string& unitsFrom = "",
422 const std::string& unitsTo = "");
423
425template<typename Object,
426 typename std::enable_if<
427 std::is_same<Object, h5gt::File>::value ||
428 std::is_same<Object, h5gt::Group>::value ||
429 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
431 Object& object, const std::string& attrName,
432 const std::string& unitsFrom = "",
433 const std::string& unitsTo = "");
434
436template<typename Object,
437 typename std::enable_if<
438 std::is_same<Object, h5gt::File>::value ||
439 std::is_same<Object, h5gt::Group>::value ||
440 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
441std::vector<float> readFloatVecAttribute(
442 Object& object, const std::string& attrName,
443 const std::string& unitsFrom = "",
444 const std::string& unitsTo = "");
445
447template<typename Object,
448 typename std::enable_if<
449 std::is_same<Object, h5gt::File>::value ||
450 std::is_same<Object, h5gt::Group>::value ||
451 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
452std::vector<double> readDoubleVecAttribute(
453 Object& object, const std::string& attrName,
454 const std::string& unitsFrom = "",
455 const std::string& unitsTo = "");
456
458template<typename Object,
459 typename std::enable_if<
460 std::is_same<Object, h5gt::File>::value ||
461 std::is_same<Object, h5gt::Group>::value ||
462 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
463Eigen::VectorXf readFloatEigenVecAttribute(
464 Object& object, const std::string& attrName,
465 const std::string& unitsFrom = "",
466 const std::string& unitsTo = "");
467
469template<typename Object,
470 typename std::enable_if<
471 std::is_same<Object, h5gt::File>::value ||
472 std::is_same<Object, h5gt::Group>::value ||
473 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
474Eigen::VectorXd readDoubleEigenVecAttribute(
475 Object& object, const std::string& attrName,
476 const std::string& unitsFrom = "",
477 const std::string& unitsTo = "");
478
487
492template<typename D>
494 h5gt::DataSet& dataset,
495 const std::string& attrName,
496 const Eigen::DenseBase<D>& v,
497 bool resize);
498
503template<typename T>
504Eigen::VectorX<T> getDataFromIndexedDataset(
505 h5gt::DataSet& dataset,
506 const std::string& attrName);
507
508// UTIL
509
510H5GEO_EXPORT std::optional<h5gt::File> openFile(
511 const std::string& fileName);
512H5GEO_EXPORT std::optional<h5gt::Group> openGroup(
513 const std::string& fileName,
514 const std::string& groupName);
515H5GEO_EXPORT std::optional<h5gt::DataSet> openDataSet(
516 const std::string& fileName,
517 const std::string& dsetName);
518
519H5GEO_EXPORT std::vector<std::string> getRawBinHeaderNames();
520H5GEO_EXPORT std::vector<std::string> getRawTraceHeaderNames();
521
541H5GEO_EXPORT bool generatePRESTKGeometry(
542 H5Seis* seis,
543 double src_x0, double src_dx, size_t src_nx,
544 double src_y0, double src_dy, size_t src_ny,
545 double src_z,
546 double rec_x0, double rec_dx, size_t rec_nx,
547 double rec_y0, double rec_dy, size_t rec_ny,
548 double rec_z,
549 double orientation,
550 bool moveRec);
551
562H5GEO_EXPORT std::map<std::string, Eigen::VectorXd>
564 double x0, double dx, size_t nx,
565 double y0, double dy, size_t ny,
566 double z,
567 double orientation);
568
574H5GEO_EXPORT bool compareStrings(
575 const std::string& bigger,
576 const std::string& smaller,
577 const CaseSensitivity& caseSensitivity = CaseSensitivity::CASE_INSENSITIVE);
578
582H5GEO_EXPORT void eraseSubStr(
583 std::string & mainStr, const std::string & toErase);
584
588H5GEO_EXPORT void eraseAllSubStr(
589 std::string & mainStr, const std::string & toErase);
590
591H5GEO_EXPORT char getDelimiter(
592 const Delimiter& delimiter);
593
598H5GEO_EXPORT std::string generateName(
599 const std::vector<std::string> &nameList,
600 std::string baseName = std::string());
601
602H5GEO_EXPORT std::vector<std::string> splitString(
603 const std::string &s, const std::string delimiter);
604
605H5GEO_EXPORT void splitHeaderNames(
606 const std::vector<std::string> &headerNamesToSplit,
607 std::vector<std::string> &fullHeaderNames,
608 std::vector<std::string> &shortHeaderNames);
609
610H5GEO_EXPORT void splitHeaderBytes(
611 const std::vector<std::string> &headerNamesToSplit,
612 std::vector<int> &bytesStart,
613 std::vector<int> &nBytes);
614
620H5GEO_EXPORT std::vector<std::string> splitPath(
621 std::string path);
622
630H5GEO_EXPORT std::vector<std::string> splitPath(
631 std::string path, std::string& filteredPath);
632
641H5GEO_EXPORT std::string splitPathToParentAndObj(
642 const std::string& path,
643 std::string& objName);
644
645H5GEO_EXPORT std::string getRelativePath(
646 const std::string& referencePath,
647 const std::string& objPath,
648 const CaseSensitivity& caseSensitivity = CaseSensitivity::CASE_INSENSITIVE);
649
650H5GEO_EXPORT void getTraceHeaderNames(
651 std::vector<std::string> &fullHeaderNames,
652 std::vector<std::string> &shortHeaderNames);
653H5GEO_EXPORT std::vector<std::string> getTraceHeaderShortNames();
654H5GEO_EXPORT std::vector<std::string> getTraceHeaderFullNames();
655
656H5GEO_EXPORT void getBinHeaderNames(
657 std::vector<std::string> &fullHeaderNames,
658 std::vector<std::string> &shortHeaderNames);
659H5GEO_EXPORT std::vector<std::string> getBinHeaderShortNames();
660H5GEO_EXPORT std::vector<std::string> getBinHeaderFullNames();
661
662H5GEO_EXPORT void getTraceHeaderBytes(
663 std::vector<int> &bytesStart,
664 std::vector<int> &nBytes);
665H5GEO_EXPORT void getBinHeaderBytes(
666 std::vector<int> &bytesStart,
667 std::vector<int> &nBytes);
668
669H5GEO_EXPORT size_t getTraceHeaderCount();
670H5GEO_EXPORT size_t getBinHeaderCount();
671
677H5GEO_EXPORT ptrdiff_t getIndexFromAttribute(
678 h5gt::DataSet& dataset,
679 const std::string& attrName);
680
775H5GEO_EXPORT bool getSurveyInfoFromSortedData(
776 const Eigen::Ref<const Eigen::VectorXf>& il,
777 const Eigen::Ref<const Eigen::VectorXf>& xl,
778 const Eigen::Ref<const Eigen::VectorXf>& x,
779 const Eigen::Ref<const Eigen::VectorXf>& y,
780 double &origin_x,
781 double &origin_y,
782 double &orientation,
783 double &ilSpacing,
784 double &xlSpacing,
785 bool &isILReversed,
786 bool &isXLReversed,
787 bool &isPlanReversed);
788
789H5GEO_EXPORT bool getSurveyInfoFromSortedData(
790 const Eigen::Ref<const Eigen::VectorXd>& il,
791 const Eigen::Ref<const Eigen::VectorXd>& xl,
792 const Eigen::Ref<const Eigen::VectorXd>& x,
793 const Eigen::Ref<const Eigen::VectorXd>& y,
794 double &origin_x,
795 double &origin_y,
796 double &orientation,
797 double &ilSpacing,
798 double &xlSpacing,
799 bool &isILReversed,
800 bool &isXLReversed,
801 bool &isPlanReversed);
802
803H5GEO_EXPORT bool getSurveyInfoFromUnsortedData(
804 Eigen::Ref<Eigen::MatrixXf> il_xl,
805 Eigen::Ref<Eigen::VectorXf> x,
806 Eigen::Ref<Eigen::VectorXf> y,
807 double &origin_x,
808 double &origin_y,
809 double &orientation,
810 double &ilSpacing,
811 double &xlSpacing,
812 bool &isILReversed,
813 bool &isXLReversed,
814 bool &isPlanReversed);
815
816H5GEO_EXPORT bool getSurveyInfoFromUnsortedData(
817 Eigen::Ref<Eigen::MatrixXd> il_xl,
818 Eigen::Ref<Eigen::VectorXd> x,
819 Eigen::Ref<Eigen::VectorXd> y,
820 double &origin_x,
821 double &origin_y,
822 double &orientation,
823 double &ilSpacing,
824 double &xlSpacing,
825 bool &isILReversed,
826 bool &isXLReversed,
827 bool &isPlanReversed);
828
835H5GEO_EXPORT bool isStraightLine(
836 const Eigen::Ref<const Eigen::VectorXf>& x,
837 const Eigen::Ref<const Eigen::VectorXf>& y,
838 float eps = std::numeric_limits<float>::epsilon());
839
840H5GEO_EXPORT bool isStraightLine(
841 const Eigen::Ref<const Eigen::VectorXd>& x,
842 const Eigen::Ref<const Eigen::VectorXd>& y,
843 double eps = std::numeric_limits<double>::epsilon());
844
845
846template<typename Object,
847 typename std::enable_if<
848 std::is_same<Object, h5gt::File>::value ||
849 std::is_same<Object, h5gt::Group>::value ||
850 std::is_same<Object, h5gt::DataSet>::value>::type* = nullptr>
851bool deleteAllAttributes(Object& object);
852
855template<typename Object,
856 typename std::enable_if<
857 std::is_same<Object, h5gt::File>::value ||
858 std::is_same<Object, h5gt::Group>::value>::type* = nullptr>
859bool unlinkContent(Object& object);
860
867template<typename T>
868Eigen::VectorX<ptrdiff_t> find_index(
869 Eigen::DenseBase<T> const & M);
870
871template<typename D, typename T,
872 typename std::enable_if<
873 std::is_arithmetic<T>::value>::type* = nullptr>
874h5gt::ElementSet rowCols2ElementSet(
875 const T& row,
876 const Eigen::DenseBase<D>& cols);
877
878template<typename D, typename T,
879 typename std::enable_if<
880 std::is_arithmetic<T>::value>::type* = nullptr>
881h5gt::ElementSet rowsCol2ElementSet(
882 const Eigen::DenseBase<D>& rows,
883 const T& col);
884
890template<typename D>
891h5gt::ElementSet rowsCols2ElementSet(
892 const Eigen::DenseBase<D>& rows,
893 const Eigen::DenseBase<D>& cols);
894
895template<typename T,
896 typename std::enable_if<
897 std::is_arithmetic<T>::value>::type* = nullptr>
898h5gt::ElementSet rowCols2ElementSet(
899 const T& row,
900 const std::vector<T>& cols);
901
902template<typename T,
903 typename std::enable_if<
904 std::is_arithmetic<T>::value>::type* = nullptr>
905h5gt::ElementSet rowsCol2ElementSet(
906 const std::vector<T>& rows,
907 const T& col);
908
914template<typename T,
915 typename std::enable_if<
916 std::is_arithmetic<T>::value>::type* = nullptr>
917h5gt::ElementSet rowsCols2ElementSet(
918 const std::vector<T>& rows,
919 const std::vector<T>& cols);
920
921} // namespace h5geo
922
923
924#ifdef H5GEO_USE_GDAL
925#include "private/h5core_sr_settings.h"
926#endif
927
928#include "private/h5coreimpl.h"
929#include "private/h5core_segy.h"
930
931
932#endif // H5CORE_H
Provides API to work with seismic.
Definition h5seis.h:33
Basic namespace.
Definition h5base.h:29
std::vector< float > readFloatVecAttribute(Object &object, const std::string &attrName, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from Attribute.
Definition h5coreimpl.h:763
Eigen::VectorXd readDoubleEigenVecAttribute(Object &object, const std::string &attrName, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from Attribute.
Definition h5coreimpl.h:805
std::vector< double > readDoubleVecAttribute(Object &object, const std::string &attrName, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from Attribute.
Definition h5coreimpl.h:777
bool unlinkContent(Object &object)
unlinkContent Unlink everything in group
Definition h5coreimpl.h:897
H5GEO_EXPORT std::string generateName(const std::vector< std::string > &nameList, std::string baseName=std::string())
generateName generates unique name by adding "_i"
Definition h5core.cpp:481
bool _overwriteDataset(Object &node, const std::string &datasetPath, T *M, size_t nH5Rows, size_t nH5Cols, const std::string &unitsFrom="", const std::string &unitsTo="")
Create or overwrite DataSet.
Definition h5coreimpl.h:128
bool _readEnumAttribute(Object &holder, const std::string &attrName, T *v, size_t nElem)
Read enum data from Attribute.
Definition h5coreimpl.h:431
h5gt::ElementSet rowsCols2ElementSet(const Eigen::DenseBase< D > &rows, const Eigen::DenseBase< D > &cols)
rowsCols2ElementSet select rectilinear block of elements, i.e. uses double loop to select every possi...
Definition h5coreimpl.h:958
Eigen::VectorX< T > getDataFromIndexedDataset(h5gt::DataSet &dataset, const std::string &attrName)
Get data from indexed DataSet.
Definition h5coreimpl.h:851
bool _readDataset(Object &node, const std::string &datasetPath, T *M, size_t nElem, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from DataSet to buffer.
Definition h5coreimpl.h:222
bool readDataset(Object &node, const std::string &datasetPath, Eigen::DenseBase< D > &M, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from DataSet.
Definition h5coreimpl.h:262
bool _overwriteAttribute(Object &holder, const std::string &attrName, T *v, size_t nElem, const std::string &unitsFrom="", const std::string &unitsTo="")
Create or overwrite Attribute.
Definition h5coreimpl.h:501
bool _readAttribute(Object &holder, const std::string &attrName, T *v, size_t nElem, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from Attribute.
Definition h5coreimpl.h:322
bool writeDataToIndexedDataset(h5gt::DataSet &dataset, const std::string &attrName, const Eigen::DenseBase< D > &v, bool resize)
writeDataToIndexedDataset Try to write vector to dataset with attribute where attribute is a single v...
Definition h5coreimpl.h:815
bool overwriteDataset(Object &node, const std::string &datasetPath, Eigen::DenseBase< D > &M, const std::string &unitsFrom="", const std::string &unitsTo="")
Create or overwrite DataSet.
Definition h5coreimpl.h:175
H5GEO_EXPORT bool getSurveyInfoFromSortedData(const Eigen::Ref< const Eigen::VectorXf > &il, const Eigen::Ref< const Eigen::VectorXf > &xl, const Eigen::Ref< const Eigen::VectorXf > &x, const Eigen::Ref< const Eigen::VectorXf > &y, double &origin_x, double &origin_y, double &orientation, double &ilSpacing, double &xlSpacing, bool &isILReversed, bool &isXLReversed, bool &isPlanReversed)
getSurveyInfoFromSortedData It is assumed that il, xl, x, y are IL_XL sorted: ind=sort_rows(il_xl),...
Definition h5core.cpp:948
bool overwriteResizableDataset(Object &node, const std::string &datasetPath, Eigen::DenseBase< D > &M, const std::string &unitsFrom="", const std::string &unitsTo="")
Resize and overwrite DataSet or create it if not exists.
Definition h5coreimpl.h:81
H5GEO_EXPORT std::string splitPathToParentAndObj(const std::string &path, std::string &objName)
splitPathToParentAndObj Return path to parent and object name. E.g. if path = /a/s then it returns /a...
Definition h5core.cpp:579
double readDoubleAttribute(Object &object, const std::string &attrName, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from Attribute.
Definition h5coreimpl.h:748
Eigen::MatrixXf readFloatEigenMtxDataset(Object &node, const std::string &datasetPath, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from DataSet.
Definition h5coreimpl.h:289
H5GEO_EXPORT ptrdiff_t getIndexFromAttribute(h5gt::DataSet &dataset, const std::string &attrName)
getIndexFromAttribute Get row/col from Datasets with attributes where attribute reflects the row/col ...
Definition h5core.cpp:701
Eigen::VectorXf readFloatEigenVecAttribute(Object &object, const std::string &attrName, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from Attribute.
Definition h5coreimpl.h:791
H5GEO_EXPORT std::vector< std::string > splitPath(std::string path)
splitPath Split path of type /path///to/where/things/happen// to output vector {"path",...
Definition h5core.cpp:544
float readFloatAttribute(Object &object, const std::string &attrName, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from Attribute.
Definition h5coreimpl.h:734
bool readAttribute(Object &holder, const std::string &attrName, Eigen::DenseBase< D > &v, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from Attribute.
Definition h5coreimpl.h:361
H5GEO_EXPORT bool generatePRESTKGeometry(H5Seis *seis, double src_x0, double src_dx, size_t src_nx, double src_y0, double src_dy, size_t src_ny, double src_z, double rec_x0, double rec_dx, size_t rec_nx, double rec_y0, double rec_dy, size_t rec_ny, double rec_z, double orientation, bool moveRec)
As the generated geometry may be pretty big we write it to H5Seis object without returning any data.
Definition h5core.cpp:229
H5GEO_EXPORT std::map< std::string, Eigen::VectorXd > generateSTKGeometry(double x0, double dx, size_t nx, double y0, double dy, size_t ny, double z, double orientation)
Convenient function to generate STACK geometry.
Definition h5core.cpp:372
bool _overwriteResizableDataset(Object &node, const std::string &datasetPath, T *M, size_t nH5Rows, size_t nH5Cols, const std::string &unitsFrom="", const std::string &unitsTo="")
Resize and overwrite DataSet or create it if not exists.
Definition h5coreimpl.h:33
std::string readStringAttribute(Object &object, const std::string &attrName)
Read enum data from Attribute.
Definition h5coreimpl.h:714
bool overwriteAttribute(Object &holder, const std::string &attrName, const std::string &str)
Create or overwrite Attribute.
Definition h5coreimpl.h:549
std::vector< T > readEnumVecAttribute(Object &object, const std::string &attrName)
Read data from Attribute.
Definition h5coreimpl.h:475
H5GEO_EXPORT bool compareStrings(const std::string &bigger, const std::string &smaller, const CaseSensitivity &caseSensitivity=CaseSensitivity::CASE_INSENSITIVE)
compareStrings Return true if strings are equal.
Definition h5core.cpp:421
H5GEO_EXPORT void eraseAllSubStr(std::string &mainStr, const std::string &toErase)
eraseAllSubStr Erase all Occurrences of given substring from main string.
Definition h5core.cpp:454
H5GEO_EXPORT void eraseSubStr(std::string &mainStr, const std::string &toErase)
eraseSubStr First Occurrence of given substring from main string.
Definition h5core.cpp:442
Eigen::MatrixXd readDoubleEigenMtxDataset(Object &node, const std::string &datasetPath, const std::string &unitsFrom="", const std::string &unitsTo="")
Read data from DataSet.
Definition h5coreimpl.h:305
Eigen::VectorX< ptrdiff_t > find_index(Eigen::DenseBase< T > const &M)
find_index find all non-zero elements's indexes. Possible usage: Eigen::VectorX<ptrdiff_t> ind = find...
Definition h5coreimpl.h:910
bool _overwriteEnumAttribute(Object &holder, const std::string &attrName, T *v, size_t nElem)
Create or overwrite registered enum Attribute.
Definition h5coreimpl.h:627
H5GEO_EXPORT bool isStraightLine(const Eigen::Ref< const Eigen::VectorXf > &x, const Eigen::Ref< const Eigen::VectorXf > &y, float eps=std::numeric_limits< float >::epsilon())
check if all points lay on the same straight line taken from here: https://helloacm....
Definition h5core.cpp:1084
bool overwriteEnumAttribute(Object &holder, const std::string &attrName, T &v)
Create or overwrite registered enum Attribute.
Definition h5coreimpl.h:668
T readEnumAttribute(Object &object, const std::string &attrName)
Read data from Attribute.
Definition h5coreimpl.h:462