-
Notifications
You must be signed in to change notification settings - Fork 0
/
gethdf5.m
45 lines (37 loc) · 1.49 KB
/
gethdf5.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function hyperslab = gethdf5(filename, varname, bl_corner, tr_corner, stride)
%function hyperslab = gethdf5(filename, varname, bl_corner, tr_corner,
%stride)
%Returns a hyperslab from a MOHID HDF5 dataset.
%If the HDF5 dataset is not a MOHID dataset, then simply use the function
%hdf5read().
%
% *_corner - tzxy (velocity), zxy(waterpoints), xy(bathymetry), txy(level)?
%Get the dimensions of the hyperslab vector
type = gettype(varname, bl_corner);
switch (type)
case 'tzxy'
for i = bl_corner(1):1:tr_corner(1);
data = hdf5read(filename, [varname,'_',sprintf('%05d',i)]);
% hyperslab(i,:,:,:) = data(...
% bl_corner(2):stride:tr_corner(2), ...
% bl_corner(3):stride:tr_corner(3), ...
% bl_corner(4):stride:tr_corner(4), ...
% );
end
case 'txy'
for i = bl_corner(1):1:tr_corner(1);
data = hdf5read(filename, [varname,'_',sprintf('%05d',i)]);
% hyperslab(i,:,:,:) = data(...
% bl_corner(2):stride:tr_corner(2), ...
% bl_corner(3):stride:tr_corner(3), ...
% );
end
case 'zxy'
data = hdf5read(filename, varname);
hyperslab = data;
case 'xy'
data = hdf5read(filename, varname);
hyperslab = data;
otherwise
disp 'gethdf5 - Wrong size in variable bl_corner - ERR1';
end