function [X1d,Y1d,Z1d,T1d,Data] = prep_lcs_data(run)

dir = ['/Users/seroka/Research/data/LCS/results/2017/' run '/wrfout_d02/Forward/LCS/'];

load([dir 'lcs_MABSB_2017_04_05_1500_agl.mat'],'rd','TimeStamp')
rd_15 = rd;
time_15 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_05_1600_agl.mat'],'rd','TimeStamp')
rd_16 = rd;
time_16 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_05_1700_agl.mat'],'rd','TimeStamp')
rd_17 = rd;
time_17 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_05_1800_agl.mat'],'rd','TimeStamp')
rd_18 = rd;
time_18 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_05_1900_agl.mat'],'rd','TimeStamp')
rd_19 = rd;
time_19 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_05_2000_agl.mat'],'rd','TimeStamp')
rd_20 = rd;
time_20 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_05_2100_agl.mat'],'rd','TimeStamp')
rd_21 = rd;
time_21 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_05_2200_agl.mat'],'rd','TimeStamp')
rd_22 = rd;
time_22 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_05_2300_agl.mat'],'rd','TimeStamp')
rd_23 = rd;
time_23 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_06_0000_agl.mat'],'rd','TimeStamp')
rd_00 = rd;
time_00 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_06_0100_agl.mat'],'rd','TimeStamp')
rd_01 = rd;
time_01 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_06_0200_agl.mat'],'rd','TimeStamp')
rd_02 = rd;
time_02 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_06_0300_agl.mat'],'rd','TimeStamp')
rd_03 = rd;
time_03 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_06_0400_agl.mat'],'rd','TimeStamp')
rd_04 = rd;
time_04 = TimeStamp;
load([dir 'lcs_MABSB_2017_04_06_0500_agl.mat'],'rd','TimeStamp','InitialLonLat')
rd_05 = rd;
time_05 = TimeStamp;

d1 = 80; %y
d2 = 88; %x

ln = reshape(InitialLonLat(:,1),d1,d2);
lt = reshape(InitialLonLat(:,2),d1,d2);

%Reshape RD to a meshgrid/regular grid
lcs_15 = nan(d1,d2,size(rd_15,2));
lcs_16 = nan(d1,d2,size(rd_16,2));
lcs_17 = nan(d1,d2,size(rd_17,2));
lcs_18 = nan(d1,d2,size(rd_18,2));
lcs_19 = nan(d1,d2,size(rd_19,2));
lcs_20 = nan(d1,d2,size(rd_20,2));
lcs_21 = nan(d1,d2,size(rd_21,2));
lcs_22 = nan(d1,d2,size(rd_22,2));
lcs_23 = nan(d1,d2,size(rd_23,2));
lcs_00 = nan(d1,d2,size(rd_00,2));
lcs_01 = nan(d1,d2,size(rd_01,2));
lcs_02 = nan(d1,d2,size(rd_02,2));
lcs_03 = nan(d1,d2,size(rd_03,2));
lcs_04 = nan(d1,d2,size(rd_04,2));
lcs_05 = nan(d1,d2,size(rd_05,2));

for k = 1:size(rd,2) %loop through height
     lcs_15(:,:,k) = reshape(rd_15(:,k),d1,d2);  %use relative dispersion as LCS metric
     lcs_16(:,:,k) = reshape(rd_16(:,k),d1,d2);  %use relative dispersion as LCS metric
     lcs_17(:,:,k) = reshape(rd_17(:,k),d1,d2);  %use relative dispersion as LCS metric
     lcs_18(:,:,k) = reshape(rd_18(:,k),d1,d2);  %use relative dispersion as LCS metric
     lcs_19(:,:,k) = reshape(rd_19(:,k),d1,d2);  %use relative dispersion as LCS metric
     lcs_20(:,:,k) = reshape(rd_20(:,k),d1,d2);  %use relative dispersion as LCS metric
     lcs_21(:,:,k) = reshape(rd_21(:,k),d1,d2);  %use relative dispersion as LCS metric
     lcs_22(:,:,k) = reshape(rd_22(:,k),d1,d2);  %use relative dispersion as LCS metric
     lcs_23(:,:,k) = reshape(rd_23(:,k),d1,d2);  %use relative dispersion as LCS metric  
     lcs_00(:,:,k) = reshape(rd_00(:,k),d1,d2);  %use relative dispersion as LCS metric   
     lcs_01(:,:,k) = reshape(rd_01(:,k),d1,d2);  %use relative dispersion as LCS metric   
     lcs_02(:,:,k) = reshape(rd_02(:,k),d1,d2);  %use relative dispersion as LCS metric   
     lcs_03(:,:,k) = reshape(rd_03(:,k),d1,d2);  %use relative dispersion as LCS metric   
     lcs_04(:,:,k) = reshape(rd_04(:,k),d1,d2);  %use relative dispersion as LCS metric   
     lcs_05(:,:,k) = reshape(rd_05(:,k),d1,d2);  %use relative dispersion as LCS metric   
end

lcs_time = nan(d1,d2,size(rd_15,2),15);
time = nan(15,1);
for t = 1:15  %loop through time 1700 to 2300UTC (7 hours)
    if t == 1
        lcs_time(:,:,:,t) = lcs_15(:,:,:);
        time(t) = time_15;
    end
    if t == 2
        lcs_time(:,:,:,t) = lcs_16(:,:,:);
        time(t) = time_16;
    end
    if t == 3
        lcs_time(:,:,:,t) = lcs_17(:,:,:);
        time(t) = time_17;
    end
    if t == 4
        lcs_time(:,:,:,t) = lcs_18(:,:,:);
        time(t) = time_18;
    end
    if t == 5
        lcs_time(:,:,:,t) = lcs_19(:,:,:);
        time(t) = time_19;
    end
    if t == 6
        lcs_time(:,:,:,t) = lcs_20(:,:,:);
        time(t) = time_20;
    end
    if t == 7
        lcs_time(:,:,:,t) = lcs_21(:,:,:);
        time(t) = time_21;
    end
    if t == 8
        lcs_time(:,:,:,t) = lcs_22(:,:,:);
        time(t) = time_22;
    end
    if t == 9
        lcs_time(:,:,:,t) = lcs_23(:,:,:);
        time(t) = time_23;
    end
    if t == 10
        lcs_time(:,:,:,t) = lcs_00(:,:,:);
        time(t) = time_00;
    end
    if t == 11
        lcs_time(:,:,:,t) = lcs_01(:,:,:);
        time(t) = time_01;
    end
    if t == 12
        lcs_time(:,:,:,t) = lcs_02(:,:,:);
        time(t) = time_02;
    end
    if t == 13
        lcs_time(:,:,:,t) = lcs_03(:,:,:);
        time(t) = time_03;
    end
    if t == 14
        lcs_time(:,:,:,t) = lcs_04(:,:,:);
        time(t) = time_04;
    end
    if t == 15
        lcs_time(:,:,:,t) = lcs_05(:,:,:);
        time(t) = time_05;
    end
end

X1d = ln(1,:);
Y1d = lt(:,1)';
Z1d = [10,50,100,150,500,600,700,800,900,1000,1500,2000,2500];
T1d = time';
Data=lcs_time; % (ny, nx, nz, nt)
Data=permute(Data,[2 1 3 4]); % (nx, ny, nz, nt)
%test = lcs_time(:,:,1,1);

% for i = 1:15
%  pcolor(X1d,Y1d,Data(:,:,1,i)); shading flat; title(datestr(time(i)));
%  pause
% end


