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
Next revision Both sides next revision
lesson_14 [2019/08/30 12:44]
argemiro
lesson_14 [2020/02/18 00:26]
argemiro
Line 1: Line 1:
-{{ :logo_guidebook1.jpg?400 |}}+{{ :logo_logo.png?400 |}}
 \\ \\
-=====LESSON 14: Using Repeat for successive calculations=====  ​+=====LESSON 14: Using "​For"​ to make successive calculations=====  ​
 \\ \\
 +In this lesson we will calculate the biomass of the expanded Legal Amazon Protected Areas per year. For this, we will use: 
 \\ \\
 +  * The protected areas map in the year 2000 ''​Guidebook_Dinamica_5/​Database/​Protected_areas/​protected_areas_2000.tif''​
 +  * The protected areas map in the year 2006 ''​Guidebook_Dinamica_5/​Database/​Protected_areas/​protected_areas_2006.tif''​
 +  * The Legal Amazon Biomass map ''​Guidebook_Dinamica_5/​Database/​biomass/​biomass.tif''​
 +\\
 +Initially, we must open all the files that will be used. Grab two **Load Categorical Map** functors and place them on the sketch. Double click each **Load Categorical Map** and open the protected areas map files for 2000 and 2006. Also grab and place one **Load Map** and open the Legal Amazon Biomass map.
 +\\
 +\\
 +{{ :​14a.png?​200 |}}
 +\\
 +\\
 +Grab and place on the sketch one **Calculate Map**. Click on the hook tool to insert three **Number Maps**. Assign a number to each Number Value. Connect the **Load Map** and **Load Categorical Map** to the **Number Map** functors. ​
 +\\
 +\\
 +{{ :​14b.png?​400 |}}
 +\\
 +\\
 +Now, write the following code inside of Calculate Map to calculate the biomass in expanded protected areas (2000-2006) using the Number Map functors:  ​
 +\\
 +    if not isNull(i2) and isNull(i3) then
 +        i1
 +    else 
 +        null
 +\\
 +{{ :​14c.png?​400 |}}
 +\\
 +\\
 +Select the IEEE 754 32 bit real as the data cell type. Grab and place on the sketch a **Save map** and connect **Calculate Map** to it. Open **Save Map**, browse to ''​Guidebook_Dinamica_5/​Models/​Set_3/​basics/​3_calculate map4/''​ and chose a file name (e.g. expanded protected areas biomass.tif).
 +Grab and place on the sketch **Extract map attributes** and connect Calculate Map to it.
 +\\
 +\\
 +{{ :​14d.png?​400 |}}
 +\\
 +\\
 +Now, grab and place on the sketch one Calculate value functor. Click on the hook tool to create three hook functors inside the Calculate Map: one Number table and two Number value functors. Click on the Number value functor and number table with the Functor Editor tool and enter “1”, “2”, “3”, respectively. This is a number identifier for each element and will be represented within the equation box as v1 (value 1), v2 (value 2) and t1 (table 1) respectively. ​
 +\\
 +Grab and place on the sketch two Real value functors to insert a double precision real constant: A CO2 conversion factor (3.666) and a Carbon Content (0.47). Connect the Extract map attributes Map to Number Table and the two Real Value functors to Number Value Functor inside the Calculate Value.
 +\\
 +\\
 +{{ :​14e.png?​400 |}}
 +\\
 +\\
 +Now, write the following equation inside to Calculate Map to calculate CO2 content in expanded protected areas (2000-2006):​ \\
 +\\
 +    t1["​cellSum"​] * t1["​cellArea"​] * v1 * v2
 +\\
 +\\
 +{{ :​14f.png?​400 |}}
 +\\
 +\\
 +<note tip>TIP: You can copy an equation from a text editor (using Ctrl+C) and paste it in the equation box (using Ctrl+V).</​note>​
 +\\
 +\\
 +Grab and place on the sketch one Set Lookup Table Value Functor to insert the calculate values into a lookup table. It is important to pay attention to add correctly the key to the line in which the value will be inserted.
 +\\
 +\\
 +{{ :​14g.png?​400 |}}
 +\\
 +\\
 +Click on the Input/​output from the library window, grab and place on the sketch the Save Lookup Table functor. ​
 +\\
 +Connect the Set Lookup Table Value to Save Lookup Table. Open Save Table, browse to ''​Guidebook_Dinamica_5/​Models/​Set_3/​basics/​3_calculate map4/ and  write the name file (expanded protected areas co2.csv). ​
 +\\
 +Save and run the model.
 +\\
 +Click on the Execute Layout and your final model will look like the one below: ​
 +\\
 +\\
 +{{ :​14h.png?​600 |}}
 +\\
 +\\
 +Now, click on eye button of “Save Lookup Table” to see the result. This functor output is table that looks like this:
 +\\
 +\\
 +{{ :​14i.png?​500 |}}
 +\\
 +\\
 +Now, an output map and an output table are produced for each iteration, Calculate Map outputs a map containing the remaining forest for each category of protected areas (1, 2, 3 or 4).
 +\\
 +Grab the container Repeat from the Control tab and place it on the sketch. Drag the previous model into it: 
 +{{ :​13_02a.png?​600 |}}
  
-==== What will you learn====+\\ 
 +Double-click the For container and in the window that opens enter the values 1 as the initial step and 4 as the final step: 
 +\\ 
 +\\ 
 +{{ :13_02b.png?600 | 
 +\\}} 
 +The Step functor associates to the enveloping container passes to Calculate Map the current step (1 to 4, that refer to each type of protected area). Thus for each iteration Calculate Map produces a map containing the current Amazon Protected areas for each time step.  
 +\\ 
 +\\ 
 +Mark the eye button at the top of “Save Table” and "Save Map" to viewer the results hereafter: \\ \\
  
-  ​Dinamica EGO data structures +**Save and run the model!** ​ \\ \\ 
-  ​* ​Dinamica EGO file formats+ 
 +The results found will be:  
 + 
 +**4 maps:** The biomass map for each type of protected area in the Legal Amazon. 
 + 
 +**4 Tables:*The biomass table for each type of protected area in the Legal Amazon.
  
-The intent of this exercise is: 
 \\ \\
 \\ \\
-For thiswe will use:  +===Congratulationsyou have successfully completed this lesson!===
 \\ \\
 +☞[[lesson_15|Next Lesson]]
 \\ \\
 +☞[[:​guidebook_start| Back to Guidebook Start]]
 +
 +
 +
  
-//Lesson under construction//​