forked from MunskyGroup/Matlab_Wrap_for_JHU_COVID19
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpop_out_map.m
112 lines (101 loc) · 3.46 KB
/
pop_out_map.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
function [h,cblab,ticklabs,K] = pop_out_map(app,j_time_to_plot,max_j)
if nargin<3
max_j = j_time_to_plot;
end
figure(314); clf;
if app.abs_2.Value
DATA = app.DATA;
DATA_Deaths = app.DATA_Deaths;
DATA_Recov = app.DATA_Recov;
app.ax_infections.YLabel.String = 'Infections (absolute number)';
app.ax_deaths.YLabel.String = 'Deaths (absolute number)';
Lat = app.Lat;
Long = app.Long;
countries = app.Countries;
else
DATA = app.Pop_Data.DATA;
DATA_Deaths = app.Pop_Data.DATA_Deaths;
DATA_Recov = app.Pop_Data.DATA_Recov;
app.ax_infections.YLabel.String = 'Infections (per 10k individuals)';
app.ax_deaths.YLabel.String = 'Deaths (per 10k individuals)';
Lat = app.Pop_Data.Lat;
Long = app.Pop_Data.Long;
countries = app.Pop_Data.Country_Names;
end
switch app.map_what.Value
case 'Active'
DATA = max(0,DATA - DATA_Deaths - DATA_Recov);
case 'Recovered'
DATA = max(0,DATA_Recov);
case 'Deaths'
DATA = DATA_Deaths;
case 'Cumulative Infected'
DATA = DATA;
case 'Recent Infected'
DATA = max(0,[DATA(:,1:3), DATA(:,4:end) - DATA(:,1:end-3)]);
end
% Create base map for World, US, or Europe
J = ones(size(DATA,1),1,'logical');
switch app.RegionDropDown.Value
case {'World'}
h = worldmap('World'); % Store the output handle!
load coastlines
plotm(coastlat, coastlon);
geoshow('landareas.shp', 'FaceColor', [0.15 0.5 0.15])
case {'US'}
h = usamap('conus');
states = shaperead('usastatelo', 'UseGeoCoords', true,...
'Selector',...
{@(name) ~any(strcmp(name,{'Alaska','Hawaii'})), 'Name'});
rng(0);
faceColors = makesymbolspec('Polygon',...
{'INDEX', [1 numel(states)], 'FaceColor', ...
polcmap(numel(states))}); %NOTE - colors are random
geoshow(h, states, 'DisplayType', 'polygon', ...
'SymbolSpec', faceColors)
J = strcmp(countries,'US')&~strcmp(countries,'Alaska')&~strcmp(countries,'Hawaii')...
&~contains(countries,'Princess');
case {'Europe'}
h = worldmap('Europe'); % Store the output handle!
load coastlines
plotm(coastlat, coastlon);
geoshow('landareas.shp', 'FaceColor', [0.15 0.5 0.15])
end
DATA = DATA(J,:);
Lat = Lat(J);
Long = Long(J);
% Extrapolate for future dates.
Nt = size(DATA,2);
if max_j>Nt
nf = 5;
[gr_rate,kept_states] = Make_Growth_Rate_Table(app,nf,DATA);
for jt = Nt+1:max_j
DATA(kept_states,jt) = DATA(kept_states,jt-1).*(2.^(1./gr_rate));
DATA(~kept_states,jt) = DATA(~kept_states,jt-1);
end
end
% [a,b] = max(DATA(:,end))
% countries = countries(J);
% countries(b)
% Bin data for plotting
cmap = colormap('jet');
if app.abs_2.Value
I = floor(log2(DATA(:,j_time_to_plot)));
mxI = log2(max(DATA(:)));
mksize = linspace(4,30,mxI);
K = floor(linspace(1,size(cmap,1),floor(log2(max(DATA(:))))));
ticklabs = 2.^[1:length(K)];
cblab = 'Size of infection';
else
nb = 7;
I = floor(log2(DATA(:,j_time_to_plot))+nb);
mxI = log2(max(DATA(:)))+nb;
mksize = linspace(4,30,mxI);
K = floor(linspace(1,size(cmap,1),floor(log2(max(DATA(:)))+nb)));
ticklabs = 2.^([1:length(K)]-nb);
cblab = 'Size of infection per 10k';
end
% Add points for all states/regions
for i=1:max(I)
geoshow(Lat(I==i),Long(I==i),'DisplayType', 'Point', 'Marker', 'o', 'Color',cmap(K(i),:),'MarkerFaceColor',cmap(K(i),:),'MarkerSize',mksize(i))
end