Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1194 | werner | 1 | /** |
2 | The `Management` object is used to for operations that remove trees from the simulation environment. |
||
3 | The iLand management is accessible using the global object `management`, which is available |
||
4 | when script code is invoked from the iLand management subsystem. |
||
5 | |||
6 | Main functions |
||
7 | -------------- |
||
8 | |||
9 | + Loading trees from iLand: use {{#crossLink "Management/load:method"}}{{/crossLink}} and {{#crossLink "Management/loadFromMap:method"}}{{/crossLink}} to load a list of trees |
||
10 | + manipulating lists of trees: use {{#crossLink "Management/filter:method"}}{{/crossLink}} to select a sub set based on some criterion, |
||
11 | or {{#crossLink "Management/sort:method"}}{{/crossLink}} to bring the list in a specific order; you can calculate {{#crossLink "Management/sum:method"}}{{/crossLink}} |
||
12 | or {{#crossLink "Management/mean:method"}}{{/crossLink}} values from all trees in the list |
||
13 | + removing trees: {{#crossLink "Management/manage:method"}}{{/crossLink}} and {{#crossLink "Management/kill:method"}}{{/crossLink}} |
||
14 | + other functions such as.... |
||
15 | |||
16 | Note that by default only living trees are processed. |
||
17 | Several special functions exists, e.g. a function to filter based on a predefined list of tree-ids (filter()), of methods |
||
18 | that select trees based on some rastered GIS data. |
||
19 | |||
20 | There are several distinct tree removal modes in iLand, namely by harvesting a tree, or by killing a tree, or due to a disturbance. |
||
21 | In general, harvesting removes all (aboveground) biomass from the system, while a killed trees' biomass is moved to the 'standing dead' pool. |
||
22 | Disturbed trees behave similar to killed trees. Note, that there are further subtle differences between removal modes: for instance, resprouting |
||
23 | is only possible from harvested trees; or, trees killed by disturbance might be treated differently by management. |
||
24 | |||
25 | The management functions typically affect only individual trees in iLand with a height >4m. However, there are some functions available |
||
26 | to alter the state of the saplings (tree cohorts < 4m height). |
||
27 | |||
28 | |||
29 | |||
30 | Expressions and tree variables |
||
31 | ------------------------------ |
||
32 | Many function of the `management` object allow to specify a filter ([Expression](http://iland.boku.ac.at/Expression)). In the context of |
||
33 | management, tree variables can be used within filter expressions: see http://iland.boku.ac.at/tree+variables |
||
34 | |||
35 | Tree species can be included in Expressions by using the short name as is; internally, the species (identity) is |
||
36 | a integer index of the species, and species short names (such as 'piab', 'fasy', or 'pico') are used as placeholders. |
||
37 | |||
38 | |||
39 | Examples |
||
40 | -------- |
||
41 | The wiki contains a small collection of useful management scripts. |
||
42 | |||
43 | @module iLand |
||
44 | @class Management |
||
45 | */ |
||
46 | |||
47 | /** |
||
48 | The number of trees that are currently in the internal list. |
||
49 | |||
50 | See also: {{#crossLink "SpatialAnalysis/load:method"}}{{/crossLink}} |
||
51 | |||
52 | @property count |
||
53 | @type integer |
||
54 | */ |
||
55 | /** |
||
56 | The removal fraction for foliage [0..1]. 0: 0% will be removed, 1: 100% will be removed from the forest by management operations (i.e. calls to manage()) |
||
57 | |||
58 | The default value is 0 (all foliage remains in the forest) |
||
59 | |||
60 | See also: {{#crossLink "SpatialAnalysis/removeBranch:method"}}{{/crossLink}}, {{#crossLink "SpatialAnalysis/removeStem:method"}}{{/crossLink}} |
||
61 | |||
62 | @property removeFoliage |
||
63 | @type double |
||
64 | @Example |
||
65 | // full tree extraction |
||
66 | management.removeFoliage = 1; management.removeBranch=1; management.removeStem = 1; |
||
67 | management.manageAll(); |
||
68 | |||
69 | */ |
||
70 | /** |
||
71 | The removal fraction for branches [0..1]. 0: 0% will be removed, 1: 100% will be removed from the forest by management operations (i.e. calls to manage()) |
||
72 | |||
73 | The default value is 0 (all branches remain in the forest) |
||
74 | |||
75 | See also: {{#crossLink "SpatialAnalysis/removeFoliage:method"}}{{/crossLink}}, {{#crossLink "SpatialAnalysis/removeStem:method"}}{{/crossLink}} |
||
76 | |||
77 | @property removeBranch |
||
78 | @type double |
||
79 | */ |
||
80 | /** |
||
81 | The removal fraction for the stem biomass [0..1]. 0: 0% will be removed, 1: 100% will be removed from the forest by management operations (i.e. calls to manage()) |
||
82 | |||
83 | The default value is 1 (100% of the stem is removed in case of management). Note that root biomass is never extracted. |
||
84 | |||
85 | See also: {{#crossLink "SpatialAnalysis/removeFoliage:method"}}{{/crossLink}}, {{#crossLink "SpatialAnalysis/removeBranch:method"}}{{/crossLink}} |
||
86 | |||
87 | @property removeStem |
||
88 | @type double |
||
89 | */ |
||
90 | |||
91 | /** |
||
92 | Load all trees into the internal list and return the number of trees. |
||
93 | |||
94 | @method loadAll |
||
95 | @return {integer} the number of trees that were loaded. |
||
96 | */ |
||
97 | /** |
||
98 | Load all trees passing the filter criterion specified in `filter` and return number of trees in the list. |
||
99 | `filter` can be any tree-related Expression. |
||
100 | |||
101 | @method load |
||
102 | @param {string} filter A valid filter Expression that is applied during the loading of the list. |
||
103 | @return {integer} the number of trees that were loaded. |
||
104 | @Example |
||
105 | // load all trees with a dbh >30 cm |
||
106 | management.load('dbh>30'); |
||
107 | */ |
||
108 | /** |
||
109 | Load all trees of a resource unit with the index `ruindex` and return the number of loaded trees. |
||
110 | |||
111 | @method loadResourceUnit |
||
112 | @param {int} ruindex The index (0-based) of the resource unit that should be loaded |
||
113 | @return {integer} the number of trees that were loaded. |
||
114 | @Example |
||
115 | for (var i=0; i<Globals.resourceUnitCount; ++) { |
||
116 | management.loadResourceIndex(i); |
||
117 | // further processing.... |
||
118 | } |
||
119 | */ |
||
120 | |||
121 | /** |
||
122 | Load all trees that are located on grid pixels with the value `standID` on the grid `map`. |
||
123 | |||
124 | @method loadFromMap |
||
125 | @param {Map} map a GIS grid that defines stand IDs. |
||
126 | @param {integer} standID the ID of the stand that should be loaded. |
||
127 | @return {integer} the number of trees that were loaded. |
||
128 | @Example |
||
129 | // Access to the global stand grid (required only once) |
||
130 | var stand_grid = Factory.newMap(); |
||
131 | // load all trees of the forest stand with ID=1 |
||
132 | management.loadFromMap(stand_grid, 1); |
||
133 | */ |
||
134 | |||
135 | /** |
||
136 | Sort the trees in the internal list in ascending order according to a criterion given |
||
137 | by `expression` (a valid [iLand Expression](http://iland.boku.ac.at/Expression)). |
||
138 | |||
139 | See also: {{#crossLink "Management/percentile:method"}}{{/crossLink}} |
||
140 | |||
141 | @method sort |
||
142 | @param {string} expression Expression used for sorting |
||
143 | @Example |
||
144 | management.sort('dbh'); // sort by diameter, largest tree are now in the end of the list |
||
145 | management.sort('-dbh'); // to sort in descending order, reverse the sign of the expression |
||
146 | */ |
||
147 | /** |
||
148 | Apply a filter `expression` on the list of trees (`expression`is a valid [iLand Expression](http://iland.boku.ac.at/Expression)) |
||
149 | and return the number of trees remaining in the lists. After calling this function, the list of |
||
150 | trees is typically reduced and contains only those trees, who meet the condition in `expression`. |
||
151 | |||
152 | See the example how to filter by species, and how to combine multiple criteria. |
||
153 | |||
154 | See also: {{#crossLink "Management/sort:method"}}{{/crossLink}}, {{#crossLink "Management/load:method"}}{{/crossLink}} |
||
155 | |||
156 | @method filter |
||
157 | @param {string} expression Expression used for filtering |
||
158 | @return {integer} the number of trees in the list after filtering. |
||
159 | @Example |
||
160 | management.loadAll(); |
||
161 | management.filter('dbh>10'); |
||
162 | // is the same as: |
||
163 | management.load('dbh>10'); |
||
164 | // using tree species names: note, that no "'" or '"" signs |
||
165 | // are used with species IDs; note also the boolean 'and' operator |
||
166 | management.filter('species=piab and dbh>20'); |
||
167 | management.loadAll(); // all trees |
||
168 | management.filter('dbh>10 and species=piab'); // reduce list |
||
169 | // ... some processing.... |
||
170 | management.filter('dbh>20'); // now only spruce trees > 20cm are still in the list |
||
171 | management.filter('stress>0'); // now only spruce trees >20cm, that have a non-zero stress rating are in the list |
||
172 | // ... |
||
173 | |||
174 | */ |
||
175 | /** |
||
176 | Apply a filter in form of a `list` of ids, return number of remaining trees. This can be useful |
||
177 | to pre-define a management on individual trees. |
||
178 | |||
179 | |||
180 | See the example below. |
||
181 | |||
182 | |||
183 | See also: {{#crossLink "Management/filter:method"}}{{/crossLink}}, http://iland.boku.ac.at/initialize+trees |
||
184 | |||
185 | @method filterIdList |
||
186 | @param {array} list A list of unique tree IDs. |
||
187 | @return {integer} the number of trees in the list after filtering. |
||
188 | @Example |
||
189 | // array of tree IDs |
||
190 | var treelist = [10,20,40,43]; // can be loaded form file... |
||
191 | management.load(); // load all trees |
||
192 | management.filter(treelist); // filter trees using the tree list |
||
193 | management.kill(); // remove all trees remaining, i.e. the trees in the tree list. |
||
194 | |||
195 | */ |
||
196 | /** |
||
197 | Shuffle all trees in the list randomly. |
||
198 | |||
199 | @method randomize |
||
200 | */ |
||
201 | |||
202 | /** |
||
203 | Retrieve the value associated with the `pct` percentile [0..100] of the currently loaded trees. A call |
||
204 | to {{#crossLink "Management/sort:method"}}{{/crossLink}}() is required in order to prepare valid |
||
205 | data. |
||
206 | |||
207 | See also: {{#crossLink "Management/sort:method"}}{{/crossLink}} |
||
208 | |||
209 | @method percentile |
||
210 | @param {integer} pct the percentile [0..100] for which to return the value |
||
211 | @return {dobule} the value associated with the `pct` percentile |
||
212 | */ |
||
213 | |||
214 | /** |
||
215 | Calculate the mean value for all trees in the internal list for `expression` (optionally filtered by the `filter` criterion). |
||
216 | |||
217 | See also: {{#crossLink "Management/sum:method"}}{{/crossLink}} |
||
218 | |||
219 | @method mean |
||
220 | @param {string} expression The expression used for calculating the mean value |
||
221 | @param {string} filter If not empty, the mean is calculated only from those trees that meet the criterion in the expression |
||
222 | @return {dobule} the mean value of `expression` |
||
223 | @Example |
||
224 | var mean_dbh = management.mean('dbh'); |
||
225 | |||
226 | */ |
||
227 | /** |
||
228 | Calculate the sum of `expression` for all trees in the internal list (optionally filtered by the `filter` criterion). |
||
229 | |||
230 | See also: {{#crossLink "Management/sum:method"}}{{/crossLink}} |
||
231 | |||
232 | @method sum |
||
233 | @param {string} expression The expression used for calculating the mean value |
||
234 | @param {string} filter If not empty, the mean is calculated only from those trees that meet the criterion in the expression |
||
235 | @return {dobule} the mean value of `expression` |
||
236 | @Example |
||
237 | // select trees that represent 50% of the total basal area |
||
238 | management.loadAll(); |
||
239 | var total_ba = management.sum('basalarea'); |
||
240 | management.randomize(); |
||
241 | management.filter('incsum(basalarea)<' + total_ba * 0.5 ); |
||
242 | console.log(management.sum('basalarea')); |
||
243 | */ |
||
244 | |||
245 | |||
246 | /** |
||
247 | Use `killPct` to remove `n` trees sampled randomly from a given percentile range (given by `from` and `to`). All |
||
248 | trees are removed, if `n` is higher than the number of trees in that range. |
||
249 | |||
250 | The tree list needs to be sorted, before percentile based selection makes sense. |
||
251 | |||
252 | See also: {{#crossLink "Management/sort:method"}}{{/crossLink}}, {{#crossLink "Management/percentile:method"}}{{/crossLink}} |
||
253 | |||
254 | @method killPct |
||
255 | @param {integer} from lower percentile of the current tree distribution (0..100) |
||
256 | @param {integer} to higher percentile of the current tree distribution (0..100) |
||
257 | @param {integer} n the number of trees to kill in the given percentile |
||
258 | @return {integer} the number of killed trees |
||
259 | @Example |
||
260 | var n = management.loadAll(); |
||
261 | management.sort('dbh'); |
||
262 | var n_killed = management.killPct(0,50, n*0.25); |
||
263 | console.log('killed ' + n_killed + ' below median: ' + management.percentile(50) ); |
||
264 | // kill 33% of the trees between the 80th and the 100th percentile. |
||
265 | management.killPct(80,100, n*0.2 * 0.33); |
||
266 | */ |
||
267 | /** |
||
268 | Kill all trees which are currently in the tree list. |
||
269 | |||
270 | See also: {{#crossLink "Management/kill:method"}}{{/crossLink}}, {{#crossLink "Management/manageAll:method"}}{{/crossLink}} |
||
271 | @method killAll |
||
272 | @return {integer} the number of killed trees. |
||
273 | */ |
||
274 | /** |
||
275 | Kill all and cut down all trees in the list. The biomass of cut down trees bypasses the standing dead wood pool, and |
||
276 | such trees can act as trap trees with regard to bark beetles. |
||
277 | |||
278 | See also: {{#crossLink "Management/kill:method"}}{{/crossLink}}, {{#crossLink "Management/manageAll:method"}}{{/crossLink}} |
||
279 | @method cutAndDrop |
||
280 | */ |
||
281 | /** |
||
282 | Remove all selected trees with with the _disturbance_ flag set. Disturbed trees are treated |
||
283 | differently with regard to carbon flows and {{#crossLinkModule "ABE"}}{{/crossLinkModule}} |
||
284 | |||
285 | See also: {{#crossLink "Management/killAll:method"}}{{/crossLink}}, {{#crossLink "Management/manageAll:method"}}{{/crossLink}} |
||
286 | @method disturbanceKill |
||
287 | @return {integer} the number of killed trees. |
||
288 | */ |
||
289 | /** |
||
290 | Kill `fraction` (0..1) of all trees for which the Expression `filter` is _true_. |
||
291 | |||
292 | See also: {{#crossLink "Management/killAll:method"}}{{/crossLink}}, {{#crossLink "Management/manage:method"}}{{/crossLink}} |
||
293 | @method kill |
||
294 | @param {string} filter A expression to select a subset of the trees. |
||
295 | @param {double} fraction give the fraction (0..1) of trees that should be killed. |
||
296 | @return {integer} the number of killed trees. |
||
297 | @Example |
||
298 | management.loadAll(); |
||
299 | // kill 30% of larch trees, and 60% of pine |
||
300 | management.kill('species = lade', 0.3); |
||
301 | management.kill('species = pisy', 0.6); |
||
302 | */ |
||
303 | |||
304 | |||
305 | /** |
||
306 | Use `managePct` to remove `n` trees sampled randomly from a given percentile range (given by `from` and `to`). All |
||
307 | trees are removed, if `n` is higher than the number of trees in that range. |
||
308 | |||
309 | The tree list needs to be sorted, before percentile based selection makes sense. |
||
310 | |||
311 | See also: {{#crossLink "Management/sort:method"}}{{/crossLink}}, {{#crossLink "Management/percentile:method"}}{{/crossLink}} |
||
312 | |||
313 | @method managePct |
||
314 | @param {integer} from lower percentile of the current tree distribution (0..100) |
||
315 | @param {integer} to higher percentile of the current tree distribution (0..100) |
||
316 | @param {integer} n the number of trees to harvest in the given percentile |
||
317 | @return {integer} the number of harvested trees |
||
318 | @Example |
||
319 | var n = management.loadAll(); |
||
320 | management.sort('dbh'); |
||
321 | var n_rem = management.managePct(0,50, n*0.25); |
||
322 | console.log('removed ' + n_rem + ' below median: ' + management.percentile(50) ); |
||
323 | // harvest 33% of the trees between the 80th and the 100th percentile. |
||
324 | management.managePct(80,100, n*0.2 * 0.33); |
||
325 | */ |
||
326 | /** |
||
327 | Harvest all trees which are currently in the tree list. |
||
328 | |||
329 | See also: {{#crossLink "Management/manage:method"}}{{/crossLink}}, {{#crossLink "Management/killAll:method"}}{{/crossLink}} |
||
330 | @method manageAll |
||
331 | @return {integer} the number of harvested trees. |
||
332 | */ |
||
333 | |||
334 | /** |
||
335 | Remove a `fraction` (0..1) of all trees for which the Expression `filter` is _true_. |
||
336 | |||
337 | See also: {{#crossLink "Management/manageAll:method"}}{{/crossLink}}, {{#crossLink "Management/kill:method"}}{{/crossLink}} |
||
338 | @method manage |
||
339 | @param {string} filter A expression to select a subset of the trees. |
||
340 | @param {double} fraction give the fraction (0..1) of trees that should be harvested. |
||
341 | @return {integer} the number of harvested trees. |
||
342 | @Example |
||
343 | management.loadAll(); |
||
344 | // kill 30% of larch trees, and 60% of pine |
||
345 | management.manage('species = lade', 0.3); |
||
346 | management.manage('species = pisy', 0.6); |
||
347 | */ |
||
348 | |||
349 | |||
350 | /** |
||
351 | Kill all saplings (i.e. trees <4m) which are located on grid pixels with the value `standID` on the grid `map`. |
||
352 | |||
353 | @method killSaplings |
||
354 | @param {Map} map A Map object with a stand grid. |
||
355 | @param {integer} standID the ID of the stand to process. |
||
356 | */ |
||
357 | |||
358 | /** |
||
359 | (Hacky) function to modify the carbon content of the snag/soil pools of resource units covered by pixels with `standID` on the `map`. |
||
360 | If the resource unit is only partially covered, the factors are scaled accordingly. |
||
361 | The parameters are remove-fractions, i.e. values of 0 mean no change, values of 1 mean removal of 100% of the carbon of the respective pool. |
||
362 | |||
363 | @method removeSoilCarbon |
||
364 | @param {Map} map A Map object with a stand grid. |
||
365 | @param {integer} standID the ID of the stand to process. |
||
366 | @param {double} SWDfrac fraction of standing woody debris to remove. |
||
367 | @param {double} DWDfrac fraction of downed woody debris to remove. |
||
368 | @param {double} litterFrac fraction of litter (yL) to remove. |
||
369 | @param {double} soilFrac fraction of SOM to remove.. |
||
370 | */ |
||
371 | |||
372 | /** |
||
373 | Function to 'manage' snags, i.e. to cut down and move biomass to the soil pools. |
||
374 | The spatial approach is as described for {{#crossLink "Management/removeSoilCarbon:method"}}{{/crossLink}}. |
||
375 | The parameter `slash_fraction` describes (from 0..1) the fraction of biomass that should be transferred to the soil |
||
376 | (0: nothing, 1: 100%). Currently, the standing woody debris pool (SWD) and the 'other wood' pools are treated equally. |
||
377 | |||
378 | @method killSaplings |
||
379 | @param {Map} map A Map object with a stand grid. |
||
380 | @param {integer} standID the ID of the stand to process. |
||
381 | */ |
||
382 | |||
383 | |||
384 | |||
385 | |||
386 | Management = {} |