-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaux_systematic_swipe_inset_plot.m
124 lines (104 loc) · 3.73 KB
/
aux_systematic_swipe_inset_plot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
%%% main parameter swipe: systematically exploring varaint detection delay %%%
clear all
close all
clc
%% Defininig solver variables
expno = 1;
setup.ti = -14;
setup.tf = 500;
tspan = [setup.ti setup.tf];
%% Defining experiment
k = 2;
setup.k = k; % Número de variantes en competencia (todo debe calzar)
setup.xi = 0.25*ones(setup.k,1);
setup.eta = 0.95*ones(setup.k,1);
setup.tspan = tspan;
setup.a = [3 4];
setup.b = [4 5];
setup.maxvar= 6*30;
setup.Phimax= [2 3]*5e2;
AbsTol = 1e-12;
RelTol = 1e-9;
options= odeset('AbsTol',AbsTol,'RelTol',RelTol,'NonNegative',1:(5*k+2));
%% calculating the reference time
setup.R0max = [1.5 1.5]';
setup.Tin = [-5 450];
[Par,Fun] = generador_parametros(setup);
odefun = @(t,y) dydt(t,y,Par,Fun);
generador_cond_inicial(Par)
[t,y] = ...
ode45(@(t,y) odefun(t,y), tspan, generador_cond_inicial(Par), options);
[~, ~, N_com, N_POE] = Nobs(t,y,Par,Fun);
[~,ind] = max(sum(N_com));
Tmax = 1+floor(t(ind)/7);
%% we have to make a swipe
R0v1 = 1.5;
n_R0 = 21;
R0max_swipe = R0v1*linspace(1,6,n_R0);
R0max_swipe_ref = linspace(1,6,n_R0);
n_Tin = 9;
Tin_swipe = 7*(Tmax + linspace(-20,20,n_Tin));
Tin_swipe_ref = linspace(-20,20,n_Tin);
Jind = [2 5 8];
Iind = [2 4 8];
ylimsup = [2500 3000 12500];
for m = 1:3
I = Iind(m);
J = Jind(m);
setup.R0max = [R0v1 R0max_swipe(I)]';
setup.Tin = [-5 Tin_swipe(J)];
[Par,Fun] = generador_parametros(setup);
odefun = @(t,y) dydt(t,y,Par,Fun);
generador_cond_inicial(Par)
[t,y] = ...
ode45(@(t,y) odefun(t,y), tspan, generador_cond_inicial(Par), options);
[Nobs_com, Nobs_POE, N_com, N_POE] = Nobs(t,y,Par,Fun);
%% Accumulating and discretising weekly cases
Nobs_com_weekly = nan(k,floor((setup.tf-setup.ti)/7) + 1);
Nobs_POE_weekly = nan(k,floor((setup.tf-setup.ti)/7) + 1);
T = floor(setup.ti/7):floor(setup.tf/7);
for i = 2:floor((setup.tf-setup.ti)/7) + 1
for j = 1:k
idx = t/7 >= T(i-1) & t/7 <= T(i);
Nobs_com_weekly(j,i) = floor(trapz(t(idx),Nobs_com(j,idx)));
Nobs_POE_weekly(j,i) = floor(trapz(t(idx),Nobs_POE(j,idx)));
end
end
h = figure('units','centimeters','position',[3*m,3,3,3]);
plot(T,Nobs_com_weekly,'LineWidth',2)
hold on
N_T = sum(Nobs_com_weekly);
plot(T,N_T,'k--','LineWidth',2)
xlim([0 60])
ylim([0 ylimsup(m)]);
ylabel('Weekly new cases','FontSize',10)
set(gca,'FontSize',8,'XColor','k','YColor','k','TickLength',[0.025 0.025])
print(h,strcat('auxinset_no_',num2str(m)),'-dpdf')
end
setup.R0max = [R0v1 R0max_swipe(I)]';
setup.Tin = [-5 500];
[Par,Fun] = generador_parametros(setup);
odefun = @(t,y) dydt(t,y,Par,Fun);
generador_cond_inicial(Par)
[t,y] = ...
ode45(@(t,y) odefun(t,y), tspan, generador_cond_inicial(Par), options);
[Nobs_com, Nobs_POE, N_com, N_POE] = Nobs(t,y,Par,Fun);
%% Accumulating and discretising weekly cases
Nobs_com_weekly = nan(k,floor((setup.tf-setup.ti)/7) + 1);
Nobs_POE_weekly = nan(k,floor((setup.tf-setup.ti)/7) + 1);
T = floor(setup.ti/7):floor(setup.tf/7);
for i = 2:floor((setup.tf-setup.ti)/7) + 1
for j = 1:k
idx = t/7 >= T(i-1) & t/7 <= T(i);
Nobs_com_weekly(j,i) = floor(trapz(t(idx),Nobs_com(j,idx)));
Nobs_POE_weekly(j,i) = floor(trapz(t(idx),Nobs_POE(j,idx)));
end
end
h = figure('units','centimeters','position',[3,3,9,3]);
plot(t/7,Nobs_com(1,:),'LineWidth',2)
hold on
xlim([10 50])
ylim([0 300]);
ylabel('Weekly new cases','FontSize',10)
set(gca,'FontSize',8,'XColor','k','YColor','k','TickLength',[0.025 0.025])
print(h,strcat('auxinset_no_',num2str(4)),'-dpdf')