% https://www.insee.fr/fr/statistiques/fichier/4769950/deces-2010-2018-csv.zip
% https://www.insee.fr/fr/statistiques/fichier/4190491/Deces_2018.zip
% https://www.insee.fr/fr/statistiques/fichier/4190491/Deces_2019.zip
% https://www.insee.fr/fr/statistiques/fichier/4190491/Deces_2020_M01.zip
% ...
% https://www.insee.fr/fr/statistiques/fichier/4190491/Deces_2020_M11.zip
%
% et aussi https://www.data.gouv.fr/en/datasets/fichier-des-personnes-decedees/
% et aussi http://data.cquest.org/insee_deces/
close all; ROOT = 'C:\TMP\COVID\deces-'; T=[]; A=[]; S=[]; AgeMax=120;
V=1970; currentMonth=12; W=2020 + currentMonth/12; % de 2017 a Decembre 2020
for ifile=V:2019 %floor(W-1)
F=sprintf('C:\\TMP\\COVID\\deces-%d.csv',ifile); x=readtable(F);
T=[T;x.datedeces]; A=[A;x.datenaiss]; S=[S;x.sexe];
end
for imonth=1:currentMonth
F=sprintf('C:\\TMP\\COVID\\Deces_2020_M%02d.csv',imonth); x=readtable(F);
T=[T;x.datedeces]; A=[A;x.datenaiss]; S=[S;x.sexe];
end
% Correction des erreurs de saisies en Mairie
T1=T(T>V*10000); T2=T1(T1<W*10000); N1=A(T>V*10000); N2=N1(T1<W*10000);
TT = sort (T2); Y=floor(TT/10000); M=max (1, floor((TT-Y*10000)/100));
D=min(30, max(1, (TT-Y*10000) - (M*100))); DATA = (Y - V) + ((M-1)/12) + ((D-1)/365);
% plot
close all;
figure; b=hist(DATA, (W-V)); ax=(V:(W-V)/(length(b)-1):W); plot (ax-1,b/1000);
grid on; ylabel('Milliers de morts par an');
figure; b=hist(DATA, 12*(W-V)); b(1)=0; ax=(V:(W-V)/(length(b)-1):W); plot (ax-1,b/1000);
grid on; ylabel('Milliers de morts par mois');
figure; b=hist(DATA, 7*12*(W-V));b(1)=0; ax=(V:(W-V)/(length(b)-1):W); plot (ax-1,b/1000);
grid on; ylabel('Milliers de morts par semaine');
M = zeros(floor(length(b)-83), 1);
for k=1:floor(-1 + length(b))-83
M(k) = sum(b(k+(0:83)));
end
figure; plot (ax(85:end)-1,M(1:end-1)/1000,'r.');
grid on; ylabel('Milliers de morts par an');
k=0;
% figure; b=hist(DATA, 365*20.9);b(1)=0; ax=(1970:(2020.9-1970)/(length(b)-1):2020.9); plot (ax,b); grid on;
% FT=min(W, max(V,floor(T/10000))); FA=min(W, max(W-AgeMax,floor(A/10000)));
% Y2=max(V, min(W, FT)); Y1=max(W-AgeMax, min(W, FA)); Y=max(0, min(AgeMax, Y2-Y1));
% M2 = floor((T-Y2*10000)/100)-1; M1 = floor((Y2*10000- A)/100)-1; M2=max(0, min(11, M2)); M=max(-12, min(12, M2-M1));
% D2 = (T-Y2*10000)-(M2*100)-1; D1 = (A-Y2*10000)-(M2*100)-1; D2=max(0, min(31, D2)); D=max(-30, min(31, D2-D1));
% AGE = Y + M/12 + D/365;
% DECES = Y2 + M2/12 + D2/365;vax leak from Albania :
https://drive.google.com/file/d/1sSsKLZ9pELHOeCBxAmoZw-MP0Fps-A8L/view?usp=sharing