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:

FieldTypeRequiredDescription
namestringYesDisplay name for the aggregation chart.
querystringYesPath to a SQL file containing a query that aggregates the input data.
descriptionstringNoTooltip text shown in the platform when hovering over the chart title.
coloursstring[]NoArray 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_data

Where 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:

ColumnTypeDescription
datetimetimestampThe timestamp of the data.
category_namestringThe name of the category. This is used to group the data into a chart series.
input_namestringThe name of the input. This is used to label the chart series.
valuefloatThe 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.