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 [2013/07/26 18:19]
juliana
tutorial:building_a_simple_model [2017/01/25 17:37] (current)
francisco [What will you learn?]
Line 8: Line 8:
   * Functors and ports   * Functors and ports
   * Writing algebraic and logical expressions   * Writing algebraic and logical expressions
-  * Functors: \\  - [[:load_map| ​Load Map]] \\ - [[:save_map| ​Save Map]] \\ - [[:calculate_map| ​Calculate Map]] \\ - [[:number_map| ​Number Map]]+  * Functors: \\  - //[[:Load Map]]// \\ - //[[:Save Map]]// \\ - //[[:​Calculate Map]]// \\ - //[[:Number Map]]//
  
  
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|Load Map]]  and [[:save_map|Save Map]] functors, which are located in the Input/​Output tab.  Now grab the container [[:calculate_map|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|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|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 29: Line 29:
 \\ \\
 \\ \\
-Click on the //Number Map// with the Functor Editor tool and enter “1” (do not write the quotation marks). This is a number identifier for a map and will be represented within the equation box as i1 (input 1). You can enter other maps by adding more //Number Map// functors, but each one must have a unique number identifier. Now you can connect the functor //Load Map// to the //Number Map// and the container //Calculate Map// to //Save Map//. Use the connect tool (the arrow icon) to establish the connections. Observe that the connection is set automatically because there is only one option for compatible ports in the respective functors and container.\\+Click on the //[[:Number Map]]// with the Functor Editor tool and enter “1” (do not write the quotation marks). This is a number identifier for a map and will be represented within the equation box as i1 (input 1). You can enter other maps by adding more //[[:Number Map]]// functors, but each one must have a unique number identifier. Now you can connect the functor //[[:Load Map]]// to the //[[:Number Map]]// and the container //[[:Calculate Map]]// to //[[:Save Map]]//. Use the connect tool (the arrow icon) to establish the connections. Observe that the connection is set automatically because there is only one option for compatible ports in the respective functors and container.\\
 \\  \\ 
 \\ \\
-{{:​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.{{ :​tutorial:​simple_model_4.jpg?​300|}}\\                                                                                    +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.\\
-\\ +
-\\+
 \\ \\
 \\ \\
Line 50: Line 48:
 \\ \\
 \\ \\
 +
 +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_3.0.2.jpg?300|}}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. \\+{{:​tutorial:​simple_model_5.1.jpg?nolink ​|}}
 \\ \\
 \\ \\
 \\ \\
 +[[:​image_expression_type|Here]] you can find examples of operators that can be applied to process data within this container.\\
 \\ \\
 \\ \\
 \\ \\
-In the next stepopen 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 mapstables and constants.{{:​tutorial:​simple_model_5.1.jpg |}}\\+ 
 +Besides writing ​the equationthere are two parameters ​that must be set. The **Cell Type** and the **Null Value**. You will always find these parameters in functors that produce maps as output. The default is "​Signed 32 Bit Integer",​ but you can use "IEEE 754 32 Bit Real" to represent fractional numbers.  
 +\\ Try to use always ​the most economical representation for data cell type to save memory. If you are not sure about the numeric range of the outputuse real number representation.{{ :tutorial:simple_model_6.jpg|}}
 \\ \\
 \\ \\
 \\ \\
-[[:​image_expression_type|Here]] you can find examples of operators that can be applied to process data within this container. 
- 
-Besides writing the equation, there are two parameters that must be set. The **data cell type** and the **null value**. You will always find these parameters in functors that produce maps as output. The default is Signed 32 Bit Integer, but you can use IEEE 32 Bit Real to represent fractional numbers. ​ 
-\\ Try to use always the most economical representation for data cell type to save memory. If you are not sure about the numeric range of the output, use real number representation.{{ :​tutorial:​simple_model_6.jpg|}} 
 \\ \\
 +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 79: Line 82:
 \\ \\
 \\ \\
-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 **Data cell type** to **Unsigned 8 Bit Integer** and the **Null Value** to “0”. 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 Define ​Null Value flag and then setting its value on Null Value field 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>​
  
 Open the Map Viewer to visualize this map. Press Histogram and then choose limits to actual and make sure that the current color palette is PseudoColor. Go to the [[:​map_viewer|Map viwer Tutorial]] if tou have any doubts. ​ The map will look like this:\\ Open the Map Viewer to visualize this map. Press Histogram and then choose limits to actual and make sure that the current color palette is PseudoColor. Go to the [[:​map_viewer|Map viwer Tutorial]] if tou have any doubts. ​ The map will look like this:\\
Line 95: Line 96:
 {{ :​tutorial:​amazon_states.1.jpg |}} {{ :​tutorial:​amazon_states.1.jpg |}}
  
-Now you need to save the result to a file. Open //Save Map// and write Mato_Grosso_state.{{ :​tutorial:​simple_model_8.jpg |}}+Now you need to save the result to a file. Open //[[:Save Map]]// and write ''​Mato_Grosso_state''​. {{ :​tutorial:​simple_model_8.jpg |}}
  
-In the Advanced tab there is an option to set the file name **suffix digits**. Although the default is 2, zero will be assigned ​since there is only one iteration.\\ Use Compression is only applicable for geotiff 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 111: 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:\\ 
 +\\ 
 +\\ 
 +{{ :​tutorial:​simple_model_9.jpg?​nolink |}}
 \\ \\
 \\ \\
-{{:​tutorial:​simple_model_9.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 |}}
  
-Save the model as “my_model” in lesson1 folderclick 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 |}}+__Congratulationsyou have successfully completed this lesson!__ Now let’s move to the next ones!
  
-__Congratulations,​ you have successfully completed the first lesson!__ Now let’s move to the next ones!+[[tutorial:​incorporating_iterations_into_a_model|Next Lesson]]