function json_flux

x = [];
time_vector = [];
time_vector_test = [];
cev = {};

fname = 'xrays-7-day.json'; 
fid = fopen(fname); 
raw = fread(fid,inf); 
str = char(raw'); 
fclose(fid); 
val = jsondecode(str)

x = [x,val.observed_flux];

%time_stamp=datenum(val.time_tag, 'yyyy-mm-ddTHH:MM:SS');
%time_vector = [time_vector time_stamp]
time_vector = [time_vector, val.time_tag];

newStr = split(time_vector,'Z');

for u=1:length(newStr)-1
    time_stamp(u)=datenum(newStr(u), 'yyyy-mm-ddTHH:MM:SS');
end


Aodd = x(1:2:end);          % Odd-Indexed Elements, 0.05-0.4nm
Aeven = x(2:2:end);         % Even-Indexed Elements, 0.1-0.8nm

Aodd_time = time_stamp(1:2:end);


% Flare time
flare_start=datenum('202207041320','yyyymmddHHMM')
flare_stop=datenum('202207041345','yyyymmddHHMM')



figure(1)
plot(Aodd_time,Aodd)
hold on;
plot(Aodd_time,Aeven,'r')
set(gca, 'YScale', 'log')
%axis([-Inf Inf 10^-9 10^-2])
%datetick('x', 'yyyymmddHHMM')
axis([flare_start flare_stop 10^-9 10^-2])
%datetick('x', 'yyyymmddHHMM')
datetick('x','HH:MM', 'keepticks', 'keeplimits');
legend('0.05-0.4 nm','0.1-0.8 nm')
xlabel('Time (HH:MM)')
ylabel('Watts m^{-2}')
set(gca,'fontsize', 32)



