17#include <h5gt/H5File.hpp>
18#include <h5gt/H5Group.hpp>
19#include <h5gt/H5DataSet.hpp>
20#include <h5gt/H5DataSpace.hpp>
21#include <h5gt/H5Attribute.hpp>
23#include <units/units.hpp>
29template<
typename Object,
typename T,
30 typename std::enable_if<
31 std::is_same<Object, h5gt::File>::value ||
32 std::is_same<Object, h5gt::Group>::value>::type*>
35 const std::string& datasetPath,
39 const std::string& unitsFrom,
40 const std::string& unitsTo)
42 if(datasetPath.empty() ||
43 !node.hasObject(datasetPath, h5gt::ObjectType::Dataset))
46 if (nH5Rows == 0 || nH5Cols == 0)
49 h5gt::DataSet dset = node.getDataSet(datasetPath);
50 if (!dset.getCreateProps().isChunked())
53 auto dtype = dset.getDataType();
54 if (!dtype.isTypeEqual(h5gt::AtomicType<T>())){
58 if (!unitsFrom.empty() && !unitsTo.empty()){
59 double coef = units::convert(
60 units::unit_from_string(unitsFrom),
61 units::unit_from_string(unitsTo));
62 for(
size_t i = 0; i < nH5Rows*nH5Cols; i++)
67 std::vector<size_t> dims = {nH5Rows, nH5Cols};
71 }
catch (h5gt::Exception e) {
76template<
typename Object,
typename D,
77 typename std::enable_if<
78 (std::is_same<Object, h5gt::File>::value ||
79 std::is_same<Object, h5gt::Group>::value) &&
80 std::is_arithmetic<typename D::Scalar>::value>::type*>
83 const std::string& datasetPath,
84 Eigen::DenseBase<D>& M,
85 const std::string& unitsFrom,
86 const std::string& unitsTo)
89 node, datasetPath, M.derived().data(), M.cols(), M.rows(), unitsFrom, unitsTo);
92template<
typename Object,
typename T,
93 typename std::enable_if<
94 (std::is_same<Object, h5gt::File>::value ||
95 std::is_same<Object, h5gt::Group>::value) &&
96 std::is_arithmetic<T>::value>::type*>
99 const std::string& datasetPath,
101 const std::string& unitsFrom,
102 const std::string& unitsTo)
105 node, datasetPath, v.data(), 1, v.size(), unitsFrom, unitsTo);
108template<
typename Object,
typename T,
109 typename std::enable_if<
110 (std::is_same<Object, h5gt::File>::value ||
111 std::is_same<Object, h5gt::Group>::value) &&
112 std::is_arithmetic<T>::value>::type*>
115 const std::string& datasetPath,
117 const std::string& unitsFrom,
118 const std::string& unitsTo)
121 node, datasetPath, &v, 1, 1, unitsFrom, unitsTo);
124template<
typename Object,
typename T,
125 typename std::enable_if<
126 std::is_same<Object, h5gt::File>::value ||
127 std::is_same<Object, h5gt::Group>::value>::type*>
130 const std::string& datasetPath,
134 const std::string& unitsFrom,
135 const std::string& unitsTo)
137 if (datasetPath.empty())
140 if (nH5Rows == 0 || nH5Cols == 0)
143 if(node.hasObject(datasetPath, h5gt::ObjectType::Dataset)){
144 h5gt::DataSet dset = node.getDataSet(datasetPath);
145 auto dtype = dset.getDataType();
146 if (!dtype.isTypeEqual(h5gt::AtomicType<T>()) ||
147 dset.getMemSpace().getElementCount() != nH5Rows*nH5Cols){
148 node.unlink(datasetPath);
149 node.template createDataSet<T>(
150 datasetPath, h5gt::DataSpace({nH5Rows, nH5Cols}));
153 node.template createDataSet<T>(
154 datasetPath, h5gt::DataSpace({nH5Rows, nH5Cols}));
157 if (!unitsFrom.empty() && !unitsTo.empty()){
158 double coef = units::convert(
159 units::unit_from_string(unitsFrom),
160 units::unit_from_string(unitsTo));
161 for(
size_t i = 0; i < nH5Rows*nH5Cols; i++)
165 node.getDataSet(datasetPath).write_raw(M);
170template<
typename Object,
typename D,
171 typename std::enable_if<
172 (std::is_same<Object, h5gt::File>::value ||
173 std::is_same<Object, h5gt::Group>::value) &&
174 std::is_arithmetic<typename D::Scalar>::value>::type*>
177 const std::string& datasetPath,
178 Eigen::DenseBase<D>& M,
179 const std::string& unitsFrom,
180 const std::string& unitsTo)
183 node, datasetPath, M.derived().data(), M.cols(), M.rows(), unitsFrom, unitsTo);
186template<
typename Object,
typename T,
187 typename std::enable_if<
188 (std::is_same<Object, h5gt::File>::value ||
189 std::is_same<Object, h5gt::Group>::value) &&
190 std::is_arithmetic<T>::value>::type*>
193 const std::string& datasetPath,
195 const std::string& unitsFrom,
196 const std::string& unitsTo)
199 node, datasetPath, v.data(), 1, v.size(), unitsFrom, unitsTo);
202template<
typename Object,
typename T,
203 typename std::enable_if<
204 (std::is_same<Object, h5gt::File>::value ||
205 std::is_same<Object, h5gt::Group>::value) &&
206 std::is_arithmetic<T>::value>::type*>
209 const std::string& datasetPath,
211 const std::string& unitsFrom,
212 const std::string& unitsTo)
215 node, datasetPath, &v, 1, 1, unitsFrom, unitsTo);
218template <
typename Object,
typename T,
219 typename std::enable_if<
220 std::is_same<Object, h5gt::File>::value ||
221 std::is_same<Object, h5gt::Group>::value>::type*>
224 const std::string& datasetPath,
227 const std::string& unitsFrom,
228 const std::string& unitsTo)
230 if (datasetPath.empty() ||
231 !node.hasObject(datasetPath, h5gt::ObjectType::Dataset))
237 h5gt::DataSet dset = node.getDataSet(datasetPath);
238 auto dtype = dset.getDataType();
239 if (!dtype.isTypeEqual(h5gt::AtomicType<T>()) ||
240 dset.getMemSpace().getElementCount() != nElem)
245 if (!unitsFrom.empty() && !unitsTo.empty()){
246 double coef = units::convert(
247 units::unit_from_string(unitsFrom),
248 units::unit_from_string(unitsTo));
249 for(
size_t i = 0; i < nElem; i++)
256template<
typename Object,
typename D,
257 typename std::enable_if<
258 (std::is_same<Object, h5gt::File>::value ||
259 std::is_same<Object, h5gt::Group>::value ||
260 std::is_same<Object, h5gt::DataSet>::value) &&
261 std::is_arithmetic<typename D::Scalar>::value>::type*>
264 const std::string& datasetPath,
265 Eigen::DenseBase<D>& M,
266 const std::string& unitsFrom,
267 const std::string& unitsTo)
270 if (datasetPath.empty() ||
271 !node.hasObject(datasetPath, h5gt::ObjectType::Dataset))
274 h5gt::DataSet dset = node.getDataSet(datasetPath);
275 auto dtype = dset.getDataType();
276 if (!dtype.isTypeEqual(h5gt::AtomicType<typename D::Scalar>()))
279 std::vector<size_t> dims = dset.getDimensions();
280 M.derived().resize(dims[1], dims[0]);
281 return _readDataset(node, datasetPath, M.derived().data(), M.size(), unitsFrom, unitsTo);
284template<
typename Object,
285 typename std::enable_if<
286 std::is_same<Object, h5gt::File>::value ||
287 std::is_same<Object, h5gt::Group>::value ||
288 std::is_same<Object, h5gt::DataSet>::value>::type*>
291 const std::string& datasetPath,
292 const std::string& unitsFrom,
293 const std::string& unitsTo)
296 readDataset(node, datasetPath, M, unitsFrom, unitsTo);
300template<
typename Object,
301 typename std::enable_if<
302 std::is_same<Object, h5gt::File>::value ||
303 std::is_same<Object, h5gt::Group>::value ||
304 std::is_same<Object, h5gt::DataSet>::value>::type*>
307 const std::string& datasetPath,
308 const std::string& unitsFrom,
309 const std::string& unitsTo)
312 readDataset(node, datasetPath, M, unitsFrom, unitsTo);
317template <
typename Object,
typename T,
318 typename std::enable_if<
319 std::is_same<Object, h5gt::File>::value ||
320 std::is_same<Object, h5gt::Group>::value ||
321 std::is_same<Object, h5gt::DataSet>::value>::type*>
324 const std::string& attrName,
327 const std::string& unitsFrom,
328 const std::string& unitsTo)
330 if (attrName.empty() || !holder.hasAttribute(attrName))
336 h5gt::Attribute attr = holder.getAttribute(attrName);
337 auto dtype = attr.getDataType();
338 if (!dtype.isTypeEqual(h5gt::AtomicType<T>()) ||
339 attr.getMemSpace().getElementCount() != nElem)
344 if (!unitsFrom.empty() && !unitsTo.empty()){
345 double coef = units::convert(
346 units::unit_from_string(unitsFrom),
347 units::unit_from_string(unitsTo));
348 for(
size_t i = 0; i < nElem; i++)
355template<
typename Object,
typename D,
356 typename std::enable_if<
357 (std::is_same<Object, h5gt::File>::value ||
358 std::is_same<Object, h5gt::Group>::value ||
359 std::is_same<Object, h5gt::DataSet>::value) &&
360 std::is_arithmetic<typename D::Scalar>::value>::type*>
363 const std::string& attrName,
364 Eigen::DenseBase<D> &v,
365 const std::string& unitsFrom,
366 const std::string& unitsTo)
369 if (attrName.empty() || !holder.hasAttribute(attrName))
372 h5gt::Attribute attr = holder.getAttribute(attrName);
373 auto dtype = attr.getDataType();
374 if (!dtype.isTypeEqual(h5gt::AtomicType<typename D::Scalar>()))
377 v.derived().resize(holder.getAttribute(attrName).getMemSpace().getElementCount());
379 holder, attrName, v.derived().data(), v.size(), unitsFrom, unitsTo);
382template <
typename Object,
typename T,
383 typename std::enable_if<
384 (std::is_same<Object, h5gt::File>::value ||
385 std::is_same<Object, h5gt::Group>::value ||
386 std::is_same<Object, h5gt::DataSet>::value) &&
387 std::is_arithmetic<T>::value>::type*>
390 const std::string& attrName,
392 const std::string& unitsFrom,
393 const std::string& unitsTo)
396 if (attrName.empty() || !holder.hasAttribute(attrName))
399 h5gt::Attribute attr = holder.getAttribute(attrName);
400 auto dtype = attr.getDataType();
401 if (!dtype.isTypeEqual(h5gt::AtomicType<T>()))
404 v.resize(holder.getAttribute(attrName).getMemSpace().getElementCount());
406 holder, attrName, v.data(), v.size(), unitsFrom, unitsTo);
409template <
typename Object,
typename T,
410 typename std::enable_if<
411 (std::is_same<Object, h5gt::File>::value ||
412 std::is_same<Object, h5gt::Group>::value ||
413 std::is_same<Object, h5gt::DataSet>::value) &&
414 std::is_arithmetic<T>::value>::type*>
417 const std::string& attrName,
419 const std::string& unitsFrom,
420 const std::string& unitsTo)
423 holder, attrName, &v, 1, unitsFrom, unitsTo);
426template <
typename Object,
typename T,
427 typename std::enable_if<
428 std::is_same<Object, h5gt::File>::value ||
429 std::is_same<Object, h5gt::Group>::value ||
430 std::is_same<Object, h5gt::DataSet>::value>::type*>
433 const std::string& attrName,
437 if (attrName.empty() || !holder.hasAttribute(attrName))
443 h5gt::Attribute attr = holder.getAttribute(attrName);
444 auto dtype_enum = h5gt::create_datatype<
445 typename std::remove_pointer<
446 typename std::remove_cv<T>::type>::type>();
447 auto dtype = attr.getDataType();
448 if (!dtype.isTypeEqual(dtype_enum) ||
449 attr.getMemSpace().getElementCount() != nElem)
456template<
typename Object,
typename T,
457 typename std::enable_if<
458 (std::is_same<Object, h5gt::File>::value ||
459 std::is_same<Object, h5gt::Group>::value ||
460 std::is_same<Object, h5gt::DataSet>::value) &&
461 std::is_enum<T>::value>::type*>
464 T value =
static_cast<T
>(0);
469template<
typename Object,
typename T,
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) &&
474 std::is_enum<T>::value>::type*>
478 if (attrName.empty() || !
object.hasAttribute(attrName))
481 h5gt::Attribute attr =
object.getAttribute(attrName);
482 auto dtype_enum = h5gt::create_datatype<
483 typename std::remove_pointer<
484 typename std::remove_cv<T>::type>::type>();
485 auto dtype = attr.getDataType();
486 if (!dtype.isTypeEqual(dtype_enum))
490 v.resize(
object.getAttribute(attrName).getMemSpace().getElementCount());
492 object, attrName, v.data(), v.size());
496template <
typename Object,
typename T,
497 typename std::enable_if<
498 std::is_same<Object, h5gt::File>::value ||
499 std::is_same<Object, h5gt::Group>::value||
500 std::is_same<Object, h5gt::DataSet>::value>::type*>
503 const std::string& attrName,
506 const std::string& unitsFrom,
507 const std::string& unitsTo)
509 if (attrName.empty())
515 if (!holder.hasAttribute(attrName))
516 holder.template createAttribute<T>(
517 attrName, h5gt::DataSpace({nElem}));
519 h5gt::Attribute attr = holder.getAttribute(attrName);
520 auto dtype = attr.getDataType();
521 if (!dtype.isTypeEqual(h5gt::AtomicType<T>()) ||
522 attr.getMemSpace().getElementCount() != nElem){
524 holder.deleteAttribute(attrName);
525 attr = holder.template createAttribute<T>(
526 attrName, h5gt::DataSpace({nElem}));
527 }
catch (h5gt::Exception e) {
532 if (!unitsFrom.empty() && !unitsTo.empty()){
533 double coef = units::convert(
534 units::unit_from_string(unitsFrom),
535 units::unit_from_string(unitsTo));
536 for(
size_t i = 0; i < nElem; i++)
544template<
typename Object,
545 typename std::enable_if<
546 std::is_same<Object, h5gt::File>::value ||
547 std::is_same<Object, h5gt::Group>::value ||
548 std::is_same<Object, h5gt::DataSet>::value>::type*>
551 const std::string& attrName,
552 const std::string& str)
554 if (attrName.empty())
557 if (!holder.hasAttribute(attrName))
558 holder.template createAttribute<std::string>(
559 attrName, h5gt::DataSpace::From(str));
561 h5gt::Attribute attr = holder.getAttribute(attrName);
562 auto dtype = attr.getDataType();
563 if (!dtype.isTypeEqual(h5gt::AtomicType<std::string>()) ||
564 attr.getMemSpace().getElementCount() != 1)
571template<
typename Object,
typename D,
572 typename std::enable_if<
573 (std::is_same<Object, h5gt::File>::value ||
574 std::is_same<Object, h5gt::Group>::value ||
575 std::is_same<Object, h5gt::DataSet>::value) &&
576 std::is_arithmetic<typename D::Scalar>::value>::type*>
579 const std::string& attrName,
580 Eigen::DenseBase<D>& v,
581 const std::string& unitsFrom,
582 const std::string& unitsTo)
585 holder, attrName, v.derived().data(), v.size(), unitsFrom, unitsTo);
588template <
typename Object,
typename T,
589 typename std::enable_if<
590 (std::is_same<Object, h5gt::File>::value ||
591 std::is_same<Object, h5gt::Group>::value ||
592 std::is_same<Object, h5gt::DataSet>::value) &&
593 std::is_arithmetic<T>::value>::type*>
596 const std::string& attrName,
598 const std::string& unitsFrom,
599 const std::string& unitsTo)
602 holder, attrName, v.data(), v.size(), unitsFrom, unitsTo);
605template <
typename Object,
typename T,
606 typename std::enable_if<
607 (std::is_same<Object, h5gt::File>::value ||
608 std::is_same<Object, h5gt::Group>::value ||
609 std::is_same<Object, h5gt::DataSet>::value) &&
610 std::is_arithmetic<T>::value>::type*>
613 const std::string& attrName,
615 const std::string& unitsFrom,
616 const std::string& unitsTo)
619 holder, attrName, &v, 1, unitsFrom, unitsTo);
622template <
typename Object,
typename T,
623 typename std::enable_if<
624 std::is_same<Object, h5gt::File>::value ||
625 std::is_same<Object, h5gt::Group>::value||
626 std::is_same<Object, h5gt::DataSet>::value>::type*>
629 const std::string& attrName,
633 if (attrName.empty())
639 auto dtype = h5gt::create_datatype<
640 typename std::remove_pointer<
641 typename std::remove_cv<T>::type>::type>();
642 if (!holder.hasAttribute(attrName))
643 holder.createAttribute(
644 attrName, h5gt::DataSpace({nElem}), dtype);
646 h5gt::Attribute attr = holder.getAttribute(attrName);
647 if (!dtype.isTypeEqual(dtype) ||
648 attr.getMemSpace().getElementCount() != nElem){
650 holder.deleteAttribute(attrName);
651 attr = holder.createAttribute(
652 attrName, h5gt::DataSpace({nElem}), dtype);
653 }
catch (h5gt::Exception e) {
662template <
typename Object,
typename T,
663 typename std::enable_if<
664 (std::is_same<Object, h5gt::File>::value ||
665 std::is_same<Object, h5gt::Group>::value ||
666 std::is_same<Object, h5gt::DataSet>::value) &&
667 std::is_enum<T>::value>::type*>
670 const std::string& attrName,
674 holder, attrName, &v, 1);
677template <
typename Object,
typename T,
678 typename std::enable_if<
679 (std::is_same<Object, h5gt::File>::value ||
680 std::is_same<Object, h5gt::Group>::value ||
681 std::is_same<Object, h5gt::DataSet>::value) &&
682 std::is_enum<T>::value>::type*>
685 const std::string& attrName,
689 holder, attrName, v.data(), v.size());
692template<
typename Object,
693 typename std::enable_if<
694 std::is_same<Object, h5gt::File>::value ||
695 std::is_same<Object, h5gt::Group>::value ||
696 std::is_same<Object, h5gt::DataSet>::value>::type*>
709template<
typename Object,
710 typename std::enable_if<
711 std::is_same<Object, h5gt::File>::value ||
712 std::is_same<Object, h5gt::Group>::value ||
713 std::is_same<Object, h5gt::DataSet>::value>::type*>
716 if (attrName.empty() || !
object.hasAttribute(attrName))
719 h5gt::Attribute attr =
object.getAttribute(attrName);
720 auto dtype = attr.getDataType();
721 if (!dtype.isTypeEqual(h5gt::AtomicType<std::string>()) ||
722 attr.getMemSpace().getElementCount() != 1)
729template<
typename Object,
730 typename std::enable_if<
731 std::is_same<Object, h5gt::File>::value ||
732 std::is_same<Object, h5gt::Group>::value ||
733 std::is_same<Object, h5gt::DataSet>::value>::type*>
735 Object&
object,
const std::string& attrName,
736 const std::string& unitsFrom,
737 const std::string& unitsTo){
738 float value = std::nan(
"nan");
743template<
typename Object,
744 typename std::enable_if<
745 std::is_same<Object, h5gt::File>::value ||
746 std::is_same<Object, h5gt::Group>::value ||
747 std::is_same<Object, h5gt::DataSet>::value>::type*>
749 Object&
object,
const std::string& attrName,
750 const std::string& unitsFrom,
751 const std::string& unitsTo)
753 double value = std::nan(
"nan");
758template<
typename Object,
759 typename std::enable_if<
760 std::is_same<Object, h5gt::File>::value ||
761 std::is_same<Object, h5gt::Group>::value ||
762 std::is_same<Object, h5gt::DataSet>::value>::type*>
764 Object&
object,
const std::string& attrName,
765 const std::string& unitsFrom,
766 const std::string& unitsTo){
767 std::vector<float> value;
772template<
typename Object,
773 typename std::enable_if<
774 std::is_same<Object, h5gt::File>::value ||
775 std::is_same<Object, h5gt::Group>::value ||
776 std::is_same<Object, h5gt::DataSet>::value>::type*>
778 Object&
object,
const std::string& attrName,
779 const std::string& unitsFrom,
780 const std::string& unitsTo){
781 std::vector<double> value;
786template<
typename Object,
787 typename std::enable_if<
788 std::is_same<Object, h5gt::File>::value ||
789 std::is_same<Object, h5gt::Group>::value ||
790 std::is_same<Object, h5gt::DataSet>::value>::type*>
792 Object&
object,
const std::string& attrName,
793 const std::string& unitsFrom,
794 const std::string& unitsTo){
795 Eigen::VectorXf value;
800template<
typename Object,
801 typename std::enable_if<
802 std::is_same<Object, h5gt::File>::value ||
803 std::is_same<Object, h5gt::Group>::value ||
804 std::is_same<Object, h5gt::DataSet>::value>::type*>
806 Object&
object,
const std::string& attrName,
807 const std::string& unitsFrom,
808 const std::string& unitsTo){
809 Eigen::VectorXd value;
816 h5gt::DataSet& dataset,
817 const std::string& attrName,
818 const Eigen::DenseBase<D>& v,
830 std::vector dims = dataset.getDimensions();
832 if (resize ==
false &&
836 if (resize ==
true &&
838 dataset.resize({dims[0], size_t(v.size())});
841 dataset.select({size_t(ind), 0}, {1, size_t(v.size())}).
842 write_raw(v.derived().data());
843 }
catch (h5gt::Exception e) {
852 h5gt::DataSet& dataset,
853 const std::string& attrName)
859 return Eigen::VectorXd();
861 std::vector dims = dataset.getDimensions();
862 Eigen::VectorX<T> v(dims[1]);
865 dataset.select({size_t(ind), 0}, {1, dims[1]}).
866 read(v.derived().data());
867 }
catch (h5gt::Exception e) {
868 return Eigen::VectorX<T>();
876template<
typename Object,
877 typename std::enable_if<
878 std::is_same<Object, h5gt::File>::value ||
879 std::is_same<Object, h5gt::Group>::value ||
880 std::is_same<Object, h5gt::DataSet>::value>::type*>
881inline bool deleteAllAttributes(Object&
object){
883 std::vector<std::string> attrNameList =
884 object.listAttributeNames();
885 for (
const auto& name : attrNameList)
886 object.deleteAttribute(name);
887 }
catch (h5gt::Exception e) {
893template<
typename Object,
894 typename std::enable_if<
895 std::is_same<Object, h5gt::File>::value ||
896 std::is_same<Object, h5gt::Group>::value>::type*>
899 std::vector<std::string> objNames =
900 object.listObjectNames();
901 for (
const auto& name : objNames)
903 }
catch (h5gt::Exception e) {
911 Eigen::DenseBase<T>
const & M){
912 Eigen::VectorX<ptrdiff_t> ind(M.size());
914 for (ptrdiff_t i = 0; i < M.size(); i++){
920 ind.conservativeResize(ii);
925template<
typename D,
typename T,
926 typename std::enable_if<
927 std::is_arithmetic<T>::value>::type*>
928inline h5gt::ElementSet rowCols2ElementSet(
930 const Eigen::DenseBase<D>& cols)
932 ptrdiff_t I = cols.size();
933 std::vector<size_t> v(2*I, row);
935 for (ptrdiff_t i = 0; i < I; i++)
938 return h5gt::ElementSet(v);
941template<
typename D,
typename T,
942 typename std::enable_if<
943 std::is_arithmetic<T>::value>::type*>
944inline h5gt::ElementSet rowsCol2ElementSet(
945 const Eigen::DenseBase<D>& rows,
948 ptrdiff_t I = rows.size();
949 std::vector<size_t> v(2*I, col);
951 for (ptrdiff_t i = 0; i < I; i++)
954 return h5gt::ElementSet(v);
959 const Eigen::DenseBase<D>& rows,
960 const Eigen::DenseBase<D>& cols)
962 ptrdiff_t I = rows.size();
963 ptrdiff_t J = cols.size();
965 std::vector<size_t> v(2*I*J);
967 for (ptrdiff_t i = 0; i < I; i++){
968 for (ptrdiff_t j = 0; j < J; j++){
969 v[2*j + 2*i*J] = rows(i);
970 v[2*j+1 + 2*i*J] = cols(j);
974 return h5gt::ElementSet(v);
978 typename std::enable_if<
979 std::is_arithmetic<T>::value>::type*>
980inline h5gt::ElementSet rowCols2ElementSet(
982 const std::vector<T>& cols)
984 size_t I = cols.size();
985 std::vector<size_t> v(2*I, row);
987 for (
size_t i = 0; i < I; i++)
990 return h5gt::ElementSet(v);
994 typename std::enable_if<
995 std::is_arithmetic<T>::value>::type*>
996inline h5gt::ElementSet rowsCol2ElementSet(
997 const std::vector<T>& rows,
1000 size_t I = rows.size();
1001 std::vector<size_t> v(2*I, col);
1003 for (
size_t i = 0; i < I; i++)
1006 return h5gt::ElementSet(v);
1010 typename std::enable_if<
1011 std::is_arithmetic<T>::value>::type*>
1013 const std::vector<T>& rows,
1014 const std::vector<T>& cols)
1016 size_t I = rows.size();
1017 size_t J = cols.size();
1019 std::vector<size_t> v(2*I*J);
1021 for (
size_t i = 0; i < I; i++){
1022 for (
size_t j = 0; j < J; j++){
1023 v[2*j + 2*i*J] = rows[i];
1024 v[2*j+1 + 2*i*J] = cols[j];
1028 return h5gt::ElementSet(v);
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
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
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
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
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
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
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
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