Mitigation Scenarios

load('data/windfarms_processed.mat')
load('data/energy_processed.mat');
load('data/birdAtRisk.mat')
%load('../2018/data/Density_estimationMap','g');
%load('../2018/data/Density_estimationMap','gd');
Set to zero if nan
birdAtRisk(isnan(birdAtRisk)) = 0;

Night vs Day

How much energy is produced during the day?
energy_day = nansum(energy(daynight))./nansum(energy(:))
energy_day = 0.4334
nansum(energy(daynight))
ans = 3.1147e+17

Scenario 1 : Ideal world

In addition to the energy produced during the day, more energy is produced without risking the birds:
energy_safe=nansum(energy(birdAtRisk==0))/nansum(energy(:))
energy_safe = 0.5779
We can compare then the reminding power lost by how much bird at risk reduction:
tmp = birdAtRisk(:)./energy(:);
[tmp_s,id] = sort(tmp);
id = id(~isnan(tmp_s));
figure('position',[0 0 1200 800]); hold on; box on; grid on
% plot(tmp_s);
tmp_e = cumsum(energy(id),'omitnan')./nansum(energy(:));
plot(tmp_e,'linewidth',2)
tmp_b = cumsum(birdAtRisk(id))./nansum(birdAtRisk(:));
plot(tmp_b,'linewidth',2)
yline(energy_day,'-k','Energy produced during the day')
yline(energy_safe,'-k','Energy produced without any bird at risk')
xline(find(tmp_b>.5,1),'-k','50% of birds at risk reduced')
yline(tmp_e(find(tmp_b>.5,1)))
xline(find(tmp_b>.1,1),'-k','90% of birds at risk reduced')
yline(tmp_e(find(tmp_b>.1,1)))
xline(find(tmp_b>.01,1),'-k','99% of birds at risk reduced')
yline(tmp_e(find(tmp_b>.01,1)))
axis tight;
legend('Energy produced','Number of bird at risk','Location','northwest')
ylabel('Cumulative Sum')
xlabel('Datapoint (grid cells x time) sorted by increasing impact (birds@risk / energey produced)')
figure('position',[0 0 1300 500]); hold on; grid on;
plot((1-tmp_e),tmp_b,'k','linewidth',2);
axis tight; xlim([0 .2])
ylabel('Percentage of bird saved')
xlabel('Percentage of Energy lost')

Scenario 2: Defined migration period

Daily
[G,t_day] = findgroups(dateshift(time,'start','day','nearest'));
tmp_b = splitapply( @sum, reshape(sum(sum(birdAtRisk),2),1,[]), G);
tmp_e = energy;
tmp_e(daynight)=0;
tmp_e = splitapply( @nansum, reshape(nansum(nansum(tmp_e),2),1,[]), G);
figure;
hold on
plot(t_day,tmp_b./sum(birdAtRisk(:)))
plot(t_day,tmp_e./nansum(energy(:)))
figure; hold on;
y=cumsum(sort(tmp_b))./sum(tmp_b);
plot(y)
yline(.5)
[~,tmp]=min(abs(y-.5));
xline(tmp,'-',['50% of bird at risk in ' num2str(numel(t_day)-tmp) ' days'])
axis tight;
Per block of week
t_week = datetime('1-Jan-2018'):7:datetime('31-Dec-2018');
tmp_col = nan(4,numel(t_week)-1);
for i_t=1:numel(t_week)-1
it = time>t_week(i_t)&time<t_week(i_t+1);
tmp_b = birdAtRisk(:,:,it);
tmp_n = ~daynight(:,:,it);
tmp_e = energy(:,:,it);
tmp_col(:,i_t) = [nansum(tmp_b(:)) nansum(tmp_b(tmp_n)) nansum(tmp_e(:)) nansum(tmp_e(tmp_n))];
end
figure('position',[0 0 1300 1000]);
subplot(2,1,1); hold on;box on
bar(t_week(1:end-1),tmp_col(1,:))
bar(t_week(1:end-1),tmp_col(2,:))
ylim([0 18e6]); ylabel('Bird at Risk [nb of bird]')
yyaxis 'right'; ax = gca; ax.YAxis(2).Color = 'k'; box on
ylim([0 18e6]/sum(tmp_col(2,:))); ylabel('Bird ar Risk. ratio of total')
subplot(2,1,2); hold on; box on
bar(t_week(1:end-1),tmp_col(3,:))
bar(t_week(1:end-1),tmp_col(4,:))
ylim([0 3e16]); ylabel('Power potential [-]')
yyaxis 'right'; ax = gca; ax.YAxis(2).Color = 'k'; box on
ylim([0 3e16]/sum(tmp_col(3,:))); ylabel('Power Potential. Normalized with total Produced')
legend('Day+Night','Night');
Off certain Season
thr_date = datetime({...
'1-Mar-2018','1-May-2018','15-Aug-2018','15-Nov-2018';...
'1-Mar-2018','1-Apr-2018','1-Oct-2018','1-Nov-2018';...
});
figure('position',[0 0 1300 500]); hold on
fill([thr_date(1,1) thr_date(1,2) thr_date(1,2) thr_date(1,1)],[0 0 10^6 10^6],'y','EdgeAlpha',0,'FaceAlpha',.5)
fill([thr_date(1,3) thr_date(1,4) thr_date(1,4) thr_date(1,3)],[0 0 10^6 10^6],'y','EdgeAlpha',0,'FaceAlpha',.5)
fill([thr_date(2,1) thr_date(2,2) thr_date(2,2) thr_date(2,1)],[0 0 10^6 10^6],'g','EdgeAlpha',0,'FaceAlpha',.5)
fill([thr_date(2,3) thr_date(2,4) thr_date(2,4) thr_date(2,3)],[0 0 10^6 10^6],'g','EdgeAlpha',0,'FaceAlpha',.5)
plot(time,reshape(sum(sum(birdAtRisk),2),1,[]),'k')
box on
clear tmp_col
tmp_col(1,:) = [nansum(birdAtRisk(:)) nansum(energy(:)) nansum(energy(:))];
for i_t=1:size(thr_date,1)
it = ~( (time>thr_date(i_t,1)&time<thr_date(i_t,2)) | (time>thr_date(i_t,3)&time<thr_date(i_t,4)) );
tmp_col(i_t+1,:) = [nansum(birdAtRisk(:,:,it),'all') nansum(energy(:,:,it),'all') nansum(energy(:,:,it),'all')+nansum(energy(:,:,~it).*daynight(:,:,~it),'all') ];
end
t=table({'No cut','yellow','green'}',tmp_col(:,1),tmp_col(:,2),tmp_col(:,3),'VariableNames',{'Mitigation','Bird at risk','Energy','Energy w/ Night'})
t = 3×4 table
 MitigationBird at riskEnergyEnergy w/ Night
1'No cut'1.1412e+087.1863e+177.1863e+17
2'yellow'5.4284e+064.1937e+175.5642e+17
3'green'4.2221e+075.7910e+176.3971e+17
t{:,2:end}=t{:,2:end}./t{1,2:end}*100
t = 3×4 table
 MitigationBird at riskEnergyEnergy w/ Night
1'No cut'100100100
2'yellow'4.756958.357377.4273
3'green'36.998180.584189.0179
Running windows of 1 and 2 weeks
Per day
time_d = dateshift(time,"start",'day');
birdAtRisk_d = splitapply(@sum, squeeze(sum(birdAtRisk,[1 2])),findgroups(time_d'));
energy_d = splitapply(@sum, squeeze(sum(energy,[1 2],'omitnan')),findgroups(time_d'));
figure; hold on; box on
plot(unique(time_d),birdAtRisk_d)
yyaxis right; plot(unique(time_d),energy_d)
figure;
plot(unique(time_d),movsum(birdAtRisk_d,14)); ylabel('Bird at risk')
yyaxis right; plot(unique(time_d),movsum(energy_d,14)); ylabel('Potential energy')

Scenario 3: Map

Where are the bird at risk during the migration period?
it = ( (time>thr_date(1,1)&time<thr_date(1,2)) | (time>thr_date(1,3)&time<thr_date(1,4)) );
tmp_b = nansum(birdAtRisk(:,:,it),3);
tmp_e = energy(:,:,it);
tmp_n = ~daynight(:,:,it);
tmp_e(~tmp_n) = 0;
tmp_e = nansum(tmp_e,3);
load coastlines
dcoast = pdist2([g.lat2D(:) g.lon2D(:)],[coastlat coastlon], @lldistkm);
dcoast = reshape(min(dcoast,[],2),size(g.lat2D));
figure; hold on; box on;
plot(dcoast(:), tmp_e(:)./tmp_b(:),'.k'); lsline;
[G,dcoast_bin] = findgroups(round(dcoast(:),-1));
plot(dcoast_bin, splitapply(@nanmean,tmp_e(:)./tmp_b(:),G),'-r','linewidth',2)
xlabel('distance to coast [km]');
ylabel('Energy lost per bird saved')
ddd=0:10:500;
tmp_bdd=nan(size(ddd)); tmp_edd=nan(size(ddd));
for i_d=1:numel(ddd)
tmp_bdd(i_d)=nansum(tmp_b(dcoast>ddd(i_d)))/nansum(birdAtRisk(:));
tmp_edd(i_d)=nansum(tmp_e(dcoast>ddd(i_d)))/nansum(energy(:));
end
figure; hold on; box on
plot(ddd,tmp_bdd)
plot(ddd,tmp_edd)
xline(50)
yline(tmp_bdd((ddd==50)))
yline(tmp_edd((ddd==50)))
xlabel('Distance to coast from which WT are turned-off [km]');
ylabel('Percentage of ... ')
legend('Bird saved','Energy lost')
figure('position',[0 0 1400 700]);
ax1=subplot(size(thr_date,1),3,(i_t-1)*3+1); hold on;
h = worldmap([g.lat(1)-2 g.lat(end)+2], [g.lon(1)-2 g.lon(end)+2]);
setm(h,'frame','on','grid','off'); set(findall(h,'Tag','MLabel'),'visible','off'); set(findall(h,'Tag','PLabel'),'visible','off')
bordersm('countries','facecolor',[228 238 243]./255);
tmp = tmp_b;
tmp(tmp==0)=nan;
surfm(g.lat,g.lon,tmp)
c=colorbar('south'); title('Birds saved [birds]');
colormap(ax1,brewermap([],'OrRd'))
ax2=subplot(size(thr_date,1),3,(i_t-1)*3+2); hold on;
h = worldmap([g.lat(1)-2 g.lat(end)+2], [g.lon(1)-2 g.lon(end)+2]);
setm(h,'frame','on','grid','off'); set(findall(h,'Tag','MLabel'),'visible','off'); set(findall(h,'Tag','PLabel'),'visible','off')
bordersm('countries','facecolor',[228 238 243]./255);
tmp2 = tmp_e;
tmp2(tmp2==0)=nan;
surfm(g.lat,g.lon,tmp2/1e12)
%scatterm(tim.Latitude,tim.Longitude,'.k');
c=colorbar('south'); title('Energy lost [TJ]');
colormap(ax2,plasma)
ax3=subplot(size(thr_date,1),3,(i_t-1)*3+3); hold on;
h = worldmap([g.lat(1)-2 g.lat(end)+2], [g.lon(1)-2 g.lon(end)+2]);
setm(h,'frame','on','grid','off'); set(findall(h,'Tag','MLabel'),'visible',