Skip to content

Commit b65d596

Browse files
authored
Merge pull request #30 from DHI/UpdateTo22.1
Update to 22.1.0 - Release 2024 Update 1
2 parents 7e987f7 + af61461 commit b65d596

File tree

7 files changed

+238
-128
lines changed

7 files changed

+238
-128
lines changed

.github/workflows/build_linux.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ jobs:
2828
- run: ls -l
2929
- name: Install nuget packages
3030
run: |
31-
nuget install DHI.MikeCore.Linux.rhel7 -Version 20.0.0 -OutputDirectory packages
31+
nuget install DHI.MikeCore.Linux.ubuntu -Version 22.1.0 -OutputDirectory packages
3232
- run: mkdir -p mikecore/bin/linux
3333
- run: pwd
3434
- run: ls -l
35-
- run: cp -r packages/DHI.MikeCore.Linux.rhel7.20.0.0/runtimes/linux-x64/native/* mikecore/bin/linux
35+
- run: cp -r packages/DHI.MikeCore.Linux.Ubuntu.22.1.0/runtimes/linux-x64/native/* mikecore/bin/linux
3636
- run: sudo apt-get install patchelf
3737
- run: |
3838
patchelf --set-rpath '$ORIGIN' mikecore/bin/linux/libufs.so
3939
patchelf --set-rpath '$ORIGIN' mikecore/bin/linux/libeum.so
4040
patchelf --set-rpath '$ORIGIN' mikecore/bin/linux/libMzCart.so
4141
patchelf --set-rpath '$ORIGIN' mikecore/bin/linux/libpfs2004.so
42-
patchelf --set-rpath '$ORIGIN' mikecore/bin/linux/libxerces-c-3.1.so
42+
patchelf --set-rpath '$ORIGIN' mikecore/bin/linux/libxerces-c-3.2.so
4343
4444
4545
- name: Set up Python ${{ matrix.python-version }}

Dockerfile

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,53 @@
1-
FROM python:3.9.4-slim
1+
FROM python:3.12.5-slim
22

3-
RUN apt-get update -y && apt-get install curl -y && apt-get install unzip -y
4-
RUN curl -o bin.zip https://globalcdn.nuget.org/packages/dhi.mikecore.linux.rhel7.20.0.0.nupkg && \
3+
# define variable version
4+
ARG VERSION=22.1.0
5+
6+
RUN apt-get update -y && apt-get install -y curl unzip patchelf
7+
RUN curl -o bin.zip https://globalcdn.nuget.org/packages/dhi.mikecore.linux.ubuntu.$VERSION.nupkg && \
58
unzip bin.zip && \
6-
mkdir -p /tmp/mikecore/bin/linux && \
7-
cp -r runtimes/linux-x64/native/* /tmp/mikecore/bin/linux
9+
mkdir -p /app/mikecore/bin/linux && \
10+
cp -r runtimes/linux-x64/native/* /app/mikecore/bin/linux
11+
12+
RUN curl -o dfs.zip https://globalcdn.nuget.org/packages/dhi.dfs.$VERSION.nupkg && \
13+
unzip -o dfs.zip && \
14+
mkdir -p /app/mikecore/bin/windows && \
15+
cp -r runtimes/win-x64/native/* /app/mikecore/bin/windows
816

9-
RUN pip install pytest numpy
17+
RUN curl -o projections.zip https://globalcdn.nuget.org/packages/dhi.projections.$VERSION.nupkg && \
18+
unzip -o projections.zip && \
19+
cp -r runtimes/win-x64/native/* /app/mikecore/bin/windows
1020

11-
ENV LD_LIBRARY_PATH=/usr/local/lib/python3.9/site-packages/mikecore/bin/linux
21+
# DHI.EUM
22+
RUN curl -o eum.zip https://globalcdn.nuget.org/packages/dhi.eum.$VERSION.nupkg && \
23+
unzip -o eum.zip && \
24+
cp -r runtimes/win-x64/native/* /app/mikecore/bin/windows
1225

13-
COPY . /tmp/
26+
# DHI.DHIfl
27+
RUN curl -o dhifl.zip https://globalcdn.nuget.org/packages/dhi.dhifl.$VERSION.nupkg && \
28+
unzip -o dhifl.zip && \
29+
cp -r runtimes/win-x64/native/* /app/mikecore/bin/windows
1430

15-
RUN pip install /tmp/.
31+
RUN pip install pytest setuptools twine wheel
1632

17-
COPY ./testdata /app/testdata
18-
COPY ./tests /app/tests
33+
RUN patchelf --set-rpath '$ORIGIN' /app/mikecore/bin/linux/libufs.so && \
34+
patchelf --set-rpath '$ORIGIN' /app/mikecore/bin/linux/libeum.so && \
35+
patchelf --set-rpath '$ORIGIN' /app/mikecore/bin/linux/libMzCart.so && \
36+
patchelf --set-rpath '$ORIGIN' /app/mikecore/bin/linux/libpfs2004.so && \
37+
patchelf --set-rpath '$ORIGIN' /app/mikecore/bin/linux/libxerces-c-3.2.so
1938

2039
WORKDIR /app
21-
CMD pytest
40+
41+
COPY . /app
42+
43+
RUN pip install .
44+
45+
RUN pytest
46+
47+
# build python package
48+
RUN python setup.py bdist_wheel
49+
50+
# get the wheel file to the host (for example)
51+
# podman build -t mikecore .
52+
# podman run -it --rm -t -v /tmp:/tmp mikecore bash
53+
# cp dist/mikecore-0.3.0-py3-none-any.whl /tmp

MIKECore.pyproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
2222
</PropertyGroup>
2323
<ItemGroup>
24+
<Compile Include="buildUtil\eumXMLProcess.py">
25+
<SubType>Code</SubType>
26+
</Compile>
2427
<Compile Include="mikecore\Dfs123File.py">
2528
<SubType>Code</SubType>
2629
</Compile>
@@ -131,6 +134,7 @@
131134
<ItemGroup>
132135
<Folder Include="mikecore\" />
133136
<Folder Include="miketools\" />
137+
<Folder Include="buildUtil\" />
134138
<Folder Include="tests\" />
135139
</ItemGroup>
136140
<ItemGroup>

buildUtil/eumXMLProcess.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Helper script to create/update the list of eumItem and eumUnit,
2+
# reading from the EUM.xml file. From the root folder, run:
3+
#
4+
# python.exe ./buildUtil/eumXMLProcess.py > eumItemUnit.txt
5+
#
6+
# then compare eumItemUnit.txt with the ./mikecore/eum.py
7+
# and copy over the missing items and units.
8+
#
9+
# This requires that the BuildNativeBin.bat has been run,
10+
# to find the EUM.xml in the right position.
11+
12+
import re
13+
14+
# Using readlines()
15+
eumFile = open('build/lib/mikecore/bin/windows/EUM.xml', 'r')
16+
eumLines = eumFile.readlines()
17+
eumFile.close()
18+
19+
recItem = re.compile('"(eumI\w+)" MzId="(\w*)"')
20+
recUnit = re.compile('"(eumU\w+)" MzId="(\w*)"')
21+
22+
itemDict = {}
23+
unitDict = {}
24+
for line in eumLines:
25+
match = recItem.search(line)
26+
if match:
27+
itemDict[int(match.group(2))] = match.group(1)
28+
match = recUnit.search(line)
29+
if match:
30+
unitDict[int(match.group(2))] = match.group(1)
31+
32+
itemKeys = list(itemDict.keys())
33+
unitKeys = list(unitDict.keys())
34+
35+
itemKeys.sort()
36+
unitKeys.sort()
37+
38+
print("# Predefined enums of EUM item types.");
39+
print("#");
40+
print("# Must be updated with every new release, or if the EUM.xml is updated");
41+
print("# Run buildUtil\eumXMLProcess.py to create the lists");
42+
print("class eumItem(IntEnum):");
43+
for key in itemKeys:
44+
print(" {} = {}".format(itemDict[key], key))
45+
46+
print("")
47+
print("# Predefined enums of EUM units.")
48+
print("#")
49+
print("# Must be updated with every new release, or if the EUM.xml is updated")
50+
print("class eumUnit(IntEnum):")
51+
for key in unitKeys:
52+
print(" {} = {}".format(unitDict[key], key))
53+

mikecore/DfsFile.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,15 @@ def __GetStaticData(self, item):
13901390
class DfsDLLUtil():
13911391
"""Utilities class, creating various Dfs classes based on pointers to DFS native data"""
13921392

1393+
# In case of incorrect eumUnitInt then return eumUmeter, the default axis unit
1394+
@staticmethod
1395+
def ToEumAxisUnit(eumUnitInt: int):
1396+
try:
1397+
spatial_axis_unit = eumUnit(eumUnitInt)
1398+
except:
1399+
spatial_axis_unit = eumUnit.eumUmeter
1400+
return spatial_axis_unit
1401+
13931402
@staticmethod
13941403
def GetDfsType(arrayData):
13951404
if (arrayData.dtype == np.float32):
@@ -1576,7 +1585,7 @@ def GetItemSpatialAxis(itemPointer):
15761585
eumUnitInt = ctypes.c_int32()
15771586
eumUnitDescr = ctypes.c_char_p()
15781587
DfsDLL.Wrapper.dfsGetItemAxisEqD0(itemPointer, ctypes.byref(eumUnitInt), ctypes.byref(eumUnitDescr))
1579-
axis = DfsAxisEqD0(eumUnit(eumUnitInt.value))
1588+
axis = DfsAxisEqD0(DfsDLLUtil.ToEumAxisUnit(eumUnitInt.value))
15801589
return (axis)
15811590

15821591
if axisType == SpaceAxisType.EqD1:
@@ -1592,7 +1601,7 @@ def GetItemSpatialAxis(itemPointer):
15921601
ctypes.byref(xCount),
15931602
ctypes.byref(x0),
15941603
ctypes.byref(dx))
1595-
axis = DfsAxisEqD1(eumUnit(eumUnitInt.value), xCount.value, x0.value, dx.value)
1604+
axis = DfsAxisEqD1(DfsDLLUtil.ToEumAxisUnit(eumUnitInt.value), xCount.value, x0.value, dx.value)
15961605
return (axis)
15971606

15981607
if axisType == SpaceAxisType.NeqD1:
@@ -1617,7 +1626,7 @@ def GetItemSpatialAxis(itemPointer):
16171626
ctypes.byref(y0),
16181627
ctypes.byref(dx),
16191628
ctypes.byref(dy))
1620-
axis = DfsAxisEqD2(eumUnit(eumUnitInt.value), xCount.value, x0.value, dx.value, yCount.value, y0.value, dy.value)
1629+
axis = DfsAxisEqD2(DfsDLLUtil.ToEumAxisUnit(eumUnitInt.value), xCount.value, x0.value, dx.value, yCount.value, y0.value, dy.value)
16211630
return (axis)
16221631

16231632
if axisType == SpaceAxisType.NeqD2:
@@ -1649,7 +1658,7 @@ def GetItemSpatialAxis(itemPointer):
16491658
ctypes.byref(dy),
16501659
ctypes.byref(dz),
16511660
)
1652-
axis = DfsAxisEqD3(eumUnit(eumUnitInt.value), xCount.value, x0.value, dx.value, yCount.value, y0.value, dy.value, zCount.value, z0.value, dz.value)
1661+
axis = DfsAxisEqD3(DfsDLLUtil.ToEumAxisUnit(eumUnitInt.value), xCount.value, x0.value, dx.value, yCount.value, y0.value, dy.value, zCount.value, z0.value, dz.value)
16531662
return axis
16541663

16551664
if axisType == SpaceAxisType.NeqD3:

mikecore/eum.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Predefined enums of EUM item types.
88
#
99
# Must be updated with every new release, or if the EUM.xml is updated
10+
# Run buildUtil\eumXMLProcess.py to create the lists
1011
class eumItem(IntEnum):
1112
eumIItemUndefined = 999
1213
eumIWaterLevel = 100000
@@ -592,10 +593,18 @@ class eumItem(IntEnum):
592593
eumIMassPerLengthPerTime = 110306
593594
eumINearBedLoadPerLength = 110307
594595
eumISubstancePerUnitArea = 110308
595-
eumIAccNearBedLoadPerLength = 110309
596+
eumIAccNearBedLoadPerLength = 110309
596597
eumIThermalConductivity = 110310
597598
eumIDirectionalVariance = 110311
598599
eumISpecificDissipationRate = 110312
600+
eumIAngularFrequency = 110313
601+
eumIStemDiameter = 110314
602+
eumIVegetationDensity = 110315
603+
eumIElasticModulus = 110316
604+
eumIBladeWidth = 110317
605+
eumIBladeThickness = 110318
606+
eumIPlantDensity = 110319
607+
eumIThickness = 110320
599608

600609
# Predefined enums of EUM units.
601610
#
@@ -768,6 +777,7 @@ class eumUnit(IntEnum):
768777
eumUouncePerYardUS3 = 2219
769778
eumUouncePerSquareFeet = 2220
770779
eumUouncePerSquareFeetUS = 2221
780+
eumUgramPerCubicCentimeter = 2222
771781
eumUKiloGramPerMeterPerSecond = 2300
772782
eumUPascalSecond = 2301
773783
eumUkilogramPerMeterPerDay = 2302
@@ -1054,6 +1064,7 @@ class eumUnit(IntEnum):
10541064
eumUmilliBar = 6108
10551065
eumUmicroPascal = 6109
10561066
eumUdeciBar = 6110
1067+
eumUGigaPascal = 6111
10571068
eumUdB_re_1muPa2second = 6150
10581069
eumUdBperLambda = 6160
10591070
eumUPSU = 6200
@@ -1122,6 +1133,7 @@ class eumUnit(IntEnum):
11221133
eumUPerAcre = 9301
11231134
eumUPerHectar = 9302
11241135
eumUperKm2 = 9303
1136+
eumUPerSquareFeet = 9304
11251137
eumUPerCubicMeter = 9350
11261138
eumUCurrencyPerCubicMeter = 9351
11271139
eumUCurrencyPerCubicFeet = 9352
@@ -1701,12 +1713,12 @@ def eumGetBaseUnit(unitKey: eumUnit) -> eumUnit:
17011713
#/ <see cref="eumUnit.eumUUnitUndefined"/> gives the first unit in the system.
17021714
#/ </summary>
17031715
@staticmethod
1704-
def eumGetNextUnit(prevUnitKey: eumUnit) -> Tuple[bool, eumUnit, str]:
1716+
def eumGetNextUnit(prevUnitKey: int) -> Tuple[bool, int, str]:
17051717
unitKey = ctypes.c_int32();
17061718
lpUnitDesc = ctypes.c_char_p();
17071719
if (0 != eumDLL.Wrapper.eumGetNextUnit(prevUnitKey, ctypes.byref(unitKey), ctypes.byref(lpUnitDesc))):
1708-
return True, eumUnit(unitKey.value), lpUnitDesc.value.decode("ascii");
1709-
return False, eumUnit.eumUUnitUndefined, "";
1720+
return True, unitKey.value, lpUnitDesc.value.decode("ascii");
1721+
return False, eumUnit.eumUUnitUndefined.value, "";
17101722

17111723
#/ <summary>
17121724
#/ Get the next unit defined in the eum-system which is equivalent

0 commit comments

Comments
 (0)