-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmatio.hdf5.cube.pas
More file actions
72 lines (59 loc) · 2.14 KB
/
matio.hdf5.cube.pas
File metadata and controls
72 lines (59 loc) · 2.14 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
unit matio.hdf5.cube;
////////////////////////////////////////////////////////////////////////////////
//
// Author: Jaap Baak
// https://github.com/transportmodelling/matio
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
interface
////////////////////////////////////////////////////////////////////////////////
Uses
SysUtils, Types, ArrBld, matio, matio.hdf5.dll, matio.hdf5;
Type
TCubeMatrixReader = Class(THdf5MatrixReader)
private
FVersion: AnsiString;
protected
Function ReadAttributes: Integer; override; // Returns size
Function MatrixGroup: ANSIString; override;
public
Property Version: AnsiString read FVersion;
end;
TCubeMatrixWriter = Class(THdf5MatrixWriter)
strict protected
Function Groups: TArray<ANSIString>; override;
Function MatrixGroup: ANSIString; override;
Procedure WriteAttributes(const FileLabel: ANSIString; Size: Integer); override;
public
Const
CubeMatrixVersion = '1.0';
end;
////////////////////////////////////////////////////////////////////////////////
implementation
////////////////////////////////////////////////////////////////////////////////
Function TCubeMatrixReader.ReadAttributes: Integer;
begin
Hdf5Dll.ReadStringAttribute(Hdf5FileId,'/','CUBE_MATRIX_VERSION',FVersion);
Hdf5Dll.ReadIntArrayAttribute(Hdf5FileId,'/','CUBE_MATRIX_ZONES',Result);
end;
Function TCubeMatrixReader.MatrixGroup: ANSIString;
begin
Result := '/matrices';
end;
////////////////////////////////////////////////////////////////////////////////
Function TCubeMatrixWriter.Groups: TArray<ANSIString>;
begin
Result := ['/matrices','/zonalReferences'];
end;
Function TCubeMatrixWriter.MatrixGroup: ANSIString;
begin
Result := '/matrices';
end;
Procedure TCubeMatrixWriter.WriteAttributes(const FileLabel: ANSIString; Size: Integer);
begin
Hdf5Dll.CreateStringAttribute(Hdf5FileId,'/','LABEL',FileLabel);
Hdf5Dll.CreateStringAttribute(Hdf5FileId,'/','CUBE_MATRIX_VERSION',CubeMatrixVersion);
Hdf5Dll.CreateIntAttribute(Hdf5FileId,'/','CUBE_MATRIX_ZONES',Size);
end;
end.