Versions Compared

Key

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

scrollbar

When adding boundary conditions to the model, you must first declare the type of the boundary you want to add. This is done as follows for a waterlevel timeseries:

Code Block
languagepy
titleCreare timeseries boundaries
flowLeftBoundaryCondition = AddFlowBoundaryCondition(fmModel, leftBoundary.Name, FlowBoundaryQuantityType.WaterLevel, BoundaryConditionDataType.TimeSeries)
flowTopBoundaryCondition = AddFlowBoundaryCondition(fmModel, topBoundary.Name, FlowBoundaryQuantityType.WaterLevel, BoundaryConditionDataType.TimeSeries)
flowBottomBoundaryCondition = AddFlowBoundaryCondition(fmModel, bottomBoundary.Name, FlowBoundaryQuantityType.WaterLevel, BoundaryConditionDataType.TimeSeries)
flowRightBoundaryCondition = AddFlowBoundaryCondition(fmModel, rightBoundary.Name, FlowBoundaryQuantityType.WaterLevel, BoundaryConditionDataType.TimeSeries)

 

This can now been seen on the map on top of the boundary :

 

We continue by declaring start and end time of our timeseries time series (and model later on) and a list of [boundary, boundary condition] pairs.

Code Block
titleCreate timeseries
from datetime import datetime, time, timedelta

startTime = datetime(2014,1,1, 12,0,0)
endTime = datetime(2014,1,12, 12,0,0)

boundaryConditionSets = [[leftBoundary,flowLeftBoundaryCondition],
                        [topBoundary,flowTopBoundaryCondition],
                        [bottomBoundary, flowBottomBoundaryCondition],
                        [rightBoundary, flowRightBoundaryCondition]]

 

Now, we want to use a WPS server to get the timeseries for the support points of the boundaries. We start by importing the WPS library (this may take some time and ends with a warning (this can be ignored)).

Code Block
languagepy
titleImport WPS library
import Libraries.Wps as wps

 

We go through the list and call "GetTidalPredictForLineString" for every boundary from the wps library. This will give us a timeseries time series for every support point on the boundary with the provided start time, stop time and frequency. This may take some time depending on the number of support points, length of the timeseries time series and the speed of your internet connection.

We continue by adding the these timeseries time series to the model by using the "AddTimeSeriesToSupportPoint" call. This will add the timeseries time series to the provided boundary condition at the support point index.

Code Block
languagepy
titleAdd WPS boundary conditions
for boundaryConditionSet in boundaryConditionSets:
    # get timeseries for each support point using wps service
    timeSeries = wps.GetTidalPredictForLineString(boundaryConditionSet[0].Geometry, EPSGCode, startTime, endTime, wps.Frequency.Hourly)

    # add resultTimeSeries to support points
    for supportPointIndex in range(len(timeSeries)):
        resultTimeSeries = timeSeries[supportPointIndex]
        AddTimeSeriesToSupportPoint(fmModel, boundaryConditionSet[1], supportPointIndex, resultTimeSeries)

 

The result can be viewed double clicking the boundary on the map and looking at the boundary conditions editor :

Here, you can see that for the left boundary there is a waterlevel timeseries water level time series declared on all the support points.

 

scrollbar