Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:building_a_simple_model [2016/12/22 19:36]
isabella
tutorial:building_a_simple_model [2017/01/25 17:37] (current)
francisco [What will you learn?]
Line 17: Line 17:
 Thus a model in Dinamica EGO is represented by a sequence of functors, whose execution takes place from left to right. A simple model consists of a functor that loads the data, for example, a map, another functor that performs some calculation as well as one that writes the result into a file. Note that the functors are connected to each other through arrows. In order to do so, they must exchange compatible data via their outputs and inputs. Dinamica EGO input parameters and data, as well as the outputs from a functor, are called ports. Hence functors are connected via compatible input and output ports. Let’s start designing your first model in Dinamica EGO.\\ Thus a model in Dinamica EGO is represented by a sequence of functors, whose execution takes place from left to right. A simple model consists of a functor that loads the data, for example, a map, another functor that performs some calculation as well as one that writes the result into a file. Note that the functors are connected to each other through arrows. In order to do so, they must exchange compatible data via their outputs and inputs. Dinamica EGO input parameters and data, as well as the outputs from a functor, are called ports. Hence functors are connected via compatible input and output ports. Let’s start designing your first model in Dinamica EGO.\\
  
-From the library window grab and place on the sketch the //[[:Load Map]]// and //[[:Save Map]]// functors, which are located in the Input/​Output tab.  Now grab the container //​[[:​Calculate Map]]// from the Map Algebra tab. Remember that a container is a special type of functor that can envelope supplementary functors or even a sequence of functors. The containers differ from a functor by its title bar.+From the library window grab and place on the sketch the //[[:Load Map]]// and //[[:Save Map]]// functors, which are located in the Input/​Output tab.  Now grab the container //​[[:​Calculate Map]]// from the Map Algebra tab. container is a special type of functor that can envelope supplementary functors or even a sequence of functors. The containers differ from a functor by its action ​bar.
  
-<note tip>​**TIP**:​ By clicking on the left top of the container ​icon, you can close and open it.</​note> ​+<note tip>​**TIP**:​ By clicking on the left top of the container ​action bar, you can close and open it.</​note> ​
  
 You should have something like this:{{ :​tutorial:​simple_model_1.5.jpg |}}\\ You should have something like this:{{ :​tutorial:​simple_model_1.5.jpg |}}\\
 \\ \\
-Now you need to connect the functors to establish a model. First, let’s understand what a //​[[:​Calculate Map]]// does. This container is a calculator used for map algebra to combine and process maps, tables and constants. As a container, it does not function by itself. There is a need to add supplementary functors to it. In this case, each map processed by this container will be represented by the functor //[[:Number Map]]// ​available ​in the Map Algebra Supplementary tabGrab //[[:Number Map]]// ​and place it inside the container //​[[:​Calculate Map]]//. The container will resize to accommodate the //[[:Number Map]]//.\\+Now you need to connect the functors to establish a model. First, let’s understand what a //​[[:​Calculate Map]]// does. This container is a calculator used for map algebra to combine and process maps, tables and constants. As a container, it does not function by itself. There is a need to add supplementary functors to it. In this case, each map processed by this container will be represented by the functor //[[:Number Map]]//. Click in the hook tool {{:​tutorial:​hook.jpg|}} to create a hook functor with //[[:Number Map]]// inside the container //​[[:​Calculate Map]]//. The container will resize to accommodate the //[[:Number Map]]//.\\
 \\ \\
 \\ \\
Line 33: Line 33:
 \\ \\
 {{:​tutorial:​simple_model_3.0.1.jpg |}}\\ {{:​tutorial:​simple_model_3.0.1.jpg |}}\\
 +
 +Clicking on the arrow with the Edit Functor Ports tool allows us to visualize the links between a pair of functors.\\ ​                                                                                  
 +
 +Now that the functors are linked, you can rearrange the model by clicking on the execute layout. Note that the model will be organized\\ from left to right or left to bottom according to its execution sequence.\\
 +\\
 +\\
 +\\
 +\\
 +\\
 +\\
 +\\
 \\ \\
 \\ \\
 \\ \\
 \\ \\
- 
-Clicking on the arrow with the Edit Functor Ports tool allows us to visualize the links between a pair of functors.\\ ​                                                                                   
- 
-Now that the functors are linked, you can rearrange the model by\\ clicking on the layout tool. Note that the model will be organized\\ from left to right or left to bottom according to its execution\\ sequence.\\ 
  
 In the next step, open the //​[[:​Calculate Map]]// container by grabbing the Edit Functor and clicking on it. Note that map #1 is represented by **i1**. The //​[[:​Calculate Map]]// enables the formulation of various algebraic and logic equations containing maps, tables and constants.\\ In the next step, open the //​[[:​Calculate Map]]// container by grabbing the Edit Functor and clicking on it. Note that map #1 is represented by **i1**. The //​[[:​Calculate Map]]// enables the formulation of various algebraic and logic equations containing maps, tables and constants.\\
-{{:​tutorial:​simple_model_5.1.jpg |}}\\+\\ 
 +\\ 
 + 
 +{{:​tutorial:​simple_model_5.1.jpg?​nolink ​|}}
 \\ \\
 \\ \\
Line 58: Line 68:
 \\ \\
 \\ \\
 +Now that you have learned the vast possibilities of this container, let’s write a simple equation: ​
 +\\ **if i1 = 9 then 1 else null** \\
 \\ \\
 +This means: Find the map class equal to 9, and set all others to null.\\ ​
 +Set the **Cell Type** to "​Unsigned 8 Bit Integer"​ and the **Null Value** to “Use default value”. Now you can close this container and open a map file to use as input for this model.
 \\ \\
 \\ \\
Line 65: Line 79:
 \\ \\
 \\ \\
-Now that you have learned the vast possibilities of this container, let’s write a simple equation: ​ 
-\\ **if i1 = 9 then 1 else null** \\ 
 \\ \\
-This means: Find the map class equal to 9, and set all others to null.\\ ​ 
-Set the **Cell Type** to "​Unsigned 8 Bit Integer"​ and the **Null Value** to “Use default value”. Now you can close this container and open a map file to use as input for this model. 
 \\ \\
 \\ \\
-Open the //[[:Load Map]]// functor and load the file ''​amazon_states.tif''​ from folder lesson1 ​(do not write the quotation marks). You do not need to worry about the other options, they are not needed for now.  +\\ 
-{{ :​tutorial:​simple_model_7.jpg |}}+\\ 
 +\\ 
 +\\ 
 +Open the //[[:Load Map]]// functor and load the file ''​amazon_states.tif''​ from folder lesson1. You do not need to worry about the other options, they are not needed for now.  
 + 
 +{{ :​tutorial:​simple_model_7.jpg?​nolink ​|}}
  
 <note important>​Although you won’t need it in this lesson, you might set the null value by first turning on the **Null Value** flag on the //[[:Load Map]]// and then setting its value to "​0"​.</​note>​ <note important>​Although you won’t need it in this lesson, you might set the null value by first turning on the **Null Value** flag on the //[[:Load Map]]// and then setting its value to "​0"​.</​note>​
Line 84: Line 99:
  
 In the Advanced tab there is an option to set the file name **Suffix Digits**. Although the default is 2, this parameter will be ignored since there is only one iteration.\\ **Use Compression** is only applicable for geotiff and img format. In the Advanced tab there is an option to set the file name **Suffix Digits**. Although the default is 2, this parameter will be ignored since there is only one iteration.\\ **Use Compression** is only applicable for geotiff and img format.
-The input map is a categorical map; its values do not represent quantities, but are identifiers to map classes, thus representing categorical data as follows:+The input map is a categorical map; its values do not represent quantities, but they are identifiers to map classes, thus representing categorical data as follows:
  
 ^ Key  ^ State  ^              ​ ^ Key  ^ State  ^              ​
Line 97: Line 112:
 | 9  | Mato Grosso ​ | | 9  | Mato Grosso ​ |
  
-Close the //​[[:​Calculate Map]]// container by clicking on its bar. The model should look like this:\\+Minimize ​the //​[[:​Calculate Map]]// container by clicking on its bar. The model should look like this:\\
 \\ \\
 \\ \\
Line 103: Line 118:
 \\ \\
 \\ \\
-Save the model as ''​my_model''​ in lesson1 folder, click on check model script integrity to check out whether the model is ready to run, and if it is, run the model by clicking on the run model script button on the top toolbar and open the result on the Map Viewer. The output map depicts only the Mato Grosso state.{{ :​tutorial:​mato_grosso_state.1.jpg |}}+Save the model as ''​my_model''​ in lesson1 folder, run the model by clicking on the run model script button on the top toolbar and open the result on the Map Viewer. The output map depicts only the Mato Grosso state.{{ :​tutorial:​mato_grosso_state.1.jpg |}}
  
 __Congratulations,​ you have successfully completed this lesson!__ Now let’s move to the next ones! __Congratulations,​ you have successfully completed this lesson!__ Now let’s move to the next ones!
  
 [[tutorial:​incorporating_iterations_into_a_model|Next Lesson]] [[tutorial:​incorporating_iterations_into_a_model|Next Lesson]]