Input Aggregations
Input aggregations are SQL-derived summary views of your input data. They display as a secondary chart below the main forecast chart in the pd4castr UI, giving you visibility into the input conditions that drove a particular forecast.
How Aggregations Execute
Aggregation queries run against model input files after a run is triggered. The results are stored alongside the forecast output and served in the pd4castr UI as supplementary charts.
Configuration
Define input aggregations in the inputAggregations array in
.pd4castrrc.json:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the aggregation chart. |
query | string | Yes | Path to a SQL file containing a query that aggregates the input data. |
description | string | No | Tooltip text shown in the platform when hovering over the chart title. |
colours | string[] | No | Array of hex colour strings for chart series. |
Here’s a configuration that shows demand and generation as secondary charts:
{
"inputAggregations": [
{
"name": "Native Demand",
"query": "queries/input-aggregations/native-demand.sql",
"description": "...",
"colours": ["#008000", "#009900", "#00B300", "#00CC00", "#00E600"]
},
{
"name": "Solar & Wind",
"query": "queries/input-aggregations/solar-wind.sql",
"description": "...",
"colours": ["#008000", "#009900", "#00B300", "#00CC00", "#00E600"]
}
]
}The SQL file at queries/input-aggregations/native-demand.sql might look like
this:
SELECT
data_timestamp AS "datetime",
region AS category_name,
'Solar & Wind' AS input_name,
(solar_generation + wind_generation) AS "value"
FROM input_dataWhere the data in the table named input_data in this case would correspond to
an input with the key of input_data.
Your query must return a table with the following columns:
| Column | Type | Description |
|---|---|---|
datetime | timestamp | The timestamp of the data. |
category_name | string | The name of the category. This is used to group the data into a chart series. |
input_name | string | The name of the input. This is used to label the chart series. |
value | float | The value of the input. |
Next Steps
- See the Configuration file reference for all aggregation fields.
- Learn about Testing your model to validate your model before publishing.