36 :
std::runtime_error(message)
93 template <
typename T>
inline hid_t
H5Type()
95 throw std::logic_error(std::string(
"H5Type does not exist for '") +
96 typeid(T).name() +
"'");
132 const H5O_info_t *
info,
void *dlist)
135 list<string>& dsetlist(*
reinterpret_cast<list<string>*
>(dlist));
136 if (info->type == H5O_TYPE_DATASET)
137 dsetlist.push_back(name);
150 const H5L_info_t *,
void *slist)
153 list<string>& stringlist(*
reinterpret_cast<list<string>*
>(slist));
155 herr_t
status = H5Oget_info_by_name (loc_id, name, &infobuf, H5P_DEFAULT);
158 if (infobuf.type == H5O_TYPE_GROUP)
159 stringlist.push_back(name);
207 H5Fflush(
_fileid,H5F_SCOPE_LOCAL);
231 hid_t fapl(H5Pcreate (H5P_FILE_ACCESS));
233 H5Pget_cache(fapl, &nelemts, &nslots, &nbytes, &w0);
235 nbytes =
size*1024*1024;
237 H5Pset_cache(fapl, nelemts, nslots, nbytes, w0);
241 throw std::logic_error(
"hdf5::Handler::open(): File '" + filename +
242 "'. Hander is already responsible for '" +
247 _fileid = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
249 else if (mode ==
"r")
251 _fileid = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
253 else if (mode ==
"rw")
255 _fileid = H5Fopen(filename.c_str(),H5F_ACC_RDWR, H5P_DEFAULT);
258 throw std::invalid_argument(
"hdf5::Handler::open(): Open mode '" +
261 throw std::invalid_argument(
"hdf5::Handler::open(): File '" + filename +
262 "' could not be opened");
274 template <
typename type>
280 hid_t dataspace_id(H5Screate(H5S_SCALAR));
281 if (dataspace_id < 0)
282 throw runtime_error(
"writeScalar(float): Could not open the dataspace");
284 hid_t dataset_id(H5Dcreate(
_fileid, valname.c_str(),H5Type<type>(),
285 dataspace_id, H5P_DEFAULT, H5P_DEFAULT , H5P_DEFAULT));
287 throw DatasetError(
"writeScalar(float): Could not open the dataset '" + valname +
"'");
289 herr_t
status(H5Dwrite(dataset_id, H5Type<type>(), H5S_ALL, H5S_ALL,
290 H5P_DEFAULT, &value));
292 throw runtime_error(
"writeScalar(): Could not write value");
294 H5Dclose(dataset_id);
295 H5Sclose(dataspace_id);
306 template <
typename type>
312 H5Eset_auto(H5E_DEFAULT,0,0);
315 hid_t dataset_id(H5Dopen(
_fileid,valname.c_str(),H5P_DEFAULT));
317 throw DatasetError(
"readScalar(): Could not open the dataset '" +
322 herr_t
status(H5Dread(dataset_id, H5Type<type>(), H5S_ALL, H5S_ALL, H5P_DEFAULT,
325 throw logic_error(
"readScalar(): Could not read the scalar value '" + valname +
"'");
327 H5Dclose(dataset_id);
349 template<
typename type>
350 void writeArray(
const std::vector<type> &array,
const size_t arrayLength,
351 const std::string& valname,
int compressLevel=2)
354 hsize_t dims[1] = {arrayLength};
359 hid_t dataspace_id = H5Screate_simple(1, dims, NULL);
360 if (dataspace_id < 0)
361 throw runtime_error(
"writeArray(): Could not open the dataspace");
365 if(compressLevel != 0)
369 hsize_t chunk[1] = {arrayLength};
370 hid_t dcpl (H5Pcreate (H5P_DATASET_CREATE));
371 H5Pset_deflate (dcpl, compressLevel);
372 H5Pset_chunk (dcpl, 1, chunk);
373 dataset_id = (H5Dcreate(
_fileid, valname.c_str(), H5Type<type>(),
374 dataspace_id, H5P_DEFAULT, dcpl, H5P_DEFAULT));
377 dataset_id = (H5Dcreate(
_fileid, valname.c_str(), H5Type<type>(),
378 dataspace_id, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT));
381 throw DatasetError(
"writeArray(): Could not open the dataset '"
384 herr_t
status(H5Dwrite(dataset_id, H5Type<type>(), H5S_ALL, H5S_ALL,
385 H5P_DEFAULT, &array.front()));
387 throw runtime_error(
"writeArray(): Could not write array");
389 H5Dclose(dataset_id);
390 H5Sclose(dataspace_id);
404 template<
typename type>
405 void readArray(std::vector<type> &array,
size_t &arrayLength,
406 const std::string& valname)
412 H5Eset_auto(H5E_DEFAULT,0,0);
414 hid_t dataset_id(H5Dopen(
_fileid, valname.c_str(), H5P_DEFAULT));
416 throw DatasetError(
"readArray(): Could not open Dataset '"+ valname +
"'");
418 hid_t dataspace_id(H5Dget_space (dataset_id));
419 if (dataspace_id < 0)
420 throw logic_error(
"readArray(): Could not open the dataspace");
422 int ndims(H5Sget_simple_extent_dims (dataspace_id, dims, NULL));
424 throw logic_error(
"readMatrix(): Could not read the dimensions");
426 arrayLength = dims[0];
428 array.resize(arrayLength,0);
430 herr_t
status(H5Dread(dataset_id, H5Type<type>(), H5S_ALL, H5S_ALL, H5P_DEFAULT,
433 throw logic_error(
"readArray: Something went wrong reading matrix data");
435 H5Sclose(dataspace_id);
436 H5Dclose(dataset_id);
455 template<
typename type>
457 const std::string& valname,
int compressLevel=2)
460 hsize_t dims[2] = {shape.second,shape.first};
465 hid_t dataspace_id = H5Screate_simple(2, dims, NULL);
466 if (dataspace_id < 0)
467 throw runtime_error(
"writeMatrix(): Could not open the dataspace");
470 if(compressLevel != 0)
475 hsize_t slowestDim(shape.second?shape.second:1);
476 hsize_t fastestDim(shape.first?shape.first:1);
477 hsize_t chunk[2] = {slowestDim,fastestDim};
478 hid_t dcpl (H5Pcreate (H5P_DATASET_CREATE));
479 herr_t stat(H5Pset_deflate (dcpl, compressLevel));
481 throw runtime_error(
"writeMatrix(): Couldn't set the compressionlevel for '"
483 stat = H5Pset_chunk (dcpl, 2, chunk);
485 throw runtime_error(
"writeMatrix(): Couldn't set the chunk for '"
487 dataset_id = H5Dcreate(
_fileid, valname.c_str(), H5Type<type>(),
488 dataspace_id, H5P_DEFAULT, dcpl, H5P_DEFAULT);
491 dataset_id = H5Dcreate(
_fileid, valname.c_str(), H5Type<type>(),
492 dataspace_id, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);
495 throw DatasetError(
"writeMatrix(): Could not open the dataset '"
498 herr_t
status(H5Dwrite(dataset_id, H5Type<type>(), H5S_ALL, H5S_ALL,
499 H5P_DEFAULT, &matrix.front()));
501 throw runtime_error(
"writeMatrix(): Could not write data");
503 H5Dclose(dataset_id);
504 H5Sclose(dataspace_id);
518 template<
typename type>
520 const std::string& valname)
525 H5Eset_auto(H5E_DEFAULT,0,0);
527 hid_t dataset_id(H5Dopen (
_fileid, valname.c_str(), H5P_DEFAULT));
529 throw DatasetError(
"readMatrix(): Could not open Dataset '"+ valname +
"'");
531 hid_t dataspace_id(H5Dget_space (dataset_id));
532 if (dataspace_id < 0)
533 throw logic_error(
"readMatrix(): Could not open the dataspace");
535 const int ndims(H5Sget_simple_extent_ndims(dataspace_id));
537 throw logic_error(
"readMatrix(): Could not read the the number of dimensions");
539 throw logic_error(
"readMatrix(): The dataset doesn't have the 2 dimensions");
543 int retNdims(H5Sget_simple_extent_dims (dataspace_id, dims, NULL));
544 if (retNdims != ndims)
545 throw logic_error(
"readMatrix(): Could not read the dimensions");
547 shape.first = dims[1];
548 shape.second = dims[0];
550 matrix.resize(shape.first*shape.second,0);
552 herr_t
status(H5Dread(dataset_id, H5Type<type>(), H5S_ALL, H5S_ALL, H5P_DEFAULT,
555 throw logic_error(
"readMatrix: Something went wrong reading matrix data");
557 H5Dclose(dataset_id);
558 H5Sclose(dataspace_id);
571 template<
typename type>
573 const std::string& valname,
int compressLevel=2)
580 H5Eset_auto(H5E_DEFAULT,0,0);
586 hid_t dataset_id(H5Dopen(
_fileid, valname.c_str(), H5P_DEFAULT));
592 vector<hsize_t> dims(shape);
593 dims.insert(dims.begin(),0);
596 vector<hsize_t> maxdims(shape);
597 maxdims.insert(maxdims.begin(),H5S_UNLIMITED);
600 hid_t dataspace_id(H5Screate_simple(dims.size(), &(dims.front()),
601 &(maxdims.front())));
602 if (dataspace_id < 0)
603 throw logic_error(
"appenddata(): Could not open the dataspace");
606 hid_t property_id(H5Pcreate(H5P_DATASET_CREATE));
608 throw logic_error(
"appenddata(): Could not create property list");
609 herr_t
status(H5Pset_layout(property_id, H5D_CHUNKED));
611 throw logic_error(
"appenddata(): Could not set the chuncked layout");
612 vector<hsize_t> chunk_dims(dims);
616 status = H5Pset_chunk(property_id, chunk_dims.size(), &(chunk_dims.front()));
618 throw logic_error(
"appenddata(): Could not define the chunck size");
619 status = H5Pset_deflate(property_id, compressLevel);
621 throw logic_error(
"appenddata(): Could not define the compression level");
624 dataset_id = H5Dcreate(
_fileid, valname.c_str(), H5Type<type>(),
625 dataspace_id, H5P_DEFAULT, property_id, H5P_DEFAULT);
627 throw logic_error(
"appenddata(): Could not create the dataset '"
631 H5Pclose(property_id);
632 H5Sclose(dataspace_id);
636 hid_t dataspace_id(H5Dget_space(dataset_id));
637 if (dataspace_id < 0)
638 throw logic_error(
"appenddata(): Could not open the dataspace");
641 const hssize_t ndims(H5Sget_simple_extent_ndims(dataspace_id));
643 throw logic_error(
"appenddata(): Could not read the the number of dimensions");
644 if (static_cast<size_t>(ndims) != shape.size()+1)
645 throw logic_error(
"appenddata(): The number of dimensions do not fit");
646 vector<hsize_t> dims(ndims);
647 int retNdims(H5Sget_simple_extent_dims(dataspace_id, &dims.front(), NULL));
648 if (retNdims != ndims)
649 throw logic_error(
"appenddata(): Could not read the dimensions");
656 H5Sclose(dataspace_id);
659 for (
size_t i(0);i<shape.size(); ++i)
660 if (dims[i+1] != shape[i])
661 throw logic_error(
"appenddata(): The dimensions are not equal");
664 hsize_t origsize(dims[0]);
668 hid_t memspace_id(H5Screate_simple(ndims, &dims.front(), NULL));
670 throw runtime_error(
"appendData(): Could not open the dataspace");
673 dims[0] = origsize + 1;
676 herr_t
status(H5Dset_extent(dataset_id, &dims.front()));
678 throw runtime_error(
"appendData(): Could not extent the dataset");
681 dataspace_id = H5Dget_space(dataset_id);
682 if (dataspace_id < 0)
683 throw logic_error(
"appenddata(): Could not open the extended dataspace");
688 vector<hsize_t>
offset(ndims,0);
689 offset[0] = origsize;
692 vector<hsize_t> count(dims);
696 status = H5Sselect_hyperslab(dataspace_id, H5S_SELECT_SET,
697 &(offset.front()), NULL,
698 &(count.front()), NULL);
700 throw runtime_error(
"appenddata(): Could define hyperslab");
702 status = H5Dwrite(dataset_id, H5Type<type>(), memspace_id, dataspace_id,
703 H5P_DEFAULT, &(data.front()));
707 ss <<
"appenddata(): Could not write data " <<
status;
708 throw runtime_error(ss.str());
711 H5Dclose(dataset_id);
712 H5Sclose(dataspace_id);
713 H5Sclose(memspace_id);
728 template<
typename type>
730 const std::string& valname)
735 H5Eset_auto(H5E_DEFAULT,0,0);
737 hid_t dataset_id(H5Dopen (
_fileid, valname.c_str(), H5P_DEFAULT));
739 throw DatasetError(
"readMultiDim(): Could not open Dataset '"+ valname +
"'");
741 hid_t dataspace_id(H5Dget_space (dataset_id));
742 if (dataspace_id < 0)
743 throw logic_error(
"readMultiDim(): Could not open the dataspace");
745 const int ndims(H5Sget_simple_extent_ndims(dataspace_id));
747 throw logic_error(
"readMultiDim(): Could not read the the number of dimensions");
751 int retNdims(H5Sget_simple_extent_dims (dataspace_id, dims, NULL));
752 if (retNdims != ndims)
753 throw logic_error(
"readMultiDim(): Could not read the dimensions");
755 size_t completesize(1);
756 for (
int i(0); i<ndims; ++i)
758 completesize *= dims[i];
759 shape.push_back(dims[i]);
762 data.resize(completesize,0);
764 herr_t
status(H5Dread(dataset_id, H5Type<type>(), H5S_ALL, H5S_ALL, H5P_DEFAULT,
767 throw logic_error(
"readMultiDim: Something went wrong reading matrix data");
769 H5Dclose(dataset_id);
770 H5Sclose(dataspace_id);
784 template<
typename type>
787 const std::string& valname)
792 H5Eset_auto(H5E_DEFAULT,0,0);
794 hid_t dataset_id(H5Dopen (
_fileid, valname.c_str(), H5P_DEFAULT));
796 throw DatasetError(
"readPartialMultiDim(): Could not open Dataset '" +
797 valname +
"' in file '" +
filename() +
"'");
799 hid_t dataspace_id(H5Dget_space(dataset_id));
800 if (dataspace_id < 0)
801 throw logic_error(
"readPartialMultiDim(): Could not open the dataspace");
803 const int ndims(H5Sget_simple_extent_ndims(dataspace_id));
805 throw logic_error(
string(
"readPartialMultiDim(): Could not read the ") +
806 "number of dimensions");
809 int retNdims(H5Sget_simple_extent_dims(dataspace_id, dims, NULL));
810 if (retNdims != ndims)
811 throw logic_error(
"readPartialMultiDim(): Could not read the dimensions");
814 if (ndims != static_cast<int>(part.
dims.size()))
817 ss <<
"readPartialMultiDim(): The provided size of the dimensions '" <<
818 part.
dims.size() <<
"' does not match the dataset dimension size '" <<
819 ndims <<
"' for dataset '" << valname <<
"' within '" <<
825 hid_t memspace_id(H5Screate_simple(part.
dims.size(), &(part.
dims.front()),
828 throw logic_error(
"readPartialMultiDim(): Could not open the memspace.");
830 herr_t
status(H5Sselect_hyperslab(dataspace_id, H5S_SELECT_SET,
833 &(part.
count.front()),
834 &(part.
block.front())));
836 throw logic_error(
string(
"readPartialMultiDim: Something went wrong ") +
837 "creating the hyperslab");
840 status = H5Dread(dataset_id, H5Type<type>(), memspace_id, dataspace_id,
841 H5P_DEFAULT, &(*data));
843 throw logic_error(
"readPartialMultiDim: Something went wrong reading partial data");
845 H5Sclose(memspace_id);
846 H5Sclose(dataspace_id);
847 H5Dclose(dataset_id);
855 void writeString(
const std::string &
string,
const std::string &dsetName)
859 hid_t dataspace_id(H5Screate (H5S_SCALAR));
860 if (dataspace_id < 0 )
861 throw runtime_error(
"writeString(): Could not open the dataspace");
863 hid_t datatype_id(H5Tcopy(H5T_C_S1));
864 if (datatype_id < 0 )
865 throw runtime_error(
"writeString(): Could not open the datatype ");
867 hid_t
status(H5Tset_size (datatype_id, H5T_VARIABLE));
869 throw runtime_error(
"writeString(): Could not set the variable size to datatype");
871 hid_t dataset_id(H5Dcreate(
_fileid, dsetName.c_str(), datatype_id,
872 dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT));
874 throw DatasetError(
"writeString(): Could not open the dataset '"
877 const char *s(
string.c_str());
878 status = H5Dwrite(dataset_id, datatype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &s);
880 throw runtime_error(
"writeString(): Could not write data");
882 H5Sclose(dataspace_id);
883 H5Dclose(dataset_id);
896 H5Eset_auto(H5E_DEFAULT,0,0);
898 hid_t dataset_id(H5Dopen(
_fileid, dsetName.c_str(), H5P_DEFAULT));
900 throw DatasetError(
"readString(): Could not open Dataset '"+ dsetName +
903 hid_t datatype_id(H5Dget_type(dataset_id));
905 throw runtime_error(
"readString(): Error retrieving the data type");
907 hsize_t datasize(H5Dget_storage_size(dataset_id));
909 throw runtime_error(
"readString(): Error retrieving the data size");
911 vector<char> buf(static_cast<int>(datasize+1),0);
912 herr_t
status(H5Dread(dataset_id,datatype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,
915 throw logic_error(
"readString: Something went wrong reading string data");
917 return string(buf.begin(),buf.end());
927 template<
typename type>
929 const std::string & dsetName)
934 hid_t dataset_id(H5Dopen(
_fileid,dsetName.c_str(),H5P_DEFAULT));
936 throw DatasetError(
"writeScalarAttribute(): Could not open the dataset '" +
940 hid_t attributespace_id(H5Screate(H5S_SCALAR));
941 if (attributespace_id < 0)
942 throw runtime_error(
"writeScalarAttribute(): Could not open the dataspace");
943 hid_t attribute_id(H5Acreate(dataset_id, valname.c_str(), H5Type<type>(),
944 attributespace_id, H5P_DEFAULT, H5P_DEFAULT));
945 if (attribute_id < 0)
946 throw runtime_error(
"writeScalarAttribute(): Could not open the attribute '"
950 herr_t
status(H5Awrite(attribute_id, H5Type<type>(), &value));
952 throw logic_error(
"writeScalarAttribute: Something went wrong reading matrix data");
954 H5Aclose(attribute_id);
955 H5Sclose(attributespace_id);
956 H5Dclose(dataset_id);
968 template<
typename type>
974 H5Eset_auto(H5E_DEFAULT,0,0);
977 hid_t dataset_id(H5Dopen(
_fileid,dsetName.c_str(),H5P_DEFAULT));
979 throw DatasetError(
"readScalarAttribute(): Could not open the dataset '" +
983 hid_t attribute_id(H5Aopen(dataset_id, valname.c_str(), H5P_DEFAULT));
984 if (attribute_id < 0)
985 throw invalid_argument(
"readScalarAttribute(): Could not open the attribute '"
990 herr_t
status(H5Aread(attribute_id, H5Type<type>(), &value));
992 throw logic_error(
"readScalarAttribute(): Could read the attribute '"
993 + valname +
"' of dataset '" + dsetName +
"'");
995 H5Aclose(attribute_id);
996 H5Dclose(dataset_id);
1007 using namespace std;
1013 int namesize(H5Fget_name(
_fileid,NULL,0));
1015 throw logic_error(
"filename(): Error when retrieving the size of the name");
1017 vector<char> fn(namesize+1,
' ');
1021 throw logic_error(
"filename(): Error when retrieving the filename");
1025 return string(fn.begin(),fn.end());
1038 shape_t
shape(
const std::string &valname)
const
1040 using namespace std;
1041 hid_t dataset_id(H5Dopen (
_fileid, valname.c_str(), H5P_DEFAULT));
1043 throw DatasetError(
"shape(): Could not open Dataset '"+ valname +
"'");
1045 hid_t dataspace_id(H5Dget_space (dataset_id));
1046 if(H5Sget_simple_extent_type(dataspace_id) != H5S_SIMPLE)
1047 throw DatasetError(
"shape(): Dataset '"+ valname +
"' is not of type " +
1048 "H5S_SIMPLE and therefore doesn't have a shape");
1050 const int ndims(H5Sget_simple_extent_ndims(dataspace_id));
1052 throw logic_error(
"shape(): Could not read the the number of dimensions");
1054 hsize_t dims[ndims];
1056 int retNdims(H5Sget_simple_extent_dims(dataspace_id, dims, NULL));
1057 if (retNdims != ndims)
1058 throw logic_error(
"shape(): Could not read the shape");
1060 return shape_t(&dims[0],&dims[0] + ndims);
1074 using namespace std;
1076 hid_t dataset_id(H5Dopen (
_fileid, valname.c_str(), H5P_DEFAULT));
1078 throw DatasetError(
"dimension(): Could not open Dataset '"+ valname +
"'");
1080 hid_t dataspace_id(H5Dget_space (dataset_id));
1081 switch(H5Sget_simple_extent_type(dataspace_id))
1085 hid_t datatype_id(H5Dget_type(dataset_id));
1086 int dtype = H5Tget_class(datatype_id);
1101 throw logic_error(
"dimension(): Datatype not supported");
1108 switch(H5Sget_simple_extent_ndims(dataspace_id))
1113 H5Sget_simple_extent_dims(dataspace_id,dims,NULL);
1124 H5Sget_simple_extent_dims(dataspace_id,dims,NULL);
1126 if (dims[0] == 1 && dims[1] == 1)
1128 else if (dims[1] == 1)
1135 throw logic_error(
"dimension(): Unkown dataspace dimension");
1140 throw logic_error(
"dimension(): Unknown dataspace type");
1144 H5Dclose(dataset_id);
1145 H5Sclose(dataspace_id);
1156 using namespace std;
1157 dsetList_t dsetlist;
1163 throw logic_error(
"datasets(): Error when iterating through the h5 file");
1175 using namespace std;
1176 dsetList_t grouplist;
1177 hid_t
status(H5Literate(
_fileid,H5_INDEX_NAME,H5_ITER_INC,NULL,
1180 throw logic_error(
"rootGroups(): Error when iterating through the h5 file");
1191 using namespace std;
1192 hsize_t currentsize;
1195 throw logic_error(
"currentFileSize(): Error when retrieving the file size");
1216 const std::string& currentfilename)
1218 using namespace std;
1219 hsize_t currentsize;
1220 H5Fget_filesize(filehandle,¤tsize);
1221 string newfilename(currentfilename);
1222 if (maxsize < currentsize)
1224 H5Fflush(filehandle,H5F_SCOPE_LOCAL);
1225 H5Fclose(filehandle);
1227 size_t found = newfilename.rfind(
"__");
1228 if (found == string::npos)
1230 newfilename.insert(newfilename.find_last_of(
"."),
"__0001");
1242 filehandle = H5Fcreate(newfilename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
1261 H5Eset_auto(H5E_DEFAULT,0,0);
1263 return (!(H5Gget_info_by_name(
_fileid, groupname.c_str(),&dummy,H5P_DEFAULT) < 0));
1276 using namespace std;
1277 string wholename(name);
1279 wholename =
"/" + name;
1280 string gname(wholename.substr(0, wholename.find_last_of(
'/')+1));
1281 for (
int i=0; i < static_cast<int>(gname.length()); ++i)
1285 string groupname(gname.substr(0,i));
1286 if (!groupname.empty() && !
groupExists(groupname))
1288 hid_t gh(H5Gcreate(
_fileid, groupname.c_str() ,H5P_DEFAULT,
1289 H5P_DEFAULT, H5P_DEFAULT));
void readArray(std::vector< type > &array, size_t &arrayLength, const std::string &valname)
read a array with a given name into a linearized array
Handler(const std::string &filename, const std::string &mode="w")
constructor opening the file
void open(const std::string &filename, const std::string &mode="w", int size=-1)
open a file
std::vector< hsize_t > count
the count
hid_t H5Type< uint8_t >()
trait implementation for unsigned 8 bit int
hid_t H5Type< uint64_t >()
trait implementation for unsigned 64 bit int
type readScalar(const std::string &valname)
read an scalar value with a given name as part of a given group
Handler()
default constructor
void writeArray(const std::vector< type > &array, const size_t arrayLength, const std::string &valname, int compressLevel=2)
write a 1d array with a given name
void appendData(const std::vector< type > &data, shape_t shape, const std::string &valname, int compressLevel=2)
create/append data to a multidimensional dataset
things written only at end of run H5Dump ProcessorSummary size
void ensureGroupExists(const std::string &name)
make sure that the requested group for the datset exists
std::string reopenFile(int &filehandle, size_t maxsize, const std::string ¤tfilename)
check filesize and open new file if too big
dsetList_t datasets() const
get the list of datasets in the file
void readMatrix(std::vector< type > &matrix, std::pair< size_t, size_t > &shape, const std::string &valname)
read a matrix with a given name into a linearized array
hid_t H5Type< float >()
trait implementation for float
void readPartialMultiDim(typename std::vector< type >::iterator data, const partiality_t &part, const std::string &valname)
partially read a multidimensional dataset with a given name into a linearized array ...
shape_t shape(const std::string &valname) const
get the shape of a dataset with a given name
herr_t group_iterator_func(hid_t loc_id, const char *name, const H5L_info_t *, void *slist)
function to gather groups of h5 file
hid_t H5Type< uint32_t >()
trait implementation for unsigned 16 bit int
DatasetError(const std::string &message)
explicit constructor
Exception thrown when there is an error with the dataset.
hid_t H5Type< double >()
trait implementation for double
std::vector< hsize_t > offset
the offset of the partial data within the original data
std::vector< hsize_t > shape_t
define the shape type
hid_t _fileid
the file handle
hid_t H5Type()
traits for matching a build in type with the corresponding h5 type
herr_t dataset_iterator_func(hid_t, const char *name, const H5O_info_t *info, void *dlist)
function to gather all datasets of the h5 file
define the partiality parameter container
std::string filename() const
retrieve the filename of the file associated with the handler
void close()
close the file used by this handler
std::string readString(const std::string &dsetName)
read a string dataset
size_t dimension(const std::string &valname) const
get the dimension of a value with a given name
std::vector< hsize_t > block
the block
std::vector< hsize_t > stride
the stride
auxiliary data[Processor]
void writeMatrix(const std::vector< type > &matrix, std::pair< size_t, size_t > shape, const std::string &valname, int compressLevel=2)
write a linearized matrix with a given name
definitions of when a hit is found
dsetList_t rootGroups() const
get the list of groups of the root group in the file
void writeString(const std::string &string, const std::string &dsetName)
write a string dataset
std::vector< hsize_t > dims
the dimensions of the partial dataset
void writeScalarAttribute(const type value, const std::string &valname, const std::string &dsetName)
write an float scalar attribute with a given name as part of a given dataset
std::list< std::string > dsetList_t
define the list of dataset names
bool groupExists(const std::string &groupname)
check if a groups exists
void readMultiDim(std::vector< type > &data, shape_t &shape, const std::string &valname)
read a multidimensional dataset with a given name into a linearized array
Handler(const Handler &)
prevent copy construction
hid_t H5Type< char >()
trait implementation for char
void writeScalar(const type value, const std::string &valname)
write an scalar value with a given name as part of a given group
type readScalarAttribute(const std::string &valname, const std::string &dsetName)
read an scalar attribute with a given name as part of a given dataset
hid_t H5Type< uint16_t >()
trait implementation for unsigned 16 bit int
size_t currentFileSize() const
retrieve the size of the current file
check if there is some light in the chamber based upon the GMD value
and the shutter status[Processor]
hid_t H5Type< int >()
trait implementation for int