Building models
Models can be edited by Admin users in the Model Editor using a YAML-based scripting language.- Open the Model Editor by clicking on Edit/Test besides the model name
Example Model
Editing models
Saving the model updates its version. New model versions do not affect the calculations of past accounting batches, only new calculations run after the version has been created.Defining new nodes
Nodes can be added to the model to represent specific variables in the accounting equations. Each node can:- Receive a value from a data source (data_point_type)
- Use a constant/mapped value from a library, or
- Have its value calculated from child nodes through the defined operator
Units
Units are not always required to be defined on nodes, but are very helpful for legibility especially when data is run through operator expressions. Useoutput_unit
to define the expected result unit:
Example with units
See Reference below: units have to conform to the supported syntax from the Unitwise library. Mismatched units between inputs on the same tier of nodes can result in errors unless explicitly converted upstream.
Testing models
Models can be tested by running them with a set of inputs to confirm the calculations. How to test the models:- Open the Model Editor by clicking on Edit/Test besides the model name
- Switch to Test Model
- Define a time range (this is necessary for certain calculations that consider duration), enter values for the model’s required inputs, and Run Test
- Review the output calculations in the Console
Reference
Below is the full list of fields that can be configured on nodes within a model.Name of the variable
output_unit
Unit. We use the Unitwise library to interpret units. Here’s a list of library-supported units.
ghg
Specifies whether the values of that node represent a type of GHG calculation. Possible values:
co2e
order
Specifies the node’s order in the parent node’s equation
nexus_nodes_attributes
Defines a new tier of child nodes.
data_point_type
Specifies the datapoint slug that the nodes is associated with, defining the node as either an input node that expects incoming data, or an input node tied to a Static Input.
operator
Operation performed on the child nodes.
Operator | Function |
---|---|
Keisan expressions | Expressions supported by the Keisan Ruby library are acceptable. A list can be found here. |
summation | Sums all child node values |
difference | Subtracts subsequent values from the first. Child nodes have to be set in the right order . |
product | Multiplies all child node values |
quotient | Divides subsequent values from the first. Child nodes have to be set in the right order . |
max | Finds the maximum value across all child node values |
min | Finds the minimum value across all child node values |
average | Finds the average of all child node values |
count | |
duration | Special operator used to convert the time range of the incoming datapoint into a duration |
map | Maps a value from an linked library |
constant
Sets a constant value on the node.
If set to
false
, the node’s computation behaviour will change such that it will always return an array in which the computation is applied to each element of the input. If the node is using data points as input, the array will have the same length as the number of data points found for that data flow. If the node is using multiple child nodes as input, the operator is applied piece-wise across each child’s output array to derive one output array.