Results Formulas

E4ST.jl produces a lot of data to comb through. There are often some complex calculations for welfare that we may want to compute in different ways over different regions without necessarily storing every possible combination of every calculation. The goal of the results formula is to give E4ST a way to calculate different results so that they can be calculated quickly on demand rather than always be calculated for every run. It also provides a way to specify custom result calculations that might not be standard to E4ST.

E4ST.summarize_tableMethod
summarize_table(::Val{:results_formulas})
column_namedata_typeunitrequireddescription
table_nameSymbolE4ST.NAtrueThe name of the table that the result is for.
result_nameSymbolE4ST.NAtrueThe name of the result that the formula is for.
formulaStringE4ST.NAtrueThe string representing the formula for the table. See add_results_formula! for more info on this.
unitType{<:E4ST.Unit}E4ST.NAtrueThe unit for the result.
descriptionStringE4ST.NAtrueA description of the result.
source
E4ST.add_results_formula!Function
add_results_formula!(data, table_name::Symbol, result_name::Symbol, formula::String, unit::Type{<:Unit}, description::String)

Adds a formula that can be used to compute results. See compute_result. This is also used by AggregationTemplate and YearlyTable.

Arguments:

  • data
  • table_name - the name of the table that the result is calculated from, either directly or as a combination of other results
  • result_name - the name of the result being calculated. Cannot be a column name within the table.
  • formula - formula can take two different forms.
    • it can be a combination of columns to be aggregated directly from table_name. See Sum, SumHourly, SumYearly, AverageYearly, MinHourly.
    • it can also be a combination of other results. I.e. (vom_cost + fuel_cost) / egen_total.
  • unit - the Unit of the resulting number
  • description - a short description of the calculation.
source
E4ST.get_results_formulasFunction
get_results_formulas(data)

Returns a dictionary mapping (table_name, result_name) to ResultsFormula.

get_results_formulas(data, table_name)

Returns only the results formulas corresponding to table table_name.

source
E4ST.compute_resultFunction
compute_result(data, table_name, result_name, idxs=(:), yr_idxs=(:), hr_idxs=(:))

Computes result result_name for table table_name for table indexes idxs, year indexes yr_idxs and hour indexes hr_idxs. See add_results_formula! to add other results formulas for computing results.

Note that this will recursively compute results for any derived result, as needed.

source
E4ST.SumType
Sum(cols...) <: Function

Function used in results formulas. Computes the sum of the product of the column for each index in idxs

\[\sum_{i \in \text{idxs}} \prod_{c \in \text{cols}} \text{table}[i, c]\]

source
E4ST.SumYearlyType
SumYearly(cols...) <: Function

Function used in results formulas. This is a function that adds up the product of each of the values given to it for each year given.

\[\sum_{i \in \text{idxs}} \sum_{y \in \text{yr\_idxs}} \prod_{c \in \text{cols}} \text{table}[i, c][y]\]

source
E4ST.SumHourlyType
SumHourly(cols...) <: Function

This is a function that adds up the product of each of the values given to it for each of the years and hours given.

\[\sum_{i \in \text{idxs}} \sum_{y \in \text{yr\_idxs}} \sum_{h \in \text{hr\_idxs}} \prod_{c \in \text{cols}} \text{table}[i, c][y, h]\]

source
E4ST.MinHourlyType
MinHourly(cols...) <: Function

This function returns the minimum hourly value.

\[\min_{y \in \text{yr\_idxs}, h \in \text{hr\_idxs}} \sum_{i \in \text{idxs}} \prod_{c \in \text{cols}} \text{table}[i, c][y, h]\]

source
E4ST.AverageYearlyType
AverageYearly(cols...) <: Function

Function used in results formulas. Computes the sum of the products of the columns for each index in idxs for each year, divided by the number of years.

\[\frac{\sum_{i \in \text{idxs}} \sum_{y \in \text{yr\_idxs}} \prod_{c \in \text{cols}} \text{table}[i, c][y]}{\text{length(yr\_idxs)}}\]

When specifying in a formula, looks like average_yearly(cols...)

source