Class: Stand

Access to properties of the current stand. The stand variable is available in the execution context of forest management and provides access to properties and functions of the stand that is currently processed.

Note that the variable stand is provided through the C++ framework and does not need to be created separately.

Use the ‘flag’ and ‘setFlag’ methods to (persistently) modify / read user-specific properties for each stand. This is a means to pass stand-specific information between activities (or between different events within one activity). In addition, each stand can hold arbitrary Javascript objects with the obj property.

Properties Overview

Name Type Description
U double The rotation length of the current stand. The rotation length is defined by the stand treatment programme that is currently assigned to a given
absoluteAge double The age of the stand given in years since the rotation started. At startup, the absoluteAge is estimated from
activity Activity The activity refers to activity that is currently active for the stand.
age double The mean age of the stand (years). It is calculated as basal area weighted mean age of all trees on the stand (>4m).
area double The total area of the stand in hectares.
basalArea double The basal area / ha stocking on the stand (living trees, >4m).
dbh double The mean DBH in cm. It is calculated as basal area weighted mean DBH of all trees on the stand (>4m).
elapsed int The number of years since the execution of the last activity for the current stand. Value is -1 if no activity was executed previously.
height double The mean height of the stand (meter). It is calculated as basal area weighted mean height of all trees on the stand (>4m).
id integer The id of the stand that is currently processed.
lastActivity string The name of the last previously executed activity, or an empty string if no activity was executed before. The name can be used to access
nspecies int The number of different tree species present on the stand (trees >4m). Use to iterate over the available species on the stand:
obj Javascript The obj is a general purpose javascript entity that is stored for a stand.
stp STP The stp refers to stand treatment program the stand is currently assigned to.
topHeight double The top height (in meters) is defined as the mean height of the 100 thickest trees per ha. For larger/ smaller stands, the number of trees is scaled accordingly.
trace boolean If trace is set to true, detailed log information is produced by ABE. This is useful for testing/ debugging.
volume double The total standing timber volume / ha of the stand (living trees, >4m).

Methods Overview

Method Return Type Description
activityByName(activity_name) Activity Use activityByName to retrieve an Activity object.
flag(name) value Retrieves the stand-specific property associated with the name ‘name’ for the stand of the current execution context.
relSpeciesBasalArea(index) double Retrieve the basal area share (0..1) of the species at position index.
relSpeciesBasalAreaOf(speciescode) double Retrieve the relative basal area of the species ‘speciescode’.
reload() void Force a reload of the stand data, i.e. fetch stand statistics (e.g. basal area, age)
setFlag(name) void Sets ‘value’ as the stand-specific property associated with the name ‘name’ for the stand of the current execution context.
setSTP(stp_name) void Sets a new STP for a stand. This can be used to “switch” from one STP to another STP.
sleep(years) void The ´sleep´ method suspends the activities on the stand for years years. Only after the specified has elapsed,
speciesBasalArea(index) double Retrieve the basal area of the species at position index.
speciesBasalAreaOf(speciescode) double Retrieve the basal area of the species with the species code ‘speciescode’.
speciesId(index) string Retrieve the species id at position index.
wakeup() void The ´wakeup´ method wakes up a stand again that was set to sleep earlier. The sleeping

Properties Details

U

double

The rotation length of the current stand. The rotation length is defined by the stand treatment programme that is currently assigned to a given stand. The ‘U’ is frequently used for timing activites relative to the length of the period.


absoluteAge

double

The age of the stand given in years since the rotation started. At startup, the absoluteAge is estimated from

the `age` of the stand (i.e. the mean age of the initialized trees). Later, the stand age counter is reset
by management activities. Note that this property is writable.

See also [age](stand.qmd#age).

activity

Activity

The activity refers to activity that is currently active for the stand.

See also: activityByName(), standId.


age

double

The mean age of the stand (years). It is calculated as basal area weighted mean age of all trees on the stand (>4m). Note the difference to absoluteAge, which is the number of years since the rotation started.

See also absoluteAge.


area

double

The total area of the stand in hectares.


basalArea

double

The basal area / ha stocking on the stand (living trees, >4m).


dbh

double

The mean DBH in cm. It is calculated as basal area weighted mean DBH of all trees on the stand (>4m). See also basalArea.


elapsed

int

The number of years since the execution of the last activity for the current stand. Value is -1 if no activity was executed previously.


height

double

The mean height of the stand (meter). It is calculated as basal area weighted mean height of all trees on the stand (>4m). See also topHeight.


id

integer

The id of the stand that is currently processed.

See also: standId in fmengine.


lastActivity

string

The name of the last previously executed activity, or an empty string if no activity was executed before. The name can be used to access properties of the activity.

       if (stand.lastActivity == "thinning1")
            stand.activity( stand.lastActivity ).enabled = true; // re-enable last activity if it was 'thinning1'

nspecies

int

The number of different tree species present on the stand (trees >4m). Use to iterate over the available species on the stand:

    // print the species id and the basal area for each available species.
    // note that the species are ordered by the basal area share.
    for (var i=0;i<stand.nspecies;++i)
        log(stand.speciesId(i) + ": " + stand.speciesBasalArea(i));

obj

Javascript

The obj is a general purpose javascript entity that is stored for a stand.

Note that obj can hold arbitrary Javascript objects, including data structures and functions. This extends the functionality available with flag and setFlag: while flag store simple data types and storage is handled by C++, obj entirely lives in Javascript world.

See also: flag().


stp

STP

The stp refers to stand treatment program the stand is currently assigned to.

See also: activity.


topHeight

double

The top height (in meters) is defined as the mean height of the 100 thickest trees per ha. For larger/ smaller stands, the number of trees is scaled accordingly. See also height.


trace

boolean

If trace is set to true, detailed log information is produced by ABE. This is useful for testing/ debugging. The trace-mode can be switched on/ off like this:

    // enable trace for stand 7
    fmengine.standId = 7; // set the current stand to the stand with Id 7
    stand.trace = true; // enable trace

See also: verbose


volume

double

The total standing timber volume / ha of the stand (living trees, >4m).


Methods Details

activityByName(activity_name)

Returns: Activity

Use activityByName to retrieve an Activity object.

Note: the variable activity is a “short-cut” to access the currently active activity.

    stand.activityByName("my_thinning_2").enabled = false; // disable an activity
    var act = stand.activityByName("my_thinning_1"); // save a reference to the activity for later use

See also: the variable [activity](stand.qmd#activity)

Parameters:

  • activity_name (string): The name of the activity to be retrieved. Activity names are provided during activity definition (see fmengine.addManagement) @return {Activity} the Activity, or undefined if not found.

Return Value Description: the Activity, or undefined if not found.


flag(name)

Returns: value

Retrieves the stand-specific property associated with the name ‘name’ for the stand of the current execution context.

    stand.setFlag('test', 3); // simple values
    stand.setFlag('my_goal', { s1: 10, s2: 20, s3: function(){return this.s1+this.s2;} } ); // complex objects (including functions are allowed)

    fmengine.log( stand.flag('my_goal').s3 + stand.flag('test') + stand.U  ); // -> 133 (if U=100 of the stand)

Parameters:

  • name (string): The (user-defined) property name of the stored parameter.

Return Value Description: The associated value for the given ‘name’. Returns ‘undefined’ if no value is assigned.


relSpeciesBasalArea(index)

Returns: double

Retrieve the basal area share (0..1) of the species at position index.

 // get the share of the dominant species:
 log( stand.relSpeciesBasalArea(0) * 100 + "%");

Parameters:

  • index (integer): The index of the species (valid between 0 and nspecies-1). @return {double} The basal area share (0..1) of the species.

Return Value Description: The basal area share (0..1) of the species.


relSpeciesBasalAreaOf(speciescode)

Returns: double

Retrieve the relative basal area of the species ‘speciescode’.

Parameters:

  • speciescode (string): The code of the species (e.g., ‘piab’). @return {double} The basal area (m2/ha) of the species, or 0 if the species is not present.

Return Value Description: The basal area (m2/ha) of the species, or 0 if the species is not present.


reload()

Returns: void

Force a reload of the stand data, i.e. fetch stand statistics (e.g. basal area, age) from the trees comprising the stand.

Usually, this is done automatically by ABE, however, it might be useful in some rare circumstances.


setFlag(name)

Returns: void

Sets ‘value’ as the stand-specific property associated with the name ‘name’ for the stand of the current execution context.

Parameters:

  • name (string): The (user-defined) property name of the stored parameter. @param {value} value The value that should be stored for ‘name’. ‘value’ can be any valid Javascript expression (including objects).

setSTP(stp_name)

Returns: void

Sets a new STP for a stand. This can be used to “switch” from one STP to another STP. Use updateSTP() from fmengine to change/update an already existing STP.

See also updateManagement().

  // get the share of the dominant species:
  console.log(stand.stp.name); // e.g. 'BAU'
  fmengine.addManagement( { ... }, 'femel');
  fmengine.standId=1; // explicitly set to stand with ID = 1
  stand.setSTP('femel');

Parameters:

  • stp_name (string): The name of the STP to set for the stand

sleep(years)

Returns: void

The ´sleep´ method suspends the activities on the stand for years years. Only after the specified has elapsed, ABE continues to examine the stand.

Parameters:

  • years (integer): The number of years that the stand should sleep.

speciesBasalArea(index)

Returns: double

Retrieve the basal area of the species at position index.

Parameters:

  • index (integer): The index of the species (valid between 0 and nspecies-1). @return {double} The basal area (m2/ha) of the species.

Return Value Description: The basal area (m2/ha) of the species.


speciesBasalAreaOf(speciescode)

Returns: double

Retrieve the basal area of the species with the species code ‘speciescode’. Note that only trees with height > 4m are included.

Parameters:

  • speciescode (string): The code of the species (e.g., ‘piab’). @return {double} The basal area (m2/ha) of the species, or 0 if the species is not present.

Return Value Description: The basal area (m2/ha) of the species, or 0 if the species is not present.


speciesId(index)

Returns: string

Retrieve the species id at position index.

Parameters:

  • index (integer): The index of the species (valid between 0 and nspecies-1). @return {string} The unique id of the species.

Return Value Description: The unique id of the species.


wakeup()

Returns: void

The ´wakeup´ method wakes up a stand again that was set to sleep earlier. The sleeping phase in canceled, and the stand is re-evaluated in the next year.