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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
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 | ||
---|---|---|
| ||
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" |
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 | ||||
---|---|---|---|---|
| ||||
chart.ExportAsImage(r"D:\Workshop\testImagewaterLevelAtObservationPoint.jpg", 1000,1000) ExportListToCsvFile(r"D:\Workshop\testwaterLevelAtObservationPoint.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 | ||
---|---|---|
| ||
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.
Image Added
We can export this map as image by calling the "ExportImage" function and using the an image (image property of the map) with the ExportImage function.
Code Block | ||||
---|---|---|---|---|
| ||||
ExportImage(map.Image, r"D:\Workshop\tempFMOutputMap.png", ImageType.PNG) |
This is the end of the Delft3D Flexible Mesh scripting tutorial.
scrollbar |
---|