You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

The fist thing we have to do is to declare where the model is located. More data that we will need later on is also located in the same folder. Therefore we will keep the root of the data folder and the one in which the SOBEK 2.1x flow model can be found as separate variables.

Declare 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.

Import Sobek2Functions library
from Libraries.Sobek2Functions import *

 The mask * (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.

At this point, it is important to make an observation. It is a good practice to place line of code to import libraries at the top of your script in a separate region. This will help you keep your code tidy and easier to update and maintain. Therefore, place the line above completel at the top of your script, select it and then create a region for it (pressing CTRL+R). You can call it Import libraries.

The other lines of code can be integrated analogously is a different region (for example one called Import model). The rest of the main code in this section can also be placed in this same region  Import model. The code corresponding to imports would then go to the first region Import libraries.

Let's now continue with the script. The function called ImportSobek2Model will import the existing 2.1x SOBEK flow model.

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

When you run this line, the model will be imported and added to the variable hydroModel. However, we cannot see the model yet because it has not been added so far to the project. The function AddToProject that we need can be found inside another library called StandardFunctions. Import all functions in that library and then add the model to the current project.

Add hydromodel to project
# Import libraries region
from Libraries.StandardFunctions import *
 
# Current scripting region
AddToProject(hydroModel)

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

Finally, we need to do rename a grid point location currently called "3". Later on this tutorial, we will import data measured at that location. In order to easily identify the location from now on, we will give it the name "Gauging Station".

Rename gridpoint location "3" to "Gauging Station"
dataPoint = GetComputationGridLocationByName(flowModel, "3")
dataPoint.Name = "Gauging Station"

This is the end of this section. For the next one, you can create a new region.

Continue with Run the flow model

 

 

 

  • No labels