HDF5 work

This commit is contained in:
Guilhem Lavaux 2015-02-11 21:23:44 +01:00
parent 1dbe46a358
commit ebaf13e336

View File

@ -97,13 +97,13 @@ namespace CosmoTool {
//! \author leo Goodstadt (04 March 2013)
//!
//!_______________________________________________________________________________________
template<typename T, std::size_t DIMENSIONS, typename hdf5_data_type>
template<typename ArrayType, typename hdf5_data_type>
void hdf5_write_array(H5::CommonFG& fg, const std::string& data_set_name,
const boost::multi_array<T, DIMENSIONS>& data,
const ArrayType& data,
const hdf5_data_type& datatype)
{
std::vector<hsize_t> dimensions(data.shape(), data.shape() + DIMENSIONS);
H5::DataSpace dataspace(DIMENSIONS, dimensions.data());
std::vector<hsize_t> dimensions(data.shape(), data.shape() + data.num_dimensions());
H5::DataSpace dataspace(data.num_dimensions(), dimensions.data());
H5::DataSet dataset = fg.createDataSet(data_set_name, datatype, dataspace);
@ -134,20 +134,28 @@ namespace CosmoTool {
}
};
template<typename T, std::size_t DIMENSIONS>
void hdf5_write_array(H5::CommonFG& fg, const std::string& data_set_name, const boost::multi_array<T, DIMENSIONS>& data )
template<> struct get_hdf5_data_type<std::complex<float> > {
static H5::DataType type() {
return hdf5_ComplexType<float>::ctype()->type;
}
};
template<> struct get_hdf5_data_type<std::complex<double> > {
static H5::DataType type() {
return hdf5_ComplexType<double>::ctype()->type;
}
};
template<typename ArrayType>
void hdf5_write_array(H5::CommonFG& fg, const std::string& data_set_name, const ArrayType& data )
{
typedef typename ArrayType::value_type T;
get_hdf5_data_type<T> hdf_data_type;
hdf5_write_array(fg, data_set_name, data, hdf_data_type.type());
}
template<typename T, std::size_t DIMENSIONS>
void hdf5_write_array(H5::CommonFG& fg, const std::string& data_set_name, const boost::multi_array<std::complex<T>, DIMENSIONS>& data )
{
hdf5_write_array(fg, data_set_name, data, hdf5_ComplexType<T>::ctype()->type);
}
// HDF5 array reader
//
// Author Guilhem Lavaux (May 2014)