# Portfolio Solar Production

## Problem description¶

Sometimes especially Energy traders are interested only in production of the whole portfolio of the PV plants. In forecasting production of a portfolio of PV plants we should consider 2 scenarios:

1. production of each PV plant is available and production of the whole portfolio is sum of individual productions: In this case we recommend creating model for each power plant and portfolio using recommended data as discussed previously in section ‘Single asset solar production forecasting’ and forecasts of these models sum up to forecast of the portfolio. Our experiments showed, that in this way you can get best accuracy out of TIM. Also, it makes it easy to consider scheduled maintenance of specific PV plants on total portfolio production (just do not add forecasted production of the plant that is being maintained).
2. only production of the whole portfolio is available: In this case the key is to find an appropriate GPS coordinates that represent portfolio the best. This task doesn’t have an exact solution, therefore knowledge of the PV plants in portfolio is required. We recommend to take into account distances between individual PV plants and their installed capacities and try out different sets of GPS coordinates. Our best practice in finding GPS coordinates for meteo data is to do clustering on locations of PV plants weighted by their installed capacity. Centroids of these clusters we use as our GPS coordinates for meteo data. However, the number of clusters that get best results is still the question.

## Data Recommendation Template¶

For each chosen GPS coordinate obtain meteorological predictors Gobal Horizontal Irradiance (GHI), Direct Normal Irradiance (DNI), Diffuse Irradiace (DIF), Temperature (TEMP), Sun Elevation (SE) and Sun Azimuth (SA) as described previously in section ‘Single asset solar production forecasting’.

## TIM Setup¶

TIM requires no setup of TIMs mathematical internals and works well in business user mode. All that is required from a user is to let TIM know a forecasting routine and desired prediction horizon. TIM can automatically learn that there is no weekly pattern, in some cases, however, (e.g. short datasets) it can be difficult to learn this and therefore we recommend switching off the WeekRest dictionary.

## Demo example¶

Dataset used in this example is assembled from an individual PV plant in Central Europe. It has hourly sampling rate and contains data from 2015-01-01 to 2016-06-30. Timestamp is in UTC+01:00 timezone and each value of the timestamp is the beginning of the period it corresponds to i.e. 'PV_obs' in the row with timestamp 2015-01-01 00:00:00 corresponds to production of PV plant during the period between 2015-01-01 00:00:00 and 2015-01-01 01:00:00. Prepared dataset can be downloaded here.

### Target¶

Target variable represents production of the PV plant. It is the second column in CSV file, right after column with timestamps. In this case name of the target is 'PV_obs'.

### Predictor candidates¶

As meteo predictors we use GHI, DNI, DIF, TEMP, SA and SE, as discussed in section 'Data Recommendation Template'. In this demo we use historical actuals for both model building and out-of-sample forecasting.

### Forecasting scenario¶

In this example we simulate day-ahead scenario. Each hour at 13th minute we want to have forecasts for each hour from 2 hours ahead until the end of the next day. Target named Energy is updated with a delay of one sample (at 10:15 only until 10:00 i.e. sample corresponding to hour 09:00). It is updated at fifth minute of each hour. Values of meteo predictors are updated each hour for the entire forecasting horizon.

### Model building and validation¶

Model is built using a range of 2015-01-01 00:00:00 - 2015-12-31 23:00:00. Out-of-sample forecasts are made on range 2016-01-01 00:00:00 - 2016-06-30 23:00:00. In this demo dataset, out-of-sample validation is performed using historical actuals of meteorological data. More representative validation may be obtained by using historical forecasts of meteorological data instead.

### Demonstration¶

#### TIM Studio¶

This section covers the use of TIM Studio to solve the challenge described above. Additional information regarding TIM Studio can be found here.

##### Select workspace¶

In the Workspaces screen, select the workspace in which the dataset should be added. If there is no available workspace, create one by clicking "Add Workspace". In this solution template, the workspace called "TIM Solution Templates" is used.

In the Datasets screen click on Add New Dataset. Stay in the tab CSV-File and insert name of the dataset. In this example, the dataset is called Solar_portfolio. Click "Browse" and select the dataset from the computer. Click "Add Dataset" to confirm.

##### Model building definition¶

Go to the Model Building Definition screen in the panel on the left. Click "Add New Definition" and fill in the desired definition name. In this demo, the MBD is called Solar_portfolio day-ahead. In the next screen, select the dataset that was previously uploaded (Solar_portfolio).

In step 2, define the desired forecasting scenario. In this example, the model is used repeatedly each hour at 13th minute. Therefore, leave all Weekdays ranges checked on. Then, set Hour ranges to All Minutes ranges to 13 and Seconds ranges to 0. Look into the section about the Cron notation for more details. Since forecasts are to be made starting two hours ahead until one day ahead, set "Forecast from" to Sample with offset 2 and set "Forecast to" to Day with offset 1. Look into the section about the relative time notation to learn more about this.

Click "Next" to advance to the next step. It is also possible to already finalize all settings at this point, in which case everything else would be set up automatically. In this example, some more changes will be made to the data updates in the third step. The target variable, PV_obs, is updated each hour at 5th minute. Click on the small arrow next to PV_obs and change the settings of this variable. Leave all Weekdays ranges checked on. Set Hour ranges to All Minutes ranges to 5 and Seconds ranges to 0. Then, set "Update until" to Sample with offset -1, since the target variable is updated until the end of previous hour.

Similar setting of data updates is needed also for all predictors. Predictors are updated at the same time as target, therefore, set the "Update when" same as for target variable. Leave the "Update until" setting at Day with offset 1 since they are updated until the end of the next day.

Click "Next" to advance to step 4. Here, training regions can be selected. Since the goal is to move on to back-testing, this screen will be left in its default settings (i.e. Use All Data). Click "Next" to advance to the next screen.

In this fifth step, the mathematical settings can be changed. We can leave it in default configuration and click "Finalize" to complete the model building definition.

##### Experiments¶

Click "Experiments" in the panel on the left to move on to back-testing. Then, click "Make experiment" next to the correct model building definition (Solar_portfolio day-ahead).

Click "Build Model" and select the appropriate training range, i.e. 2015-01-01 00:00:00 - 2015-12-31 23:00:00.

The in-sample prediction as well as the Model Tree Map become visible.

Click "Validate model" and select the correct Out-of-sample period for back-testing, i.e. 2016-01-01 00:00:00 - 2016-06-30 23:00:00.

This generates the aggregated forecasts for D+0 and D+1.

#### TIM Connector¶

This section covers the use of TIM Connector to solve the challenge described above. Additional information regarding TIM Connector can be found in the respective section.

##### 2. Create folder with dataset¶

Create folder e.g. TIM_Datasets which contains dataset folder (Solar_portfolio) with the dataset file [data.csv] and the configuration file [conf.yaml].

TIM_Datasets/Solar_portfolio/ data.csv conf.yaml

The YAML configuration file defines the forecasting scenario described above.

Model building: Model building considers the range 2015-01-01 00:00:00 - 2015-12-31 23:00:00. Target named Energy is updated at fifth minute of each hour with delay of one sample. All predictors are updated each hour for the entire forecasting horizon. We do not have to specify data updates for predictors in the configuration file as this is the default setting.

Configuration: Model is used repeatedly each hour at 13th minute. Forecasts are made from two hours ahead until the end of next day.

Forecasting: Out-of-sample forecasts are made for the range 2016-01-01 00:00:00 - 2016-06-30 23:00:00.

The content of the exemplary YAML configuration file is shown below:

version: "1.0"
type: Forecasting

modelBuilding:
data:
rows:
- from: 2015-01-01 00:00:00
to:   2015-12-31 23:00:00
- uniqueName: PV_obs
updateUntil:
baseUnit: Sample
offset: -1
updateTime:
- type: Day
value: "*"
- type: Hour
value: "*"
- type: Minute
value: "5"
configuration:
usage:
usageType: Repeating
usageTime:
- type: Day
value: "*"
- type: Hour
value: "*"
- type: Minute
value: "13"
predictionFrom:
baseUnit: Sample
offset: 2
predictionTo:
baseUnit: Day
offset: 1
forecasting:
configuration:
predictionScope:
type: Ranges
ranges:
- from: 2016-01-01 00:00:00
to:   2016-06-30 23:00:00

##### 3. Call connector from the command line¶

Using a terminal, change the current directory to TIM Connector's builddir with the command: > cd pathToConnector\builddir. Then, call the connector with the following command: > pathToConnector\timconnect.exe path\to\TIM_Datasets`.

##### 4. Fill in user credentials¶

Following the previous command, the user will be prompted to fill in their user credentials. Fill in the correct information and click "OK" to continue.

Output in console:

Output in folder: Predictions Report/timeStamp/conf/prediction.csv Errors Report/timeStamp/conf/accuracy.txt The following accuracies were reported by TIM: Model building stage: RMSE = 2.14, MAE = 0.79
Validation stage: RMSE = 1.61, MAE = 0.82