Versions Compared

Key

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

The fist thing we have to do is to declare where the model is located :

Code Block
languagepy
titleDeclare paths
rootPath = r"D:\Workshop\data"
model213Path = rootPath + r"\SW_max.lit\2"

 

Next, we want to import the model using the Delta Shell SOBEK 2 importer. This method can be found in a library called Sobek2Functions in the Libraries folder of the toolbox. You can gain access to all the methods included in that library by adding (and then running) the following code.

Code Block
languagepy
titleImport Sobek2Functions library
from Libraries.Sobek2Functions import *

 The mask * written above will  (asterisk) written after the keyword import will import and make all the functions contained in the Sobek2Functions library available for use. All of them will now also appear in the code completion dialog ( when you hit CTRL + SPACE).

 

The function called "ImportSobek2Model" which we will use to ImportSobek2Model will import the existing 2.1x SOBEK flow model.

Code Block
languagepy
titleImport Sobek 2.13 model
hydroModel = ImportSobek2Model(model213Path + r"\NETWORK.TP",useRR=False, useFLOW=True, useRTC=False, useWAQ=False)

After running When you run this line, the model is will be imported and added to the variable "hydroModel". However, but we can not cannot see the model yet.For this we need to import yet because it has not been added to the project yet. The function AddToProject that we need can be found inside another library called "StandardFunctions" because this library has a function for adding an item to the StandardFunctions. Import all functions in that library and then add the model to the current project.

Code Block
languagepy
titleAdd hydromodel to project
from Libraries.StandardFunctions import *
AddToProject(hydroModel)

Now we should have the imported model in our project (see the project toolwindow):

The last thing we need to do is to rename a gridpoint location called "3" to "Gauging Station". This is because we use this later on in the tutorial (we will have measurements for this point)

Code Block
languagepy
titleRename gridpoint location "3" to "Gauging Station"
dataPoint = GetComputationGridLocationByName(flowModel, "3")
dataPoint.Name = "Gauging Station"
Panel

Continue with Run the flow model