Skip to content
Merged
49 changes: 42 additions & 7 deletions avaframe/ana5Utils/distanceTimeAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,15 @@ def setupThalwegTimeDiagram(dem, cfgRangeTime):
indStartOfRunout = rasterTransfo['indStartOfRunout']
# create range raster with respect to runout area start point
# minus in upstream direction of runout area start point
rangeGates = rasterTransfo['s'][:] - rasterTransfo['s'][indStartOfRunout]
if cfgRangeTime['GENERAL']['sType'].lower() == 'parallel':
rangeGates = rasterTransfo['sParallel'][:] - rasterTransfo['sParallel'][indStartOfRunout]
elif cfgRangeTime['GENERAL']['sType'].lower() == 'projected':
rangeGates = rasterTransfo['s'][:] - rasterTransfo['s'][indStartOfRunout]
else:
message = ('sType for tt-diagram is invalid, valid options are: projected and parallel' %
cfgRangeTime['GENERAL']['sType'])
log.error(message)
raise AssertionError
rangeRaster = np.repeat([rangeGates], newRasterDEM.shape[1], axis=0).T

# create dictionary with info on front distance, mean values, range distance array
Expand All @@ -383,8 +391,8 @@ def setupThalwegTimeDiagram(dem, cfgRangeTime):
mtiInfo['rasterTransfo'] = rasterTransfo
mtiInfo['type'] = 'thalwegTime'
mtiInfo['z'] = rasterTransfo['z']
mtiInfo['s'] = rasterTransfo['s']
mtiInfo['referencePointName'] = 'beta point'
mtiInfo['sType'] = cfgRangeTime['GENERAL']['sType']

return mtiInfo

Expand Down Expand Up @@ -431,23 +439,48 @@ def extractFrontAndMeanValuesTT(cfgRangeTime, flowF, demHeader, mtiInfo):
rasterArea = rasterTransfo['rasterArea']
maxaCrossMax, aCrossMax, aCrossMean = aT.getMaxMeanValues(slRaster, rasterArea)

# add mean values for each cross-section for actual time step to mean values array
# reshape is required as rows- mean values for each crossprofile and cols: time steps
# use the max or the mean of each cross section
if cfgRangeTime['GENERAL']['maxOrMean'].lower() == 'max':
aCross = aCrossMax
else:
aCross = aCrossMean

# add max or mean values for each cross-section for actual time step to mti values array
# reshape is required as rows- max/mean values for each crossprofile and cols: time steps
if mtiInfo['timeList'] == []:
mtiInfo['mti'] = aCrossMean.reshape(-1, 1)
mtiInfo['mti'] = aCross.reshape(-1, 1)

else:
mtiInfo['mti'] = np.hstack((mtiInfo['mti'], aCrossMean.reshape(-1, 1)))
mtiInfo['mti'] = np.hstack((mtiInfo['mti'], aCross.reshape(-1, 1)))

# extract avalanche front distance to reference point in path following coordinate system
indStartOfRunout = rasterTransfo['indStartOfRunout']
lindex = np.nonzero(slRaster > cfgRangeTime['GENERAL'].getfloat('thresholdResult'))[0]
if lindex.any():
cUpper = min(lindex)
cLower = max(lindex)
rangeValue = rasterTransfo['s'][cLower] - rasterTransfo['s'][indStartOfRunout]
if mtiInfo['sType'].lower() == 'parallel':
rangeValue = rasterTransfo['sParallel'][cLower] - rasterTransfo['sParallel'][indStartOfRunout]
elif mtiInfo['sType'].lower() == 'projected':
rangeValue = rasterTransfo['s'][cLower] - rasterTransfo['s'][indStartOfRunout]
else:
message = ('sType for tt-diagram is invalid, valid options are: projected and parallel' %
cfgRangeTime['GENERAL']['sType'])
log.error(message)
raise AssertionError
mtiInfo['rangeList'].append(rangeValue)
# if animation plot shall be created add transformation info to mtiInfo dict for plots
if cfgRangeTime['PLOTS'].getboolean('animate'):
mtiInfo['slRaster'] = slRaster
mtiInfo['rasterTransfo'] = rasterTransfo
mtiInfo['cLower'] = cLower
else:
cLower = np.nan
mtiInfo['rangeList'].append(np.nan)
if cfgRangeTime['PLOTS'].getboolean('animate'):
mtiInfo['slRaster'] = slRaster
mtiInfo['rasterTransfo'] = rasterTransfo
mtiInfo['cLower'] = cLower

# plot avalanche front and transformed raster field
if cfgRangeTime['PLOTS'].getboolean('debugPlot'):
Expand Down Expand Up @@ -546,6 +579,7 @@ def fetchRangeTimeInfo(cfgRangeTime, cfg, dtRangeTime, t, demHeader, fields, mti
# extract front and average values of result parameter
if cfg['VISUALISATION'].getboolean('TTdiagram'):
mtiInfo = extractFrontAndMeanValuesTT(cfgRangeTime, fields[rangeTimeResType], demHeader, mtiInfo)

else:
# extract front in simulation result for each time step and average values along range gates
# for colorcoding range time plot
Expand Down Expand Up @@ -695,6 +729,7 @@ def approachVelocity(mtiInfo, minVelTimeStep):
rangeListSorted = np.asarray(rangeList)[np.argsort(timeList)] + abs(np.nanmin(np.asarray(rangeList)))
maxVel = 0.0
rangeVel = 0.0
timeVel = 0.0

# use minimum time step for computing approach velocity
for i in range(len(timeListSorted)):
Expand Down
37 changes: 36 additions & 1 deletion avaframe/ana5Utils/distanceTimeAnalysisCfg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ radarLocation =

#++++++++thalweg time diagram along avalanche path ++++++++++++
# domain width orthogonal to avalanche path
domainWidth = 200
domainWidth = 600

# The cell size for the new (s,l) raster is automatically computed from the reference result file (leave the following field empty)
# It is possible to force the cell size to take another value, then specify this new value below, otherwise leave empty (default).
Expand All @@ -44,9 +44,44 @@ interpMethod = bilinear
# dsMin meters after the beta point also have an angle bellow 10°
dsMin = 30

# use the maximum rangeTimeResType or the mean rangeTimeResType (max or mean) values computed for crossprofiles along path
maxOrMean = mean

# use flow parallel or projected distance along flow path for plots and to compute approach velocity
# options: projected, parallel
sType = projected


[PLOTS]
# every gateContours gate range plotted as contour line in radar field of view plot
gateContours = 20
# show debug plots
debugPlot = False
# width of velocity legend in fraction of full figure width
width = 0.25
# height of velocity legend in fraction of full figure height
height = 0.25
# line width of velocity legend lines
lw = 0.25
# text size of velocity legend
textsize = 7
# if an animation of flow result, transformed into TT domain and TT-diagram shall be created
# if True uncomment section ANIMATE and add values to parameters
animate = False

[ANIMATE]
# parameters for extent of tt-diagram - should have ranges to capture the full extent of the avalanche
# the default values provided here can be used for a default null simulation for avaParabola and FT
# set extent of tt-diagram and result type min and max values as reMin, resMax
resMin = 0
resMax = 1.9
# set extent of tt-diagram time steps (xMin and xMax) and distance to beta point (yMin and yMax)
xMin = 0
xMax = 160
yMax = 870
yMin = 1840
# annotate x, y with East and North in res Type plot
xyEastNorth = True
# add titles to all three panels, 1. simulation extent x, y at t=%.2fs, 2. s, l domain extent,
# 3. tt-diagram
panelTitles = True
6 changes: 6 additions & 0 deletions avaframe/com1DFA/com1DFA.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from avaframe.com1DFA import particleInitialisation as pI
from avaframe.com1DFA import checkCfg
from avaframe.ana5Utils import distanceTimeAnalysis as dtAna
import avaframe.out3Plot.outDistanceTimeAnalysis as dtAnaPlots

#######################################
# Set flags here
Expand Down Expand Up @@ -1368,6 +1369,11 @@ def DFAIterate(cfg, particles, fields, dem, simHash=''):
mtiInfo, dtRangeTime = dtAna.fetchRangeTimeInfo(cfgRangeTime, cfg, dtRangeTime, t, demRT['header'],
fields, mtiInfo)

# create plots for tt diagram animation
if cfgRangeTime['PLOTS'].getboolean('animate') and cfg['VISUALISATION'].getboolean('TTdiagram'):
TTResType = cfgRangeTime['GENERAL']['rangeTimeResType']
dtAnaPlots.animationPlot(demRT, fields[TTResType], demRT['header']['cellsize'], TTResType, cfgRangeTime, mtiInfo, t)

# make sure the array is not empty
if t >= dtSave[0]:
Tsave.append(t)
Expand Down
Loading