Skip to content

Commit c640ea7

Browse files
Postprocessing tools (#216)
* Re-ordered the existing AeoLiS simulation examples The examples by deVries2023 are merged with the other existing examples and a new README file is added, covering all available examples. * Updated plotting functions with improved documentation * Add files via upload
1 parent 9b5af76 commit c640ea7

File tree

7 files changed

+155
-123
lines changed

7 files changed

+155
-123
lines changed

aeolis/examples/README.txt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
This folder contains a variation of AeoLiS simulation setups.
2+
3+
4+
1D - (simple) One-dimensional examples:
5+
6+
1D/case1_small_waves
7+
<description>
8+
9+
1D/case2_larger_waves
10+
<description>
11+
12+
1D/case3_erosion_avalanching
13+
<description>
14+
15+
1D/case4_surface_moisture
16+
<description>
17+
18+
19+
2D - (simple) Two-dimensional examples
20+
21+
2D/Barchan_dune
22+
<description>
23+
24+
2D/Parabolic_dune
25+
<description>
26+
27+
2D/Carrara_Coast
28+
<description>
29+
30+
31+
deVries2023 - Simulations describing ...
32+
33+
deVries2023/Run 1 - Fetch effects and spatial variability in supply
34+
<description>
35+
36+
deVries2023/Run 2 - Fetch effects and wind directionality
37+
<description>
38+
39+
deVries2023/Run 3 - Fetch effects and temporal variability in supply
40+
<description>
41+
42+
deVries2023/Run 4 - Predictions of decadal development
43+
<description>
44+
45+
46+
grainsizevariations - SHORT DESCRIPTION
47+
<description>
48+
49+
50+
sandengine_small_grids - Fast Sand Engine simulation
51+
Simulation of the subaerial Sand Engine evolution, describing supply-limiting effects like moisture and sediment sorting on a larger scale
52+
53+
54+
vanWesten2024 - Landform simulations as described in the AeoLiS landform publication (van Westen, 2024)
55+
56+
vanWesten2024/barchan_morocco
57+
<description>
58+
59+
vanWesten2024/barchan_rotate
60+
<description>
61+
62+
vanWesten2024/blowout
63+
<description>
64+
65+
vanWesten2024/embryo
66+
<description>
67+
68+
vanWesten2024/parabolic
69+
<description>
70+
71+
72+
73+
74+
75+
76+
77+

tools/aeolis_output.nc

537 KB
Binary file not shown.

tools/visualization/plotting.py renamed to tools/postprocessing/plotting_functions.py

Lines changed: 9 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
def plot1d(ncfile, itransects=0, itimes=0, ifrac=0, params='zb'):
1919

20-
'''Generic function for plotting 2D parameters from AeoLiS netcdf results
20+
'''Generic function for plotting 1D parameters from AeoLiS netcdf results
2121
2222
Parameters
2323
----------
@@ -30,17 +30,18 @@ def plot1d(ncfile, itransects=0, itimes=0, ifrac=0, params='zb'):
3030
ifrac : integer
3131
index of fraction, only used when the results has multiple dimensions ( >=4 )
3232
params :
33-
string or list of strings describing the name of the parameter for plotting
33+
string or list of strings describing the name of the parameter for plotting'
34+
the parameters that can be plotted are defined in the AeoLiS input file.
3435
3536
Returns
3637
-------
37-
figs/ axs?
38+
figs/ ax
3839
...
3940
4041
Examples
4142
--------
42-
>>> ploted(parse_value('T'))
43-
bool
43+
>>> plot1d(ncfile, itransects=0, itimes=0, ifrac=0, params='zb') # plot the bed level for the first transect and timestep 0
44+
>>> plot1d(ncfile, itransects=0, itimes=-1, ifrac=0, params=['zb', 'Hs']) # plot the bed level and wave height for the first transect and last timestep
4445
4546
'''
4647

@@ -103,17 +104,16 @@ def plot2d(ncfile, itimes=0, ifrac=0, param='zb', cmap=plt.cm.jet, clim='auto',
103104
Boolean for indicating plotting difference between timesteps or the actual value
104105
itimeDelta : integer
105106
index for the starting timestep in the netcdf-file when merging, only used when delta == Bool
106-
quiver?
107107
108108
Returns
109109
-------
110-
figs/ axs?
110+
figs/ ax
111111
...
112112
113113
Examples
114114
--------
115-
>>> ploted(parse_value('T'))
116-
bool
115+
>>> plot2d(ncfile, itimes=0, ifrac=0, param='zb') # plot the bed level for True first timestep
116+
>>> plot2d(ncfile, itimes=-1, ifrac=0, param='zb', cmap=plt.cm.jet, clim='auto', delta=False, itimeDelta=0) # plot the bed level difference for the first timestep
117117
118118
'''
119119

@@ -153,100 +153,3 @@ def plot2d(ncfile, itimes=0, ifrac=0, param='zb', cmap=plt.cm.jet, clim='auto',
153153
plt.colorbar(pc)
154154

155155
return fig, ax
156-
157-
158-
def plot3d(ncfile, itimes, scalez=1., vangle=90., hangle=0.):
159-
160-
'''Generic function for plotting 2D parameters from AeoLiS netcdf results
161-
162-
Parameters
163-
----------
164-
ncfile : str
165-
filename of the netcdf-file containing the results
166-
itimes : integer or array of integers
167-
index or list of indices describing the timestep-indices in the netcdf-file for plotting
168-
169-
Returns
170-
-------
171-
figs/ axs?
172-
...
173-
174-
Examples
175-
--------
176-
>>> ploted(parse_value('T'))
177-
bool
178-
179-
'''
180-
181-
rgb=255.
182-
sand = [230/rgb,230/rgb,210/rgb]
183-
blue = [0/rgb, 166/rgb, 214/rgb]
184-
sand = [230/rgb,230/rgb,210/rgb]
185-
vegetation = [120/rgb,180/rgb,50/rgb]
186-
white = [255/rgb,255/rgb,255/rgb]
187-
gray = [100/rgb,100/rgb,100/rgb]
188-
189-
190-
if type(itimes) == int:
191-
itimes = [itimes]
192-
193-
for it in itimes:
194-
195-
with netCDF4.Dataset(ncfile, 'r') as ds:
196-
197-
# get spatial dimensions and bed levels
198-
x = ds.variables['x'][:,:]
199-
y = ds.variables['y'][:,:]
200-
z = ds.variables['zb'][it,:,:]
201-
202-
fig = plt.figure()
203-
ax = plt.gca(projection='3d')
204-
205-
x_scale = 1.
206-
y_scale = 1. # np.max(x)/np.max(y)
207-
z_scale = scalez*np.max(z)/np.max(x)
208-
209-
scale=np.diag([x_scale, y_scale, z_scale, 1.0])
210-
scale=scale*(1.0/scale.max())
211-
scale[3,3]=1.0
212-
213-
def short_proj():
214-
return np.dot(Axes3D.get_proj(ax), scale)
215-
216-
ax.get_proj = short_proj
217-
218-
# lay-out of axes
219-
ax.set_ylabel('alongshore distance [m]')
220-
ax.set_xlabel('cross-shore distance [m]')
221-
ax.axes.get_xaxis().set_ticks([])
222-
ax.axes.get_yaxis().set_ticks([])
223-
ax.axes.get_xaxis().set_visible(False)
224-
ax.axes.get_yaxis().set_visible(False)
225-
226-
# perspective
227-
ax.view_init(vangle, hangle)
228-
ax.set_proj_type(proj_type='persp')
229-
230-
# make the panes transparent
231-
for axis in [ax.xaxis, ax.yaxis, ax.zaxis]:
232-
axis.set_pane_color((0/rgb,166/rgb,214/rgb,0.0))
233-
axis._axinfo["grid"]['color'] = (1,1,1,0)
234-
axis.line.set_color((1.0, 1.0, 1.0, 0.0))
235-
236-
ax.set_axis_off()
237-
pos_z = z.copy()
238-
neg_z = z.copy()
239-
# neg_z[(neg_z > 0.2)] = np.nan
240-
pos_z[(pos_z < 0.2)] = np.nan
241-
242-
# ax.plot_surface(y, x, neg_z[:,:], color=white, linewidth=0, antialiased=False, shade=False, alpha=1.0, rstride=1, cstride=1)
243-
ax.plot_surface(y, x, pos_z[:,:], color=sand, linewidth=0, antialiased=False, shade=True, alpha=1.0, rstride=1, cstride=1)
244-
245-
# plt.savefig(r'c:\Users\weste_bt\AeoLiS\Examples\Parabolic figures\plottoptime' + str('{:03}'.format(time_index)) + '.png', dpi=200)
246-
# plt.show()
247-
# plt.close(fig)
248-
249-
return fig, ax
250-
251-
252-

tools/postprocessing/plotting_run.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from plotting_functions import plot1d, plot2d
2+
import matplotlib.pyplot as plt
3+
import os
4+
5+
# This script is used to plot the results of the AeoLiS model
6+
# The functions plot1d and plot2d are defined in the plotting_functions.py file
7+
# Using this script as a template, you can easily start plotting some basic results generated by the AeoLiS model
8+
9+
# Get the path to the netcdf-file containing the results of the AeoLiS model run
10+
# This is relative to the location of the current script
11+
ncfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'aeolis_output.nc')
12+
13+
14+
############################################################################################################
15+
# The function plot2d is used to plot 2D results of the AeoLiS model
16+
17+
# - ncfile: path to the netcdf-file containing the results of the AeoLiS model run
18+
# - itimes: index of the time step to plot (default: 0)
19+
# - ifrac: grainfraction to plot (default: 0)
20+
# - param: parameter to plot (default: 'zb')
21+
# - cmap: colormap to use (default: plt.cm.jet)
22+
# - clim: color limits [min, max], or 'auto' will automatically determine the color limits (default: 'auto')
23+
# - delta: plot the difference between the current and previous time step (default: False)
24+
# - itimeDelta: time step difference (default: -1), only used if delta=True
25+
26+
# Plot the bed level at the first time step
27+
fig, ax = plot2d(ncfile)
28+
ax.set_title('Bed level at the first time step')
29+
30+
# Plot the bed level at the last time step
31+
fig, ax = plot2d(ncfile, param='zb', itimes=-1)
32+
ax.set_title('Bed level at the last time step')
33+
34+
# Plot the bed level at the first time step with a different colormap and color limits
35+
fig, ax = plot2d(ncfile, param='zb', itimes=0, delta=True, itimeDelta=-1, cmap=plt.cm.RdBu, clim=[-1.5, 1.5])
36+
ax.set_title('Bed level change between the first and last time step with custom colormap and color limits')
37+
38+
# Plot the wind velocity at the last timestep using the viridis colormap
39+
fig, ax = plot2d(ncfile, param='uw', itimes=-1, cmap=plt.cm.viridis)
40+
ax.set_title('Wind velocity at the last time step')
41+
42+
# Plot the velocity threshold at the last timestep only for the 1st fraction
43+
fig, ax = plot2d(ncfile, param='uth', itimes=-1, ifrac=0, clim=[0, 0.4])
44+
ax.set_title('Velocity threshold at the last time step for the 1st fraction')
45+
46+
47+
############################################################################################################
48+
# The function plot1d is used to plot 1D results of the AeoLiS model of a single transect
49+
# Timesteps, transects and parameters can be given as a list to plot multiple results at once
50+
51+
# - ncfile: path to the netcdf-file containing the results of the AeoLiS model run
52+
# - itransects: index of the transect to plot (default: 0)
53+
# - itimes: index of the time step to plot (default: 0)
54+
# - ifrac: grainfraction to plot (default: 0)
55+
# - params: list of parameters to plot (default: ['zb'])
56+
57+
# Plot the bed level and water level at the first transect and last timestep
58+
fig, ax = plot1d(ncfile, itransects=0, itimes=-1, ifrac=0, params=['zb', 'zs'])
59+
ax.set_title('Bed level and water level at the first transect and last timestep')
60+
61+
# Plot the bed level at the first, middle and last timestep for the first transect
62+
fig, ax = plot1d(ncfile, itransects=0, itimes=[0, 4, -1], ifrac=0, params='zb')
63+
ax.set_title('Bed level at the first, middle and last timestep for the first transect')
64+
65+
# Plot the bed level for the first and last transect at the last timestep
66+
fig, ax = plot1d(ncfile, itransects=[0, -1], itimes=-1, ifrac=0, params='zb')
67+
ax.set_title('Bed level for the first and last transect at the last timestep')
68+
69+
plt.show()
File renamed without changes.
File renamed without changes.

tools/visualization/run_plots.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)