close all
clear all

stn = {'KSLC',          'QO2',     };
id  = {'Salt Lake City','Ogden',};
data = {};
loc = {};

for i = 1:length(stn)

disp(stn(i))
    
temp = webread(char(strcat('http://api.mesowest.net/v2/stations/', ...
    'timeseries?stid=',stn(i),'&start=201312080000&end=201312210000', ...
    '&token=1234567890')));

data_temp = {temp.STATION.OBSERVATIONS.date_time, ...
    temp.STATION.OBSERVATIONS.air_temp_set_1};

data = [data; data_temp];

loc = [loc; {temp.STATION.LATITUDE, temp.STATION.LONGITUDE}];

end

%%

time_stn = data(:,1);
temp_stn = data(:,2);

time_temp = [time_stn{1}];

for i = 1:length(time_temp)
    time_slc(i) = strcat(time_temp{i}(1:10),{' '},time_temp{i}(12:19));
end

time_temp = [time_stn{2}];

for i = 1:length(time_temp)
    time_ogd(i) = strcat(time_temp{i}(1:10),{' '},time_temp{i}(12:19));
end

%%

data_model_slc = importdata('/uufs/chpc.utah.edu/common/home/horel-group3/horel_data/cfoster/wrf_daq_runs/dec2013/time_series/SLC.d03.TS',' ',1);

time_model_slc = (data_model_slc.data(:,2) ./ 24) + datenum('2013-12-08 00:00:00');
temp_model_slc = data_model_slc.data(:,6) - 273.16;

data_model_ogd = importdata('/uufs/chpc.utah.edu/common/home/horel-group3/horel_data/cfoster/wrf_daq_runs/dec2013/time_series/QO2.d03.TS',' ',1);

time_model_ogd = (data_model_ogd.data(:,2) ./ 24) + datenum('2013-12-08 00:00:00');
temp_model_ogd = data_model_ogd.data(:,6) - 273.16;

%%

figure('Position',[100, 100, 1400, 800])

subplot(2,1,1)
plot(datenum(time_slc),cell2mat(temp_stn(1)),'k','LineWidth',1.5)
hold on
plot(time_model_slc,temp_model_slc,'b','LineWidth',1.5)
axis([min(time_model_slc) max(time_model_slc) -20 5])
set(gca,'XTick',[min(time_model_slc):1:max(time_model_slc)])
set(gca,'XTickLabel','')
title('Salt Lake City')
legend('Salt Lake City','Model','location','southeast')

subplot(2,1,2)
plot(datenum(time_ogd),cell2mat(temp_stn(2)),'k','LineWidth',1.5)
hold on
plot(time_model_ogd,temp_model_ogd,'b','LineWidth',1.5)
datetick('x','mm/dd')
axis([min(time_model_ogd) max(time_model_ogd) -20 5])
xlabel('Date (Ticks at 00 UTC)')
title('Ogden')
legend('Ogden','Model','location','southeast')

%%

figure(2)
compare(cell2mat(temp_stn(1)),temp_model_slc)

%%
close all

dh = 720; % Times steps in an hour in model time series data

hour_ogd_model_temp = [temp_model_ogd(dh:dh:end)];
hour_ogd_statn_temp = [cell2mat(temp_stn(2))];
hour_ogd_statn_temp = [hour_ogd_statn_temp(1:4:end)];

%%

for i = [ds:ds:length(temp_model_slc)]
    
   


