for i=1:9
    [new_city(i,:) new_cityloct(i,:)]=FIND_CityLoc(cityloc_new(i,:),total_grid,trmm_pos);
end


TheTCPRiskFun2(size(t1d), cityloct(1,:), selcord_w(t1d), sel_gage_t_w(t1d), ...
    tcd_final_w(t1d,1:5), tcd_serial_w{1,1}{1,1}(t1d), 50, 1);

hold on
TheTCPRiskFun2(size(t2d), cityloct(1,:), selcord_w(t2d), sel_gage_t_w(t2d), ...
    tcd_final_w(t2d,1:5), tcd_serial_w{1,1}{1,1}(t2d), 50, 1);


TheTCPRiskE2021Poisson(new_cityloct(1,1),new_cityloct(1,2),t2d,NATCP4_w, ...
                tcd_final_w(:,1), tcd_serial_w{1}{1}, 50, 1969, 1, 'r');
hold on            
TheTCPRiskE2021Poisson(new_cityloct(1,1),new_cityloct(1,2),t1d,NATCP4_w, ...
                tcd_final_w(:,1), tcd_serial_w{1}{1}, 50, 1949, 1, 'b');

figure()
TheTCPRiskE2021Poisson(new_cityloct(9,1),new_cityloct(9,2),t2d,NATCP4_w, ...
                tcd_final_w(:,1), tcd_serial_w{1}{1}, 50, 1969, 1, 'r');
hold on            
TheTCPRiskE2021Poisson(new_cityloct(9,1),new_cityloct(9,2),t1d,NATCP4_w, ...
                tcd_final_w(:,1), tcd_serial_w{1}{1}, 50, 1949, 1, 'b');
            
            
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Plot the event risk curves for cities
for i=1:9
subplot(3,3,i)
TheTCPRiskE2021Poisson(new_cityloct(i,1),new_cityloct(i,2),t1e,Event_TCP4, ...
                Event_Year, EventSerial{1,1}, 50, 1949, 1, 'b');
hold on              
TheTCPRiskE2021Poisson(new_cityloct(i,1),new_cityloct(i,2),t2e,Event_TCP4, ...
                Event_Year, EventSerial{1,1}, 50, 1969, 1, 'r');

if i==1
ylim([0 700]);
legend('early CI','early','late CI','late','location','Northwest','fontsize',9);
else
ylim([0 300]);
if i==2 || i==3 || i==4|| i==5
    legend('early CI','early','late CI','late','location','Southeast','fontsize',9);
else
    legend('early CI','early','late CI','late','location','Northwest','fontsize',9);
end
end
title(append(cityname_new(i),'(',new_city_text(i,1:5),char(176),', ',new_city_text(i,6:10),char(176),')'));
legend('boxoff')
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Plot the daily risk curves for cities
for i=1:9
subplot(3,3,i)
TheTCPRiskE2021Poisson(new_cityloct(i,1),new_cityloct(i,2),t1d,NATCP4_w, ...
                tcd_final_w(:,1), tcd_serial_w{1}{1}, 50, 1949, 1, 'b');
hold on
            
TheTCPRiskE2021Poisson(new_cityloct(i,1),new_cityloct(i,2),t2d,NATCP4_w, ...
                tcd_final_w(:,1), tcd_serial_w{1}{1}, 50, 1969, 1, 'r');      


if i==1
ylim([0 150]);
legend('early CI','early','late CI','late','location','Southeast','fontsize',9);
else
ylim([0 150]);
if i==2 || i==3 || i==4|| i==5|| i==8
    legend('early CI','early','late CI','late','location','Southeast','fontsize',9);
else
    legend('early CI','early','late CI','late','location','Northwest','fontsize',9);
end
end
title(append(cityname_new(i),'(',new_city_text(i,1:5),char(176),', ',new_city_text(i,6:10),char(176),')'));
legend('boxoff')
end

append(cityname_new(1),'(',new_city_text(i,1:5),char(176),', ',new_city_text(i,6:10),char(176),')')


%Plot the event risk curves for cities 35 years
for i=1:9
subplot(3,3,i)
TheTCPRiskE2021Poisson(new_cityloct(i,1),new_cityloct(i,2),t1e,Event_TCP4, ...
                Event_Year, EventSerial{1,1}, 35, 1949, 1, 'b');
hold on              
TheTCPRiskE2021Poisson(new_cityloct(i,1),new_cityloct(i,2),t2e,Event_TCP4, ...
                Event_Year, EventSerial{1,1}, 35, 1984, 1, 'r');
xlim([0 35])
if i==1
ylim([0 700]);
legend('early CI','early','late CI','late','location','Northwest','fontsize',9);
else
ylim([0 300]);
if i==2 || i==3 || i==4|| i==5
    legend('early CI','early','late CI','late','location','Southeast','fontsize',9);
else
    legend('early CI','early','late CI','late','location','Northwest','fontsize',9);
end
end
title(append(cityname_new(i),'(',new_city_text(i,1:5),char(176),', ',new_city_text(i,6:10),char(176),')'));
legend('boxoff')
end
