Skip to content

Assemble hourly reserve requirements

Build a table of hourly requirements for one reserve component and two solve years. You will prepare compatible quantities, match them to product fractions, and fill a complete output grid. The result contains six rows, including zeros for a missing hour and a year with no observations.

Core supports the operations in the table mapping reference. The mapping in the repository runs through assemble_tables or the optional build_system(..., table_mapping_path=...) path. The seven inputs in this guide are prepared tables, so reading native files is a separate step.

The example uses ReEDS reserve policy. The operations are ordinary table operations, and the same quantity/factor structure applies to other applications. You do not need to write a custom reserve handler.

The conformance contract defines the exact format for both handwritten and generated mappings. In this example, the parser consumes the table named reserve_requirement_rows. Keep that exact name on its single table record, even if you rename intermediate tables for your application.

Start with the seven prepared tables below. File reading, profile reshaping, component naming, and calendar creation are upstream work. This tutorial begins with their named table results, not with paths to native ReEDS files.

Use these application configuration values:

BindingValue
primary_weather_year2012
solve_year_rows[{"solve_year": 2032}, {"solve_year": 2040}]

Placeholders for whole values preserve their type. Although written as JSON strings, "{primary_weather_year}" resolves to an integer and "{solve_year_rows}" resolves to a list of records, not text containing JSON. In the rows constructor, "values": "{solve_year_rows}" therefore supplies [{"solve_year": 2032}, {"solve_year": 2040}] as the values array.

Names and categories are strings, years are int64, and quantities and fractions are float64. Timestamps are datetime values. They are displayed as text below. The fractions are finite and not null, and the product name is unique.

reserve_hierarchy maps the input region to its transmission region:

regiontransmission_region
p1controlled

load_profile_rows contains two hours of load:

regionsolve_yeardatetimeweather_yearvalue
p120322012-01-01 00:00201210.0
p120322012-01-01 01:00201210.0

renewable_values contains already scaled generation and capacity factors:

regionsolve_yeardatetimecategoryvaluecapacity_factor
p120322012-01-01 00:00wind20.00.2
p120322012-01-01 01:00wind0.00.0
p120322012-01-01 00:00solar0.00.0
p120322012-01-01 01:00solar100.00.5

generator_owners contains installed capacity. The 200 MW solar owner has the profile above. The 300 MW solar owner has no profile. Owner identifiers are omitted here because this calculation groups by region and year.

regionsolve_yearcategorycapacity
p12032wind100.0
p12032solar200.0
p12032solar300.0

reserve_products contains the calculation fractions:

reserve_typeload_fractionwind_fractionsolar_fraction
SPINNING0.30.10.2

reserve_component_rows identifies the existing component that will own the requirement time series:

nametransmission_regionreserve_type
controlled_SPINNINGcontrolledSPINNING

calendar contains three hourly datetime values: 2012-01-01 00:00, 2012-01-01 01:00, and 2012-01-01 02:00. The last hour has no observations. Keep it in the calendar so the output can include it.

Define reserve_load_quantities from load_profile_rows. Join reserve_hierarchy on region, filter weather_year using {primary_weather_year}, and sum value by transmission region, solve year, and datetime. Name the sum quantity_mw.

Use the table record’s final columns map to retain the keys and quantity, and add the literal kind = "load". This map runs after operations. Its keys name output fields. A string value copies a source column, while {"value": "load"} supplies literal text.

Inside an operation, columns has that operation’s meaning. It can list the fields from the right table to include in a join, or the keys to group by. It is not the map that defines the final output columns.

The resulting table has these five columns:

ColumnType
datetimedatetime
kindstring
quantity_mwfloat64
solve_yearint64
transmission_regionstring

Expect 10 MW at each of the first two hours for controlled, 2032. The hierarchy join runs before the filter because that is their order in operations.

Define reserve_wind_quantities from renewable_values. Join the hierarchy, keep category = "wind", and sum value over the same hourly keys. Project the same five columns and use the literal kind = "wind".

Expect 20 MW at midnight and 0 MW at 01:00. Do not multiply value by installed capacity again, because the prepared source already contains generation in MW.

Define reserve_solar_capacity from generator_owners. Join the hierarchy, keep solar owners, and sum capacity by transmission region and solve year into quantity_mw. This table has no hourly key.

Expect one 500 MW row for controlled, 2032. Include the owner without a profile. Restricting capacity to owners found in renewable_values would incorrectly produce 200 MW.

Define reserve_solar_quantities from renewable_values. Join the hierarchy, keep solar rows, and calculate the maximum capacity_factor for each combination of transmission_region, solve_year, and datetime. Name that aggregate max_cf.

Filter max_cf with greater_than and value zero. Join the retained hours to reserve_solar_capacity on transmission region and solve year. Project the five quantity columns and add the literal kind = "solar".

Expect one 500 MW quantity at 01:00 and no solar row at midnight. The capacity factor selects active hours. It does not scale the installed capacity. The quantity is therefore 500 MW, not 250 MW or the 100 MW generation value.

This requirement policy is separate from eligibility to provide reserve. Excluding solar from provider membership does not remove its contribution to requirements.

Define reserve_factors from reserve_products. Keep reserve_type as the unpivot identifier. Map the three fraction columns to the labels load, wind, and solar, using kind for the label column and fraction for the value.

Expect these rows:

reserve_typekindfraction
SPINNINGload0.3
SPINNINGsolar0.2
SPINNINGwind0.1

"load": "load_fraction" maps the output label to its input column explicitly. There is no suffix stripping. Additional product metadata does not become a factor. Calculation fractions are distinct from component metadata such as or_load_percentage, or_wind_percentage, and or_pv_percentage.

Define reserve_quantities with a concat operation listing load, wind, and solar quantity tables in that order. Omit source, because concat constructs the starting table.

Expect five rows for controlled, 2032:

datetimekindquantity_mw
2012-01-01 00:00load10.0
2012-01-01 01:00load10.0
2012-01-01 00:00wind20.0
2012-01-01 01:00wind0.0
2012-01-01 01:00solar500.0

The displayed rows also retain transmission_region and solve_year. There is no solar row at midnight and no quantity row at 02:00. Concatenation appends rows without matching or aggregating them.

7. Calculate each product’s contributions

Section titled “7. Calculate each product’s contributions”

Define reserve_contributions from reserve_quantities. Inner join reserve_factors on kind, retaining reserve_type and fraction from the right side. Multiply quantity_mw by fraction into contribution.

Before grouping, expect:

datetimekindquantity_mwfractioncontribution
2012-01-01 00:00load10.00.33.0
2012-01-01 01:00load10.00.33.0
2012-01-01 00:00wind20.00.12.0
2012-01-01 01:00wind0.00.10.0
2012-01-01 01:00solar500.00.2100.0

Now group by transmission region, reserve type, solve year, and datetime, and sum contribution. Expect totals of 5 MW and 103 MW. Keep reserve_type in the group so additional products have separate totals.

You can check the 01:00 arithmetic independently. This Python example checks the numbers, not execution of the JSON. Decimal arithmetic is used only to display an exact result.

>>> from decimal import Decimal
>>> quantities: dict[str, Decimal] = {
... "load": Decimal("10"), "wind": Decimal("0"), "solar": Decimal("500")
... }
>>> fractions: dict[str, Decimal] = {
... "solar": Decimal("0.2"), "load": Decimal("0.3"), "wind": Decimal("0.1")
... }
>>> contributions: list[Decimal] = [
... amount * fractions[kind] for kind, amount in quantities.items()
... ]
>>> contributions
# [Decimal('3.0'), Decimal('0.0'), Decimal('100.0')]
>>> sum(contributions)
# Decimal('103.0')

Define solve_years with a rows constructor. Declare an int64 solve_year column and use {solve_year_rows} for its records.

Expect two rows, 2032 and 2040. The requested years come from configuration, not from the observations. Keep 2040 even though no quantities exist for that year.

Define reserve_requirement_rows from reserve_component_rows. Cross join solve_years, then the datetime column of calendar. One component, two years, and three hours give six grid rows.

Left join reserve_contributions on all four matching keys: transmission region, reserve type, solve year, and datetime. Fill a null contribution with zero. Sort by name, solve_year, and datetime.

Finally, project datetime, name, solve_year, and requirement, copying contribution into requirement. Expect:

datetimenamerequirementsolve_year
2012-01-01 00:00controlled_SPINNING5.02032
2012-01-01 01:00controlled_SPINNING103.02032
2012-01-01 02:00controlled_SPINNING0.02032
2012-01-01 00:00controlled_SPINNING0.02040
2012-01-01 01:00controlled_SPINNING0.02040
2012-01-01 02:00controlled_SPINNING0.02040

Notice that datetime stays on the weather year calendar. The solve year is a separate field. Missing observations do not remove grid rows.

Place the nine records in dependency order in table_mapping.json. The seven prepared sources must be available before these records. This is the complete configuration for the calculation above:

[
{
"columns": {
"datetime": "datetime",
"kind": {
"value": "load"
},
"quantity_mw": "quantity_mw",
"solve_year": "solve_year",
"transmission_region": "transmission_region"
},
"name": "reserve_load_quantities",
"operations": [
{
"how": "inner",
"on": [
"region"
],
"operation": "join",
"source": "reserve_hierarchy"
},
{
"column": "weather_year",
"comparison": "equals",
"operation": "filter",
"value": "{primary_weather_year}"
},
{
"aggregate": [
{
"column": "value",
"operation": "sum",
"output": "quantity_mw"
}
],
"columns": [
"transmission_region",
"solve_year",
"datetime"
],
"operation": "group_by"
}
],
"source": "load_profile_rows"
},
{
"columns": {
"datetime": "datetime",
"kind": {
"value": "wind"
},
"quantity_mw": "quantity_mw",
"solve_year": "solve_year",
"transmission_region": "transmission_region"
},
"name": "reserve_wind_quantities",
"operations": [
{
"how": "inner",
"on": [
"region"
],
"operation": "join",
"source": "reserve_hierarchy"
},
{
"column": "category",
"comparison": "equals",
"operation": "filter",
"value": "wind"
},
{
"aggregate": [
{
"column": "value",
"operation": "sum",
"output": "quantity_mw"
}
],
"columns": [
"transmission_region",
"solve_year",
"datetime"
],
"operation": "group_by"
}
],
"source": "renewable_values"
},
{
"name": "reserve_solar_capacity",
"operations": [
{
"how": "inner",
"on": [
"region"
],
"operation": "join",
"source": "reserve_hierarchy"
},
{
"column": "category",
"comparison": "equals",
"operation": "filter",
"value": "solar"
},
{
"aggregate": [
{
"column": "capacity",
"operation": "sum",
"output": "quantity_mw"
}
],
"columns": [
"transmission_region",
"solve_year"
],
"operation": "group_by"
}
],
"source": "generator_owners"
},
{
"columns": {
"datetime": "datetime",
"kind": {
"value": "solar"
},
"quantity_mw": "quantity_mw",
"solve_year": "solve_year",
"transmission_region": "transmission_region"
},
"name": "reserve_solar_quantities",
"operations": [
{
"how": "inner",
"on": [
"region"
],
"operation": "join",
"source": "reserve_hierarchy"
},
{
"column": "category",
"comparison": "equals",
"operation": "filter",
"value": "solar"
},
{
"aggregate": [
{
"column": "capacity_factor",
"operation": "max",
"output": "max_cf"
}
],
"columns": [
"transmission_region",
"solve_year",
"datetime"
],
"operation": "group_by"
},
{
"column": "max_cf",
"comparison": "greater_than",
"operation": "filter",
"value": 0
},
{
"columns": [
"quantity_mw"
],
"how": "inner",
"on": [
"transmission_region",
"solve_year"
],
"operation": "join",
"source": "reserve_solar_capacity"
}
],
"source": "renewable_values"
},
{
"name": "reserve_factors",
"operations": [
{
"columns": {
"load": "load_fraction",
"solar": "solar_fraction",
"wind": "wind_fraction"
},
"index": [
"reserve_type"
],
"operation": "unpivot",
"value_name": "fraction",
"variable_name": "kind"
}
],
"source": "reserve_products"
},
{
"name": "reserve_quantities",
"operations": [
{
"operation": "concat",
"sources": [
"reserve_load_quantities",
"reserve_wind_quantities",
"reserve_solar_quantities"
]
}
]
},
{
"name": "reserve_contributions",
"operations": [
{
"columns": [
"reserve_type",
"fraction"
],
"how": "inner",
"on": [
"kind"
],
"operation": "join",
"source": "reserve_factors"
},
{
"columns": [
"quantity_mw",
"fraction"
],
"operation": "multiply",
"output": "contribution"
},
{
"aggregate": [
{
"column": "contribution",
"operation": "sum",
"output": "contribution"
}
],
"columns": [
"transmission_region",
"reserve_type",
"solve_year",
"datetime"
],
"operation": "group_by"
}
],
"source": "reserve_quantities"
},
{
"name": "solve_years",
"operations": [
{
"operation": "rows",
"schema": [
{
"dtype": "int64",
"name": "solve_year"
}
],
"values": "{solve_year_rows}"
}
]
},
{
"columns": {
"datetime": "datetime",
"name": "name",
"requirement": "contribution",
"solve_year": "solve_year"
},
"name": "reserve_requirement_rows",
"operations": [
{
"how": "cross",
"operation": "join",
"source": "solve_years"
},
{
"columns": [
"datetime"
],
"how": "cross",
"operation": "join",
"source": "calendar"
},
{
"columns": [
"contribution"
],
"how": "left",
"on": [
"transmission_region",
"reserve_type",
"solve_year",
"datetime"
],
"operation": "join",
"source": "reserve_contributions"
},
{
"columns": [
"contribution"
],
"operation": "fill_null",
"value": 0
},
{
"columns": [
"name",
"solve_year",
"datetime"
],
"operation": "sort"
}
],
"source": "reserve_component_rows"
}
]

Add the following time series instruction to the list in parser_rules.json, not to the nine table records in table_mapping.json. The reserve component must already exist when this instruction attaches its series:

{
"kind": "time_series",
"source": "reserve_requirement_rows",
"name": "requirement",
"values": "requirement",
"time_axis": {
"kind": "column",
"column": "datetime",
"resolution_seconds": 3600
},
"metadata": {"weather_year": "{primary_weather_year}"},
"metadata_columns": {"solve_year": "solve_year"},
"skip_if_empty": true,
"owners": [{"component_type": "ReEDSReserve", "name_field": "name"}]
}

ReEDSReserve is the application’s model. The source table’s name column identifies the owner through owners[].name_field. The instruction’s "name": "requirement" names the attached time series. Its values field selects the source table’s requirement column, and solve_year partitions the samples into separate metadata groups. The three hourly samples give each group a regular time axis. skip_if_empty controls an empty source, not invalid nonempty data. See Attach time series for that contract.

To add a product, contributor, or coefficient that changes by year, use the guides to adapt table mappings. For exact operation fields, defaults, and null behavior, use the table mapping reference.