clear all;
close all;


%% load domain 3 (1.33km) data and extract temperature
%load WRF output data for Roosevelt

% load ROO13s TS file data for ROO13s and ROO13sd3
ROO13s = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzROO.d03.TS',' ',1);
ROO13sd3_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzROO.d03.TS',' ',1);
VER13s = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzVER.d03.TS',' ',1);
VER13sd3_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzVER.d03.TS',' ',1);
OUR13s = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzOUR.d03.TS',' ',1);
OUR13sd3_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzOUR.d03.TS',' ',1);
MYT13s = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzMYT.d03.TS',' ',1);
MYT13sd3_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzMYT.d03.TS',' ',1);
RED13s = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzRED.d03.TS',' ',1);
RED13sd3_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzRED.d03.TS',' ',1);
HOR13s = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzHOR.d03.TS',' ',1);
HOR13sd3_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzHOR.d03.TS',' ',1);

% Extract temperature data (column 6, once imported)
ROO13sT = ROO13s.data(:,6);
ROO13sd3T_TIN12IAU0T = ROO13sd3_TIN12IAU0T.data(:,6);
VER13sT = VER13s.data(:,6);
VER13sd3T_TIN12IAU0T = VER13sd3_TIN12IAU0T.data(:,6);
OUR13sT = OUR13s.data(:,6);
OUR13sd3T_TIN12IAU0T = OUR13sd3_TIN12IAU0T.data(:,6);
MYT13sT = MYT13s.data(:,6);
MYT13sd3T_TIN12IAU0T = MYT13sd3_TIN12IAU0T.data(:,6);
RED13sT = RED13s.data(:,6);
RED13sd3T_TIN12IAU0T = RED13sd3_TIN12IAU0T.data(:,6);
HOR13sT = HOR13s.data(:,6);
HOR13sd3T_TIN12IAU0T = HOR13sd3_TIN12IAU0T.data(:,6);

%% convert domain 3 data to hourly and celsius 

%WRF data output every timestep (5 seconds for 1.33km domain)
%UU Research Trailer data output every 5 minutes (300 seconds)
%K74V and QRS output every 1 hour (3600 seconds)
%Need to correctly match data due to mismatch in time frequency
%Create array for WRF @ 300 sec freq to match research trailer

% n is interval used to convert data from every 5 sec to hourly
n = 720;

%Build array for hourly data
ROO13sThrly = ROO13sT(n:n:end);
VER13sThrly = VER13sT(n:n:end);
OUR13sThrly = OUR13sT(n:n:end);
MYT13sThrly = MYT13sT(n:n:end);
RED13sThrly = RED13sT(n:n:end);
HOR13sThrly = HOR13sT(n:n:end);

ROO13sd3T_TIN12IAU0Thrly = ROO13sd3T_TIN12IAU0T(n:n:end);
VER13sd3T_TIN12IAU0Thrly = VER13sd3T_TIN12IAU0T(n:n:end);
OUR13sd3T_TIN12IAU0Thrly = OUR13sd3T_TIN12IAU0T(n:n:end);
MYT13sd3T_TIN12IAU0Thrly = MYT13sd3T_TIN12IAU0T(n:n:end);
RED13sd3T_TIN12IAU0Thrly = RED13sd3T_TIN12IAU0T(n:n:end);
HOR13sd3T_TIN12IAU0Thrly = HOR13sd3T_TIN12IAU0T(n:n:end);

%Convert wrfT to from K to deg C         
ROO13sThrly = ROO13sThrly-273.15;
ROO13sd3T_TIN12IAU0Thrly = ROO13sd3T_TIN12IAU0Thrly-273.15;
VER13sThrly = VER13sThrly-273.15;
VER13sd3T_TIN12IAU0Thrly = VER13sd3T_TIN12IAU0Thrly-273.15;
OUR13sThrly = OUR13sThrly-273.15;
OUR13sd3T_TIN12IAU0Thrly = OUR13sd3T_TIN12IAU0Thrly-273.15;
MYT13sThrly = MYT13sThrly-273.15;
MYT13sd3T_TIN12IAU0Thrly = MYT13sd3T_TIN12IAU0Thrly-273.15;
RED13sThrly = RED13sThrly-273.15;
RED13sd3T_TIN12IAU0Thrly = RED13sd3T_TIN12IAU0Thrly-273.15;
HOR13sThrly = HOR13sThrly-273.15;
HOR13sd3T_TIN12IAU0Thrly = HOR13sd3T_TIN12IAU0Thrly-273.15;

% % Define the variables of interest as a cell of strings.  Format must be
% % {'XXX';'YYY'}  The variable names are different lenths which requires
% % the use of a cell.
% vars = {'HOR';'MYT';'OUR';'ROO';'RED';'VER'};

%% load domain 2 (4km) data
%load TS data for each location for each model run
ROO13sd2 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzROO.d02.TS',' ',1);
ROO13sd2_TIN15IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN15IAU0/TS_files/zzROO.d02.TS',' ',1);
ROO13sd2_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzROO.d02.TS',' ',1);
ROO13sd2_TIN3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3/TS_files/zzROO.d02.TS',' ',1);
ROO13sd2_TIN3IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3IAU0/TS_files/zzROO.d02.TS',' ',1);
ROO13sd2_WSM3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_WSM3/TS_files/zzROO.d02.TS',' ',1);
ROO13sd2_TFSCA = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TFSCA/TS_files/zzROO.d02.TS',' ',1);

VER13sd2 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzVER.d02.TS',' ',1);
VER13sd2_TIN15IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN15IAU0/TS_files/zzVER.d02.TS',' ',1);
VER13sd2_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzVER.d02.TS',' ',1);
VER13sd2_TIN3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3/TS_files/zzVER.d02.TS',' ',1);
VER13sd2_TIN3IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3IAU0/TS_files/zzVER.d02.TS',' ',1);
VER13sd2_WSM3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_WSM3/TS_files/zzVER.d02.TS',' ',1);
VER13sd2_TFSCA = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TFSCA/TS_files/zzVER.d02.TS',' ',1);

OUR13sd2 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzOUR.d02.TS',' ',1);
OUR13sd2_TIN15IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN15IAU0/TS_files/zzOUR.d02.TS',' ',1);
OUR13sd2_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzOUR.d02.TS',' ',1);
OUR13sd2_TIN3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3/TS_files/zzOUR.d02.TS',' ',1);
OUR13sd2_TIN3IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3IAU0/TS_files/zzOUR.d02.TS',' ',1);
OUR13sd2_WSM3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_WSM3/TS_files/zzOUR.d02.TS',' ',1);
OUR13sd2_TFSCA = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TFSCA/TS_files/zzOUR.d02.TS',' ',1);

MYT13sd2 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzMYT.d02.TS',' ',1);
MYT13sd2_TIN15IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN15IAU0/TS_files/zzMYT.d02.TS',' ',1);
MYT13sd2_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzMYT.d02.TS',' ',1);
MYT13sd2_TIN3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3/TS_files/zzMYT.d02.TS',' ',1);
MYT13sd2_TIN3IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3IAU0/TS_files/zzMYT.d02.TS',' ',1);
MYT13sd2_WSM3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_WSM3/TS_files/zzMYT.d02.TS',' ',1);
MYT13sd2_TFSCA = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TFSCA/TS_files/zzMYT.d02.TS',' ',1);

RED13sd2 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzRED.d02.TS',' ',1);
RED13sd2_TIN15IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN15IAU0/TS_files/zzRED.d02.TS',' ',1);
RED13sd2_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzRED.d02.TS',' ',1);
RED13sd2_TIN3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3/TS_files/zzRED.d02.TS',' ',1);
RED13sd2_TIN3IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3IAU0/TS_files/zzRED.d02.TS',' ',1);
RED13sd2_WSM3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_WSM3/TS_files/zzRED.d02.TS',' ',1);
RED13sd2_TFSCA = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TFSCA/TS_files/zzRED.d02.TS',' ',1);

HOR13sd2 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_v1/TS_files/zzHOR.d02.TS',' ',1);
HOR13sd2_TIN15IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN15IAU0/TS_files/zzHOR.d02.TS',' ',1);
HOR13sd2_TIN12IAU0T = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN12IAU0T/TS_files/zzHOR.d02.TS',' ',1);
HOR13sd2_TIN3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3/TS_files/zzHOR.d02.TS',' ',1);
HOR13sd2_TIN3IAU0 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TIN3IAU0/TS_files/zzHOR.d02.TS',' ',1);
HOR13sd2_WSM3 = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_WSM3/TS_files/zzHOR.d02.TS',' ',1);
HOR13sd2_TFSCA = importdata('/uufs/chpc.utah.edu/common/home/horel-group2/eneemann/Uintah_Basin_Runs/WRFv3.5/Feb_2013_snow_TFSCA/TS_files/zzHOR.d02.TS',' ',1);


% Extract temperature data (column 6, once imported) for each location/run
ROO13sd2T = ROO13sd2.data(:,6);
ROO13sd2T_TIN15IAU0 = ROO13sd2_TIN15IAU0.data(:,6);
ROO13sd2T_TIN12IAU0T = ROO13sd2_TIN12IAU0T.data(:,6);
ROO13sd2T_TIN3 = ROO13sd2_TIN3.data(:,6);
ROO13sd2T_TIN3IAU0 = ROO13sd2_TIN3IAU0.data(:,6);
ROO13sd2T_WSM3 = ROO13sd2_WSM3.data(:,6);
ROO13sd2T_TFSCA = ROO13sd2_TFSCA.data(:,6);

VER13sd2T = VER13sd2.data(:,6);
VER13sd2T_TIN15IAU0 = VER13sd2_TIN15IAU0.data(:,6);
VER13sd2T_TIN12IAU0T = VER13sd2_TIN12IAU0T.data(:,6);
VER13sd2T_TIN3 = VER13sd2_TIN3.data(:,6);
VER13sd2T_TIN3IAU0 = VER13sd2_TIN3IAU0.data(:,6);
VER13sd2T_WSM3 = VER13sd2_WSM3.data(:,6);
VER13sd2T_TFSCA = VER13sd2_TFSCA.data(:,6);

OUR13sd2T = OUR13sd2.data(:,6);
OUR13sd2T_TIN15IAU0 = OUR13sd2_TIN15IAU0.data(:,6);
OUR13sd2T_TIN12IAU0T = OUR13sd2_TIN12IAU0T.data(:,6);
OUR13sd2T_TIN3 = OUR13sd2_TIN3.data(:,6);
OUR13sd2T_TIN3IAU0 = OUR13sd2_TIN3IAU0.data(:,6);
OUR13sd2T_WSM3 = OUR13sd2_WSM3.data(:,6);
OUR13sd2T_TFSCA = OUR13sd2_TFSCA.data(:,6);

MYT13sd2T = MYT13sd2.data(:,6);
MYT13sd2T_TIN15IAU0 = MYT13sd2_TIN15IAU0.data(:,6);
MYT13sd2T_TIN12IAU0T = MYT13sd2_TIN12IAU0T.data(:,6);
MYT13sd2T_TIN3 = MYT13sd2_TIN3.data(:,6);
MYT13sd2T_TIN3IAU0 = MYT13sd2_TIN3IAU0.data(:,6);
MYT13sd2T_WSM3 = MYT13sd2_WSM3.data(:,6);
MYT13sd2T_TFSCA = MYT13sd2_TFSCA.data(:,6);

RED13sd2T = RED13sd2.data(:,6);
RED13sd2T_TIN15IAU0 = RED13sd2_TIN15IAU0.data(:,6);
RED13sd2T_TIN12IAU0T = RED13sd2_TIN12IAU0T.data(:,6);
RED13sd2T_TIN3 = RED13sd2_TIN3.data(:,6);
RED13sd2T_TIN3IAU0 = RED13sd2_TIN3IAU0.data(:,6);
RED13sd2T_WSM3 = RED13sd2_WSM3.data(:,6);
RED13sd2T_TFSCA = RED13sd2_TFSCA.data(:,6);

HOR13sd2T = HOR13sd2.data(:,6);
HOR13sd2T_TIN15IAU0 = HOR13sd2_TIN15IAU0.data(:,6);
HOR13sd2T_TIN12IAU0T = HOR13sd2_TIN12IAU0T.data(:,6);
HOR13sd2T_TIN3 = HOR13sd2_TIN3.data(:,6);
HOR13sd2T_TIN3IAU0 = HOR13sd2_TIN3IAU0.data(:,6);
HOR13sd2T_WSM3 = HOR13sd2_WSM3.data(:,6);
HOR13sd2T_TFSCA = HOR13sd2_TFSCA.data(:,6);

%% convert domain 2 data to hourly and celsius

%WRF data output every timestep (15 seconds for 4km domain)
%UU Research Trailer data output every 5 minutes (300 seconds)
%K74V and QRS output every 1 hour (3600 seconds)
%Need to correctly match data due to mismatch in time frequency
%Create array for WRF @ 300 sec freq to match research trailer
 
%Build array for hourly  data
% m is interval to convert data from every 15 sec to hourly
m = 240;

ROO13sd2Thrly = ROO13sd2T(m:m:end);
ROO13sd2T_TIN12IAU0Thrly = ROO13sd2T_TIN12IAU0T(m:m:end);
ROO13sd2T_TIN3hrly = ROO13sd2T_TIN3(m:m:end);
ROO13sd2T_TIN3IAU0hrly = ROO13sd2T_TIN3IAU0(m:m:end);
ROO13sd2T_WSM3hrly = ROO13sd2T_WSM3(m:m:end);
ROO13sd2T_TIN15IAU0hrly = ROO13sd2T_TIN15IAU0(m:m:end);
ROO13sd2T_TFSCAhrly = ROO13sd2T_TFSCA(m:m:end);

VER13sd2Thrly = VER13sd2T(m:m:end);
VER13sd2T_TIN12IAU0Thrly = VER13sd2T_TIN12IAU0T(m:m:end);
VER13sd2T_TIN3hrly = VER13sd2T_TIN3(m:m:end);
VER13sd2T_TIN3IAU0hrly = VER13sd2T_TIN3IAU0(m:m:end);
VER13sd2T_WSM3hrly = VER13sd2T_WSM3(m:m:end);
VER13sd2T_TIN15IAU0hrly = VER13sd2T_TIN15IAU0(m:m:end);
VER13sd2T_TFSCAhrly = VER13sd2T_TFSCA(m:m:end);

OUR13sd2Thrly = OUR13sd2T(m:m:end);
OUR13sd2T_TIN12IAU0Thrly = OUR13sd2T_TIN12IAU0T(m:m:end);
OUR13sd2T_TIN3hrly = OUR13sd2T_TIN3(m:m:end);
OUR13sd2T_TIN3IAU0hrly = OUR13sd2T_TIN3IAU0(m:m:end);
OUR13sd2T_WSM3hrly = OUR13sd2T_WSM3(m:m:end);
OUR13sd2T_TIN15IAU0hrly = OUR13sd2T_TIN15IAU0(m:m:end);
OUR13sd2T_TFSCAhrly = OUR13sd2T_TFSCA(m:m:end);

MYT13sd2Thrly = MYT13sd2T(m:m:end);
MYT13sd2T_TIN12IAU0Thrly = MYT13sd2T_TIN12IAU0T(m:m:end);
MYT13sd2T_TIN3hrly = MYT13sd2T_TIN3(m:m:end);
MYT13sd2T_TIN3IAU0hrly = MYT13sd2T_TIN3IAU0(m:m:end);
MYT13sd2T_WSM3hrly = MYT13sd2T_WSM3(m:m:end);
MYT13sd2T_TIN15IAU0hrly = MYT13sd2T_TIN15IAU0(m:m:end);
MYT13sd2T_TFSCAhrly = MYT13sd2T_TFSCA(m:m:end);

RED13sd2Thrly = RED13sd2T(m:m:end);
RED13sd2T_TIN12IAU0Thrly = RED13sd2T_TIN12IAU0T(m:m:end);
RED13sd2T_TIN3hrly = RED13sd2T_TIN3(m:m:end);
RED13sd2T_TIN3IAU0hrly = RED13sd2T_TIN3IAU0(m:m:end);
RED13sd2T_WSM3hrly = RED13sd2T_WSM3(m:m:end);
RED13sd2T_TIN15IAU0hrly = RED13sd2T_TIN15IAU0(m:m:end);
RED13sd2T_TFSCAhrly = RED13sd2T_TFSCA(m:m:end);

HOR13sd2Thrly = HOR13sd2T(m:m:end);
HOR13sd2T_TIN12IAU0Thrly = HOR13sd2T_TIN12IAU0T(m:m:end);
HOR13sd2T_TIN3hrly = HOR13sd2T_TIN3(m:m:end);
HOR13sd2T_TIN3IAU0hrly = HOR13sd2T_TIN3IAU0(m:m:end);
HOR13sd2T_WSM3hrly = HOR13sd2T_WSM3(m:m:end);
HOR13sd2T_TIN15IAU0hrly = HOR13sd2T_TIN15IAU0(m:m:end);
HOR13sd2T_TFSCAhrly = HOR13sd2T_TFSCA(m:m:end);

%Convert wrfT to from K to deg C  

ROO13sd2Thrly = ROO13sd2Thrly-273.15;
ROO13sd2T_TIN12IAU0Thrly = ROO13sd2T_TIN12IAU0Thrly-273.15;
ROO13sd2T_TIN3hrly = ROO13sd2T_TIN3hrly-273.15;
ROO13sd2T_TIN3IAU0hrly = ROO13sd2T_TIN3IAU0hrly-273.15;
ROO13sd2T_WSM3hrly = ROO13sd2T_WSM3hrly-273.15;
ROO13sd2T_TIN15IAU0hrly = ROO13sd2T_TIN15IAU0hrly-273.15;
ROO13sd2T_TFSCAhrly = ROO13sd2T_TFSCAhrly-273.15;

VER13sd2Thrly = VER13sd2Thrly-273.15;
VER13sd2T_TIN12IAU0Thrly = VER13sd2T_TIN12IAU0Thrly-273.15;
VER13sd2T_TIN3hrly = VER13sd2T_TIN3hrly-273.15;
VER13sd2T_TIN3IAU0hrly = VER13sd2T_TIN3IAU0hrly-273.15;
VER13sd2T_WSM3hrly = VER13sd2T_WSM3hrly-273.15;
VER13sd2T_TIN15IAU0hrly = VER13sd2T_TIN15IAU0hrly-273.15;
VER13sd2T_TFSCAhrly = VER13sd2T_TFSCAhrly-273.15;

OUR13sd2Thrly = OUR13sd2Thrly-273.15;
OUR13sd2T_TIN12IAU0Thrly = OUR13sd2T_TIN12IAU0Thrly-273.15;
OUR13sd2T_TIN3hrly = OUR13sd2T_TIN3hrly-273.15;
OUR13sd2T_TIN3IAU0hrly = OUR13sd2T_TIN3IAU0hrly-273.15;
OUR13sd2T_WSM3hrly = OUR13sd2T_WSM3hrly-273.15;
OUR13sd2T_TIN15IAU0hrly = OUR13sd2T_TIN15IAU0hrly-273.15;
OUR13sd2T_TFSCAhrly = OUR13sd2T_TFSCAhrly-273.15;

MYT13sd2Thrly = MYT13sd2Thrly-273.15;
MYT13sd2T_TIN12IAU0Thrly = MYT13sd2T_TIN12IAU0Thrly-273.15;
MYT13sd2T_TIN3hrly = MYT13sd2T_TIN3hrly-273.15;
MYT13sd2T_TIN3IAU0hrly = MYT13sd2T_TIN3IAU0hrly-273.15;
MYT13sd2T_WSM3hrly = MYT13sd2T_WSM3hrly-273.15;
MYT13sd2T_TIN15IAU0hrly = MYT13sd2T_TIN15IAU0hrly-273.15;
MYT13sd2T_TFSCAhrly = MYT13sd2T_TFSCAhrly-273.15;

RED13sd2Thrly = RED13sd2Thrly-273.15;
RED13sd2T_TIN12IAU0Thrly = RED13sd2T_TIN12IAU0Thrly-273.15;
RED13sd2T_TIN3hrly = RED13sd2T_TIN3hrly-273.15;
RED13sd2T_TIN3IAU0hrly = RED13sd2T_TIN3IAU0hrly-273.15;
RED13sd2T_WSM3hrly = RED13sd2T_WSM3hrly-273.15;
RED13sd2T_TIN15IAU0hrly = RED13sd2T_TIN15IAU0hrly-273.15;
RED13sd2T_TFSCAhrly = RED13sd2T_TFSCAhrly-273.15;

HOR13sd2Thrly = HOR13sd2Thrly-273.15;
HOR13sd2T_TIN12IAU0Thrly = HOR13sd2T_TIN12IAU0Thrly-273.15;
HOR13sd2T_TIN3hrly = HOR13sd2T_TIN3hrly-273.15;
HOR13sd2T_TIN3IAU0hrly = HOR13sd2T_TIN3IAU0hrly-273.15;
HOR13sd2T_WSM3hrly = HOR13sd2T_WSM3hrly-273.15;
HOR13sd2T_TIN15IAU0hrly = HOR13sd2T_TIN15IAU0hrly-273.15;
HOR13sd2T_TFSCAhrly = HOR13sd2T_TFSCAhrly-273.15;

%% Load observation data

%load obs data from UU Research Trailer
load UUTrail16Feb.csv
trailtime = UUTrail16Feb(:,1);
trailT = UUTrail16Feb(:,2);
p = 12;         %time interval to convert from 5 min to hourly
trailThrly = trailT(p:p:end);

% %load Roosevelt DAQ data
% load QRS16Feb.csv
% daqThrly = QRS16Feb(:,2);
% 
% %load Roosevelt Airport data
% load K74V16Feb.csv
% roosapThrly = K74V16Feb(:,2);

%load Vernal Airport data
load KVEL16Feb.csv
vernalThrly = KVEL16Feb(:,2);

%load Ouray obs data
load AN76816Feb.csv
ourayThrly = AN76816Feb(:,2);

%load Myton obs data
load MYT516Feb.csv
mytonThrly = MYT516Feb(:,2);

%load Red Wash obs data
load AN76716Feb.csv
redwashThrly = AN76716Feb(:,2);

%load Horsepool obs data
load HPL16Feb.csv
horseThrly = HPL16Feb(:,2);

%% Plot Roosevelt time series of WRF output & T obs (1 hr freq)

datenum = zeros(1,144);                     %build vector of dates in 
for k=1:144                                 %number format
    datenum(k)=735266 + k/24;
end

figure('Color',[1 1 1]);
%plot(datenum, ROO13sThrly, 'r','LineWidth',1.5)
hold on
plot(datenum, ROO13sd2Thrly, 'b','LineWidth',1.5)
plot(datenum, ROO13sd2T_TIN15IAU0hrly, 'r','LineWidth',1.5)
plot(datenum, ROO13sd2T_TIN12IAU0Thrly, 'm','LineWidth',1.5)
plot(datenum, ROO13sd2T_TIN3hrly, 'y','LineWidth',1.5)
plot(datenum, ROO13sd2T_TIN3IAU0hrly, 'g','LineWidth',1.5)
% plot(datenum, ROO13sd2T_WSM3hrly, 'c','LineWidth',1.5)
plot(datenum, ROO13sd3T_TIN12IAU0Thrly, 'c','LineWidth',1.5)
plot(datenum, trailThrly, 'k--','LineWidth',1.5)

datetick('x','dd-mmm-yyyy HH:MM:SS')
axis([735266 735272 -20 5])
whitebg([0.7 0.7 0.7]);
set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
    '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
    '6-Feb-13 00Z','7-Feb-13 00Z'})
xlabel('Date & Time','FontWeight','bold','FontSize',12);
ylabel('Temperature (deg C)','FontWeight','bold','FontSize',12);
title('Roosevelt Trailer, Hourly T Time Series','FontWeight','bold','FontSize',12);
legend('4km Thomp','4km TIN15IAU0','4km TIN12IAU0T','4km TIN3','4km TIN3IAU0','1.3km TIN12IAU0T','Observations');
hold off

print -painters -dpdf -r600 figure1.pdf

%% Plot Vernal time series of T obs at airport & WRF output (1 hr freq)
figure('Color',[1 1 1]);
%plot(datenum, VER13sThrly, 'r','LineWidth',1.5)
hold on
plot(datenum, VER13sd2Thrly, 'b','LineWidth',1.5)
plot(datenum, VER13sd2T_TIN15IAU0hrly, 'r','LineWidth',1.5)
plot(datenum, VER13sd2T_TIN12IAU0Thrly, 'm','LineWidth',1.5)
plot(datenum, VER13sd2T_TIN3hrly, 'y','LineWidth',1.5)
plot(datenum, VER13sd2T_TIN3IAU0hrly, 'g','LineWidth',1.5)
% plot(datenum, VER13sd2T_WSM3hrly, 'c','LineWidth',1.5)
plot(datenum, VER13sd3T_TIN12IAU0Thrly, 'c','LineWidth',1.5)
plot(datenum, vernalThrly, 'k--','LineWidth',1.5)

datetick('x','dd-mmm-yyyy HH:MM:SS')
axis([735266 735272 -20 5])
whitebg([0.7 0.7 0.7]);
set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
    '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
    '6-Feb-13 00Z','7-Feb-13 00Z'})
xlabel('Date & Time','FontWeight','bold','FontSize',12);
ylabel('Temperature (deg C)','FontWeight','bold','FontSize',12);
title('Vernal, Hourly T Time Series','FontWeight','bold','FontSize',12);
legend('4km Thomp','4km TIN15IAU0','4km TIN12IAU0T','4km TIN3','4km TIN3IAU0','1.3km TIN12IAU0T','Observations');
hold off
print -dpdf -r600 figure2.pdf


%% Plot Ouray time series of T obs at Ouray DAQ & WRF output (1 hr freq)
figure('Color',[1 1 1]);
%plot(datenum, OUR13sThrly, 'r','LineWidth',1.5)
hold on
plot(datenum, OUR13sd2Thrly, 'b','LineWidth',1.5)
plot(datenum, OUR13sd2T_TIN15IAU0hrly, 'r','LineWidth',1.5)
plot(datenum, OUR13sd2T_TIN12IAU0Thrly, 'm','LineWidth',1.5)
plot(datenum, OUR13sd2T_TIN3hrly, 'y','LineWidth',1.5)
plot(datenum, OUR13sd2T_TIN3IAU0hrly, 'g','LineWidth',1.5)
% plot(datenum, OUR13sd2T_WSM3hrly, 'c','LineWidth',1.5)
plot(datenum, OUR13sd3T_TIN12IAU0Thrly, 'c','LineWidth',1.5)
plot(datenum, ourayThrly, 'k--','LineWidth',1.5)

datetick('x','dd-mmm-yyyy HH:MM:SS')
axis([735266 735272 -20 5])
whitebg([0.7 0.7 0.7]);
set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
    '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
    '6-Feb-13 00Z','7-Feb-13 00Z'})
xlabel('Date & Time','FontWeight','bold','FontSize',12);
ylabel('Temperature (deg C)','FontWeight','bold','FontSize',12);
title('Ouray, Hourly T Time Series','FontWeight','bold','FontSize',12);
legend('4km Thomp','4km TIN15IAU0','4km TIN12IAU0T','4km TIN3','4km TIN3IAU0','1.3km TIN12IAU0T','Observations');
hold off

%% Plot Myton time series of T obs & WRF output (1 hr freq)
figure('Color',[1 1 1]);
%plot(datenum, MYT13sThrly, 'r','LineWidth',1.5)
hold on
plot(datenum, MYT13sd2Thrly, 'b','LineWidth',1.5)
plot(datenum, MYT13sd2T_TIN15IAU0hrly, 'r','LineWidth',1.5)
plot(datenum, MYT13sd2T_TIN12IAU0Thrly, 'm','LineWidth',1.5)
plot(datenum, MYT13sd2T_TIN3hrly, 'y','LineWidth',1.5)
plot(datenum, MYT13sd2T_TIN3IAU0hrly, 'g','LineWidth',1.5)
% plot(datenum, MYT13sd2T_WSM3hrly, 'c','LineWidth',1.5)
plot(datenum, MYT13sd3T_TIN12IAU0Thrly, 'c','LineWidth',1.5)
plot(datenum, mytonThrly, 'k--','LineWidth',1.5)

datetick('x','dd-mmm-yyyy HH:MM:SS')
axis([735266 735272 -20 5])
whitebg([0.7 0.7 0.7]);
set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
    '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
    '6-Feb-13 00Z','7-Feb-13 00Z'})
xlabel('Date & Time','FontWeight','bold','FontSize',12);
ylabel('Temperature (deg C)','FontWeight','bold','FontSize',12);
title('Myton, Hourly T Time Series','FontWeight','bold','FontSize',12);
legend('4km Thomp','4km TIN15IAU0','4km TIN12IAU0T','4km TIN3','4km TIN3IAU0','1.3km TIN12IAU0T','Observations');
hold off

%% Plot Red Wash time series of T obs & WRF output (1 hr freq)
figure('Color',[1 1 1]);
%plot(datenum, RED13sThrly, 'r','LineWidth',1.5)
hold on
plot(datenum, RED13sd2Thrly, 'b','LineWidth',1.5)
plot(datenum, RED13sd2T_TIN15IAU0hrly, 'r','LineWidth',1.5)
plot(datenum, RED13sd2T_TIN12IAU0Thrly, 'm','LineWidth',1.5)
plot(datenum, RED13sd2T_TIN3hrly, 'y','LineWidth',1.5)
plot(datenum, RED13sd2T_TIN3IAU0hrly, 'g','LineWidth',1.5)
% plot(datenum, RED13sd2T_WSM3hrly, 'c','LineWidth',1.5)
plot(datenum, RED13sd3T_TIN12IAU0Thrly, 'c','LineWidth',1.5)
plot(datenum, redwashThrly, 'k--','LineWidth',1.5)

datetick('x','dd-mmm-yyyy HH:MM:SS')
axis([735266 735272 -20 5])
whitebg([0.7 0.7 0.7]);
set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
    '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
    '6-Feb-13 00Z','7-Feb-13 00Z'})
xlabel('Date & Time','FontWeight','bold','FontSize',12);
ylabel('Temperature (deg C)','FontWeight','bold','FontSize',12);
title('Red Wash, Hourly T Time Series','FontWeight','bold','FontSize',12);
legend('4km Thomp','4km TIN15IAU0','4km TIN12IAU0T','4km TIN3','4km TIN3IAU0','1.3km TIN12IAU0T','Observations');
hold off

% figure('Color',[1 1 1]);
% plot(datenum, RED13smaghrly, 'r','LineWidth',1.5)
% hold on
% plot(datenum, redwashmaghrly, 'k','LineWidth',1.5)
% 
% datetick('x','dd-mmm-yyyy HH:MM:SS')
% axis auto
% set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
% set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
%     '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
%     '6-Feb-13 00Z','7-Feb-13 00Z'})
% xlabel('Date & Time','FontWeight','bold','FontSize',12);
% ylabel('Wind Speed (m/s)','FontWeight','bold','FontSize',12);
% title('Red Wash, Hourly Wind Speed','FontWeight','bold','FontSize',12);
% legend('WRF 1.3km','Observations');
% hold off

% RED13sTerror = RED13sThrly - redwashThrly;
% avg_REDTerror = mean(RED13sTerror)
% abs_RED13sTerror = abs(RED13sThrly - redwashThrly);
% mae_REDT = mean(abs_RED13sTerror)

%% Plot Horsepool time series of T obs & WRF output (1 hr freq)
figure('Color',[1 1 1]);
%plot(datenum, HOR13sThrly, 'r','LineWidth',1.5)
hold on
plot(datenum, HOR13sd2Thrly, 'b','LineWidth',1.5)
plot(datenum, HOR13sd2T_TIN15IAU0hrly, 'r','LineWidth',1.5)
plot(datenum, HOR13sd2T_TIN12IAU0Thrly, 'm','LineWidth',1.5)
plot(datenum, HOR13sd2T_TIN3hrly, 'y','LineWidth',1.5)
plot(datenum, HOR13sd2T_TIN3IAU0hrly, 'g','LineWidth',1.5)
% plot(datenum, HOR13sd2T_WSM3hrly, 'c','LineWidth',1.5)
plot(datenum, HOR13sd3T_TIN12IAU0Thrly, 'c','LineWidth',1.5)
plot(datenum, horseThrly, 'k--','LineWidth',1.5)

datetick('x','dd-mmm-yyyy HH:MM:SS')
axis([735266 735272 -20 5])
whitebg([0.7 0.7 0.7]);
set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
    '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
    '6-Feb-13 00Z','7-Feb-13 00Z'})
xlabel('Date & Time','FontWeight','bold','FontSize',12);
ylabel('Temperature (deg C)','FontWeight','bold','FontSize',12);
title('Horsepool, Hourly T Time Series','FontWeight','bold','FontSize',12);
legend('4km Thomp','4km TIN15IAU0','4km TIN12IAU0T','4km TIN3','4km TIN3IAU0','1.3km TIN12IAU0T','Observations');
hold off

% HOR13sTerror = HOR13sThrly - horseThrly;
% avg_HORTerror = mean(HOR13sTerror)
% abs_HOR13sTerror = abs(HOR13sThrly - horseThrly);
% mae_HORT = mean(abs_HOR13sTerror)

%% Error Calculations
% Compute Errors for each location

%domain 3
ROO13sTerror = ROO13sThrly - trailThrly;
VER13sTerror = VER13sThrly - vernalThrly;
OUR13sTerror = OUR13sThrly - ourayThrly;
MYT13sTerror = MYT13sThrly - mytonThrly;
RED13sTerror = RED13sThrly - redwashThrly;
HOR13sTerror = HOR13sThrly - horseThrly;

avg13sTerror = zeros(144,1);

for i = 1:144;
    avg13sTerror(i) = (ROO13sTerror(i)+VER13sTerror(i)+OUR13sTerror(i)...
        +MYT13sTerror(i)+RED13sTerror(i)+HOR13sTerror(i))/6;
end

avg13s_error = mean(avg13sTerror)

%domain 2
ROO13sd2Terror = ROO13sd2Thrly - trailThrly;
VER13sd2Terror = VER13sd2Thrly - vernalThrly;
OUR13sd2Terror = OUR13sd2Thrly - ourayThrly;
MYT13sd2Terror = MYT13sd2Thrly - mytonThrly;
RED13sd2Terror = RED13sd2Thrly - redwashThrly;
HOR13sd2Terror = HOR13sd2Thrly - horseThrly;
 
avg13sd2Terror = zeros(144,1);
 
for i = 1:144;
    avg13sd2Terror(i) = (ROO13sd2Terror(i)+VER13sd2Terror(i)+OUR13sd2Terror(i)...
        +MYT13sd2Terror(i)+RED13sd2Terror(i)+HOR13sd2Terror(i))/6;
end
 
avg13sd2_error = mean(avg13sd2Terror)

%domain 2 - TIN15IAU0
ROO13sd2T_TIN15IAU0error = ROO13sd2T_TIN15IAU0hrly - trailThrly;
VER13sd2T_TIN15IAU0error = VER13sd2T_TIN15IAU0hrly - vernalThrly;
OUR13sd2T_TIN15IAU0error = OUR13sd2T_TIN15IAU0hrly - ourayThrly;
MYT13sd2T_TIN15IAU0error = MYT13sd2T_TIN15IAU0hrly - mytonThrly;
RED13sd2T_TIN15IAU0error = RED13sd2T_TIN15IAU0hrly - redwashThrly;
HOR13sd2T_TIN15IAU0error = HOR13sd2T_TIN15IAU0hrly - horseThrly;
 
avg13sd2T_TIN15IAU0error = zeros(144,1);
 
for i = 1:144;
    avg13sd2T_TIN15IAU0error(i) = (ROO13sd2T_TIN15IAU0error(i)+VER13sd2T_TIN15IAU0error(i)+OUR13sd2T_TIN15IAU0error(i)...
        +MYT13sd2T_TIN15IAU0error(i)+RED13sd2T_TIN15IAU0error(i)+HOR13sd2T_TIN15IAU0error(i))/6;
end
 
avg13sd2_TIN15IAU0_error = mean(avg13sd2T_TIN15IAU0error)


%domain 2 - TIN12IAU0T
ROO13sd2T_TIN12IAU0Terror = ROO13sd2T_TIN12IAU0Thrly - trailThrly;
VER13sd2T_TIN12IAU0Terror = VER13sd2T_TIN12IAU0Thrly - vernalThrly;
OUR13sd2T_TIN12IAU0Terror = OUR13sd2T_TIN12IAU0Thrly - ourayThrly;
MYT13sd2T_TIN12IAU0Terror = MYT13sd2T_TIN12IAU0Thrly - mytonThrly;
RED13sd2T_TIN12IAU0Terror = RED13sd2T_TIN12IAU0Thrly - redwashThrly;
HOR13sd2T_TIN12IAU0Terror = HOR13sd2T_TIN12IAU0Thrly - horseThrly;
 
avg13sd2T_TIN12IAU0Terror = zeros(144,1);
 
for i = 1:144;
    avg13sd2T_TIN12IAU0Terror(i) = (ROO13sd2T_TIN12IAU0Terror(i)+VER13sd2T_TIN12IAU0Terror(i)+OUR13sd2T_TIN12IAU0Terror(i)...
        +MYT13sd2T_TIN12IAU0Terror(i)+RED13sd2T_TIN12IAU0Terror(i)+HOR13sd2T_TIN12IAU0Terror(i))/6;
end
 
avg13sd2_TIN12IAU0T_error = mean(avg13sd2T_TIN12IAU0Terror)

%domain 2 - TIN3
ROO13sd2T_TIN3error = ROO13sd2T_TIN3hrly - trailThrly;
VER13sd2T_TIN3error = VER13sd2T_TIN3hrly - vernalThrly;
OUR13sd2T_TIN3error = OUR13sd2T_TIN3hrly - ourayThrly;
MYT13sd2T_TIN3error = MYT13sd2T_TIN3hrly - mytonThrly;
RED13sd2T_TIN3error = RED13sd2T_TIN3hrly - redwashThrly;
HOR13sd2T_TIN3error = HOR13sd2T_TIN3hrly - horseThrly;
 
avg13sd2T_TIN3error = zeros(144,1);
 
for i = 1:144;
    avg13sd2T_TIN3error(i) = (ROO13sd2T_TIN3error(i)+VER13sd2T_TIN3error(i)+OUR13sd2T_TIN3error(i)...
        +MYT13sd2T_TIN3error(i)+RED13sd2T_TIN3error(i)+HOR13sd2T_TIN3error(i))/6;
end
 
avg13sd2_TIN3_error = mean(avg13sd2T_TIN3error)

%domain 2 - TIN3IAU0
ROO13sd2T_TIN3IAU0error = ROO13sd2T_TIN3IAU0hrly - trailThrly;
VER13sd2T_TIN3IAU0error = VER13sd2T_TIN3IAU0hrly - vernalThrly;
OUR13sd2T_TIN3IAU0error = OUR13sd2T_TIN3IAU0hrly - ourayThrly;
MYT13sd2T_TIN3IAU0error = MYT13sd2T_TIN3IAU0hrly - mytonThrly;
RED13sd2T_TIN3IAU0error = RED13sd2T_TIN3IAU0hrly - redwashThrly;
HOR13sd2T_TIN3IAU0error = HOR13sd2T_TIN3IAU0hrly - horseThrly;
 
avg13sd2T_TIN3IAU0error = zeros(144,1);
 
for i = 1:144;
    avg13sd2T_TIN3IAU0error(i) = (ROO13sd2T_TIN3IAU0error(i)+VER13sd2T_TIN3IAU0error(i)+OUR13sd2T_TIN3IAU0error(i)...
        +MYT13sd2T_TIN3IAU0error(i)+RED13sd2T_TIN3IAU0error(i)+HOR13sd2T_TIN3IAU0error(i))/6;
end
 
avg13sd2_TIN3IAU0_error = mean(avg13sd2T_TIN3IAU0error)

%domain 2 - WSM3
ROO13sd2T_WSM3error = ROO13sd2T_WSM3hrly - trailThrly;
VER13sd2T_WSM3error = VER13sd2T_WSM3hrly - vernalThrly;
OUR13sd2T_WSM3error = OUR13sd2T_WSM3hrly - ourayThrly;
MYT13sd2T_WSM3error = MYT13sd2T_WSM3hrly - mytonThrly;
RED13sd2T_WSM3error = RED13sd2T_WSM3hrly - redwashThrly;
HOR13sd2T_WSM3error = HOR13sd2T_WSM3hrly - horseThrly;
 
avg13sd2T_WSM3error = zeros(144,1);
 
for i = 1:144;
    avg13sd2T_WSM3error(i) = (ROO13sd2T_WSM3error(i)+VER13sd2T_WSM3error(i)+OUR13sd2T_WSM3error(i)...
        +MYT13sd2T_WSM3error(i)+RED13sd2T_WSM3error(i)+HOR13sd2T_WSM3error(i))/6;
end
 
avg13sd2_WSM3_error = mean(avg13sd2T_WSM3error)

%domain 3 - TIN12IAU0T
ROO13sd3T_TIN12IAU0Terror = ROO13sd3T_TIN12IAU0Thrly - trailThrly;
VER13sd3T_TIN12IAU0Terror = VER13sd3T_TIN12IAU0Thrly - vernalThrly;
OUR13sd3T_TIN12IAU0Terror = OUR13sd3T_TIN12IAU0Thrly - ourayThrly;
MYT13sd3T_TIN12IAU0Terror = MYT13sd3T_TIN12IAU0Thrly - mytonThrly;
RED13sd3T_TIN12IAU0Terror = RED13sd3T_TIN12IAU0Thrly - redwashThrly;
HOR13sd3T_TIN12IAU0Terror = HOR13sd3T_TIN12IAU0Thrly - horseThrly;
 
avg13sd3T_TIN12IAU0Terror = zeros(144,1);
 
for i = 1:144;
    avg13sd3T_TIN12IAU0Terror(i) = (ROO13sd3T_TIN12IAU0Terror(i)+VER13sd3T_TIN12IAU0Terror(i)+OUR13sd3T_TIN12IAU0Terror(i)...
        +MYT13sd3T_TIN12IAU0Terror(i)+RED13sd3T_TIN12IAU0Terror(i)+HOR13sd3T_TIN12IAU0Terror(i))/6;
end
 
avg13sd3_TIN12IAU0T_error = mean(avg13sd3T_TIN12IAU0Terror)

zero = zeros(1,144);
%Plot Average error
figure('Color',[1 1 1]);
%plot(datenum, avg13sTerror, 'r','LineWidth',1.5)
hold on
plot(datenum, avg13sd2Terror, 'b','LineWidth',1.5)
plot(datenum, avg13sd2T_TIN15IAU0error, 'r','LineWidth',1.5)
plot(datenum, avg13sd2T_TIN12IAU0Terror, 'm','LineWidth',1.5)
plot(datenum, avg13sd2T_TIN3error, 'y','LineWidth',1.5)
plot(datenum, avg13sd2T_TIN3IAU0error, 'g','LineWidth',1.5)
% plot(datenum, avg13sd2T_WSM3error, 'c','LineWidth',1.5)
plot(datenum, avg13sd3T_TIN12IAU0Terror, 'c','LineWidth',1.5)
plot(datenum, zero, 'k--')
datetick('x','dd-mmm-yyyy HH:MM:SS')
axis([735266 735272 -5 10])
whitebg([0.7 0.7 0.7]);
set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
    '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
    '6-Feb-13 00Z','7-Feb-13 00Z'})
xlabel('Date & Time','FontWeight','bold','FontSize',12);
ylabel('Temperature Error (deg C)','FontWeight','bold','FontSize',12);
title('Mean Temperature Error','FontWeight','bold','FontSize',12);
legend('4km Thomp','4km TIN15IAU0','4km TIN12IAU0T','4km TIN3','4km TIN3IAU0','1.3km TIN12IAU0T');
hold off


%% Absolute error calculations

%domain 3
abs_ROO13sTerror = abs(ROO13sThrly - trailThrly);
abs_VER13sTerror = abs(VER13sThrly - vernalThrly);
abs_OUR13sTerror = abs(OUR13sThrly - ourayThrly);
abs_MYT13sTerror = abs(MYT13sThrly - mytonThrly);
abs_RED13sTerror = abs(RED13sThrly - redwashThrly);
abs_HOR13sTerror = abs(HOR13sThrly - horseThrly);

mae_13sT = zeros(144,1);


for i = 1:144;
    mae_13sT(i) = (abs_ROO13sTerror(i)+abs_VER13sTerror(i)+abs_OUR13sTerror(i)...
        +abs_MYT13sTerror(i)+abs_RED13sTerror(i)+abs_HOR13sTerror(i))/6;
end

mae13sT = mean(mae_13sT)

%domain 2
abs_ROO13sd2Terror = abs(ROO13sd2Thrly - trailThrly);
abs_VER13sd2Terror = abs(VER13sd2Thrly - vernalThrly);
abs_OUR13sd2Terror = abs(OUR13sd2Thrly - ourayThrly);
abs_MYT13sd2Terror = abs(MYT13sd2Thrly - mytonThrly);
abs_RED13sd2Terror = abs(RED13sd2Thrly - redwashThrly);
abs_HOR13sd2Terror = abs(HOR13sd2Thrly - horseThrly);
 
mae_13sd2T = zeros(144,1);
 
for i = 1:144;
    mae_13sd2T(i) = (abs_ROO13sd2Terror(i)+abs_VER13sd2Terror(i)+abs_OUR13sd2Terror(i)...
        +abs_MYT13sd2Terror(i)+abs_RED13sd2Terror(i)+abs_HOR13sd2Terror(i))/6;
end
 
mae13sd2T = mean(mae_13sd2T)

%domain 2 - TIN15IAU0
abs_ROO13sd2T_TIN15IAU0error = abs(ROO13sd2T_TIN15IAU0hrly - trailThrly);
abs_VER13sd2T_TIN15IAU0error = abs(VER13sd2T_TIN15IAU0hrly - vernalThrly);
abs_OUR13sd2T_TIN15IAU0error = abs(OUR13sd2T_TIN15IAU0hrly - ourayThrly);
abs_MYT13sd2T_TIN15IAU0error = abs(MYT13sd2T_TIN15IAU0hrly - mytonThrly);
abs_RED13sd2T_TIN15IAU0error = abs(RED13sd2T_TIN15IAU0hrly - redwashThrly);
abs_HOR13sd2T_TIN15IAU0error = abs(HOR13sd2T_TIN15IAU0hrly - horseThrly);
 
mae_13sd2T_TIN15IAU0 = zeros(144,1);
 
 
for i = 1:144;
    mae_13sd2T_TIN15IAU0(i) = (abs_ROO13sd2T_TIN15IAU0error(i)+abs_VER13sd2T_TIN15IAU0error(i)+abs_OUR13sd2T_TIN15IAU0error(i)...
        +abs_MYT13sd2T_TIN15IAU0error(i)+abs_RED13sd2T_TIN15IAU0error(i)+abs_HOR13sd2T_TIN15IAU0error(i))/6;
end
 
mae13sd2T_TIN15IAU0 = mean(mae_13sd2T_TIN15IAU0)

%domain 2 - TIN12IAU0T
abs_ROO13sd2T_TIN12IAU0Terror = abs(ROO13sd2T_TIN12IAU0Thrly - trailThrly);
abs_VER13sd2T_TIN12IAU0Terror = abs(VER13sd2T_TIN12IAU0Thrly - vernalThrly);
abs_OUR13sd2T_TIN12IAU0Terror = abs(OUR13sd2T_TIN12IAU0Thrly - ourayThrly);
abs_MYT13sd2T_TIN12IAU0Terror = abs(MYT13sd2T_TIN12IAU0Thrly - mytonThrly);
abs_RED13sd2T_TIN12IAU0Terror = abs(RED13sd2T_TIN12IAU0Thrly - redwashThrly);
abs_HOR13sd2T_TIN12IAU0Terror = abs(HOR13sd2T_TIN12IAU0Thrly - horseThrly);
 
mae_13sd2T_TIN12IAU0T = zeros(144,1);
 
 
for i = 1:144;
    mae_13sd2T_TIN12IAU0T(i) = (abs_ROO13sd2T_TIN12IAU0Terror(i)+abs_VER13sd2T_TIN12IAU0Terror(i)+abs_OUR13sd2T_TIN12IAU0Terror(i)...
        +abs_MYT13sd2T_TIN12IAU0Terror(i)+abs_RED13sd2T_TIN12IAU0Terror(i)+abs_HOR13sd2T_TIN12IAU0Terror(i))/6;
end
 
mae13sd2T_TIN12IAU0T = mean(mae_13sd2T_TIN12IAU0T)

%domain 2 - TIN3
abs_ROO13sd2T_TIN3error = abs(ROO13sd2T_TIN3hrly - trailThrly);
abs_VER13sd2T_TIN3error = abs(VER13sd2T_TIN3hrly - vernalThrly);
abs_OUR13sd2T_TIN3error = abs(OUR13sd2T_TIN3hrly - ourayThrly);
abs_MYT13sd2T_TIN3error = abs(MYT13sd2T_TIN3hrly - mytonThrly);
abs_RED13sd2T_TIN3error = abs(RED13sd2T_TIN3hrly - redwashThrly);
abs_HOR13sd2T_TIN3error = abs(HOR13sd2T_TIN3hrly - horseThrly);
 
mae_13sd2T_TIN3 = zeros(144,1);
 
 
for i = 1:144;
    mae_13sd2T_TIN3(i) = (abs_ROO13sd2T_TIN3error(i)+abs_VER13sd2T_TIN3error(i)+abs_OUR13sd2T_TIN3error(i)...
        +abs_MYT13sd2T_TIN3error(i)+abs_RED13sd2T_TIN3error(i)+abs_HOR13sd2T_TIN3error(i))/6;
end
 
mae13sd2T_TIN3 = mean(mae_13sd2T_TIN3)

%domain 2 - TIN3IAU0
abs_ROO13sd2T_TIN3IAU0error = abs(ROO13sd2T_TIN3IAU0hrly - trailThrly);
abs_VER13sd2T_TIN3IAU0error = abs(VER13sd2T_TIN3IAU0hrly - vernalThrly);
abs_OUR13sd2T_TIN3IAU0error = abs(OUR13sd2T_TIN3IAU0hrly - ourayThrly);
abs_MYT13sd2T_TIN3IAU0error = abs(MYT13sd2T_TIN3IAU0hrly - mytonThrly);
abs_RED13sd2T_TIN3IAU0error = abs(RED13sd2T_TIN3IAU0hrly - redwashThrly);
abs_HOR13sd2T_TIN3IAU0error = abs(HOR13sd2T_TIN3IAU0hrly - horseThrly);
 
mae_13sd2T_TIN3IAU0 = zeros(144,1);
 
 
for i = 1:144;
    mae_13sd2T_TIN3IAU0(i) = (abs_ROO13sd2T_TIN3IAU0error(i)+abs_VER13sd2T_TIN3IAU0error(i)+abs_OUR13sd2T_TIN3IAU0error(i)...
        +abs_MYT13sd2T_TIN3IAU0error(i)+abs_RED13sd2T_TIN3IAU0error(i)+abs_HOR13sd2T_TIN3IAU0error(i))/6;
end
 
mae13sd2T_TIN3IAU0 = mean(mae_13sd2T_TIN3IAU0)

%domain 2 - WSM3
abs_ROO13sd2T_WSM3error = abs(ROO13sd2T_WSM3hrly - trailThrly);
abs_VER13sd2T_WSM3error = abs(VER13sd2T_WSM3hrly - vernalThrly);
abs_OUR13sd2T_WSM3error = abs(OUR13sd2T_WSM3hrly - ourayThrly);
abs_MYT13sd2T_WSM3error = abs(MYT13sd2T_WSM3hrly - mytonThrly);
abs_RED13sd2T_WSM3error = abs(RED13sd2T_WSM3hrly - redwashThrly);
abs_HOR13sd2T_WSM3error = abs(HOR13sd2T_WSM3hrly - horseThrly);
 
mae_13sd2T_WSM3 = zeros(144,1);
 
 
for i = 1:144;
    mae_13sd2T_WSM3(i) = (abs_ROO13sd2T_WSM3error(i)+abs_VER13sd2T_WSM3error(i)+abs_OUR13sd2T_WSM3error(i)...
        +abs_MYT13sd2T_WSM3error(i)+abs_RED13sd2T_WSM3error(i)+abs_HOR13sd2T_WSM3error(i))/6;
end
 
mae13sd2T_WSM3 = mean(mae_13sd2T_WSM3)

%domain 3 - TIN12IAU0T
abs_ROO13sd3T_TIN12IAU0Terror = abs(ROO13sd3T_TIN12IAU0Thrly - trailThrly);
abs_VER13sd3T_TIN12IAU0Terror = abs(VER13sd3T_TIN12IAU0Thrly - vernalThrly);
abs_OUR13sd3T_TIN12IAU0Terror = abs(OUR13sd3T_TIN12IAU0Thrly - ourayThrly);
abs_MYT13sd3T_TIN12IAU0Terror = abs(MYT13sd3T_TIN12IAU0Thrly - mytonThrly);
abs_RED13sd3T_TIN12IAU0Terror = abs(RED13sd3T_TIN12IAU0Thrly - redwashThrly);
abs_HOR13sd3T_TIN12IAU0Terror = abs(HOR13sd3T_TIN12IAU0Thrly - horseThrly);
 
mae_13sd3T_TIN12IAU0T = zeros(144,1);
 
 
for i = 1:144;
    mae_13sd3T_TIN12IAU0T(i) = (abs_ROO13sd3T_TIN12IAU0Terror(i)+abs_VER13sd3T_TIN12IAU0Terror(i)+abs_OUR13sd3T_TIN12IAU0Terror(i)...
        +abs_MYT13sd3T_TIN12IAU0Terror(i)+abs_RED13sd3T_TIN12IAU0Terror(i)+abs_HOR13sd3T_TIN12IAU0Terror(i))/6;
end
 
mae13sd3T_TIN12IAU0T = mean(mae_13sd3T_TIN12IAU0T)

zero = zeros(1,144);
%Plot Average Absolute error
figure('Color',[1 1 1]);
%plot(datenum, mae_13sT, 'r','LineWidth',1.5)
hold on
plot(datenum, mae_13sd2T, 'b','LineWidth',1.5)
plot(datenum, mae_13sd2T_TIN15IAU0, 'r','LineWidth',1.5)
plot(datenum, mae_13sd2T_TIN12IAU0T, 'm','LineWidth',1.5)
plot(datenum, mae_13sd2T_TIN3, 'y','LineWidth',1.5)
plot(datenum, mae_13sd2T_TIN3IAU0, 'g','LineWidth',1.5)
% plot(datenum, mae_13sd2T_WSM3, 'c','LineWidth',1.5)
plot(datenum, mae_13sd3T_TIN12IAU0T, 'c','LineWidth',1.5)
plot(datenum, zero, 'k--')
datetick('x','dd-mmm-yyyy HH:MM:SS')
axis([735266 735272 0 15])
whitebg([0.7 0.7 0.7]);
% set(gcf,'Color',[0.7,0.7,0.7])
set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
    '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
    '6-Feb-13 00Z','7-Feb-13 00Z'})
xlabel('Date & Time','FontWeight','bold','FontSize',12);
ylabel('Mean Abs Temperature Error (deg C)','FontWeight','bold','FontSize',12);
title('Mean Abs Temperature Error','FontWeight','bold','FontSize',12);
legend('4km Thomp','4km TIN15IAU0','4km TIN12IAU0T','4km TIN3','4km TIN3IAU0','1.3km TIN12IAU0T');
hold off

% %% 
% %Plot Average Absolute error
% figure('Color',[1 1 1]);
% plot(datenum, mae_13sT, 'r','LineWidth',1.5)
% hold on
% plot(datenum, mae_13sd2T, 'b','LineWidth',1.5)
% plot(datenum, zero, 'k--')
% datetick('x','dd-mmm-yyyy HH:MM:SS')
% axis([735266 735272 0 15])
% set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
% set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
%     '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
%     '6-Feb-13 00Z','7-Feb-13 00Z'})
% xlabel('Date & Time','FontWeight','bold','FontSize',12);
% ylabel('Mean Abs Temperature Error (deg C)','FontWeight','bold','FontSize',12);
% title('Mean Abs Temperature Error','FontWeight','bold','FontSize',12);
% legend('WRF 1.3km','WRF 4km');
% hold off

%% RMSE calculations

%domain 3
sq_ROO13sTerror = (ROO13sThrly - trailThrly).^2;
sq_VER13sTerror = (VER13sThrly - vernalThrly).^2;
sq_OUR13sTerror = (OUR13sThrly - ourayThrly).^2;
sq_MYT13sTerror = (MYT13sThrly - mytonThrly).^2;
sq_RED13sTerror = (RED13sThrly - redwashThrly).^2;
sq_HOR13sTerror = (HOR13sThrly - horseThrly).^2;

sqemat_13sT = [sq_ROO13sTerror sq_VER13sTerror sq_OUR13sTerror...
    sq_MYT13sTerror sq_RED13sTerror sq_HOR13sTerror];

%need to create vector with RMSE at each time step (to plot it)
mse_TS_13sT = zeros(144,1);
for i = 1:144;
    mse_TS_13sT(i) = mean(sqemat_13sT(i,:));
end
RMSE_TS_13sT = sqrt(mse_TS_13sT);

%calculate total RMSE for entire matrix of squared errors
RMSE_13sT = sqrt(mean(mean(sqemat_13sT)))

%domain 2
sq_ROO13sd2Terror = (ROO13sd2Thrly - trailThrly).^2;
sq_VER13sd2Terror = (VER13sd2Thrly - vernalThrly).^2;
sq_OUR13sd2Terror = (OUR13sd2Thrly - ourayThrly).^2;
sq_MYT13sd2Terror = (MYT13sd2Thrly - mytonThrly).^2;
sq_RED13sd2Terror = (RED13sd2Thrly - redwashThrly).^2;
sq_HOR13sd2Terror = (HOR13sd2Thrly - horseThrly).^2;
 
sqemat_13sd2T = [sq_ROO13sd2Terror sq_VER13sd2Terror sq_OUR13sd2Terror...
    sq_MYT13sd2Terror sq_RED13sd2Terror sq_HOR13sd2Terror];
 
mse_TS_13sd2T = zeros(144,1);
for i = 1:144;
    mse_TS_13sd2T(i) = mean(sqemat_13sd2T(i,:));
end
RMSE_TS_13sd2T = sqrt(mse_TS_13sd2T);
 
RMSE_13sd2T = sqrt(mean(mean(sqemat_13sd2T)))

%domain 2 - TIN15IAU0
sq_ROO13sd2T_TIN15IAU0error = (ROO13sd2T_TIN15IAU0hrly - trailThrly).^2;
sq_VER13sd2T_TIN15IAU0error = (VER13sd2T_TIN15IAU0hrly - vernalThrly).^2;
sq_OUR13sd2T_TIN15IAU0error = (OUR13sd2T_TIN15IAU0hrly - ourayThrly).^2;
sq_MYT13sd2T_TIN15IAU0error = (MYT13sd2T_TIN15IAU0hrly - mytonThrly).^2;
sq_RED13sd2T_TIN15IAU0error = (RED13sd2T_TIN15IAU0hrly - redwashThrly).^2;
sq_HOR13sd2T_TIN15IAU0error = (HOR13sd2T_TIN15IAU0hrly - horseThrly).^2;
 
sqemat_13sd2T_TIN15IAU0 = [sq_ROO13sd2T_TIN15IAU0error sq_VER13sd2T_TIN15IAU0error sq_OUR13sd2T_TIN15IAU0error...
    sq_MYT13sd2T_TIN15IAU0error sq_RED13sd2T_TIN15IAU0error sq_HOR13sd2T_TIN15IAU0error];
 
mse_TS_13sd2T_TIN15IAU0 = zeros(144,1);
for i = 1:144;
    mse_TS_13sd2T_TIN15IAU0(i) = mean(sqemat_13sd2T_TIN15IAU0(i,:));
end
RMSE_TS_13sd2T_TIN15IAU0 = sqrt(mse_TS_13sd2T_TIN15IAU0);
 
RMSE_13sd2T_TIN15IAU0 = sqrt(mean(mean(sqemat_13sd2T_TIN15IAU0)))

%domain 2 - TIN12IAU0T
sq_ROO13sd2T_TIN12IAU0Terror = (ROO13sd2T_TIN12IAU0Thrly - trailThrly).^2;
sq_VER13sd2T_TIN12IAU0Terror = (VER13sd2T_TIN12IAU0Thrly - vernalThrly).^2;
sq_OUR13sd2T_TIN12IAU0Terror = (OUR13sd2T_TIN12IAU0Thrly - ourayThrly).^2;
sq_MYT13sd2T_TIN12IAU0Terror = (MYT13sd2T_TIN12IAU0Thrly - mytonThrly).^2;
sq_RED13sd2T_TIN12IAU0Terror = (RED13sd2T_TIN12IAU0Thrly - redwashThrly).^2;
sq_HOR13sd2T_TIN12IAU0Terror = (HOR13sd2T_TIN12IAU0Thrly - horseThrly).^2;
 
sqemat_13sd2T_TIN12IAU0T = [sq_ROO13sd2T_TIN12IAU0Terror sq_VER13sd2T_TIN12IAU0Terror sq_OUR13sd2T_TIN12IAU0Terror...
    sq_MYT13sd2T_TIN12IAU0Terror sq_RED13sd2T_TIN12IAU0Terror sq_HOR13sd2T_TIN12IAU0Terror];
 
mse_TS_13sd2T_TIN12IAU0T = zeros(144,1);
for i = 1:144;
    mse_TS_13sd2T_TIN12IAU0T(i) = mean(sqemat_13sd2T_TIN12IAU0T(i,:));
end
RMSE_TS_13sd2T_TIN12IAU0T = sqrt(mse_TS_13sd2T_TIN12IAU0T);
 
RMSE_13sd2T_TIN12IAU0T = sqrt(mean(mean(sqemat_13sd2T_TIN12IAU0T)))

%domain 2 - TIN3
sq_ROO13sd2T_TIN3error = (ROO13sd2T_TIN3hrly - trailThrly).^2;
sq_VER13sd2T_TIN3error = (VER13sd2T_TIN3hrly - vernalThrly).^2;
sq_OUR13sd2T_TIN3error = (OUR13sd2T_TIN3hrly - ourayThrly).^2;
sq_MYT13sd2T_TIN3error = (MYT13sd2T_TIN3hrly - mytonThrly).^2;
sq_RED13sd2T_TIN3error = (RED13sd2T_TIN3hrly - redwashThrly).^2;
sq_HOR13sd2T_TIN3error = (HOR13sd2T_TIN3hrly - horseThrly).^2;
 
sqemat_13sd2T_TIN3 = [sq_ROO13sd2T_TIN3error sq_VER13sd2T_TIN3error sq_OUR13sd2T_TIN3error...
    sq_MYT13sd2T_TIN3error sq_RED13sd2T_TIN3error sq_HOR13sd2T_TIN3error];
 
mse_TS_13sd2T_TIN3 = zeros(144,1);
for i = 1:144;
    mse_TS_13sd2T_TIN3(i) = mean(sqemat_13sd2T_TIN3(i,:));
end
RMSE_TS_13sd2T_TIN3 = sqrt(mse_TS_13sd2T_TIN3);
 
RMSE_13sd2T_TIN3 = sqrt(mean(mean(sqemat_13sd2T_TIN3)))

%domain 2 - TIN3IAU0
sq_ROO13sd2T_TIN3IAU0error = (ROO13sd2T_TIN3IAU0hrly - trailThrly).^2;
sq_VER13sd2T_TIN3IAU0error = (VER13sd2T_TIN3IAU0hrly - vernalThrly).^2;
sq_OUR13sd2T_TIN3IAU0error = (OUR13sd2T_TIN3IAU0hrly - ourayThrly).^2;
sq_MYT13sd2T_TIN3IAU0error = (MYT13sd2T_TIN3IAU0hrly - mytonThrly).^2;
sq_RED13sd2T_TIN3IAU0error = (RED13sd2T_TIN3IAU0hrly - redwashThrly).^2;
sq_HOR13sd2T_TIN3IAU0error = (HOR13sd2T_TIN3IAU0hrly - horseThrly).^2;
 
sqemat_13sd2T_TIN3IAU0 = [sq_ROO13sd2T_TIN3IAU0error sq_VER13sd2T_TIN3IAU0error sq_OUR13sd2T_TIN3IAU0error...
    sq_MYT13sd2T_TIN3IAU0error sq_RED13sd2T_TIN3IAU0error sq_HOR13sd2T_TIN3IAU0error];
 
mse_TS_13sd2T_TIN3IAU0 = zeros(144,1);
for i = 1:144;
    mse_TS_13sd2T_TIN3IAU0(i) = mean(sqemat_13sd2T_TIN3IAU0(i,:));
end
RMSE_TS_13sd2T_TIN3IAU0 = sqrt(mse_TS_13sd2T_TIN3IAU0);
 
RMSE_13sd2T_TIN3IAU0 = sqrt(mean(mean(sqemat_13sd2T_TIN3IAU0)))

%domain 2 - WSM3
sq_ROO13sd2T_WSM3error = (ROO13sd2T_WSM3hrly - trailThrly).^2;
sq_VER13sd2T_WSM3error = (VER13sd2T_WSM3hrly - vernalThrly).^2;
sq_OUR13sd2T_WSM3error = (OUR13sd2T_WSM3hrly - ourayThrly).^2;
sq_MYT13sd2T_WSM3error = (MYT13sd2T_WSM3hrly - mytonThrly).^2;
sq_RED13sd2T_WSM3error = (RED13sd2T_WSM3hrly - redwashThrly).^2;
sq_HOR13sd2T_WSM3error = (HOR13sd2T_WSM3hrly - horseThrly).^2;
 
sqemat_13sd2T_WSM3 = [sq_ROO13sd2T_WSM3error sq_VER13sd2T_WSM3error sq_OUR13sd2T_WSM3error...
    sq_MYT13sd2T_WSM3error sq_RED13sd2T_WSM3error sq_HOR13sd2T_WSM3error];
 
mse_TS_13sd2T_WSM3 = zeros(144,1);
for i = 1:144;
    mse_TS_13sd2T_WSM3(i) = mean(sqemat_13sd2T_WSM3(i,:));
end
RMSE_TS_13sd2T_WSM3 = sqrt(mse_TS_13sd2T_WSM3);
 
RMSE_13sd2T_WSM3 = sqrt(mean(mean(sqemat_13sd2T_WSM3)))

%domain 3 - TIN12IAU0T
sq_ROO13sd3T_TIN12IAU0Terror = (ROO13sd3T_TIN12IAU0Thrly - trailThrly).^2;
sq_VER13sd3T_TIN12IAU0Terror = (VER13sd3T_TIN12IAU0Thrly - vernalThrly).^2;
sq_OUR13sd3T_TIN12IAU0Terror = (OUR13sd3T_TIN12IAU0Thrly - ourayThrly).^2;
sq_MYT13sd3T_TIN12IAU0Terror = (MYT13sd3T_TIN12IAU0Thrly - mytonThrly).^2;
sq_RED13sd3T_TIN12IAU0Terror = (RED13sd3T_TIN12IAU0Thrly - redwashThrly).^2;
sq_HOR13sd3T_TIN12IAU0Terror = (HOR13sd3T_TIN12IAU0Thrly - horseThrly).^2;
 
sqemat_13sd3T_TIN12IAU0T = [sq_ROO13sd3T_TIN12IAU0Terror sq_VER13sd3T_TIN12IAU0Terror sq_OUR13sd3T_TIN12IAU0Terror...
    sq_MYT13sd3T_TIN12IAU0Terror sq_RED13sd3T_TIN12IAU0Terror sq_HOR13sd3T_TIN12IAU0Terror];
 
mse_TS_13sd3T_TIN12IAU0T = zeros(144,1);
for i = 1:144;
    mse_TS_13sd3T_TIN12IAU0T(i) = mean(sqemat_13sd3T_TIN12IAU0T(i,:));
end
RMSE_TS_13sd3T_TIN12IAU0T = sqrt(mse_TS_13sd3T_TIN12IAU0T);
 
RMSE_13sd3T_TIN12IAU0T = sqrt(mean(mean(sqemat_13sd3T_TIN12IAU0T)))

zero = zeros(1,144);
%Plot Average Absolute error
figure('Color',[1 1 1]);
%plot(datenum, RMSE_TS_13sT, 'r','LineWidth',1.5)
hold on
plot(datenum, RMSE_TS_13sd2T, 'b','LineWidth',1.5)
plot(datenum, RMSE_TS_13sd2T_TIN15IAU0, 'r','LineWidth',1.5)
plot(datenum, RMSE_TS_13sd2T_TIN12IAU0T, 'm','LineWidth',1.5)
plot(datenum, RMSE_TS_13sd2T_TIN3, 'y','LineWidth',1.5)
plot(datenum, RMSE_TS_13sd2T_TIN3IAU0, 'g','LineWidth',1.5)
% plot(datenum, RMSE_TS_13sd2T_WSM3, 'c','LineWidth',1.5)
plot(datenum, RMSE_TS_13sd3T_TIN12IAU0T, 'c','LineWidth',1.5)
plot(datenum, zero, 'k--')
datetick('x','dd-mmm-yyyy HH:MM:SS')
axis([735266 735272 0 15])
whitebg([0.7 0.7 0.7]);
% set(gcf,'Color',[0.7,0.7,0.7])
set(gca,'XTick',[735266 735267 735268 735269 735270 735271 735272])
set(gca,'XTickLabel',{'1-Feb-13 00Z','2-Feb-13 00Z',...
    '3-Feb-13 00Z','4-Feb-13 00Z','5-Feb-13 00Z',...
    '6-Feb-13 00Z','7-Feb-13 00Z'})
xlabel('Date & Time','FontWeight','bold','FontSize',12);
ylabel('RMSE (deg C)','FontWeight','bold','FontSize',12);
title('Root Mean Square Error','FontWeight','bold','FontSize',12);
legend('4km Thomp','4km TIN15IAU0','4km TIN12IAU0T','4km TIN3','4km TIN3IAU0','1.3km TIN12IAU0T');
hold off

