%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % This script is used to merge policy data from different periods and calculate % the corresponding averages as reported in: % % Daniel Nohrstedt, Maurizio Mazzoleni, Charles F. Parker, and Giuliano Di % Baldassarre. Policy change after natural hazard % events, Nature Communication % % This script was prepared by Maurizio Mazzoleni % Uppsala University, 2020 % mail to: maurizio.mazzoleni@geo.uu.se % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%Join period 2007-2009 with period 2009-2011 as they have different #countries %Merge countries count_p1_2=[querybuilder20072009;querybuilder20092011]; %Merge PFA hfa_period1_2(:,1)=[nanmean(HFA_2007_2009(:,1:4),2);nanmean(HFA_2009_2011(:,1:4),2)]; %priority for action 1 hfa_period1_2(:,2)=[nanmean(HFA_2007_2009(:,5:8),2);nanmean(HFA_2009_2011(:,5:8),2)]; %PA 2 hfa_period1_2(:,3)=[nanmean(HFA_2007_2009(:,9:12),2);nanmean(HFA_2009_2011(:,9:12),2)]; %PA 3 hfa_period1_2(:,4)=[nanmean(HFA_2007_2009(:,13:18),2);nanmean(HFA_2009_2011(:,13:18),2)]; %PA 4 hfa_period1_2(:,5)=[nanmean(HFA_2007_2009(:,19:22),2);nanmean(HFA_2009_2011(:,19:22),2)]; %PA 5 %Sort count_p1_1=sortrows(count_p1_2,1); hfa_period1_sort1=cat(2,count_p1_2,num2cell(hfa_period1_2)); hfa_period1_sort2=sortrows(hfa_period1_sort1,1); hfa_period1_3=hfa_period1_sort2(:,3:end); hfa_period1_1=cell2mat(hfa_period1_3); %Average calculation for i=1:size(count_p1_1,1) if i==1 count_p1{1,1}=count_p1_1{i,1}; count_p1{1,2}=count_p1_1{i,2}; hfa_period1(1,:)=(hfa_period1_1(i,:)+hfa_period1_1(i+1,:))/2; elseif i>1 && i1 && i'pais' Asecond=row; elseif c3==2 %if the period with less countries is the second period Afirst= row; Asecond=ii; end countryChange{d,1}=temp_country; %writes cell with countries present in both periods, and thus policy change is possible to calculate countryChange{d,2}=temp_namecountry; if Norm_PFAchange==0 HFAChange(d,:)=hfa_period{2}(Asecond,:)-hfa_period{1}(Afirst,:); elseif Norm_PFAchange==1 HFAChange(d,:)=(hfa_period{2}(Asecond,:)-hfa_period{1}(Afirst,:))./hfa_period{1}(Afirst,:); end d=d+1; end end