No BSD License  

Highlights from
Energy Bid Stack Viewer

image thumbnail
from Energy Bid Stack Viewer by Paul Taylor
Energy Bid Stack Viewer for Australian electricity market

energy_bid_stack(varargin)
function varargout = energy_bid_stack(varargin)
% ENERGY_BID_STACK M-file for energy_bid_stack.fig
%      ENERGY_BID_STACK, by itself, creates a new ENERGY_BID_STACK or raises the existing
%      singleton*.
%
%      H = ENERGY_BID_STACK returns the handle to a new ENERGY_BID_STACK or the handle to
%      the existing singleton*.
%
%      ENERGY_BID_STACK('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ENERGY_BID_STACK.M with the given input arguments.
%
%      ENERGY_BID_STACK('Property','Value',...) creates a new ENERGY_BID_STACK or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before energy_bid_stack_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to energy_bid_stack_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help energy_bid_stack

% Last Modified by GUIDE v2.5 15-Sep-2005 15:22:52

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @energy_bid_stack_OpeningFcn, ...
                   'gui_OutputFcn',  @energy_bid_stack_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before energy_bid_stack is made visible.
function energy_bid_stack_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to energy_bid_stack (see VARARGIN)

% Choose default command line output for energy_bid_stack
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes energy_bid_stack wait for user response (see UIRESUME)
% uiwait(handles.figure1);

movegui('center')

% --- Outputs from this function are returned to the command line.
function varargout = energy_bid_stack_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on slider movement.
function scrollLayer_Callback(hObject, eventdata, handles)
% hObject    handle to scrollLayer (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

handles = create_surf(handles);
handles = create_area_plot(handles);
rotate3d(handles.ax3D,'on');

guidata(hObject,handles);


% --- Executes on slider movement.
function scrollDay_Callback(hObject, eventdata, handles)
% hObject    handle to scrollDay (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

if isfield(handles.data,'h_day_area')
    handles.data = rmfield(handles.data,'h_day_area');
end
handles = create_area_plot(handles);
set(handles.data.h_day_slider,'XData',round(repmat(get(handles.scrollDay,'Value'),4,1)));

guidata(hObject,handles);

% --- Executes on button press in cmdGetData.
function cmdGetData_Callback(hObject, eventdata, handles)
% hObject    handle to cmdGetData (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% specify the date range and generator name
DUID_str  = 'MURRAY';
DATE_from = '#01/06/2003#';
DATE_to   = '#30/06/2003#';

% Retrieve the data from the database
[daily_data,period_data] = get_data(DUID_str,DATE_from,DATE_to);

% Construct the data cubes required for the plots
[area_data,disp_dates,price_bands] = build_data(daily_data,period_data);
handles.data.area_data   = area_data;
handles.data.disp_dates  = disp_dates;
handles.data.price_bands = price_bands;

% initialise the screen controls such as scrollbars
layer_len = size(handles.data.area_data,2);
set(handles.scrollLayer,'Max',layer_len);
set(handles.scrollLayer,'Value',layer_len);
set(handles.scrollLayer,'Sliderstep',[1/(layer_len-1)  1/(layer_len-1)]);

day_len = size(handles.data.area_data,3);
set(handles.scrollDay,'Max',day_len);
set(handles.scrollDay,'Sliderstep',[1/(day_len-1)  1/(day_len-1)]);

period_len = size(handles.data.area_data,1);
set(handles.scrollPeriod,'Max',period_len);
set(handles.scrollPeriod,'Sliderstep',[1/(period_len-1)  4*1/(period_len-1)]);

% Create the 3D and 2D plots
handles = create_surf(handles);
rotate3d(handles.ax3D,'on');
create_area_plot(handles);

guidata(hObject,handles);


% --- Executes on slider movement.
function scrollPeriod_Callback(hObject, eventdata, handles)
% hObject    handle to scrollPeriod (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


if isfield(handles.data,'h_period_area')
    handles.data = rmfield(handles.data,'h_period_area');
end
handles = create_area_plot(handles);
set(handles.data.h_period_slider,'YData',round(repmat(get(handles.scrollPeriod,'Value'),4,1)));

guidata(hObject,handles);


% --- Executes on button press in chkShowLayerOnly.
function chkShowLayerOnly_Callback(hObject, eventdata, handles)
% hObject    handle to chkShowLayerOnly (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chkShowLayerOnly

handles = create_surf(handles);
handles = create_area_plot(handles);
rotate3d(handles.ax3D,'on');

guidata(hObject,handles);

Contact us at files@mathworks.com