+school_reopenings = {
+ 'ES': {'date': '2020-05-18'},
+ 'FR': {'date': '2020-05-18'}, # some areas only
+# 'IT': {'date': '2020-09-01'},
+ # 'IE': {'date': '2020-09-01'},
+ 'DE': {'date': '2020-05-04'},
+ 'UK': {'date': '2020-06-01'}
+}
+```
+
+```python
+data_since_threshold[data_since_threshold.dateRep == '2020-05-04'].loc[(slice(None), ['DE']), :].first_valid_index()
+```
+
+```python
+data_since_threshold[data_since_threshold.dateRep == '2020-05-04'].loc[(slice(None), ['DE']), :].iloc[0].deaths_m7
+```
+
+```python
+for cID in school_reopenings:
+ dst_in = data_since_threshold[data_since_threshold.dateRep == (school_reopenings[cID]['date'])].loc[(slice(None), [cID]), :]
+ dst_i = dst_in.first_valid_index()
+ dst_n = dst_in.iloc[0].deaths_m7
+ school_reopenings[cID]['since_threshold'] = dst_i[0]
+ school_reopenings[cID]['deaths_m7'] = dst_n
+school_reopenings
+```
+
+```python
+ax = deaths_m7[COUNTRIES_CORE].plot(figsize=(15, 9), title="Deaths per day, 7 day moving average")
+# uk_projection.deaths_m7.plot(ax=ax)
+for c in COUNTRIES_CORE:
+ lvi = deaths_m7[c].last_valid_index()
+ ax.text(x = lvi + 1, y = deaths_m7[c][lvi], s = f"{c}: {deaths_m7[c][lvi]:.0f}")
+ if c in school_reopenings:
+ marker_col = [l for l in ax.lines if l.get_label() == c][0].get_color()
+ ax.plot(school_reopenings[c]['since_threshold'], school_reopenings[c]['deaths_m7'], '*',
+ markersize=18, markerfacecolor=marker_col, markeredgecolor=marker_col)
+ ax.text(x = school_reopenings[c]['since_threshold'] + 1, y = school_reopenings[c]['deaths_m7'],
+ s = f"{school_reopenings[c]['date']}: {school_reopenings[c]['deaths_m7']:.0f}")
+plt.savefig('school_reopenings.png')
+```
+
+```python
+# ax = deaths_m7[COUNTRIES_CORE].plot(figsize=(15, 9), title="Deaths per day, 7 day moving average",
+# xlim=(46, 91), ylim=(0, 400))
+# # uk_projection.deaths_m7.plot(ax=ax)
+# for c in COUNTRIES_CORE:
+# lvi = deaths_m7[c].last_valid_index()
+# ax.text(x = lvi + 1, y = deaths_m7[c][lvi], s = f"{c}: {deaths_m7[c][lvi]:.0f}", fontsize=14)
+# if c in school_reopenings:
+# marker_col = [l for l in ax.lines if l.get_label() == c][0].get_color()
+# ax.plot(school_reopenings[c]['since_threshold'], school_reopenings[c]['deaths_m7'], '*',
+# markersize=18, markerfacecolor=marker_col, markeredgecolor=marker_col)
+# ax.text(x = school_reopenings[c]['since_threshold'] + 1, y = school_reopenings[c]['deaths_m7'],
+# s = f"{school_reopenings[c]['date']}: {school_reopenings[c]['deaths_m7']:.0f}",
+# fontsize=14)
+# plt.savefig('school_reopenings_detail.png')
+```
+
+# Lockdown graphs
+
+```python
+lockdown_dates = {
+ 'ES': { 'part_start': {'date': '2020-03-14'}
+ , 'full_start': {'date': '2020-03-15'}
+ , 'part_finish': {'date': '2020-05-18'}
+ },
+ 'FR': { 'part_start': {'date': '2020-03-13'}
+ , 'full_start': {'date': '2020-03-17'}
+ , 'part_finish': {'date': '2020-05-11'}
+ },
+ 'IT': { 'part_start': {'date': '2020-03-08'}
+ , 'full_start': {'date': '2020-03-10'}
+ , 'part_finish': {'date': '2020-05-04'}
+ },
+ 'DE': { #'part_start': {'date': '2020-03-13'}
+ 'full_start': {'date': '2020-03-22'}
+ , 'part_finish': {'date': '2020-05-06'}
+ },
+ 'UK': { 'part_start': {'date': '2020-03-23'}
+ , 'full_start': {'date': '2020-03-23'}
+ , 'part_finish': {'date': '2020-05-31'}
+ },
+ 'IE': { #'part_start': {'date': '2020-03-12'}
+ 'full_start': {'date': '2020-03-27'}
+ , 'part_finish': {'date': '2020-05-18'}
+ },
+}
+```
+
+```python
+for cID in lockdown_dates:
+ for phase in lockdown_dates[cID]:
+ dst_in = data_since_threshold[data_since_threshold.dateRep == (lockdown_dates[cID][phase]['date'])].loc[(slice(None), [cID]), :]
+ dst_i = dst_in.first_valid_index()
+ dst_n = dst_in.iloc[0].deaths_m7
+ dst_c = dst_in.iloc[0].cases_m7
+ lockdown_dates[cID][phase]['since_threshold'] = dst_i[0]
+ lockdown_dates[cID][phase]['deaths_m7'] = dst_n
+ lockdown_dates[cID][phase]['cases_m7'] = dst_c
+
+lockdown_dates
+```
+
+```python
+ax = deaths_m7[COUNTRIES_CORE].plot(figsize=(15, 9), title="Deaths per day, 7 day moving averagee, with lockdown dates")
+ax.set_xlabel(f"Days since {DEATH_COUNT_THRESHOLD} deaths")
+# uk_projection.deaths_m7.plot(ax=ax)
+for c in COUNTRIES_CORE:
+ lvi = deaths_m7[c].last_valid_index()
+ if c != 'UK':
+ ax.text(x = lvi + 1, y = deaths_m7[c][lvi], s = f"{c}: {deaths_m7[c][lvi]:.0f}")
+ if c in lockdown_dates:
+ for phase in lockdown_dates[c]:
+ marker_col = [l for l in ax.lines if l.get_label() == c][0].get_color()
+ ax.plot(lockdown_dates[c][phase]['since_threshold'], lockdown_dates[c][phase]['deaths_m7'], '*',
+ markersize=18, markerfacecolor=marker_col, markeredgecolor=marker_col)
+ if 'start' not in phase:
+ ax.text(x = lockdown_dates[c][phase]['since_threshold'] + 1, y = lockdown_dates[c][phase]['deaths_m7'],
+ s = f"{lockdown_dates[c][phase]['date']}: {lockdown_dates[c][phase]['deaths_m7']:.0f}")
+# plt.savefig('school_reopenings.png')
+```
+
+```python
+ax = cases_m7.iloc[-50:][COUNTRIES_CORE].plot(figsize=(15, 9), title="Cases per day, 7 day moving average, with lockdown dates") #, ylim=(-10, 1500))
+ax.set_xlabel(f"Days since {DEATH_COUNT_THRESHOLD} deaths")
+# uk_projection.deaths_m7.plot(ax=ax)
+for c in COUNTRIES_CORE:
+ lvi = cases_m7[c].last_valid_index()
+# if c != 'UK':
+ ax.text(x = lvi + 1, y = cases_m7[c][lvi], s = f"{c}: {cases_m7[c][lvi]:.0f}")
+
+```
+
+```python
+ax = cases_m7[COUNTRIES_CORE].plot(figsize=(15, 9), title="Cases per day, 7 day moving average, with lockdown dates")
+ax.set_xlabel(f"Days since {DEATH_COUNT_THRESHOLD} deaths")
+# uk_projection.deaths_m7.plot(ax=ax)
+for c in COUNTRIES_CORE:
+ lvi = cases_m7[c].last_valid_index()
+# if c != 'UK':
+ ax.text(x = lvi + 1, y = cases_m7[c][lvi], s = f"{c}: {cases_m7[c][lvi]:.0f}")
+ if c in lockdown_dates:
+ for phase in lockdown_dates[c]:
+ marker_col = [l for l in ax.lines if l.get_label() == c][0].get_color()
+ if 'start' in phase:
+ marker_shape = '^'
+ else:
+ marker_shape = 'v'
+ ax.plot(lockdown_dates[c][phase]['since_threshold'], lockdown_dates[c][phase]['cases_m7'],
+ marker_shape,
+ markersize=18, markerfacecolor=marker_col, markeredgecolor=marker_col)
+ if 'start' not in phase:
+ ax.text(x = lockdown_dates[c][phase]['since_threshold'] + 1, y = lockdown_dates[c][phase]['cases_m7'],
+ s = f"{lockdown_dates[c][phase]['date']}: {lockdown_dates[c][phase]['cases_m7']:.0f}")
+plt.savefig('cases_per_day_with_lockdown.png')
+```
+
+```python
+ax = cases_m7[COUNTRIES_CORE].plot(figsize=(10, 6), title="Cases per day, 7 day moving average")
+for c in COUNTRIES_CORE:
+ lvi = cases_m7[c].last_valid_index()
+ ax.text(x = lvi + 1, y = cases_m7[c][lvi], s = c)
+plt.savefig('covid_cases_per_day-core.png')
+```
+
+```python
+ax = deaths_m7[COUNTRIES_CORE].plot(figsize=(15, 9), title="Deaths per day, 7 day moving average",
+ xlim=(0, 15),
+ ylim=(0, 66)
+ )
+# uk_projection.deaths_m7.plot(ax=ax)
+for c in COUNTRIES_CORE:
+ lvi = deaths_m7[c].last_valid_index()
+ if c in lockdown_dates:
+ for phase in lockdown_dates[c]:
+ if 'start' in phase:
+ print(c, phase)
+ marker_col = [l for l in ax.lines if l.get_label() == c][0].get_color()
+ ax.plot(lockdown_dates[c][phase]['since_threshold'], lockdown_dates[c][phase]['deaths_m7'], '*',
+ markersize=18, markerfacecolor=marker_col, markeredgecolor=marker_col)
+ ax.text(x = lockdown_dates[c][phase]['since_threshold'] + 0.3, y = lockdown_dates[c][phase]['deaths_m7'],
+ s = f"{lockdown_dates[c][phase]['date']}: {lockdown_dates[c][phase]['deaths_m7']:.0f}")
+# plt.savefig('school_reopenings.png')
+```
+
+```python
+
+```
+
+```python
+