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 plotcouples 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 the areaSeries, we create the a chart and open a the corresponding view for the chart.

Code Block
languagepy
titleCreate chart and open view
chart = CreateChart([areaSeries])
chart.Name = "Waterlevel at observation point"

OpenView(chart)

 

 

The chart is still a bit basic and missing some information, so we are going to edit the charthas 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 = 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"

 

Now we have the chart we want The code above will produce the chart to be changed to:

 

Now, we also want to export the timeseries so we can use it outside Deltashell. For this, we have two options : export the chart as image or export the timeseries to a .csv (Comma separated values) fileThe 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("D:\\waterLevelAtObservationPoint.jpg", 1000,1000)

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

 

We can also Additionally, we can create a map for a certain quantity (waterleveloutput value (e.g. water level) at a certain time. For this, we need to import the mapfunctions. Using the map functions, we create a map, waterlevel layer 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 . Then, we add the layers to the map.Layers and open the viewas background. Both layers are then added to a map object just created, and, finally, the corresponding view can be opened. To set the time selection of that will be rendered in the view to a certain date , we use "the function SetViewTimeSelection".

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

map = Map()
outputLayer = mf.CreateLayerForObject(fmModel.OutputWaterLevel)
satLayer = CreateSatelliteImageLayer()
map.Layers.AddRange([outputLayer, satLayer])

view = OpenView(map)
SetViewTimeSelection(view, datetime(2014,1,4, 12,0,0))

 

We should get This will give us a map showing the water level at our the selected time-step like the image below:.

 

We can export this map as an image by calling the "ExportImage" function and using the (image property of the map) with the ExportImage function.

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

 

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

scrollbar