tutorials:radiation-model-in-crop_model2
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials:radiation-model-in-crop_model2 [2025/05/27 16:12] – created barley1965 | tutorials:radiation-model-in-crop_model2 [2025/05/27 17:53] (current) – barley1965 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Plotting the absorbed light in a chart ====== | ====== Plotting the absorbed light in a chart ====== | ||
- | Open the file // | + | //Open the file {{ : |
For this, we have to declare a kind of data table in which the output is stored: | For this, we have to declare a kind of data table in which the output is stored: | ||
+ | |||
+ | <code java> | ||
+ | //insert a table here for the output: | ||
+ | const DatasetRef lightdata = new DatasetRef(" | ||
+ | </ | ||
+ | |||
+ | We then have to initiate the chart in the '' | ||
<code java> | <code java> | ||
Line 18: | Line 25: | ||
] | ] | ||
</ | </ | ||
+ | |||
+ | Note that if you want to declare imperative code in a method that also contains rules (like the present '' | ||
- | We then have to initiate the chart in the init() method. For this, we will use the new method initChart() that will be defined later: | + | <code java> |
+ | public void grow () | ||
+ | { | ||
+ | run(); | ||
+ | lm.compute(); | ||
+ | absorb(); | ||
+ | // | ||
+ | updateChart(); | ||
+ | } | ||
+ | </ | ||
- | Note that if you want to declare imperative | + | The latter is another new method, '' |
+ | The two new methods are defined, first '' | ||
+ | |||
+ | <code java> | ||
+ | // | ||
+ | protected void initChart() | ||
+ | { | ||
+ | lightdata.clear(); | ||
+ | chart(lightdata, XY_PLOT); | ||
+ | } | ||
+ | </ | ||
- | The latter is another new method, | + | This method |
- | The two new methods are defined, first initChart(): | + | |
+ | <code java> | ||
+ | // | ||
+ | protected void updateChart() | ||
+ | { | ||
+ | lightdata.addRow().set(0, | ||
+ | } | ||
+ | </ | ||
- | This method does something with the data table lightdata, in fact it empties it at each new run, using the method | + | The '' |
+ | {{tutorials: | ||
- | The addRow() method of DatasetRef does the actual job, more specifically its sub-method set(), which adds the data into the 0th column of the table: The data are produced by the sum method, which searches for all leaves (* Leaf *) that are already produced and then sums up their parameter al. Searching for objects in the graph is a very powerful option in GroIMP. You can also do this at any time of the simulation by typing search commands in the XL Console, for instance the following command | + | will search for all objects |
- | + | ||
- | will search for all objects Leaf in the scene/graph (you have to write “Example1.Leaf” to indicate that the module was defined within the class “Example1.rgg”) the value of the parameter al and calculate the sum of it. If you omit Example1, the module Leaf cannot be found and you get an error message instead: | + | {{tutorials: |
You can also have a look at the data table itself: | You can also have a look at the data table itself: | ||
- | Main Menu: Panels -> Explorers -> Datasets | + | |
+ | //Main Menu: Panels -> Explorers -> Datasets// | ||
+ | |||
+ | {{tutorials: | ||
This will give you a new window: | This will give you a new window: | ||
+ | |||
+ | {{tutorials: | ||
- | When you double-click on the Dataset “- Light intercepted…” you get the actual table, with two columns, # and A, where the first column contains the steps, the second the sum of light intercepted by the leaves: | + | When you double-click on the //Dataset “- Light intercepted…”// you get the actual table, with two columns, |
+ | |||
+ | {{tutorials: | ||
+ | |||
| | ||
tutorials/radiation-model-in-crop_model2.1748355161.txt.gz · Last modified: 2025/05/27 16:12 by barley1965