function [t, data] = golem_data(shot, diagNAME,diagPATH)
% Simple interface for GOLEM database
% Use: [t, data] = golem_data(10011, 'loop_voltage')
% plot(t, data)
% t - time vector Nx1
% data - data
if nargin<=2
diagPATH='/Diagnostics/BasicDiagnostics/Results';
end
% initate output data
t = 0; data=[];
% initiate remote url path
baseURL='http://golem.fjfi.cvut.cz/shots/';
% initate the temporary file where to temporary save data
local_file = 'data_loc';
% full path of the remote URL link to data
remote_file = [baseURL, int2str(shot),diagPATH '/' diagNAME];
% Access data: write them in local_file
try
urlwrite(remote_file, local_file);
catch me
disp('No path found to data');
return
end
% Load the temporary file
if exist(local_file)
try
data = load(local_file,'\t');
eval(['! rm ' local_file])
catch error
disp(['Missing diagnostic ', diagn, ' in shot ', num2str(shot)])
return
end
else
disp(['Missing diagnostic ', diagn, ' in shot ', num2str(shot)])
t=[];
data=[];
return
end
% extract data files
if length(data)==1
t=data;
else
t=data(:,1);
data=data(:,2);
end