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. I.e. "SumHourly(vom, egen)". See Sum, SumHourly, SumYearly, AverageYearly, MinHourly. Note that the columns here can either be column names or variable names stored with data, like dam_co2
    • 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.

If any result is computed to be NaN, returns 0.0 instead, so that the NaN does not "infect" other results.

source

Result Aggregation Functions

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.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)}}\]

source
E4ST.MinYearlyType
MinYearly(cols...) <: Function

This function returns the minimum yearly value.

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

source
E4ST.MaxYearlyType
MaxYearly(cols...) <: Function

This function returns the maximum yearly value.

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

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.SumHourlyWeightedType
SumHourlyWeighted(cols...) <: Function

This is a function that adds up the product of each of the values given to it times the hour weight 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}} w_{h} \prod_{c \in \text{cols}} \text{table}[i, c][y, h]\]

source
E4ST.AverageHourlyType
AverageHourly(cols...) <: Function

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

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

source
E4ST.AverageHourlyWeightedType
AverageHourlyWeighted(cols...) <: Function

Function used in results formulas. Computes the sum of the products of the columns for each index in idxs for each year and hour weighted by the number of hours, divided by the total number of hours.

\[\frac{\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]}{\sum_{y \in \text{yr\_idxs}}\sum{h \in \text{hr\_idxs}} w_{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.MaxHourlyType
MaxHourly(cols...) <: Function

This function returns the maximum aggregated hourly value. Sums up all values for that hour over the given idxs, then takes the maximum. Suited for results like load where you want to know the maximum of the regional load.

\[\max_{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.SumMinHourlyType
SumMinHourly(cols...) <: Function

This function returns the sum of each of the minimum hourly values.

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

source
E4ST.SumMaxHourlyType
SumMaxHourly(cols...) <: Function

This function returns the sum of each of the maximum hourly values.

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

source
E4ST.CostOfServiceRebateType
CostOfServiceRebate(table_name) <: Function

This is a special function that computes the sum of the net total revenue times the regulatory factor reg_factor. This only works for the gen table and storage table.

source