We have a hydrodynamic flow model, which has been built with Sobek 2.12, of the fluvial system around Zwolle. The model has been completely set up, except for the Boundary condition at one of the tributaries, at Boxbergen, and the roughness of both main tributaries. We also have a time series of water level measurements at the entrance of the channels which flow across the center of Zwolle. Using this information, build a script to automatically calibrate the model.
The workflow of this tutorial has been divided into the following steps:
Children Display |
---|
Opdracht SOBEK DSD 2014.pdfOpdracht SOBEK DSD 2014.pdf
\\
{code:title=Sobek scripting example|linenumbers=true|language=python}
#region Import libs
# python libs
from SobekWorkshopHelperFunctions import *
# .Net libs
from System import DateTime, Double
from System.Collections.Generic import List
# DeltaShell libs
from SharpMap import Map
from DelftTools.Shell.Core.Workflow import ActivityRunner
from DeltaShell.Plugins.SharpMapGis.ImportExport import CsvFunctionExporter
from DeltaShell.Plugins.DelftModels.WaterFlowModel.DataObjects import WaterFlowModel1DBoundaryNodeDataType
#endregion
rootPath = "D:\\scripting\\"
# Import of csv (station data)
CsvPath = rootPath + "waterflow_at_6_Measured.csv"
measuredTimeSeries = ImportCsvTimeSeries(CsvPath, "Time", "Value" ,"dd-M-yyyy H:mm:ss")
measuredTimeSeries.Components[0].Name = "Measured time series"
ModelPath = rootPath + "SW_max.lit\\2\\"
# Read hisfile waterlevel time series
hisTimeSeries = GetHisFileTimeSeriesForLocation(ModelPath + "calcpnt.his", "6")
# Import SOBEK 2.13 model (Maas)
model = ImportSobek2Model(ModelPath + "NETWORK.TP",False,True,False,False)
waterFlowModel = GetItemByName(model.Models, "water flow 1d")
waterFlowModel.Network.CoordinateSystem = Map.CoordinateSystemFactory.CreateFromEPSG(28992) #RD new
# Run model
ActivityRunner.RunActivity(waterFlowModel)
# Get timeseries at calculation point P_1128
calculationPoint = GetItemByName(waterFlowModel.NetworkDiscretization.Locations.Values, "6")
timeSeriesBase = waterFlowModel.OutputWaterLevel.GetTimeSeries(calculationPoint)
timeSeriesBase.Components[0].Name = "Base time series"
# Create time series list containing all timeseries to compare
timeSeriesToCompare = List[TimeSeries]()
timeSeriesToCompare.Add(measuredTimeSeries)
timeSeriesToCompare.Add(hisTimeSeries)
timeSeriesToCompare.Add(timeSeriesBase)
# Run loop with changing boundary data
boundary = GetItemByName(waterFlowModel.BoundaryConditions, "Hancate - Q :0 m^3/s")
boundary.DataType = WaterFlowModel1DBoundaryNodeDataType.FlowConstant
for i in range(1,4): # 1, 2, 3
boundary.Flow = 30.0 * i
ActivityRunner.RunActivity(waterFlowModel)
timeSeries = waterFlowModel.OutputWaterLevel.GetTimeSeries(calculationPoint)
timeSeries.Components[0].Name = "Case " + str(i) + " : N_001 flow " + str(boundary.Flow)
timeSeriesToCompare.Add(timeSeries)
# show in chart
Gui.DocumentViewsResolver.OpenViewForData(timeSeriesToCompare)
# export time series to csv
exporter = CsvFunctionExporter()
index = 0
for ts in timeSeriesToCompare:
exporter.Export(ts, rootPath + "waterflow_at_6_" + str(index) + ".csv")
index += 1
{code}
scrollbar