Code covered by the BSD License  

Highlights from
Electricity Load Forecasting for the Australian Market Case Study

image thumbnail

Electricity Load Forecasting for the Australian Market Case Study



19 Jun 2011 (Updated )

This is a case study of forecasting short-term electricity loads for the Australian market.

genPredictors2(data, term, holidays)
function [X, dates, labels] = genPredictors2(data, term, holidays)
% GENPREDICTORS generates a matrix of predictor variables for the load
% forecasting model. 
% [X, dates, labels] = genPredictors(data, term, holidays)
% Inputs:
% data     : A Dataset array of historical weather and load information
% term     : 'long' or 'short' indicating the horizon of the forecast.
%            Predictors such as previous day load are not included in the 
%            long term forecast.
% holidays : A vector of holidays. If this is not specified, holidays are
%            generated by the function CREATEHOLIDAYDATES
% Outputs:
% X     : A matrix of predictor data where each row corresponds to an
%         observation (hourly load) and each column corresponds to a variable
% dates : A vector of dates for each observation
% labels: A cell array of strings describing each predictor

% Convert Dates into a Numeric Representation
if ~isfield(data,'NumDate')
    dates = datenum(data.Date, 'yyyy-mm-dd HH:MM:SS') + (data.Hour-1)/24;
    dates = data.NumDate;
    if all(floor(dates)==dates) % true if dates don't include any hour information
        dates = dates + (data.Hour-1)/24;

% Process Holidays
if nargin < 3 || isempty(holidays)
    holidays = createHolidayDates(min(dates), max(dates));
    holidays = datenum(holidays,'dd/mm/yyyy');

% Create Predictors

% Short term forecasting inputs
% Lagged load inputs
prevDaySameHourLoad = [NaN(24*2,1); data.SYSLoad(1:end-24*2)];
prevWeekSameHourLoad = [NaN(168*2,1); data.SYSLoad(1:end-168*2)];
prev24HrAveLoad = filter(ones(1,48)/48, 1, data.SYSLoad);

% Date predictors
dayOfWeek = weekday(dates);

% Non-business days
isWorkingDay = ~ismember(floor(dates),holidays) & ~ismember(dayOfWeek,[1 7]);
%[~,~,isWorkingDay] = createHolidayDates(data.NumDate);

if strncmpi(term, 'long', 4);
    % Long Term Forecast Predictors
    X = [data.DryBulb data.DewPnt daily5dayHighAve daily5dayLowAve data.Hour dayOfWeek isWorkingDay];
    labels = {'DryBulb', 'DewPoint', 'Prev5DayHighAve', 'Prev5DayLowAve', 'Hour', 'Weekday', 'IsWorkingDay'};
    % Short Term
    X = [data.DryBulb data.DewPnt data.WetBulb data.Humidity data.Hour dayOfWeek isWorkingDay prevWeekSameHourLoad prevDaySameHourLoad prev24HrAveLoad];
    labels = {'DryBulb', 'DewPoint', 'WetBulb','Humidity','Hour', 'Weekday', 'IsWorkingDay', 'PrevWeekSameHourLoad', 'prevDaySameHourLoad', 'prev24HrAveLoad'};

function y = rep24(x)
y = repmat(x(:), 1, 24)';
y = y(:);

Contact us