Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

scrollbar

 

Now that Once the model has been run, we can access the generated output. We start by getting the waterlevel timeseries water level time series for the observation point, by using the GetFlowFlexibleMeshTimeSeries function and passing 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) to it.

Code Block
languagepy
titleGet timeseries for observation point
waterlevelSeries = GetFlowFlexibleMeshTimeSeries(fmModel, "Water level (waterlevel)", observationPoint)

 

Now we have This will return a list of [datetime, value] that we can plotof couples of values for time and variable which can plotted. To create a chart, we start by import the ChartFunctions library and creating creat an area series for our timeseriestime series, stored in the variable areaSeries.

Code Block
languagepy
titleCreate area series
from Libraries.ChartFunctions import *

areaSeries = CreateAreaSeries(waterlevelSeries)

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

Code Block
languagepy
titleCreate 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.

Code Block
titleImprove chart layout
areaSeries.Color = Color.CadetBlue
areaSeries.Title = "Waterlevel at observation point"observationPoint.Name
areaSeries.LineVisible = False
areaSeries.PointerVisible = False

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

chart.LeftAxis.AutomaticTitle = False"Waterlevel (m)"
chart.LeftAxis.MinimumAutomatic = -0.05False
chart.LeftAxis.MaximumMinimum = 0.75-4
chart.LeftAxis.TitleMaximum = "Waterlevel (m)"5

chart.BottomAxis.Title = "Time"

 

Image Removed

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

Image Added

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). 

Code Block
languagepy
titleExport data
chart.ExportAsImage(r"D:\Workshop\testImagewaterLevelAtObservationPoint.jpg", 1000,1000)

ExportListToCsvFile(r"D:\Workshop\testwaterLevelAtObservationPoint.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.

Code Block
titleCreate map for output
from Libraries.MapFunctions import *

map = Map()

outputLayer = mf.CreateLayerForObject(waterlevelOutputfmModel.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.

Image Added

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

Code Block
languagepy
titleExport map image
ExportImage(map.Image, r"D:\Workshop\tempFMOutputMap.png", ImageType.PNG)

  

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

scrollbar