measuredWaterLevelFM.csv
For the initial conditions of water level, we will use some measurements at the start time of simulation. Since the information is only available at a few locations, we will interpolate those values to the rest of points within the enclosing polygon. Finally, we will assign a default value to the locations which have not been interpolated.
To begin with, we will import the measured data contained in the file measuredWaterLevelFM.csv, and will store that data in the list measuredWaterLevelsWe start by creating a list of coordinates using the cell centers (the initial waterlevel values are defined per cell).
Code Block |
---|
language | py |
---|
title | Set intial confitions | Import water level data |
---|
|
# add initial conditions
import csv
measuredWaterLevelscoordinates = [[cell.Center.X, cell.Center.Y] for cell in fmModel.Grid.Cells] |
]
with open(r"D:\Workshop\data\measuredWaterLevelFM.csv") as csvfile:
lines = csv.reader(csvfile, delimiter=',')
headers = lines.next()
for line in lines:
measuredWaterLevels.append(map(float, line))
|
Once loaded, we add the sample points to the initial water level coverage of the model. Then, we will interpolate the just added set of samples. In order to carry out these spatial operations, we first need to import the corresponding library.
Code Block |
---|
language | py |
---|
title | Add sample points to initital water level |
---|
|
from Libraries.SpatialOperations import *
samplePoints = AddSamplePoints(fmModel, fmModel.InitialWaterLevel, measuredWaterLevels, subsetName = "subset water level measurements", sampleOperationName = "measurements 1-Jan-2012")
InterpolateSamplePoints(samplePoints[0], samplePoints[1], interpName ="Interpolated water level measurements") |
Finally, we set the initial water level to 0.15 m for all the points that haven't been assigned any value after the interpolation. We do this for the entire domain (Envelope of the domain)Then we get the waterlevel for these coordinates at the start time and set them as the initial waterlevel of our model.
Code Block |
---|
language | py |
---|
title | Set intial confitions |
---|
|
initialWaterLevels = wps.GetTidalPredictForTime(startTime, coordinates, EPSGCode)
fmModel.InitialWaterLevels.SetValues(initialWaterLevels) |
default water level value to non assigned locations |
|
AddSpatialOperationByPolygon("SetValue", fmModel, fmModel.InitialWaterLevel, "Envelope", values = [0.15], pointwiseType = "OverwriteWhereMissing") |
The initial conditions have now been fully specified. Let's now proceed with the model parameters.
To limit the calculation time, we change the maximum and initial delta t (time) to 1 hour using the SetModelProperty" function.
Code Block |
---|
language | py |
---|
title | Set dtMax and dtInitial |
---|
|
# set model max and initial timestep size
timeStep = timedelta(hours=1)
SetModelProperty(fmModel, KnownProperties.DtMax, str(timeStep.total_seconds()))
SetModelProperty(fmModel, KnownProperties.DtInit, str(timeStep.total_seconds())) |