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 reading the waterlevels at the cell centers from a CSV (Comma separated values) file into the initialWaterLevels list.
Code Block |
---|
language | py |
---|
title | Set intial confitionsImport water level data |
---|
|
# add initial conditions
import csv
initialWaterLevelsmeasuredWaterLevels = []
with open(r"D:\\Workshop\data\Data\\initialmeasuredWaterLevelFM.csv") as csvfile:
lines = csv.reader(csvfile, delimiter=',')
headers = lines.next()
for line in lines:
initialWaterLevelsmeasuredWaterLevels.append(map(float(, line[0]))
|
Once loaded, we add the sample points to the initial water level coverage of the model. Then, we add the list of values to the model :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 values to model |
---|
|
fmModel.InitialWaterLevels.SetValues(initialWaterLevels) |
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).
Code Block |
---|
language | py |
---|
title | Set 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())) |