Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
HTML |
---|
<script type="text/javascript">
AJS.toInit(function() {
// unbind directly-embedded images
AJS.$("img.confluence-embedded-image").unbind("click.fb");
});
</script> |
The first 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.
Code Block | ||||
---|---|---|---|---|
| ||||
rootPath = r"D:\Workshop\data" model213Path = rootPath + r"\SW_max.lit\2" |
Then Next, we want to import the model using the Deltashell Sobek Delta Shell SOBEK 2 importer. For this we will need to use This method can be found in a library called "Sobek2Functions " in the "Libraries" folder folder of the toolbox. This is done by adding the following line (and running it)You can gain access to all the methods included in that library by adding (and then running) the following code.
Code Block | ||||
---|---|---|---|---|
| ||||
from Libraries.Sobek2Functions import * |
This will The mask * (asterisk) written after the keyword import will import and make all the functions (because of the *) contained in the Sobek2Functions library available for use. All these functions of them will now also appear in the code completion dialog (when you use ctrl + space).
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 completely 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 Image Added will import the existing 2.1x SOBEK flow In this library we have a function called "ImportSobek2Model" which we will use to import the existing model.
Code Block | ||||
---|---|---|---|---|
| ||||
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 because it has not been added so far to the project. The function AddToProject Image Added 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 | ||||
---|---|---|---|---|
| ||||
# 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 toolwindowtool window):
Within the integrated model just added to the project, we will be using the flow model. We can assign that object to a new variable.
Code Block | ||||
---|---|---|---|---|
| ||||
flowModel = GetModelByName("Flow1D") |
Finally, we will rename a grid point location currently called "3". Later on in 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".
Code Block | ||||
---|---|---|---|---|
| ||||
from Libraries.SobekWaterFlowFunctions import *
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.
Note: The icon Image Added indicates functions that you might find interesting to see how they have been built. You can do this by opening the corresponding library (another normal script python file on its own) in the toolbox and checking the code which defines the function or method you are interested in.
Panel |
---|