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
Last revision Both sides next revision
lesson_11 [2020/02/12 14:43]
argemiro
lesson_11 [2020/02/17 13:20]
pedrog
Line 35: Line 35:
 \\ \\
 \\ \\
-Previously, the submodel only calculating productivity for crop 3. Now, we must give the user the option to choose the crop to be calculated. For this, we must create an entry (creating an input for the submodel). For this, place a functor Integer value (where the user can choose the crop - 1, 2 or 3) and connect to get table from key functor: +  * You will see:
- +
-{{ :​guide_01.png?​600 |}}+
 \\ \\
 \\ \\
-{{ :guide_02.png?600 |}}+{{ :aaa2.png?600 |}}
 \\ \\
 \\ \\
-Click on Apply changes and Publish ​the submodel:+===Using ​the submodel ​in an independent model===
 \\ \\
-{{ :guide_03.png?600 |}}+   * Previously, the submodel only calculated productivity for crop 3. Now, we must give the user the option to choose the crop to be analyzed. For this, it is necessary to create an entry where it will be possible to specify the crop to be analyzed (1, 2 or 3)
 \\ \\
 +\\
 +<note important>​
 +To edit the submodel creating this input for the submodel, you need to open the submodel by clicking on its name in the lateral bar.
 +</​note>​
 +\\
 +\\
 +  * So, with the model open to be edited, place a functor Integer value (where the user can choose the crop - 1, 2 or 3) and connect to get table from key functor:
  
-  * We can use this submodel in an independent model. To do so, select the submodel tab on the sketch, open submodel options and select **Publish Submodel**. Create a new model script, grab a **Load Table Functor** and place it on the sketch. Double click the Load Table Functor and open the IBGE_crop_information_complete.csv file located in ''​Guidebook_Dinamica_5/​Models/​Set_2/​basics/​2_add_table_column_set_table_by_key/​IBGE_crop_information_complete.csv''​. 
 \\ \\
-  ​* Grab a **Reorder Table Column** and place it on the sketch to switch the order of the year and crop key columns. Connect the Load Table to Reorder Table Column. In the Functor Editor window insert the index of the column to be moved (1) and the new column index (0).+{{ :​aaa3.png?​600 |}} 
 +\\ 
 +  ​On the top bar of the Functor integer value, click on the option Export functor inputs and outputs, and, in the new window, double-click the editor icon (pencil) and enter the name "​Crop"​. Click Ok: 
 +\\ 
 +{{ :​aaa6.png?​600 |}} 
 +\\ 
 +  * After including the changes, click on Apply changes / Edit Submodel Properties as shown in the image below and click OK: 
 +\\ 
 +{{ :​aaa10.png?​600 |}} 
 +\\ 
 +Next, click OK, and again OK: 
 +{{ :​aaa5.png?​600 |}} 
 +\\ 
 +  * Create a new model script, grab a **Load Table Functor** and place it on the sketch. Double click the Load Table Functor and open the IBGE_crop_information_complete.csv file located in ''​Guidebook_Dinamica_5/​Models/​Set_2/​basics/​2_add_table_column_set_table_by_key/​IBGE_crop_information_complete.csv''​. ​Grab a **Reorder Table Column** and place it on the sketch to switch the order of the year and crop key columns. Connect the Load Table to Reorder Table Column. In the Functor Editor window insert the index of the column to be moved (1) and the new column index (0) and click OK.
 \\ \\
 \\ \\
Line 56: Line 73:
 \\ \\
 \\ \\
-  * Now, let'​s ​insert our previously created Submodel. First, click on the Submodels tab and from the library window grab a **Calc Most Productive year** Submodel ​and place it on the sketch. ​We want to calculate ​the most productive year for each crop; thuswe will use this Submodel 3 times, i.e. for the crops 1, 2 and 3.+  * To insert our previously created Submodel, click on the Local Submodels tab and from the library window grab the Calc Most Productive year submodel ​and place it on the sketch. ​This will import ​the submodelclick ok on the prompted warning.
 \\ \\
 \\ \\
-{{ :imagem83.png?400 |}}+  * We want to calculate the most productive year for each crop; thus, we will use this Submodel 3 times, i.e. for the crops 1, 2 and 3. For this, Double click in each submodel loaded and insert the number that corresponds to each crop, as the image below
 \\ \\
 +{{ :​aaa7.png?​600 |}}
 \\ \\
   * To save the results to a file, grab three **Save Table** functors, place them on the sketch and connect to each Submodel (for the three crops). Open **Save Table** Functors, browse to the ''​Guidebook_Dinamica_5/​Models/​Set_2/​basics/​6_submodel''​ and write the file names (e.g. most_productive_year_for_crop_1.csv, ​ most_productive_year_for_crop_2.csv and most_productive_year_for_crop_3.csv).   * To save the results to a file, grab three **Save Table** functors, place them on the sketch and connect to each Submodel (for the three crops). Open **Save Table** Functors, browse to the ''​Guidebook_Dinamica_5/​Models/​Set_2/​basics/​6_submodel''​ and write the file names (e.g. most_productive_year_for_crop_1.csv, ​ most_productive_year_for_crop_2.csv and most_productive_year_for_crop_3.csv).
Line 67: Line 85:
   * The final model will look like the one in the imagem below. Save and run the model.   * The final model will look like the one in the imagem below. Save and run the model.
 \\ \\
-{{ :imagem85.png?400 |}}+<​note>​The red box highlights the window in which the crop should be chosen</​note>​ 
 +\\ 
 +{{ :aaa8.png?700 |}}
 \\ \\
 \\ \\