Skip to content

Commit

Permalink
Updated EUM items and units matching 22.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperGr committed Sep 9, 2024
1 parent 6ebbb1a commit d0a0cee
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
4 changes: 4 additions & 0 deletions MIKECore.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="buildUtil\eumXMLProcess.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="mikecore\Dfs123File.py">
<SubType>Code</SubType>
</Compile>
Expand Down Expand Up @@ -131,6 +134,7 @@
<ItemGroup>
<Folder Include="mikecore\" />
<Folder Include="miketools\" />
<Folder Include="buildUtil\" />
<Folder Include="tests\" />
</ItemGroup>
<ItemGroup>
Expand Down
53 changes: 53 additions & 0 deletions buildUtil/eumXMLProcess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Helper script to create/update the list of eumItem and eumUnit,
# reading from the EUM.xml file. From the root folder, run:
#
# python.exe ./buildUtil/eumXMLProcess.py > eumItemUnit.txt
#
# then compare eumItemUnit.txt with the ./mikecore/eum.py
# and copy over the missing items and units.
#
# This requires that the BuildNativeBin.bat has been run,
# to find the EUM.xml in the right position.

import re

# Using readlines()
eumFile = open('build/lib/mikecore/bin/windows/EUM.xml', 'r')
eumLines = eumFile.readlines()
eumFile.close()

recItem = re.compile('"(eumI\w+)" MzId="(\w*)"')
recUnit = re.compile('"(eumU\w+)" MzId="(\w*)"')

itemDict = {}
unitDict = {}
for line in eumLines:
match = recItem.search(line)
if match:
itemDict[int(match.group(2))] = match.group(1)
match = recUnit.search(line)
if match:
unitDict[int(match.group(2))] = match.group(1)

itemKeys = list(itemDict.keys())
unitKeys = list(unitDict.keys())

itemKeys.sort()
unitKeys.sort()

print("# Predefined enums of EUM item types.");
print("#");
print("# Must be updated with every new release, or if the EUM.xml is updated");
print("# Run buildUtil\eumXMLProcess.py to create the lists");
print("class eumItem(IntEnum):");
for key in itemKeys:
print(" {} = {}".format(itemDict[key], key))

print("")
print("# Predefined enums of EUM units.")
print("#")
print("# Must be updated with every new release, or if the EUM.xml is updated")
print("class eumUnit(IntEnum):")
for key in unitKeys:
print(" {} = {}".format(unitDict[key], key))

14 changes: 13 additions & 1 deletion mikecore/eum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Predefined enums of EUM item types.
#
# Must be updated with every new release, or if the EUM.xml is updated
# Run buildUtil\eumXMLProcess.py to create the lists
class eumItem(IntEnum):
eumIItemUndefined = 999
eumIWaterLevel = 100000
Expand Down Expand Up @@ -592,10 +593,18 @@ class eumItem(IntEnum):
eumIMassPerLengthPerTime = 110306
eumINearBedLoadPerLength = 110307
eumISubstancePerUnitArea = 110308
eumIAccNearBedLoadPerLength = 110309
eumIAccNearBedLoadPerLength = 110309
eumIThermalConductivity = 110310
eumIDirectionalVariance = 110311
eumISpecificDissipationRate = 110312
eumIAngularFrequency = 110313
eumIStemDiameter = 110314
eumIVegetationDensity = 110315
eumIElasticModulus = 110316
eumIBladeWidth = 110317
eumIBladeThickness = 110318
eumIPlantDensity = 110319
eumIThickness = 110320

# Predefined enums of EUM units.
#
Expand Down Expand Up @@ -768,6 +777,7 @@ class eumUnit(IntEnum):
eumUouncePerYardUS3 = 2219
eumUouncePerSquareFeet = 2220
eumUouncePerSquareFeetUS = 2221
eumUgramPerCubicCentimeter = 2222
eumUKiloGramPerMeterPerSecond = 2300
eumUPascalSecond = 2301
eumUkilogramPerMeterPerDay = 2302
Expand Down Expand Up @@ -1054,6 +1064,7 @@ class eumUnit(IntEnum):
eumUmilliBar = 6108
eumUmicroPascal = 6109
eumUdeciBar = 6110
eumUGigaPascal = 6111
eumUdB_re_1muPa2second = 6150
eumUdBperLambda = 6160
eumUPSU = 6200
Expand Down Expand Up @@ -1122,6 +1133,7 @@ class eumUnit(IntEnum):
eumUPerAcre = 9301
eumUPerHectar = 9302
eumUperKm2 = 9303
eumUPerSquareFeet = 9304
eumUPerCubicMeter = 9350
eumUCurrencyPerCubicMeter = 9351
eumUCurrencyPerCubicFeet = 9352
Expand Down

0 comments on commit d0a0cee

Please sign in to comment.