Once the model has been run, we can access the generated output. We start by getting the water level time series for the observation point, by using the function GetFlowFlexibleMeshTimeSeries, which takes as parameters the model, the name of the output time series to obtain, and the feature at which the output will be retrieved (in the case of this tutorial, the observation point).

Get timeseries for observation point
waterlevelSeries = GetFlowFlexibleMeshTimeSeries(fmModel, "Water level (waterlevel)", observationPoint)

This will return a list of couples of values for time and variable which can plotted. To create a chart, we import the ChartFunctions library and creat an area series for our time series, stored in the variable areaSeries.

Create area series
from Libraries.ChartFunctions import *

areaSeries = CreateAreaSeries(waterlevelSeries)

With areaSeries, we create a chart and open the corresponding view.

Create chart and open view
chart = CreateChart([areaSeries])
chart.Name = "Waterlevel at observation point"

OpenView(chart)

 

The chart has a default layout, which means it has a very basic style and some important information may not be visible. However, the contents and layout can be highly customized.

Improve chart layout
areaSeries.Color = Color.CadetBlue
areaSeries.Title = observationPoint.Name
areaSeries.LineVisible = False
areaSeries.PointerVisible = False

chart.Legend.Visible = True
chart.Legend.Alignment = LegendAlignment.Bottom

chart.LeftAxis.Title = "Waterlevel (m)"
chart.LeftAxis.Automatic = False
chart.LeftAxis.Minimum = -4
chart.LeftAxis.Maximum = 5

chart.BottomAxis.Title = "Time"

The code above will produce the chart to be changed to:

The results can be exported export so that they can be used outside Delta Shell. There are two ways to implement this. For the results a one or more locations in the model, we can export the previously created chart as an image file. We can also export the output time series to a comma separated values file (*.csv).

Export data
chart.ExportAsImage(r"D:\Workshop\waterLevelAtObservationPoint.jpg", 1000,1000)

ExportListToCsvFile(r"D:\Workshop\waterLevelAtObservationPoint.csv", waterlevelSeries)

Additionally, we can create a map for a certain output value (e.g. water level) at a certain time. This functionality can be imported from the MapFunctions library. We can then create a map containing an output water level layer, and a satellite image layer as background. Both layers are then added to a map object just created, and, finally, the corresponding view can be opened. To set the time that will be rendered in the view, we use the function SetViewTimeSelection.

Create map for output
from Libraries.MapFunctions import *

map = Map()
outputLayer = mf.CreateLayerForObject(fmModel.OutputWaterLevel)
satLayer = CreateSatelliteImageLayer()
map.Layers.AddRange([outputLayer, satLayer])
map.Layers[0].Visible = True
view = OpenView(map)
SetViewTimeSelection(view, datetime(2014,1,4, 12,0,0))
ZoomToLayer(map.Layers[0])

This will give us a map showing the water level at the selected time-step.

We can export this map as an image (image property of the map) with the ExportImage function.

Export map image
ExportImage(map.Image, r"D:\Workshop\FMOutputMap.png", ImageType.PNG)

 

This is the end of the Delft3D Flexible Mesh scripting tutorial.

 

  • No labels