Skip to content

Commit

Permalink
adapted to rebased master
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulaSp3 committed Sep 16, 2024
1 parent 20e2330 commit 571697e
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 12 deletions.
19 changes: 11 additions & 8 deletions avaframe/runStandardTestsCom4FlowPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
from avaframe.in3Utils import logUtils


def read_raster(path):
def readRasters(path):
raster = rasterio.open(path)
output = raster.read(1)
return output


def compare(path, pathRef):
raster = read_raster(path)
rasterRef = read_raster(pathRef)
def compareRasters(path, pathRef):
raster = readRasters(path)
rasterRef = readRasters(pathRef)
diff = rasterRef - raster
equal = np.array_equal(rasterRef, raster)
closeArray = np.isclose(raster, rasterRef , rtol=1e-04, equal_nan=True)
Expand All @@ -36,7 +36,7 @@ def compare(path, pathRef):


# Which result types for comparison plots
outputVariable = ['FP_travel_angle', 'z_delta']
outputVariable = ['fpTravelAngle', 'zdelta']

# log file name; leave empty to use default runLog.log
logName = 'runStandardTestsCom4FlowPy'
Expand Down Expand Up @@ -103,6 +103,9 @@ def compare(path, pathRef):
cfgPath["tempDir"] = cfgPath["workDir"] / "temp"
fU.makeADir(cfgPath["tempDir"])
cfgPath["deleteTemp"] = "False"
cfgPath["uid"] = cfgUtils.cfgHash(cfg)
cfgPath["timeString"] = ""
cfgPath["outputFiles"] = "zDelta|travelLength|fpTravelAngle|flux"

# Set timing
startTime = time.time()
Expand All @@ -113,9 +116,9 @@ def compare(path, pathRef):
log.info(('Took %s seconds to calculate.' % (timeNeeded)))

for variable in outputVariable:
pathRasterRef = refDir / ('%s.tif' % variable)
pathRaster = compDir / ('%s.tif' % variable)
diff, eq, close = compare(pathRaster, pathRasterRef)
pathRasterRef = refDir / (f'com4_{cfgPath["uid"]}__{variable}.tif')
pathRaster = compDir / (f'com4_{cfgPath["uid"]}__{variable}.tif')
diff, eq, close = compareRasters(pathRaster, pathRasterRef)

if eq and np.sum(abs(diff[diff != 0])) == 0:
message = f'{testName}: for {variable}: rasters are equal \n'
Expand Down
46 changes: 44 additions & 2 deletions benchmarksCom4FlowPy/avaArzlerAlm/ArzlerAlm_com4FlowPyCfg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ max_z = 8848

infra = False

#++++++++++++ Use a dynamic u_max Limit
# Requires an additional tif-file containing the uMax (in m/s)
# or zDeltaMax (m) Limits
# in every cell where a release cell is.
# the paths for each release cells are calculated with these uMax values
# (computed to z_delta, similar to the max_z) or zDelta values.
# In varUmaxParameter the parameter (uMax in m/s or zDeltaMax in m)
# provided is given.
variableUmaxLim = False
varUmaxParameter = uMax

#++++++++++++ Use a dynamic alpha angle
# Requires an additional tif-file containing the alpha angles
# in every cell where a release cell is.
# The paths for each release cells are calculated with these alpha angles
variableAlpha = False

#++++++++++++ Use a dynamic exponent
# Requires an additional tif-file containing the exponents
# in every cell where a release cell is.
# The paths for each release cells are calculated with these exponent
variableExponent = False

#++++++++++++ Use Forest Information
# NOTE AH 20240408: Dummy settings for Forest Interaction
# The forest implementation should mimick/reproduce the
Expand All @@ -42,7 +65,6 @@ infra = False
#
# Forest-Interaction is only used if 'forest' is set to 'True'
#++++++++++++

forest = False

#++++++++++++
Expand Down Expand Up @@ -153,6 +175,23 @@ maxChunks = 500

# Optional Custom Paths
[PATHS]

# define format of output raster files (default = .tif)
# available options: [.tif, .asc]
# if you plan to utilize avaFrame tools to analyse result rasters
# then you should choose '.asc' here!
outputFileFormat = .tif

# define the different output files that are written to disk
# default = 'zDelta|cellCounts|travelLength|fpTravelAngle'
# additional options:
# slTravelAngle
# flux
# zDeltaSum
# if forestInteraction: forestInteraction is automatically added to outputs
# if infra: backCalculation is automatically added to output
outputFiles = zDelta|cellCounts|travelLength|fpTravelAngle|slTravelAngle|flux

#++++++++++++ Custom paths True/False
# default: False
# if set to 'False':
Expand All @@ -176,6 +215,9 @@ demPath =
releasePath =
infraPath =
forestPath =
varUmaxPath =
varAlphaPath =
varExponentPath =

# plot save results flags------------------------
# NOTE-TODO: These Flags still don't do anything,
Expand All @@ -197,4 +239,4 @@ writeRes = True
# keep intermediate results
fullOut = False

#----------------------------------------------------------
#----------------------------------------------------------
Binary file not shown.
Binary file removed benchmarksCom4FlowPy/avaArzlerAlm/cell_counts.tif
Binary file not shown.
File renamed without changes.
Binary file removed benchmarksCom4FlowPy/avaArzlerAlm/travel_length.tif
Binary file not shown.
11 changes: 11 additions & 0 deletions benchmarksCom4FlowPy/avaArzlerAlm/z_delta.tif.aux.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<PAMDataset>
<PAMRasterBand band="1">
<Metadata>
<MDI key="STATISTICS_MAXIMUM">267.93823242188</MDI>
<MDI key="STATISTICS_MEAN">4.4432088366262</MDI>
<MDI key="STATISTICS_MINIMUM">0</MDI>
<MDI key="STATISTICS_STDDEV">26.540062227169</MDI>
<MDI key="STATISTICS_VALID_PERCENT">100</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>
Binary file removed benchmarksCom4FlowPy/avaArzlerAlm/z_delta_sum.tif
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ max_z = 8848

infra = False

#++++++++++++ Use a dynamic u_max Limit
# Requires an additional tif-file containing the uMax (in m/s)
# or zDeltaMax (m) Limits
# in every cell where a release cell is.
# the paths for each release cells are calculated with these uMax values
# (computed to z_delta, similar to the max_z) or zDelta values.
# In varUmaxParameter the parameter (uMax in m/s or zDeltaMax in m)
# provided is given.
variableUmaxLim = False
varUmaxParameter = uMax

#++++++++++++ Use a dynamic alpha angle
# Requires an additional tif-file containing the alpha angles
# in every cell where a release cell is.
# The paths for each release cells are calculated with these alpha angles
variableAlpha = False

#++++++++++++ Use a dynamic exponent
# Requires an additional tif-file containing the exponents
# in every cell where a release cell is.
# The paths for each release cells are calculated with these exponent
variableExponent = False

#++++++++++++ Use Forest Information
# NOTE AH 20240408: Dummy settings for Forest Interaction
# The forest implementation should mimick/reproduce the
Expand All @@ -42,7 +65,6 @@ infra = False
#
# Forest-Interaction is only used if 'forest' is set to 'True'
#++++++++++++

forest = False

#++++++++++++
Expand Down Expand Up @@ -153,6 +175,23 @@ maxChunks = 500

# Optional Custom Paths
[PATHS]

# define format of output raster files (default = .tif)
# available options: [.tif, .asc]
# if you plan to utilize avaFrame tools to analyse result rasters
# then you should choose '.asc' here!
outputFileFormat = .tif

# define the different output files that are written to disk
# default = 'zDelta|cellCounts|travelLength|fpTravelAngle'
# additional options:
# slTravelAngle
# flux
# zDeltaSum
# if forestInteraction: forestInteraction is automatically added to outputs
# if infra: backCalculation is automatically added to output
outputFiles = zDelta|cellCounts|travelLength|fpTravelAngle|slTravelAngle|flux

#++++++++++++ Custom paths True/False
# default: False
# if set to 'False':
Expand All @@ -176,6 +215,9 @@ demPath =
releasePath =
infraPath =
forestPath =
varUmaxPath =
varAlphaPath =
varExponentPath =

# plot save results flags------------------------
# NOTE-TODO: These Flags still don't do anything,
Expand All @@ -197,4 +239,4 @@ writeRes = True
# keep intermediate results
fullOut = False

#----------------------------------------------------------
#----------------------------------------------------------
11 changes: 11 additions & 0 deletions benchmarksCom4FlowPy/avaParabolaChanneldPaper/z_delta.tif.aux.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<PAMDataset>
<PAMRasterBand band="1">
<Metadata>
<MDI key="STATISTICS_MAXIMUM">218.48492431641</MDI>
<MDI key="STATISTICS_MEAN">5.4687844678271</MDI>
<MDI key="STATISTICS_MINIMUM">0</MDI>
<MDI key="STATISTICS_STDDEV">28.404478131686</MDI>
<MDI key="STATISTICS_VALID_PERCENT">100</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>

0 comments on commit 571697e

Please sign in to comment.