%% This is included in the release as an example Matlab script that reads and
%  plots the data.

%  Script developer:  Cathy May, Univ Central Florida, cmay@knights.ucf.edu,
%                     402.706.8771

%% THESE NEED TO BE CHANGED BASED ON THE DESIRED PLOT
clear all;close all;clc;
name = 'KARL16'; % name of the storm either 'EARL' or 'KARL16'

if strcmp(name,'EARL') == 1
for m = 1:6 % change the file location
    load(['Y:\HIRAD_cathy\EARL\shift_centers\files\EARL_leg',num2str(m),'.mat']);
    legs(m) = leg;
end
end

if strcmp(name,'KARL16') == 1
for m = 2:10 % change the file location
    load(['Y:\HIRAD_cathy\KARL_16\shift_centers\files\KARL16_leg',num2str(m),'.mat']);
    legs(m) = leg;
end    
end

mn = find(legs(2).az == -65); % min azimuth angle
mx = find(legs(2).az == 65); % max azimuth angle
nums = [2 4]; % legs that you would like plotted ex. 1 or 1:6
type = 'p'; % 'p' is a pcolor plot (smoothed image), 's' is a scatter plot
l_l = 'storm'; % earth or storm relative coordinates ('earth' or 'storm')

%% 

if strcmp(l_l,'storm') == 1
if strcmp(type,'s') == 1
figure;turbo_cscat(legs(nums(1)).del_lon(:,mn:mx),...
    legs(nums(1)).del_lat(:,mn:mx),...
    legs(nums(1)).delTB5xx(:,mn:mx),'.');
all_nums = [' ',num2str(nums(1))];
name_num = num2str(nums(1));
if length(nums) > 1;hold on;
for s = 2:length(nums)
turbo_cscat(legs(nums(s)).del_lon(:,mn:mx),...
    legs(nums(s)).del_lat(:,mn:mx),...
    legs(nums(s)).delTB5xx(:,mn:mx),'.');
all_nums = [all_nums,', ',num2str(nums(s))];
name_num = [name_num,num2str(nums(s))];
end
end
end

if strcmp(type,'p') == 1
figure;pcolor(legs(nums(1)).del_lon(:,mn:mx),...
    legs(nums(1)).del_lat(:,mn:mx),...
    legs(nums(1)).delTB5xx(:,mn:mx));shading interp;
all_nums = [' ',num2str(nums(1))];
name_num = num2str(nums(1));
if length(nums) > 1;hold on;
for s = 2:length(nums)
pcolor(legs(nums(s)).del_lon(:,mn:mx),...
    legs(nums(s)).del_lat(:,mn:mx),...
    legs(nums(s)).delTB5xx(:,mn:mx));shading interp;
all_nums = [all_nums,', ',num2str(nums(s))];
name_num = [name_num,num2str(nums(s))];
end
end
end
end


if strcmp(l_l,'earth') == 1
if strcmp(type,'s') == 1
figure;turbo_cscat(legs(nums(1)).swath_lon(:,mn:mx),...
    legs(nums(1)).swath_lat(:,mn:mx),...
    legs(nums(1)).delTB5xx(:,mn:mx),'.');
all_nums = [' ',num2str(nums(1))];
name_num = num2str(nums(1));
if length(nums) > 1;hold on;
for s = 2:length(nums)
turbo_cscat(legs(nums(s)).swath_lon(:,mn:mx),...
    legs(nums(s)).swath_lat(:,mn:mx),...
    legs(nums(s)).delTB5xx(:,mn:mx),'.');
all_nums = [all_nums,', ',num2str(nums(s))];
name_num = [name_num,num2str(nums(s))];
end
end
end

if strcmp(type,'p') == 1
figure;pcolor(legs(nums(1)).swath_lon(:,mn:mx),...
    legs(nums(1)).swath_lat(:,mn:mx),...
    legs(nums(1)).delTB5xx(:,mn:mx));shading interp;
all_nums = [' ',num2str(nums(1))];
name_num = num2str(nums(1));
if length(nums) > 1;hold on;
for s = 2:length(nums)
pcolor(legs(nums(s)).swath_lon(:,mn:mx),...
    legs(nums(s)).swath_lat(:,mn:mx),...
    legs(nums(s)).delTB5xx(:,mn:mx));shading interp;
all_nums = [all_nums,', ',num2str(nums(s))];
name_num = [name_num,num2str(nums(s))];
end
end
end
end


grid on;set(gca,'Layer','top');colorbar;caxis([0 100]);axis equal;  

%axis([-2 2.5 -2.5 2]);  % If you want to put have a certain axis / zoom

title(['HIRAD 5 GHz Excess T_B, ',name,' Leg',all_nums]);

% saveas(gcf,[name,'_leg',name_num,'.jpg']); % Easy way to save the plots
% close;

