-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_dfs_static_item.py
130 lines (105 loc) · 5 KB
/
test_dfs_static_item.py
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import unittest
from mikecore.DfsFileFactory import DfsFileFactory
from mikecore.DfsFile import *
from numpy.testing import *
class Test_dfs_static_item(unittest.TestCase):
def test_static_item(self):
dfsFile = DfsFileFactory.DfsGenericOpen("testdata/OresundHD.dfsu")
staticItems = []
staticItemNumber = 1;
while (True):
varstaticItem = dfsFile.ReadStaticItem(staticItemNumber);
if (varstaticItem is None):
break;
staticItems.append(varstaticItem);
staticItemNumber += 1
assert staticItems != None
assert 9 == len(staticItems)
# Check x-coord static item
staticItem = staticItems[1];
assert 2 == staticItem.ItemNumber
assert 2057 == staticItem.ElementCount
#assert 2057 == staticItem.UsedElementCount
assert "X-coord" == staticItem.Name
if (eumItem.eumIItemUndefined == staticItem.Quantity.Item):
assert eumUnit.eumUUnitUndefined == staticItem.Quantity.Unit
elif (eumItem.eumIGeographicalCoordinate == staticItem.Quantity.Item):
assert eumUnit.eumUmeter == staticItem.Quantity.Unit
else:
assert "X coordinate axis item type mismatch" == ""
if (staticItem.DataType != DfsSimpleType.Double and staticItem.DataType != DfsSimpleType.Float):
assert "DataType of X static item mismatch" == ""
#assert deleteValueFloat == staticItem.ReferenceCoordinateX
#assert deleteValueFloat == staticItem.ReferenceCoordinateY
#assert deleteValueFloat == staticItem.ReferenceCoordinateZ
#assert deleteValueFloat == staticItem.OrientationAlpha
#assert deleteValueFloat == staticItem.OrientationPhi
#assert deleteValueFloat == staticItem.OrientationTheta
# Check dummy spatial axis
axis = staticItem.SpatialAxis
assert SpaceAxisType.EqD1 == axis.AxisType
assert 1 == axis.Dimension
assert 2057 == axis.XCount
assert 0 == axis.X0
assert 1 == axis.Dx
# Check data - first and last coordinate
assert_allclose(359978.8, staticItem.Data[0])
assert_allclose(338109.5, staticItem.Data[2056])
#--------------------------------------
# Check element type static item
staticItem = staticItems[6];
assert 7 == staticItem.ItemNumber;
assert 3636 == staticItem.ElementCount
#assert 3636 == staticItem.UsedElementCount
if (eumItem.eumIItemUndefined == staticItem.Quantity.Item):
assert eumUnit.eumUUnitUndefined == staticItem.Quantity.Unit
elif (eumItem.eumIIntegerCode == staticItem.Quantity.Item):
assert eumUnit.eumUintCode == staticItem.Quantity.Unit
else:
raise Exception("Element Type coordinate axis item type mismatch")
assert DfsSimpleType.Int == staticItem.DataType
assert "Element type" == staticItem.Name
# Check dummy spatial axis
axis = staticItem.SpatialAxis
assert SpaceAxisType.EqD1 == axis.AxisType
assert 3636, axis.XCount
# Check data - first and last elements
assert 21 == staticItem.Data[0]
assert 21 == staticItem.Data[3635]
#--------------------------------------
# Check connectivity static item
staticItem = staticItems[8];
assert 9 == staticItem.ItemNumber
assert 3 * 3636 == staticItem.ElementCount
#assert 3 * 3636 == staticItem.UsedElementCount
if (eumItem.eumIItemUndefined == staticItem.Quantity.Item):
assert eumUnit.eumUUnitUndefined == staticItem.Quantity.Unit
elif (eumItem.eumIIntegerCode == staticItem.Quantity.Item):
assert eumUnit.eumUintCode == staticItem.Quantity.Unit
else:
raise Exception("Connectivity coordinate axis item type mismatch")
assert DfsSimpleType.Int == staticItem.DataType
assert "Connectivity" == staticItem.Name
#assert deleteValueFloat == staticItem.ReferenceCoordinateX
#assert deleteValueFloat == staticItem.ReferenceCoordinateY
#assert deleteValueFloat == staticItem.ReferenceCoordinateZ
#assert deleteValueFloat == staticItem.OrientationAlpha
#assert deleteValueFloat == staticItem.OrientationPhi
#assert deleteValueFloat == staticItem.OrientationTheta
# Check dummy spatial axis
axis = staticItem.SpatialAxis;
assert SpaceAxisType.EqD1 == axis.AxisType
assert 1 == axis.Dimension
# TODO: Assert.AreEqual(eumUnit.eumUmeter, axis.AxisUnit
assert 3 * 3636 == axis.XCount
assert 0 == axis.X0
assert 1 == axis.Dx
# Check data - first and last element
assert 1 == staticItem.Data[0]
assert 2 == staticItem.Data[1]
assert 3 == staticItem.Data[2]
assert 1698 == staticItem.Data[10905]
assert 1697 == staticItem.Data[10906]
assert 2056 == staticItem.Data[10907]
if __name__ == '__main__':
unittest.main()