Seceptible-Infectiou-Recovered-Sceptible (SIRS) model coupled to climate.
# init
%matplotlib inline
import sys
wython = '/tiger/scratch/gpfs/GEOCLIM/wenchang/wython'
if wython not in sys.path:
sys.path.append(wython)
%run -im wystart
# https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/
# from IPython.core.interactiveshell import InteractiveShell
# InteractiveShell.ast_node_interactivity = 'last' # options: 'all', 'none'
# https://stackoverflow.com/questions/41125690/matplotlib-notebook-showing-a-blank-histogram
# in case to switch back to the notebook backend, run the 2 lines below,
# reload(plt)
# %matplotlib notebook
# import xaddon, xfilter, xtc
[imported]: os.path, sys, os, datetime, glob [imported]: xarray as xr, numpy as np, matplotlib.pyplot as plt, pandas as pd [imported]: from matplotlib.pyplot import figure, close [executed]: plt.ion() [config]: plt.rcParams['figure.dpi'] = 128 [config]: plt.rcParams['figure.figsize'] = [6.4, 6.4*9/16]: [imported]: from misc.colormap_parula import parula [config]: xr.set_options(cmap_sequential=parula) [iPython config]: InlineBackend.figure_format ='retina' [added]: PROJ_LIB = /home/wenchang/anaconda3/share/proj
from scipy.integrate import odeint
from scipy.integrate import solve_ivp
regions = dict(
London=(51.5074, 0.1278),
NYC=(40.7128, -74.0060+360),
LA=(34.0522, -118.2437+360),
Wuhan=(30.5928, 114.3055),
Delhi=(28.7041, 77.1025),
Maracaibo=(10.6427, -71.6125+360),
Kinshasa=(-4.4419, 15.2663),
Jakarta=(-6.2088, 106.8456),
Johannesburg=(-26.2041, 28.0473),
Buenos_Aires=(-34.6037, -58.3816+360),
Melbourne=(-37.8136, 144.9631)
)
from numpy import pi as Pi
def get_q(case='cos', qmin=0.002, qmax=0.014, qrange=None, phi0=None, qyear=None):
'''obtain specific humidity annual cycle'''
# case = 'merra2'
# qmin, qmax = 0.002, 0.018# units: kg/kg
if case == 'cos':
if phi0 is None:
phi0 = -Pi
if qrange is None:
qrange = qmax - qmin
else: #overide qmax according to qmin and qrange
qmax = qmin + qrange
t = np.arange(0, 365)
t = xr.DataArray(t, dims='time', coords=[t])
t.attrs['units'] = 'day'
qmean = (qmin + qmax)/2
cycle = np.cos(2*Pi*t/365 + phi0) # normalized to have range of [0, 1]
q = qmean + (qrange/2)*cycle
q.name = 'q'
q.attrs['units'] = 'kg/kg'
s = f'cos-curve q: '
if not hasattr(qmin, 'ndim'):
s += f'qmin = {qmin}; '
if not hasattr(qmax, 'ndim'):
s += f'qmax = {qmax}; '
if not hasattr(phi0, 'ndim'):
s += f'phi0 = {phi0/Pi:.1f}xPi; '
q.attrs['note'] = s
elif case == 'era5':
ifile = '/tigress/wenchang/data/era5/analysis_wy/2m_specific_humidity/daily/clim/q2m.run7clim.2010-2019.nc'
q = (
xr.open_dataset(ifile)
['q2m']
.rename(dayofyear='time')
.load()
)
q.attrs['note'] = case
elif case == 'era5_single_year':
ifiles = f'/tigress/wenchang/data/era5/analysis_wy/2m_specific_humidity/daily/era5.2m_specific_humidity.daily.{qyear}-??.nc'
q = (
xr.open_mfdataset(ifiles, combine='by_coords')
['q2m']
# .load()
)
q.attrs['note'] = f'{case} {qyear}'
elif case == 'merra2':
ifile = '/tigress/gvecchi/ANALYSIS/DISEASE/COVID-19/merra_weekly_clim.nc'
q2m = (
xr.open_dataset('/tigress/gvecchi/ANALYSIS/DISEASE/COVID-19/merra_weekly_clim.nc')
.rename(WEEK_QV2M='q2m', TT='time', LAT='latitude', LON='longitude')['q2m']
)
q = (
xr.open_dataset(ifile)
.rename(WEEK_QV2M='q2m', TT='time', LAT='latitude', LON='longitude')
['q2m']
.pipe(lambda x: x.assign_coords(time=x.time.dt.dayofyear))
.reindex(time=np.arange(1, 366), method='nearest')
.load()
)
# shift from 0-center to 180E-center
if q.longitude.min() < 0:
q = q.roll(longitude=q.longitude.size//2)
q = q.assign_coords(
longitude=q.longitude.where(q.longitude>=0, other=q.longitude+360).values
)
q.attrs['note'] = case
return q
q = get_q()
q.plot()
plt.title(q.note)
# q.isel(time=0).plot(cmap='plasma')
# plt.title(case)
# plt.figure()
# for city,(latx, lonx) in regions.items():
# q.sel(latitude=latx, longitude=lonx, method='nearest').plot(label=city)
# print()
# plt.legend()
# plt.title(case)
Text(0.5, 1.0, 'cos-curve q: qmin = 0.002; qmax = 0.014; phi0 = -1.0xPi; ')
climdepens ={
'HKU1': dict(a=-227.5, R0_min=1.4, R0_max=2.5),
'OC43': dict(a=-32.5, R0_min=1.4, R0_max=2.5)
}
def q2R0(q, a, R0_min, R0_max):
'''R0 dependence on climate (specific humidity)'''
R0 = (R0_max - R0_min) * np.exp(a*q) + R0_min
if isinstance(R0, xr.DataArray):
R0.name = 'R0'
return R0
def R0_at_t(R0, t, cycle=True):
'''R0 as function of t (time) and specific humidity (q).
q has dims of (n_time, n_grid).'''
#R0_min, R0_max = 1.4, 2.5
#a = -227.5 for HKU1 and -32.5 for OC43
if cycle:# cycle through the first 365 daily specific humidity
R0t = R0.isel(time=int( np.mod(t, 365) ), drop=True)
else:
R0t = R0.isel(time=int(t), drop=True)
return R0t
# func_R0(0, R0t)
Ldis = {
'HKU1': 66.25*7,
'OC43': 62.5*7
}
An example from scpy
document: https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.integrate.odeint.html.
# pendulum model
def pend(y, t, b, c):
theta, omega = y
dydt = [omega,
-b*omega - c*np.sin(theta)]
return dydt
b, c = 0.25, 5.0
y0 = [np.pi - 0.1, 0.0]
t = np.linspace(0, 30, 30*10+1)
sol = odeint(pend, y0, t, args=(b, c))
# visualize
fig, axes = plt.subplots(1, 2, figsize=(6,3))
ax = axes[0]
ax.plot(t, sol[:, 0], 'C0', label='theta(t)')
ax.plot(t, sol[:, 1], 'C1', label='omega(t)')
ax.legend(loc='best')
ax.set_xlabel('t')
ax.grid('on')
ax = axes[1]
ax.scatter(sol[0, 0], sol[0, 1], color='k', marker='v')
ax.plot(sol[:, 0], sol[:, 1], color='C2')
ax.set_xlabel('theta(t)')
ax.set_ylabel('omega(t)')
plt.tight_layout()
# Lorenz system: https://en.wikipedia.org/wiki/Lorenz_system
# images: http://paulbourke.net/fractals/lorenz/
from mpl_toolkits.mplot3d import Axes3D
sigma = 10.0
rho = 28.0
beta = 8.0 / 3.0
def f(state, t):
x, y, z = state # Unpack the state vector
return sigma * (y - x), x * (rho - z) - y, x * y - beta * z # Derivatives
state0 = [1.0, 1.0, 1.0]
t = np.arange(0.0, 100.0, 0.01)
states = odeint(f, state0, t)
fig = plt.figure(figsize=(6,4))
ax = fig.gca(projection='3d')
ax.plot(states[:, 0], states[:, 1], states[:, 2], lw=0.5, color='C1')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_title('Lorenz System')
plt.tight_layout()
def model_nondimSIRS(yy, tt, tao, R0):
'''non-dimensionized version of SIRS model from Baker et al., 2020.
tao = L/D
R0 = beta*D
'''
ss, ii = yy
dydt = [
(1-ss-ii)/tao - R0*ii*ss,
R0*ii*ss - ii
]
return dydt
tao, R0 = 66.25*7/5, 2
y0 = [1.0-1e-5, 1e-5]
t = np.linspace(0, 5*365//5, 5*365//5*20+1)
sol = odeint(model_nondimSIRS, y0, t, args=(tao, R0))
fig, axes = plt.subplots(1, 2, figsize=(6,3))
ax = axes[0]
ax.plot(t, sol[:, 0], 'C1', label='S(t)/N')
ax.plot(t, sol[:, 1], 'C3', label='I(t)/N')
ax.legend(loc='best')
ax.set_xlabel('t[D]')
ax.grid('on')
ax = axes[1]
ax.scatter(sol[0, 0], sol[0, 1], color='k', marker='^')
ax.plot(sol[:, 0], sol[:, 1], color='C0')
ax.set_xlabel('S(t)/N')
ax.set_ylabel('I(t)/N')
plt.tight_layout()
def sirsplot(R0=2, tao=66.25*7/5, I0=1e-5, T=None, nt=None):
#tao, R0 = 65*7/5, 1.5
if T is None:
T = 5*365//5
if nt is None:
nt = T*5+1
y0 = [1.0-I0, I0]
t = np.linspace(0, T, nt)
sol = odeint(model_nondimSIRS, y0, t, args=(tao, R0))
fig, axes = plt.subplots(1, 2, figsize=(6,3))
ax = axes[0]
ax.plot(t, sol[:, 0], 'C1', label='S(t)/N')
ax.plot(t, sol[:, 1], 'C3', label='I(t)/N')
ax.legend(loc='best')
ax.set_xlabel('t[D]')
ax.grid('on')
ax = axes[1]
ax.scatter(sol[0, 0], sol[0, 1], color='k', marker='^')
ax.plot(sol[:, 0], sol[:, 1], color='C0')
ax.set_xlabel('S(t)/N')
ax.set_ylabel('I(t)/N')
ax.text(0.98, 0.98, f'R0 = {R0}\ntao = {tao}\nI0={I0}',
ha='right', va='top', transform=ax.transAxes)
plt.tight_layout()
sirsplot()
sirsplot(R0=1.8)
sirsplot(R0=1.5)
sirsplot(I0=1e-4)
def model_SIRS(y, t, R0, L, D):
'''Normalized version SIRS model from Baker et al., 2020.
L: immunity length, 60 weeks
D: infection period, 5 days
R0 = beta*D
'''
ss, ii = y
dydt = [
(1-ss-ii)/L - R0*ii*ss/D,
R0*ii*ss/D - ii/D
]
return dydt
def run_SIRS(R0=2, L=66.25*7, D=5, I0=1e-5, T=10*365, dt=1):
# R0 = 2
# L = 60*7
# D = 5
# I0 = 1e-5
# T = 10*365
# dt = 1
y0 = [1.0-I0, I0]
t = np.linspace(0, T, int(T/dt)+1)
sol = odeint(model_SIRS, y0, t, args=(R0, L, D))
da = xr.DataArray(sol, dims=['t', 'si'], coords=[t, ['S/N', 'I/N']])
da.t.attrs['units'] = 'day'
return da
da = run_SIRS()
da.sel(si='I/N').plot()
[<matplotlib.lines.Line2D at 0x7ff515a43490>]
def siplot(R0=2, L=66.25*7, D=5, I0=1e-5, T=10*365, dt=1):
#tao, R0 = 65*7/5, 1.5
# y0 = [1.0-I0, I0]
# t = np.linspace(0, T, int(T/dt)+1)
# sol = odeint(SIRS_RH, y0, t, args=(R0, L, D))
# da = xr.DataArray(sol, dims=['t', 'y'], coords=[t, ['S/N', 'I/N']])
# da.t.attrs['units'] = 'day'
da = run_SIRS(R0=R0, L=L, D=D, I0=I0, T=T, dt=dt)
df = da.to_pandas()
fig, axes = plt.subplots(1, 2, figsize=(7, 3))
ax = axes[0]
df.plot(ax=ax, secondary_y='I/N')
xticks = np.arange(0, t[-1]+1, 365)
ax.set_xticks(xticks)
ax.set_xticklabels((xticks/365).astype('int'))
ax.set_xlabel('time [year]')
# ax.grid('on')
ax = axes[1]
df.plot(ax=ax, x='S/N', y='I/N', color='C2', legend=False)
ax.scatter(sol[0, 0], sol[0, 1], color='k', marker='^')
ax.set_xlabel('S/N')
ax.set_ylabel('I/N')
# ax.grid('on')
ax.text(0.98, 0.98, f'R0 = {R0}\nL = {L}\nD= {D}\nI0={I0}',
ha='right', va='top', transform=ax.transAxes)
# ax.set_ylim(0, None)
plt.tight_layout()
siplot()
siplot(R0=1.5)
siplot(R0=5)
siplot(R0=5, dt=0.5)
siplot(R0=1.1, T=10*365)
siplot(R0=1.2, T=10*365)
R0s = np.arange(2, 1.2, -0.1)
das = []
for R0 in R0s:
das.append(run_SIRS(R0=R0, T=5*365, I0=1e-5, D=5))
da = xr.concat(das, dim=pd.Index(R0s, name='R0'))
fig, ax = plt.subplots(1,1,figsize=(6,3))
colors = plt.cm.Spectral(np.linspace(0,1,da.R0.size))
for R0,c in zip(da.R0, colors):
da.sel(si='I/N', R0=R0).plot(color=c, label=f'R0 = {R0.item():.1f}')
# da.sel(vname='I/N').plot(hue='R0')
ax.set_title('')
ax.set_ylabel('I/N')
ax.set_xlim(0, 365*1)
plt.legend()
plt.tight_layout()
Ds = np.arange(5, 21, 5)
das = []
for D in Ds:
das.append(run_SIRS(R0=2, T=5*365, I0=1e-5, D=D))
da = xr.concat(das, dim=pd.Index(Ds, name='D'))
fig, ax = plt.subplots(1,1,figsize=(6,3))
colors = plt.cm.Spectral(np.linspace(0,1,da.D.size))
for D,c in zip(da.D, colors):
da.sel(si='I/N', D=D).plot(color=c, label=f'D = {D.item()}')
ax.set_title('')
ax.set_ylabel('I/N')
plt.xlim(0, 365*3)
plt.legend()
plt.tight_layout()
Ls = 7*np.arange(60, 30, -5)
das = []
for L in Ls:
das.append(run_SIRS(R0=2, T=5*365, I0=1e-5, L=L))
da = xr.concat(das, dim=pd.Index(Ls, name='L'))
fig, ax = plt.subplots(1,1,figsize=(6,3))
colors = plt.cm.Spectral_r(np.linspace(0,1,da.L.size))
for L,c in zip(da.L, colors):
da.sel(si='I/N', L=L).plot(color=c, label=f'L = {L.item()}')
# da.sel(vname='I/N').plot(hue='R0')
ax.set_title('')
ax.set_ylabel('I/N')
plt.xlim(0, 365*3)
plt.legend()
plt.tight_layout()
fig, ax = plt.subplots(1,1,figsize=(6,3))
dts = [1/8, 1/4, 1/2, 1, 1*2, 1*4]
colors = plt.cm.Spectral_r(np.linspace(0,1,len(dts)))
for dt,c in zip(dts, colors):
da = run_SIRS(dt=dt)
da.sel(si='I/N').sel(t=slice(52, 62)).plot(color=c, label=f'dt = {dt}')
# da.sel(vname='I/N').plot(hue='R0')
ax.set_title('')
ax.set_ylabel('I/N')
# plt.xlim(50, 60)
plt.legend()
plt.tight_layout()
Do multiple Ro
s simutaneously.
def model_vecSIRS(y, t, R0, L, D):
'''Normalized version SIRS model from Baker et al., 2020.
L: immunity length, 60 weeks
D: infection period, 5 days
R0 = beta*D
'''
N = y.size
ss = y[:N//2]
ii = y[N//2:]
dydt = np.array([
(1-ss-ii)/L - R0*ii*ss/D,
R0*ii*ss/D - ii/D
]).ravel()
return dydt
def run_vecSIRS(R0=2, L=60*7, D=5, I0=1e-5, T=10*365, dt=1):
# R0 = 2
# L = 60*7
# D = 5
# I0 = 1e-5
# T = 10*365
# dt = 1
zeros = I0*L*D*R0*0
y0 = np.array([1.0-I0+zeros, I0+zeros]).ravel()
t = np.linspace(0, T, int(T/dt)+1)
sol = odeint(model_vecSIRS, y0, t, args=(R0, L, D))
sol = sol.reshape(t.size, 2, y0.size//2)
da = xr.DataArray(sol, dims=['t', 'si', 'case'],coords=[t, ['S/N', 'I/N'], np.arange(1, y0.size//2+1)])
da.t.attrs['units'] = 'day'
return da
R0=np.arange(2,1,-0.1)
I0 = R0*0 + 1e-5
da = run_SIRSvec(I0=I0, R0=R0)
da = da.rename(case='R0').assign_coords(R0=R0)
print(da)
<xarray.DataArray (t: 3651, si: 2, R0: 10)> array([[[9.99990000e-01, 9.99990000e-01, 9.99990000e-01, ..., 9.99990000e-01, 9.99990000e-01, 9.99990000e-01], [1.00000000e-05, 1.00000000e-05, 1.00000000e-05, ..., 1.00000000e-05, 1.00000000e-05, 1.00000000e-05]], [[9.99985566e-01, 9.99985833e-01, 9.99986094e-01, ..., 9.99987322e-01, 9.99987554e-01, 9.99987780e-01], [1.22181222e-05, 1.19750938e-05, 1.17371103e-05, ..., 1.06184326e-05, 1.04081083e-05, 1.02019920e-05]], [[9.99980153e-01, 9.99980847e-01, 9.99981514e-01, ..., 9.99984484e-01, 9.99985012e-01, 9.99985520e-01], [1.49287123e-05, 1.43406275e-05, 1.37762151e-05, ..., 1.12751164e-05, 1.08328692e-05, 1.04080593e-05]], ..., [[5.00072619e-01, 5.26291764e-01, 5.55417489e-01, ..., 7.68322689e-01, 8.32731461e-01, 9.09011175e-01], [5.87643030e-03, 5.58596293e-03, 5.21756192e-03, ..., 2.71041919e-03, 2.00627133e-03, 1.03960376e-03]], [[5.00073455e-01, 5.26289210e-01, 5.55420363e-01, ..., 7.68326464e-01, 8.32724019e-01, 9.09017431e-01], [5.87660201e-03, 5.58590918e-03, 5.21730531e-03, ..., 2.70978066e-03, 2.00597975e-03, 1.03958624e-03]], [[5.00074251e-01, 5.26286679e-01, 5.55423276e-01, ..., 7.68330355e-01, 8.32716656e-01, 9.09023674e-01], [5.87677564e-03, 5.58585003e-03, 5.21705415e-03, ..., 2.70914498e-03, 2.00568465e-03, 1.03957015e-03]]]) Coordinates: * t (t) float64 0.0 1.0 2.0 3.0 ... 3.648e+03 3.649e+03 3.65e+03 * si (si) <U3 'S/N' 'I/N' * R0 (R0) float64 2.0 1.9 1.8 1.7 1.6 1.5 1.4 1.3 1.2 1.1
R0 = np.arange(2, 1.2, -0.1)
I0 = 1e-5
da = run_vecSIRS(I0=I0, R0=R0)
da = da.rename(case='R0').assign_coords(R0=R0)
fig, ax = plt.subplots(1,1,figsize=(6,3))
colors = plt.cm.Spectral(np.linspace(0,1,da.R0.size))
for R0,c in zip(da.R0, colors):
da.sel(si='I/N', R0=R0).plot(color=c, label=f'R0 = {R0.item():.1f}')
# da.sel(vname='I/N').plot(hue='R0')
ax.set_title('')
ax.set_ylabel('I/N')
ax.set_xlim(0, 365*1)
plt.legend()
plt.tight_layout()
fig = plt.figure(figsize=(5, 4))
q = np.arange(0, 20+1)
dis = 'OC43'
R0 = q2R0(q/1000, **climdepens[dis])
plt.plot(q, R0, label=f'{dis}')
dis = 'HKU1'
R0 = q2R0(q/1000, **climdepens[dis])
plt.plot(q, R0, label=f'{dis}')
plt.legend()
plt.xlabel('q[g/kg]')
plt.ylabel('R0')
plt.tight_layout()
# idealized q annual cycle
dis = 'HKU1'
q = get_q()
R0 = q2R0(q, **climdepens[dis])
df = pd.DataFrame({'q': q, 'R0': R0}, index=pd.Index(R0.time, name='t[day]'))
df.plot(secondary_y='R0')
plt.title(q.note)
Text(0.5, 1.0, 'cos-curve q: qmin = 0.002; qmax = 0.014; phi0 = 1.0xPi')
# idealized q annual cycle
dis = 'HKU1'
q = get_q(phi0=0)
R0 = q2R0(q, **climdepens[dis])
df = pd.DataFrame({'q': q, 'R0': R0}, index=pd.Index(R0.time, name='t[day]'))
df.plot(secondary_y='R0')
plt.title(q.note)
Text(0.5, 1.0, 'cos-curve q: qmin = 0.002; qmax = 0.014; phi0 = 0.0xPi')
# idealized q annual cycle
dis = 'HKU1'
q = get_q(phi0=-np.pi/2)
R0 = q2R0(q, **climdepens[dis])
df = pd.DataFrame({'q': q, 'R0': R0}, index=pd.Index(R0.time, name='t[day]'))
df.plot(secondary_y='R0')
plt.title(q.note)
Text(0.5, 1.0, 'cos-curve q: qmin = 0.002; qmax = 0.014; phi0 = -0.5xPi')
# idealized q annual cycle
dis = 'HKU1'
q = get_q(phi0=-np.pi*3/2)
R0 = q2R0(q, **climdepens[dis])
df = pd.DataFrame({'q': q, 'R0': R0}, index=pd.Index(R0.time, name='t[day]'))
df.plot(secondary_y='R0')
plt.title(q.note)
Text(0.5, 1.0, 'cos-curve q: qmin = 0.002; qmax = 0.014; phi0 = -1.5xPi')
q_era5 = get_q('era5')
q = q_era5
q.isel(time=0).plot(cmap='plasma')
plt.title(q.note)
Text(0.5, 1.0, 'era5')
q_merra2 = get_q('merra2')
q = q_merra2
q.isel(time=0).plot(cmap='plasma')
plt.title(q.note)
/home/wenchang/anaconda3/lib/python3.7/site-packages/xarray/core/dataarray.py:2823: FutureWarning: roll_coords will be set to False in the future. Explicitly set roll_coords to silence warning. shifts=shifts, roll_coords=roll_coords, **shifts_kwargs
Text(0.5, 1.0, 'merra2')
q = q_era5
for city,(latx, lonx) in regions.items():
q.sel(latitude=latx, longitude=lonx, method='nearest').plot(label=city)
print()
plt.legend(bbox_to_anchor=(1,1), loc='upper left')
plt.title(q.note)
plt.tight_layout()
print(plt.ylim())
(0.0014669001218862831, 0.02305866334354505)
q = q_merra2
for city,(latx, lonx) in regions.items():
q.sel(latitude=latx, longitude=lonx, method='nearest').plot(label=city)
print()
plt.legend(bbox_to_anchor=(1,1), loc='upper left')
plt.title(q.note)
plt.ylim(0.0014669001218862831, 0.02305866334354505)
plt.tight_layout()
# realistic q annual cycle
dis = 'HKU1'
city = 'NYC'
latx, lonx = regions[city]
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
R0 = q2R0(q, **climdepens[dis])
df = pd.DataFrame({f'q_{city}': q, f'R0_{dis}': R0})
df.plot(secondary_y=f'R0_{dis}')
plt.title(q.note)
Text(0.5, 1.0, 'era5')
# realistic q annual cycle
dis = 'OC43'
city = 'NYC'
latx, lonx = regions[city]
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
R0 = q2R0(q, **climdepens[dis])
df = pd.DataFrame({f'q_{city}': q, f'R0_{dis}': R0})
df.plot(secondary_y=f'R0_{dis}')
plt.title(q.note)
Text(0.5, 1.0, 'era5')
odeint
backend¶def model_climSIRS(y, t, L, D, R0):
'''SIRS model right hand side from Baker et al., 2020.
Input:
-------
y: y[0:y.size//2] is S/N; y[y.size//2:] is I/N
t: time (units is 'day')
L: immunity length, 7x66.25(62.5) days for HKU1 (OC43)
D: infection period, 5 days
R0 = beta*D, ignored if q is not None
q: specific humidity, xr.DataArray, dims ('time', ...)
a: climate dependence parameter, -227.5(-32.5) for HKU1(OC43)
Return:
--------
dydy: half d(S/N)/dt, half d(I/N)/dt
'''
N = y.size
ss = y[:N//2]
ii = y[N//2:]
if hasattr(R0, 'time'): # R0 is time-dependent
_R0 = R0_at_t(R0, t)
if _R0.ndim < 1:
_R0 = _R0.item()
else:
_R0 = R0
dydt = np.array([
(1-ss-ii)/L - _R0*ii*ss/D,
_R0*ii*ss/D - ii/D
]).ravel()
return dydt
from scipy.integrate import odeint
def run_climSIRS(ii0=1e-5, ss0=None, T=5*365, dt=1, L=None, D=5, R0=2, dis='HKU1'):
'''Integrate SIRS model from Baker et al., 2020.
Input:
-------
I0: initial I/N
T: time stop (start is 1; units is 'day')
dt: time step
L: immunity length, 7x66.25(62.5) days for HKU1 (OC43)
D: infection period, 5 days
R0 = beta*D, ignored if q is not None
q: specific humidity, xr.DataArray, dims ('time', ...)
a: climate dependence parameter, -227.5(-32.5) for HKU1(OC43)
Return:
--------
ds: solution for the SIRS model.
'''
if L is None and dis is not None:
L = Ls[dis]
if hasattr(R0, 'time'): # R0 time-dependent
if R0.ndim > 1:#
grid = R0.stack(grid=R0.isel(time=0).dims).grid # grid info is saved
zeros = np.zeros(grid.size) # broadcast array by R0.dims[1:]
else: # only time dimension
zeros = ii0*L*D*0 # broadcast array by ii0*L*D*a
else: # R0 time-independent
zeros = ii0*L*D*R0*0
# default initial S/N value determined by initial I/N value
if ss0 is None:
ss0 = 1 - ii0
# broadcast initial values by adding zeros
ii0 = ii0 + zeros
ss0 = ss0 + zeros
y0 = np.hstack([ss0, ii0])
t = np.arange(0, T, dt)
sol = odeint(model_climSIRS, y0, t, args=(L, D, R0))
ss = sol[:, 0:y0.size//2]
ii = sol[:, y0.size//2:]
da_ss = xr.DataArray(ss, dims=['t', 'grid'],coords=[t, np.arange(1, y0.size//2+1)])
da_ss.attrs['long_name'] = 'S/N'
da_ii = xr.DataArray(ii, dims=['t', 'grid'],coords=[t, np.arange(1, y0.size//2+1)])
da_ii.attrs['long_name'] = 'I/N'
if hasattr(R0, 'time') and R0.ndim > 1: # R0 has more than "time" dimensions
da_ss = da_ss.assign_coords(grid=grid).unstack()
da_ii = da_ii.assign_coords(grid=grid).unstack()
ds = xr.Dataset(dict(ss=da_ss, ii=da_ii, year=da_ss.t/365))
ds.t.attrs['units'] = 'day'
return ds
latx, lonx = regions['NYC']
# q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
# q = get_q()
ds = run_climSIRS(R0=2, T=2*365, ii0=1/8e6, L=66.25*7)
ds.ii.plot()
ds
array([ 0, 1, 2, ..., 727, 728, 729])
array([1])
array([[0.99999987], [0.99999982], [0.99999975], [0.99999967], [0.99999957], [0.99999944], [0.99999928], [0.9999991 ], [0.99999886], [0.99999858], [0.99999823], [0.9999978 ], [0.99999728], [0.99999665], [0.99999588], [0.99999493], [0.99999377], [0.99999236], [0.99999063], [0.9999885 ], [0.99998592], [0.99998277], [0.99997895], [0.99997418], [0.99996844], [0.99996144], [0.99995286], [0.99994239], [0.9999296 ], [0.99991397], [0.99989489], [0.99987159], [0.99984312], [0.99980835], [0.99976589], [0.99971404], [0.99965072], [0.99957338], [0.99947897], [0.99936371], [0.99922297], [0.99905114], [0.99884139], [0.99858537], [0.99827296], [0.99789177], [0.9974268 ], [0.99685975], [0.99616846], [0.99532608], [0.9943001 ], [0.99305128], [0.99153238], [0.98968667], [0.98744634], [0.98473069], [0.98144427], [0.97747496], [0.9726923 ], [0.96694615], [0.9600661 ], [0.95186222], [0.94212744], [0.93064262], [0.91718472], [0.901539 ], [0.88351514], [0.86296732], [0.83981679], [0.81407455], [0.78586072], [0.75541633], [0.72310378], [0.68939336], [0.65483587], [0.62002473], [0.5855528 ], [0.55197084], [0.51975374], [0.48927844], [0.4608148 ], [0.434528 ], [0.41048961], [0.38869363], [0.36907449], [0.35152435], [0.33590835], [0.32207702], [0.30987574], [0.29915161], [0.28975799], [0.28155736], [0.27442282], [0.26823868], [0.2629004 ], [0.25831413], [0.25439603], [0.25107147], [0.24827416], [0.2459453 ], [0.24403284], [0.24249064], [0.24127789], [0.24035842], [0.23970019], [0.23927481], [0.23905709], [0.23902467], [0.23915769], [0.2394385 ], [0.23985138], [0.24038234], [0.24101891], [0.24174999], [0.24256563], [0.24345698], [0.24441611], [0.24543592], [0.24651008], [0.2476329 ], [0.24879928], [0.25000465], [0.25124491], [0.25251637], [0.25381572], [0.25513999], [0.25648649], [0.25785282], [0.2592368 ], [0.26063647], [0.26205008], [0.26347603], [0.26491288], [0.26635934], [0.26781423], [0.26927649], [0.27074518], [0.27221941], [0.27369841], [0.27518146], [0.27666793], [0.27815723], [0.27964883], [0.28114224], [0.28263705], [0.28413284], [0.28562926], [0.28712599], [0.28862273], [0.29011921], [0.29161518], [0.29311042], [0.29460474], [0.29609794], [0.29758986], [0.29908035], [0.30056926], [0.30205647], [0.30354186], [0.30502534], [0.3065068 ], [0.30798615], [0.30946332], [0.31093824], [0.31241084], [0.31388106], [0.31534884], [0.31681414], [0.31827691], [0.31973711], [0.32119471], [0.32264966], [0.32410195], [0.32555153], [0.32699839], [0.32844251], [0.32988386], [0.33132243], [0.33275819], [0.33419115], [0.33562127], [0.33704855], [0.33847299], [0.33989456], [0.34131327], [0.34272911], [0.34414206], [0.34555214], [0.34695932], [0.34836361], [0.34976501], [0.35116351], [0.35255911], [0.35395181], [0.35534162], [0.35672852], [0.35811253], [0.35949364], [0.36087185], [0.36224716], [0.36361958], [0.36498911], [0.36635575], [0.36771951], [0.36908038], [0.37043837], [0.37179348], [0.37314572], [0.37449509], [0.37584159], [0.37718523], [0.37852601], [0.37986394], [0.38119902], [0.38253125], [0.38386064], [0.3851872 ], [0.38651092], [0.38783182], [0.38914989], [0.39046515], [0.39177759], [0.39308723], [0.39439406], [0.3956981 ], [0.39699934], [0.3982978 ], [0.39959348], [0.40088638], [0.40217651], [0.40346387], [0.40474847], [0.40603032], [0.40730941], [0.40858577], [0.40985938], [0.41113026], [0.41239841], [0.41366384], [0.41492655], [0.41618655], [0.41744384], [0.41869843], [0.41995033], [0.42119954], [0.42244606], [0.4236899 ], [0.42493107], [0.42616958], [0.42740541], [0.4286386 ], [0.42986913], [0.43109701], [0.43232226], [0.43354487], [0.43476485], [0.43598221], [0.43719694], [0.43840907], [0.43961859], [0.4408255 ], [0.44202982], [0.44323155], [0.44443069], [0.44562725], [0.44682124], [0.44801266], [0.44920151], [0.45038781], [0.45157155], [0.45275275], [0.4539314 ], [0.45510752], [0.4562811 ], [0.45745216], [0.4586207 ], [0.45978672], [0.46095023], [0.46211124], [0.46326975], [0.46442576], [0.46557928], [0.46673033], [0.46787889], [0.46902498], [0.4701686 ], [0.47130976], [0.47244846], [0.47358472], [0.47471852], [0.47584988], [0.47697881], [0.47810531], [0.47922938], [0.48035103], [0.48147026], [0.48258708], [0.4837015 ], [0.48481352], [0.48592314], [0.48703037], [0.48813522], [0.48923769], [0.49033779], [0.49143551], [0.49253087], [0.49362387], [0.49471452], [0.49580282], [0.49688877], [0.49797239], [0.49905367], [0.50013262], [0.50120924], [0.50228355], [0.50335554], [0.50442523], [0.50549261], [0.50655769], [0.50762047], [0.50868097], [0.50973918], [0.51079511], [0.51184876], [0.51290015], [0.51394927], [0.51499613], [0.51604073], [0.51708308], [0.51812319], [0.51916105], [0.52019668], [0.52123008], [0.52226125], [0.5232902 ], [0.52431693], [0.52534144], [0.52636375], [0.52738386], [0.52840177], [0.52941748], [0.530431 ], [0.53144234], [0.5324515 ], [0.53345848], [0.53446329], [0.53546593], [0.53646642], [0.53746474], [0.53846092], [0.53945494], [0.54044682], [0.54143657], [0.54242417], [0.54340965], [0.544393 ], [0.54537424], [0.54635335], [0.54733035], [0.54830525], [0.54927804], [0.55024873], [0.55121733], [0.55218384], [0.55314826], [0.5541106 ], [0.55507086], [0.55602905], [0.55698517], [0.55793922], [0.55889122], [0.55984116], [0.56078905], [0.56173489], [0.56267869], [0.56362044], [0.56456017], [0.56549786], [0.56643352], [0.56736717], [0.56829879], [0.5692284 ], [0.57015599], [0.57108159], [0.57200518], [0.57292677], [0.57384636], [0.57476396], [0.57567958], [0.57659321], [0.57750486], [0.57841454], [0.57932224], [0.58022797], [0.58113174], [0.58203355], [0.5829334 ], [0.5838313 ], [0.58472725], [0.58562125], [0.5865133 ], [0.58740341], [0.58829159], [0.58917783], [0.59006214], [0.59094452], [0.59182498], [0.59270351], [0.59358013], [0.59445483], [0.59532761], [0.59619849], [0.59706745], [0.59793451], [0.59879967], [0.59966292], [0.60052428], [0.60138374], [0.60224131], [0.60309698], [0.60395076], [0.60480266], [0.60565266], [0.60650078], [0.60734701], [0.60819136], [0.60903382], [0.6098744 ], [0.6107131 ], [0.61154991], [0.61238484], [0.61321789], [0.61404905], [0.61487833], [0.61570572], [0.61653122], [0.61735484], [0.61817656], [0.61899638], [0.61981431], [0.62063034], [0.62144446], [0.62225667], [0.62306697], [0.62387534], [0.62468179], [0.62548631], [0.62628889], [0.62708952], [0.62788819], [0.6286849 ], [0.62947963], [0.63027237], [0.63106311], [0.63185184], [0.63263853], [0.63342318], [0.63420577], [0.63498627], [0.63576467], [0.63654094], [0.63731507], [0.63808702], [0.63885677], [0.63962429], [0.64038955], [0.64115251], [0.64191313], [0.64267138], [0.64342721], [0.64418058], [0.64493144], [0.64567973], [0.64642539], [0.64716836], [0.64790859], [0.64864599], [0.6493805 ], [0.65011202], [0.65084047], [0.65156575], [0.65228777], [0.65300641], [0.65372155], [0.65443307], [0.65514082], [0.65584466], [0.65654444], [0.65723997], [0.65793109], [0.65861758], [0.65929925], [0.65997586], [0.66064716], [0.6613129 ], [0.66197278], [0.66262651], [0.66327374], [0.66391415], [0.66454733], [0.66517288], [0.66579036], [0.6663993 ], [0.66699917], [0.66758945], [0.66816953], [0.66873877], [0.6692965 ], [0.66984198], [0.67037441], [0.67089294], [0.67139665], [0.67188455], [0.67235558], [0.6728086 ], [0.67324237], [0.67365559], [0.67404682], [0.67441456], [0.67475714], [0.67507283], [0.67535975], [0.67561585], [0.67583899], [0.67602684], [0.67617693], [0.67628658], [0.67635296], [0.67637305], [0.67634361], [0.6762612 ], [0.67612216], [0.6759226 ], [0.67565838], [0.67532516], [0.67491829], [0.67443292], [0.67386391], [0.67320588], [0.67245317], [0.67159992], [0.67064 ], [0.66956706], [0.66837457], [0.66705578], [0.66560382], [0.66401172], [0.66227239], [0.66037881], [0.65832396], [0.65610095], [0.65370309], [0.651124 ], [0.64835765], [0.64539855], [0.64224178], [0.63888316], [0.63531933], [0.63154792], [0.62756765], [0.62337841], [0.61898145], [0.61437939], [0.60957638], [0.60457809], [0.59939185], [0.59402656], [0.58849273], [0.58280246], [0.57696932], [0.5710083 ], [0.56493563], [0.55876863], [0.55252557], [0.54622539], [0.53988756], [0.53353178], [0.52717781], [0.52084519], [0.51455306], [0.50831993], [0.50216349], [0.49610046], [0.49014643], [0.48431578], [0.47862152], [0.47307532], [0.46768742], [0.46246663], [0.45742036], [0.45255465], [0.44787419], [0.44338243], [0.43908165], [0.434973 ], [0.43105664], [0.42733183], [0.42379697], [0.42044977], [0.41728727], [0.41430599], [0.41150197], [0.40887084], [0.40640795], [0.40410837], [0.40196698], [0.39997854], [0.39813769], [0.39643904], [0.39487721], [0.3934468 ], [0.3921425 ], [0.39095904], [0.38989128], [0.38893416], [0.38808277], [0.38733232], [0.38667816], [0.3861158 ], [0.3856409 ], [0.38524927], [0.3849369 ], [0.38469991], [0.3845346 ], [0.3844374 ], [0.3844049 ], [0.38443386], [0.38452117], [0.38466385], [0.38485907], [0.38510413], [0.38539646], [0.38573362], [0.38611327], [0.38653319], [0.38699129], [0.38748555], [0.38801407], [0.38857506], [0.38916678], [0.38978761], [0.39043601], [0.3911105 ], [0.3918097 ], [0.39253227], [0.39327697], [0.3940426 ], [0.39482804], [0.3956322 ], [0.39645408], [0.39729271], [0.39814718], [0.39901661], [0.39990018], [0.4007971 ], [0.40170665], [0.4026281 ], [0.4035608 ], [0.4045041 ], [0.40545741], [0.40642015], [0.40739177], [0.40837176], [0.40935964], [0.41035492], [0.41135718], [0.41236598], [0.41338092], [0.41440164], [0.41542776], [0.41645893], [0.41749484], [0.41853517], [0.41957962], [0.4206279 ], [0.42167976], [0.42273493], [0.42379318], [0.42485425], [0.42591795], [0.42698404], [0.42805234], [0.42912265], [0.43019478], [0.43126856], [0.43234383], [0.43342042], [0.43449819], [0.43557698], [0.43665665], [0.43773709], [0.43881815], [0.43989972], [0.44098168], [0.44206391], [0.44314632], [0.44422881], [0.44531126], [0.4463936 ], [0.44747572], [0.44855755], [0.449639 ], [0.45072 ], [0.45180047], [0.45288033], [0.45395951], [0.45503796], [0.4561156 ], [0.45719237], [0.45826821], [0.45934307], [0.46041689], [0.46148961], [0.46256119], [0.46363158], [0.46470072], [0.46576858], [0.4668351 ], [0.46790025], [0.46896399], [0.47002626], [0.47108704], [0.47214629], [0.47320396], [0.47426003], [0.47531446], [0.47636721], [0.47741826], [0.47846757], [0.47951511]])
array([[1.25000000e-07], [1.52842391e-07], [1.86848714e-07], [2.28395335e-07], [2.79314196e-07], [3.43363860e-07], [4.21623761e-07], [5.15305195e-07], [6.32881379e-07], [7.75986489e-07], [9.48136431e-07], [1.16444738e-06], [1.42665069e-06], [1.74226573e-06], [2.13216331e-06], [2.60733176e-06], [3.19249011e-06], [3.90274727e-06], [4.77147179e-06], [5.83831511e-06], [7.13633405e-06], [8.72301157e-06], [1.06430574e-05], [1.30398122e-05], [1.59220330e-05], [1.94434079e-05], [2.37532174e-05], [2.90162671e-05], [3.54461371e-05], [4.33022868e-05], [5.28913655e-05], [6.46035597e-05], [7.89118592e-05], [9.63878824e-05], [1.17724466e-04], [1.43782255e-04], [1.75604299e-04], [2.14463544e-04], [2.61901231e-04], [3.19807893e-04], [3.90504691e-04], [4.76806447e-04], [5.82134880e-04], [7.10663204e-04], [8.67465386e-04], [1.05871386e-03], [1.29190445e-03], [1.57614389e-03], [1.92243713e-03], [2.34409564e-03], [2.85717404e-03], [3.48097628e-03], [4.23862931e-03], [5.15772761e-03], [6.27100907e-03], [7.61705249e-03], [9.24094687e-03], [1.11948316e-02], [1.35381907e-02], [1.63377157e-02], [1.96665508e-02], [2.36024802e-02], [2.82248780e-02], [3.36098566e-02], [3.98233809e-02], [4.69120740e-02], [5.48920164e-02], [6.37360540e-02], [7.33611636e-02], [8.36179480e-02], [9.42852314e-02], [1.05072358e-01], [1.15631502e-01], [1.25580321e-01], [1.34533047e-01], [1.42135438e-01], [1.48098118e-01], [1.52222248e-01], [1.54413508e-01], [1.54682925e-01], [1.53135886e-01], [1.49952715e-01], [1.45365072e-01], [1.39632090e-01], [1.33019229e-01], [1.25781543e-01], [1.18151901e-01], [1.10333899e-01], [1.02498685e-01], [9.47847619e-02], [8.72998325e-02], [8.01238852e-02], [7.33128972e-02], [6.69026798e-02], [6.09126148e-02], [5.53490555e-02], [5.02083153e-02], [4.54792206e-02], [4.11452343e-02], [3.71861852e-02], [3.35796384e-02], [3.03019767e-02], [2.73292156e-02], [2.46376146e-02], [2.22041190e-02], [2.00066652e-02], [1.80243803e-02], [1.62377016e-02], [1.46284323e-02], [1.31797505e-02], [1.18761862e-02], [1.07035795e-02], [9.64900760e-03], [8.70072026e-03], [7.84805894e-03], [7.08137631e-03], [6.39195881e-03], [5.77194568e-03], [5.21425741e-03], [4.71252435e-03], [4.26102082e-03], [3.85460416e-03], [3.48865793e-03], [3.15904028e-03], [2.86203693e-03], [2.59431851e-03], [2.35289915e-03], [2.13510427e-03], [1.93853531e-03], [1.76104403e-03], [1.60070393e-03], [1.45578939e-03], [1.32475233e-03], [1.20620568e-03], [1.09890458e-03], [1.00173321e-03], [9.13689589e-04], [8.33874989e-04], [7.61481598e-04], [6.95785112e-04], [6.36134856e-04], [5.81944401e-04], [5.32688119e-04], [4.87891942e-04], [4.47129910e-04], [4.10018839e-04], [3.76212717e-04], [3.45400865e-04], [3.17302396e-04], [2.91664232e-04], [2.68258265e-04], [2.46878098e-04], [2.27337891e-04], [2.09469446e-04], [1.93120624e-04], [1.78154040e-04], [1.64444989e-04], [1.51881329e-04], [1.40361370e-04], [1.29792408e-04], [1.20090395e-04], [1.11179495e-04], [1.02990919e-04], [9.54614833e-05], [8.85346338e-05], [8.21588977e-05], [7.62869118e-05], [7.08762600e-05], [6.58880458e-05], [6.12865258e-05], [5.70397368e-05], [5.31182040e-05], [4.94949624e-05], [4.61458944e-05], [4.30485202e-05], [4.01819849e-05], [3.75279018e-05], [3.50694363e-05], [3.27908408e-05], [3.06777404e-05], [2.87173623e-05], [2.68976919e-05], [2.52075884e-05], [2.36371550e-05], [2.21772313e-05], [2.08192485e-05], [1.95553993e-05], [1.83786982e-05], [1.72825600e-05], [1.62607684e-05], [1.53081927e-05], [1.44194538e-05], [1.35898729e-05], [1.28151639e-05], [1.20914035e-05], [1.14148654e-05], [1.07821055e-05], [1.01899564e-05], [9.63552341e-06], [9.11619728e-06], [8.62964893e-06], [8.17369842e-06], [7.74601105e-06], [7.34465186e-06], [6.96790603e-06], [6.61420436e-06], [6.28183613e-06], [5.96934869e-06], [5.67546394e-06], [5.39814822e-06], [5.13854891e-06], [4.89366739e-06], [4.66278783e-06], [4.44519208e-06], [4.24008369e-06], [4.04667655e-06], [3.86421360e-06], [3.69193780e-06], [3.52909977e-06], [3.37526376e-06], [3.22996395e-06], [3.09261098e-06], [2.96261550e-06], [2.83939481e-06], [2.72269358e-06], [2.61223783e-06], [2.50761647e-06], [2.40841846e-06], [2.31423617e-06], [2.22487290e-06], [2.14012859e-06], [2.05970932e-06], [1.98332116e-06], [1.91067218e-06], [1.84162458e-06], [1.77603919e-06], [1.71370183e-06], [1.65439831e-06], [1.59791446e-06], [1.54406585e-06], [1.49281135e-06], [1.44402025e-06], [1.39754431e-06], [1.35323529e-06], [1.31094492e-06], [1.27058814e-06], [1.23211583e-06], [1.19542297e-06], [1.16040448e-06], [1.12695531e-06], [1.09497692e-06], [1.06443805e-06], [1.03527792e-06], [1.00742130e-06], [9.80792951e-07], [9.55317628e-07], [9.30938270e-07], [9.07628632e-07], [8.85336924e-07], [8.64010445e-07], [8.43598230e-07], [8.24069006e-07], [8.05384721e-07], [7.87503207e-07], [7.70382292e-07], [7.53990367e-07], [7.38304187e-07], [7.23290951e-07], [7.08917828e-07], [6.95154246e-07], [6.81982867e-07], [6.69379715e-07], [6.57319091e-07], [6.45775342e-07], [6.34731019e-07], [6.24170367e-07], [6.14073208e-07], [6.04419361e-07], [5.95190849e-07], [5.86377160e-07], [5.77963029e-07], [5.69932621e-07], [5.62270265e-07], [5.54966176e-07], [5.48010073e-07], [5.41389557e-07], [5.35092227e-07], [5.29112396e-07], [5.23430925e-07], [5.18048698e-07], [5.12954720e-07], [5.08138839e-07], [5.03594481e-07], [4.99314186e-07], [4.95290290e-07], [4.91515800e-07], [4.87984389e-07], [4.84690400e-07], [4.81628846e-07], [4.78795406e-07], [4.76186430e-07], [4.73798936e-07], [4.71630610e-07], [4.69679806e-07], [4.67945549e-07], [4.66427531e-07], [4.65126113e-07], [4.64040093e-07], [4.63154729e-07], [4.62465828e-07], [4.61972272e-07], [4.61673378e-07], [4.61568900e-07], [4.61659028e-07], [4.61944385e-07], [4.62426032e-07], [4.63105466e-07], [4.63984618e-07], [4.65065855e-07], [4.66351981e-07], [4.67846234e-07], [4.69552289e-07], [4.71474255e-07], [4.73549580e-07], [4.75790625e-07], [4.78238865e-07], [4.80898167e-07], [4.83772766e-07], [4.86867265e-07], [4.90186636e-07], [4.93736220e-07], [4.97521726e-07], [5.01549229e-07], [5.05825177e-07], [5.10356383e-07], [5.15150030e-07], [5.20213667e-07], [5.25555215e-07], [5.31182961e-07], [5.37105561e-07], [5.43332039e-07], [5.49857592e-07], [5.56673136e-07], [5.63812788e-07], [5.71286276e-07], [5.79103671e-07], [5.87275383e-07], [5.95812167e-07], [6.04725120e-07], [6.14025679e-07], [6.23725624e-07], [6.33837079e-07], [6.44372507e-07], [6.55344715e-07], [6.66766851e-07], [6.78652406e-07], [6.91015213e-07], [7.03869446e-07], [7.17229623e-07], [7.31122144e-07], [7.45732052e-07], [7.60940011e-07], [7.76766790e-07], [7.93233704e-07], [8.10362615e-07], [8.28175930e-07], [8.46696605e-07], [8.65948141e-07], [8.85954586e-07], [9.06740534e-07], [9.28331126e-07], [9.50752049e-07], [9.74029537e-07], [9.98190369e-07], [1.02333141e-06], [1.04978348e-06], [1.07733094e-06], [1.10601907e-06], [1.13589452e-06], [1.16700531e-06], [1.19940084e-06], [1.23313187e-06], [1.26825055e-06], [1.30481036e-06], [1.34286621e-06], [1.38247432e-06], [1.42375110e-06], [1.46721995e-06], [1.51258885e-06], [1.55994134e-06], [1.60936344e-06], [1.66094364e-06], [1.71477292e-06], [1.77094472e-06], [1.82955496e-06], [1.89070206e-06], [1.95448687e-06], [2.02101278e-06], [2.09041423e-06], [2.16343231e-06], [2.23979125e-06], [2.31965118e-06], [2.40317786e-06], [2.49054266e-06], [2.58192259e-06], [2.67750025e-06], [2.77746389e-06], [2.88209975e-06], [2.99223962e-06], [3.10768357e-06], [3.22869637e-06], [3.35555199e-06], [3.48853365e-06], [3.62793376e-06], [3.77405399e-06], [3.92720519e-06], [4.08787354e-06], [4.25702301e-06], [4.43466239e-06], [4.62123875e-06], [4.81721658e-06], [5.02307783e-06], [5.23932186e-06], [5.46672923e-06], [5.70642705e-06], [5.95864473e-06], [6.22406287e-06], [6.50338861e-06], [6.79735569e-06], [7.10672445e-06], [7.43265528e-06], [7.77654769e-06], [8.13901884e-06], [8.52111451e-06], [8.92392416e-06], [9.34858090e-06], [9.79702806e-06], [1.02706490e-05], [1.07706517e-05], [1.12985483e-05], [1.18559138e-05], [1.24443857e-05], [1.30673992e-05], [1.37260926e-05], [1.44225545e-05], [1.51589831e-05], [1.59376670e-05], [1.67613527e-05], [1.76338899e-05], [1.85576169e-05], [1.95356558e-05], [2.05712750e-05], [2.16692264e-05], [2.28331416e-05], [2.40669903e-05], [2.53750962e-05], [2.67627158e-05], [2.82358405e-05], [2.97992613e-05], [3.14586601e-05], [3.32200067e-05], [3.50917303e-05], [3.70802183e-05], [3.91930355e-05], [4.14387587e-05], [4.38272547e-05], [4.63673641e-05], [4.90689969e-05], [5.19444196e-05], [5.50053548e-05], [5.82638017e-05], [6.17330942e-05], [6.54301010e-05], [6.93690283e-05], [7.35660901e-05], [7.80397023e-05], [8.28102445e-05], [8.78974664e-05], [9.33245090e-05], [9.91159096e-05], [1.05296581e-04], [1.11893978e-04], [1.18938941e-04], [1.26463769e-04], [1.34503208e-04], [1.43094644e-04], [1.52277588e-04], [1.62095370e-04], [1.72594522e-04], [1.83824285e-04], [1.95838898e-04], [2.08696031e-04], [2.22457200e-04], [2.37190165e-04], [2.52966490e-04], [2.69863397e-04], [2.87965718e-04], [3.07362330e-04], [3.28148495e-04], [3.50430734e-04], [3.74320745e-04], [3.99937147e-04], [4.27412227e-04], [4.56886398e-04], [4.88507751e-04], [5.22439823e-04], [5.58859173e-04], [5.97951049e-04], [6.39916026e-04], [6.84974732e-04], [7.33359792e-04], [7.85324157e-04], [8.41137965e-04], [9.01089838e-04], [9.65494733e-04], [1.03468545e-03], [1.10902243e-03], [1.18889261e-03], [1.27470646e-03], [1.36691015e-03], [1.46597587e-03], [1.57240974e-03], [1.68675606e-03], [1.80958902e-03], [1.94152632e-03], [2.08322398e-03], [2.23537986e-03], [2.39873355e-03], [2.57406897e-03], [2.76221578e-03], [2.96404827e-03], [3.18048808e-03], [3.41250160e-03], [3.66110078e-03], [3.92734180e-03], [4.21231983e-03], [4.51717209e-03], [4.84306638e-03], [5.19119791e-03], [5.56278768e-03], [5.95906030e-03], [6.38124989e-03], [6.83057522e-03], [7.30822563e-03], [7.81535725e-03], [8.35304769e-03], [8.92230029e-03], [9.52400710e-03], [1.01589100e-02], [1.08275851e-02], [1.15304057e-02], [1.22675087e-02], [1.30387493e-02], [1.38436728e-02], [1.46814679e-02], [1.55509351e-02], [1.64504466e-02], [1.73779141e-02], [1.83307631e-02], [1.93059032e-02], [2.02997264e-02], [2.13080823e-02], [2.23263108e-02], [2.33492254e-02], [2.43711881e-02], [2.53861003e-02], [2.63875242e-02], [2.73687206e-02], [2.83227370e-02], [2.92425227e-02], [3.01210263e-02], [3.09513235e-02], [3.17267278e-02], [3.24409182e-02], [3.30880524e-02], [3.36628794e-02], [3.41608341e-02], [3.45781224e-02], [3.49117923e-02], [3.51597678e-02], [3.53208940e-02], [3.53949230e-02], [3.53825100e-02], [3.52851798e-02], [3.51052606e-02], [3.48458353e-02], [3.45106441e-02], [3.41040057e-02], [3.36307199e-02], [3.30959654e-02], [3.25052070e-02], [3.18640952e-02], [3.11783791e-02], [3.04538170e-02], [2.96961062e-02], [2.89108088e-02], [2.81032977e-02], [2.72787087e-02], [2.64418952e-02], [2.55974078e-02], [2.47494631e-02], [2.39019386e-02], [2.30583583e-02], [2.22219041e-02], [2.13954078e-02], [2.05813673e-02], [1.97819563e-02], [1.89990433e-02], [1.82342062e-02], [1.74887542e-02], [1.67637455e-02], [1.60600091e-02], [1.53781647e-02], [1.47186425e-02], [1.40817036e-02], [1.34674582e-02], [1.28758825e-02], [1.23068367e-02], [1.17600798e-02], [1.12352844e-02], [1.07320495e-02], [1.02499129e-02], [9.78836192e-03], [9.34684354e-03], [8.92477298e-03], [8.52154152e-03], [8.13652368e-03], [7.76908304e-03], [7.41857792e-03], [7.08436519e-03], [6.76580480e-03], [6.46226402e-03], [6.17311896e-03], [5.89775669e-03], [5.63557961e-03], [5.38600292e-03], [5.14846016e-03], [4.92240094e-03], [4.70729341e-03], [4.50262442e-03], [4.30789885e-03], [4.12264130e-03], [3.94639397e-03], [3.77871931e-03], [3.61919898e-03], [3.46743018e-03], [3.32302928e-03], [3.18563061e-03], [3.05488404e-03], [2.93045647e-03], [2.81203100e-03], [2.69930526e-03], [2.59199187e-03], [2.48981779e-03], [2.39252323e-03], [2.29986148e-03], [2.21159829e-03], [2.12751131e-03], [2.04738949e-03], [1.97103257e-03], [1.89825072e-03], [1.82886388e-03], [1.76270120e-03], [1.69960092e-03], [1.63940966e-03], [1.58198193e-03], [1.52718001e-03], [1.47487342e-03], [1.42493834e-03], [1.37725761e-03], [1.33172028e-03], [1.28822102e-03], [1.24666016e-03], [1.20694336e-03], [1.16898104e-03], [1.13268839e-03], [1.09798516e-03], [1.06479515e-03], [1.03304618e-03], [1.00267007e-03], [9.73601913e-04], [9.45780106e-04], [9.19146128e-04], [8.93644754e-04], [8.69223645e-04], [8.45833217e-04], [8.23426635e-04], [8.01959460e-04], [7.81388835e-04], [7.61674502e-04], [7.42778363e-04], [7.24664364e-04], [7.07298067e-04], [6.90646693e-04], [6.74679260e-04], [6.59366387e-04], [6.44680192e-04], [6.30594069e-04], [6.17082804e-04], [6.04122480e-04], [5.91690411e-04], [5.79765008e-04], [5.68325686e-04], [5.57352945e-04], [5.46828269e-04], [5.36734046e-04], [5.27053604e-04], [5.17770943e-04], [5.08870971e-04], [5.00339351e-04], [4.92162456e-04], [4.84327282e-04], [4.76821501e-04], [4.69633407e-04], [4.62751874e-04], [4.56166335e-04], [4.49866750e-04], [4.43843587e-04], [4.38087811e-04], [4.32590832e-04], [4.27344484e-04], [4.22341053e-04], [4.17573229e-04], [4.13034063e-04], [4.08716977e-04], [4.04615773e-04], [4.00724571e-04], [3.97037761e-04], [3.93550236e-04], [3.90256949e-04]])
array([0. , 0.00273973, 0.00547945, 0.00821918, 0.0109589 , 0.01369863, 0.01643836, 0.01917808, 0.02191781, 0.02465753, 0.02739726, 0.03013699, 0.03287671, 0.03561644, 0.03835616, 0.04109589, 0.04383562, 0.04657534, 0.04931507, 0.05205479, 0.05479452, 0.05753425, 0.06027397, 0.0630137 , 0.06575342, 0.06849315, 0.07123288, 0.0739726 , 0.07671233, 0.07945205, 0.08219178, 0.08493151, 0.08767123, 0.09041096, 0.09315068, 0.09589041, 0.09863014, 0.10136986, 0.10410959, 0.10684932, 0.10958904, 0.11232877, 0.11506849, 0.11780822, 0.12054795, 0.12328767, 0.1260274 , 0.12876712, 0.13150685, 0.13424658, 0.1369863 , 0.13972603, 0.14246575, 0.14520548, 0.14794521, 0.15068493, 0.15342466, 0.15616438, 0.15890411, 0.16164384, 0.16438356, 0.16712329, 0.16986301, 0.17260274, 0.17534247, 0.17808219, 0.18082192, 0.18356164, 0.18630137, 0.1890411 , 0.19178082, 0.19452055, 0.19726027, 0.2 , 0.20273973, 0.20547945, 0.20821918, 0.2109589 , 0.21369863, 0.21643836, 0.21917808, 0.22191781, 0.22465753, 0.22739726, 0.23013699, 0.23287671, 0.23561644, 0.23835616, 0.24109589, 0.24383562, 0.24657534, 0.24931507, 0.25205479, 0.25479452, 0.25753425, 0.26027397, 0.2630137 , 0.26575342, 0.26849315, 0.27123288, 0.2739726 , 0.27671233, 0.27945205, 0.28219178, 0.28493151, 0.28767123, 0.29041096, 0.29315068, 0.29589041, 0.29863014, 0.30136986, 0.30410959, 0.30684932, 0.30958904, 0.31232877, 0.31506849, 0.31780822, 0.32054795, 0.32328767, 0.3260274 , 0.32876712, 0.33150685, 0.33424658, 0.3369863 , 0.33972603, 0.34246575, 0.34520548, 0.34794521, 0.35068493, 0.35342466, 0.35616438, 0.35890411, 0.36164384, 0.36438356, 0.36712329, 0.36986301, 0.37260274, 0.37534247, 0.37808219, 0.38082192, 0.38356164, 0.38630137, 0.3890411 , 0.39178082, 0.39452055, 0.39726027, 0.4 , 0.40273973, 0.40547945, 0.40821918, 0.4109589 , 0.41369863, 0.41643836, 0.41917808, 0.42191781, 0.42465753, 0.42739726, 0.43013699, 0.43287671, 0.43561644, 0.43835616, 0.44109589, 0.44383562, 0.44657534, 0.44931507, 0.45205479, 0.45479452, 0.45753425, 0.46027397, 0.4630137 , 0.46575342, 0.46849315, 0.47123288, 0.4739726 , 0.47671233, 0.47945205, 0.48219178, 0.48493151, 0.48767123, 0.49041096, 0.49315068, 0.49589041, 0.49863014, 0.50136986, 0.50410959, 0.50684932, 0.50958904, 0.51232877, 0.51506849, 0.51780822, 0.52054795, 0.52328767, 0.5260274 , 0.52876712, 0.53150685, 0.53424658, 0.5369863 , 0.53972603, 0.54246575, 0.54520548, 0.54794521, 0.55068493, 0.55342466, 0.55616438, 0.55890411, 0.56164384, 0.56438356, 0.56712329, 0.56986301, 0.57260274, 0.57534247, 0.57808219, 0.58082192, 0.58356164, 0.58630137, 0.5890411 , 0.59178082, 0.59452055, 0.59726027, 0.6 , 0.60273973, 0.60547945, 0.60821918, 0.6109589 , 0.61369863, 0.61643836, 0.61917808, 0.62191781, 0.62465753, 0.62739726, 0.63013699, 0.63287671, 0.63561644, 0.63835616, 0.64109589, 0.64383562, 0.64657534, 0.64931507, 0.65205479, 0.65479452, 0.65753425, 0.66027397, 0.6630137 , 0.66575342, 0.66849315, 0.67123288, 0.6739726 , 0.67671233, 0.67945205, 0.68219178, 0.68493151, 0.68767123, 0.69041096, 0.69315068, 0.69589041, 0.69863014, 0.70136986, 0.70410959, 0.70684932, 0.70958904, 0.71232877, 0.71506849, 0.71780822, 0.72054795, 0.72328767, 0.7260274 , 0.72876712, 0.73150685, 0.73424658, 0.7369863 , 0.73972603, 0.74246575, 0.74520548, 0.74794521, 0.75068493, 0.75342466, 0.75616438, 0.75890411, 0.76164384, 0.76438356, 0.76712329, 0.76986301, 0.77260274, 0.77534247, 0.77808219, 0.78082192, 0.78356164, 0.78630137, 0.7890411 , 0.79178082, 0.79452055, 0.79726027, 0.8 , 0.80273973, 0.80547945, 0.80821918, 0.8109589 , 0.81369863, 0.81643836, 0.81917808, 0.82191781, 0.82465753, 0.82739726, 0.83013699, 0.83287671, 0.83561644, 0.83835616, 0.84109589, 0.84383562, 0.84657534, 0.84931507, 0.85205479, 0.85479452, 0.85753425, 0.86027397, 0.8630137 , 0.86575342, 0.86849315, 0.87123288, 0.8739726 , 0.87671233, 0.87945205, 0.88219178, 0.88493151, 0.88767123, 0.89041096, 0.89315068, 0.89589041, 0.89863014, 0.90136986, 0.90410959, 0.90684932, 0.90958904, 0.91232877, 0.91506849, 0.91780822, 0.92054795, 0.92328767, 0.9260274 , 0.92876712, 0.93150685, 0.93424658, 0.9369863 , 0.93972603, 0.94246575, 0.94520548, 0.94794521, 0.95068493, 0.95342466, 0.95616438, 0.95890411, 0.96164384, 0.96438356, 0.96712329, 0.96986301, 0.97260274, 0.97534247, 0.97808219, 0.98082192, 0.98356164, 0.98630137, 0.9890411 , 0.99178082, 0.99452055, 0.99726027, 1. , 1.00273973, 1.00547945, 1.00821918, 1.0109589 , 1.01369863, 1.01643836, 1.01917808, 1.02191781, 1.02465753, 1.02739726, 1.03013699, 1.03287671, 1.03561644, 1.03835616, 1.04109589, 1.04383562, 1.04657534, 1.04931507, 1.05205479, 1.05479452, 1.05753425, 1.06027397, 1.0630137 , 1.06575342, 1.06849315, 1.07123288, 1.0739726 , 1.07671233, 1.07945205, 1.08219178, 1.08493151, 1.08767123, 1.09041096, 1.09315068, 1.09589041, 1.09863014, 1.10136986, 1.10410959, 1.10684932, 1.10958904, 1.11232877, 1.11506849, 1.11780822, 1.12054795, 1.12328767, 1.1260274 , 1.12876712, 1.13150685, 1.13424658, 1.1369863 , 1.13972603, 1.14246575, 1.14520548, 1.14794521, 1.15068493, 1.15342466, 1.15616438, 1.15890411, 1.16164384, 1.16438356, 1.16712329, 1.16986301, 1.17260274, 1.17534247, 1.17808219, 1.18082192, 1.18356164, 1.18630137, 1.1890411 , 1.19178082, 1.19452055, 1.19726027, 1.2 , 1.20273973, 1.20547945, 1.20821918, 1.2109589 , 1.21369863, 1.21643836, 1.21917808, 1.22191781, 1.22465753, 1.22739726, 1.23013699, 1.23287671, 1.23561644, 1.23835616, 1.24109589, 1.24383562, 1.24657534, 1.24931507, 1.25205479, 1.25479452, 1.25753425, 1.26027397, 1.2630137 , 1.26575342, 1.26849315, 1.27123288, 1.2739726 , 1.27671233, 1.27945205, 1.28219178, 1.28493151, 1.28767123, 1.29041096, 1.29315068, 1.29589041, 1.29863014, 1.30136986, 1.30410959, 1.30684932, 1.30958904, 1.31232877, 1.31506849, 1.31780822, 1.32054795, 1.32328767, 1.3260274 , 1.32876712, 1.33150685, 1.33424658, 1.3369863 , 1.33972603, 1.34246575, 1.34520548, 1.34794521, 1.35068493, 1.35342466, 1.35616438, 1.35890411, 1.36164384, 1.36438356, 1.36712329, 1.36986301, 1.37260274, 1.37534247, 1.37808219, 1.38082192, 1.38356164, 1.38630137, 1.3890411 , 1.39178082, 1.39452055, 1.39726027, 1.4 , 1.40273973, 1.40547945, 1.40821918, 1.4109589 , 1.41369863, 1.41643836, 1.41917808, 1.42191781, 1.42465753, 1.42739726, 1.43013699, 1.43287671, 1.43561644, 1.43835616, 1.44109589, 1.44383562, 1.44657534, 1.44931507, 1.45205479, 1.45479452, 1.45753425, 1.46027397, 1.4630137 , 1.46575342, 1.46849315, 1.47123288, 1.4739726 , 1.47671233, 1.47945205, 1.48219178, 1.48493151, 1.48767123, 1.49041096, 1.49315068, 1.49589041, 1.49863014, 1.50136986, 1.50410959, 1.50684932, 1.50958904, 1.51232877, 1.51506849, 1.51780822, 1.52054795, 1.52328767, 1.5260274 , 1.52876712, 1.53150685, 1.53424658, 1.5369863 , 1.53972603, 1.54246575, 1.54520548, 1.54794521, 1.55068493, 1.55342466, 1.55616438, 1.55890411, 1.56164384, 1.56438356, 1.56712329, 1.56986301, 1.57260274, 1.57534247, 1.57808219, 1.58082192, 1.58356164, 1.58630137, 1.5890411 , 1.59178082, 1.59452055, 1.59726027, 1.6 , 1.60273973, 1.60547945, 1.60821918, 1.6109589 , 1.61369863, 1.61643836, 1.61917808, 1.62191781, 1.62465753, 1.62739726, 1.63013699, 1.63287671, 1.63561644, 1.63835616, 1.64109589, 1.64383562, 1.64657534, 1.64931507, 1.65205479, 1.65479452, 1.65753425, 1.66027397, 1.6630137 , 1.66575342, 1.66849315, 1.67123288, 1.6739726 , 1.67671233, 1.67945205, 1.68219178, 1.68493151, 1.68767123, 1.69041096, 1.69315068, 1.69589041, 1.69863014, 1.70136986, 1.70410959, 1.70684932, 1.70958904, 1.71232877, 1.71506849, 1.71780822, 1.72054795, 1.72328767, 1.7260274 , 1.72876712, 1.73150685, 1.73424658, 1.7369863 , 1.73972603, 1.74246575, 1.74520548, 1.74794521, 1.75068493, 1.75342466, 1.75616438, 1.75890411, 1.76164384, 1.76438356, 1.76712329, 1.76986301, 1.77260274, 1.77534247, 1.77808219, 1.78082192, 1.78356164, 1.78630137, 1.7890411 , 1.79178082, 1.79452055, 1.79726027, 1.8 , 1.80273973, 1.80547945, 1.80821918, 1.8109589 , 1.81369863, 1.81643836, 1.81917808, 1.82191781, 1.82465753, 1.82739726, 1.83013699, 1.83287671, 1.83561644, 1.83835616, 1.84109589, 1.84383562, 1.84657534, 1.84931507, 1.85205479, 1.85479452, 1.85753425, 1.86027397, 1.8630137 , 1.86575342, 1.86849315, 1.87123288, 1.8739726 , 1.87671233, 1.87945205, 1.88219178, 1.88493151, 1.88767123, 1.89041096, 1.89315068, 1.89589041, 1.89863014, 1.90136986, 1.90410959, 1.90684932, 1.90958904, 1.91232877, 1.91506849, 1.91780822, 1.92054795, 1.92328767, 1.9260274 , 1.92876712, 1.93150685, 1.93424658, 1.9369863 , 1.93972603, 1.94246575, 1.94520548, 1.94794521, 1.95068493, 1.95342466, 1.95616438, 1.95890411, 1.96164384, 1.96438356, 1.96712329, 1.96986301, 1.97260274, 1.97534247, 1.97808219, 1.98082192, 1.98356164, 1.98630137, 1.9890411 , 1.99178082, 1.99452055, 1.99726027])
#R0 is a ndarray
dis='HKU1'
R0 = np.arange(2,1.3,-0.2)
ds = run_climSIRS(dis=dis, ii0=1/8e6, R0=R0, T=3*365)
ds = ds.assign_coords(grid=R0).rename(grid='R0')
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(hue='R0')
[<matplotlib.lines.Line2D at 0x7f81fab48110>, <matplotlib.lines.Line2D at 0x7f81fab48390>, <matplotlib.lines.Line2D at 0x7f81fab48550>, <matplotlib.lines.Line2D at 0x7f81fab48710>]
# NYC q vs. idealized q for 'HKU1'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'HKU1'
T = 1*365
# q is from ERA5 NYC location
cities = ['NYC', 'Johannesburg']
colors = ['k', 'k']
# city = 'NYC'
for city,c in zip(cities, colors):
latx, lonx = regions[city]
color = c
if city == 'NYC':
label = f'{city}({dis})'
ls = '-'
else:
label = f'{city}'
ls = '--'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color, ls=ls)
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color, ls=ls)
ds = run_climSIRS(R0=R0, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=label,
ls=ls
)
#q is idealized
from numpy import pi as Pi
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
labels = ['qpeakJul', 'qpeakOct', 'qpeakOct', 'qpeakApr']
for phi0,label in zip(phi0s, labels):
q = get_q(phi0=phi0)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds = run_climSIRS(R0=R0, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=label)
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
The cell below is the same as the above except we run the four cases together. For reasons not quite understood, it is very slow and takes four times time to run.
# NYC q vs. idealized q for 'HKU1'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'HKU1'
T = 3.5*365
# q is from ERA5 NYC location
city = 'NYC'
latx, lonx = regions[city]
color = 'k'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color)
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color)
ds = run_climSIRS(R0=R0, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=f'{dis}_{city}')
#q is idealized
from numpy import pi as Pi
qpeakmons = ['Jul', 'Oct', 'Jan', 'Apr']
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
phi0s = xr.DataArray(phi0s, dims='qpeakmon', coords=[qpeakmons])
qs = get_q(phi0=phi0s)
R0s = q2R0(qs, **climdepens[dis])
ds = run_climSIRS(R0=R0s, T=T, ii0=1/8e6, dis=dis)
for mon in qpeakmons:
q = qs.sel(qpeakmon=mon)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = R0s.sel(qpeakmon=mon)
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds.sel(qpeakmon=mon).ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=label)
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
# NYC q vs. idealized q for 'OC43'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'OC43'
T = 2*365
# q is from ERA5 NYC location
city = 'NYC'
latx, lonx = regions[city]
color = 'k'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color)
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color)
ds = run_climSIRS(q=q, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=f'{dis}_{city}')
#q is idealized
from numpy import pi as Pi
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
labels = ['Jul_qpeak', 'Oct_qpeak', 'Jan_qpeak', 'Apr_qpeak']
for phi0,label in zip(phi0s, labels):
q = get_q(phi0=phi0)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds = run_climSIRS(q=q, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=label)
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
# NYC q vs. idealized q for 'HKU1'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'HKU1'
T = 3.5*365
qfactor = 1.1
# q is from ERA5 NYC location
city = 'NYC'
latx, lonx = regions[city]
color = 'k'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color)
q.pipe(lambda q: q*qfactor).plot(ax=axes[0], color=color, ls='--')
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color)
q2R0(q*qfactor, **climdepens[dis]).plot(ax=axes[1], color=color, ls='--')
ds = run_climSIRS(q=q, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=f'{dis}_{city}')
run_climSIRS(q=q*qfactor, T=T, ii0=1/8e6, dis=dis) \
.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
ls='--')
#q is idealized
from numpy import pi as Pi
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
labels = ['Jul_qpeak', 'Oct_qpeak', 'Jan_qpeak', 'Apr_qpeak']
for phi0,label in zip(phi0s, labels):
q = get_q(phi0=phi0)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds = run_climSIRS(q=q, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=label)
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
names = ['NYC', 'Maracaibo', 'Delhi']
dss = []
for name in names:
print(name)
latx, lonx = regions[name]
q = q2m.sel(latitude=[latx,], longitude=[lonx,], method='nearest')
ds = run_climSIRS(q=q, T=5*365, I0=1/8e6, L=62.5*7, a=-32.5)
ds.ii.plot()
ds.ii.squeeze().isel(t=ds.ii.squeeze()==ds.ii.max())
dss.append(ds.drop(['latitude', 'longitude']))
# ds_ = xr.concat(dss, dim=pd.Index(names, name='city'))
# ofile = '/tigress/wenchang/analysis/climate_and_disease/climSIRS/ClimSIRS.OC43.run7climq.cities.nc'
# print(ofile)
# ds_.to_netcdf(ofile)
# print('[saved]:', ofile)
NYC Maracaibo Delhi
# MERRA2 q
q2m = (
xr.open_dataset('/tigress/gvecchi/ANALYSIS/DISEASE/COVID-19/merra_weekly_clim.nc')
.rename(WEEK_QV2M='q2m', TT='time', LAT='latitude', LON='longitude')['q2m']
)
q2m = q2m.assign_coords(time=q2m.time.dt.dayofyear).reindex(time=np.arange(1, 366), method='nearest')
names = ['NYC', 'Maracaibo', 'Delhi']
dss = []
for name in names:
print(name, end=' ')
latx, lonx = regions[name]
if lonx > 180:
lonx -= 360
print(latx, lonx)
q = q2m.sel(latitude=[latx,], longitude=[lonx,], method='nearest')
ds = run_climSIRS(q=q, T=5*365, I0=1/8e6, L=62.5*7, a=-32.5)
ds.ii.plot()
print( ds.ii.squeeze().isel(t=ds.ii.squeeze()==ds.ii.max()) )
dss.append(ds.drop(['latitude', 'longitude']))
# ds_ = xr.concat(dss, dim=pd.Index(names, name='city'))
# ofile = '/tigress/wenchang/analysis/climate_and_disease/climSIRS/ClimSIRS.OC43.merra2wclimq.cities.nc'
# print(ofile)
# ds_.to_netcdf(ofile)
# print('[saved]:', ofile)
NYC 40.7128 -74.00599999999997 <xarray.DataArray 'ii' (t: 1)> array([0.21764435]) Coordinates: * t (t) float64 60.0 latitude float64 40.5 longitude float64 -73.75 Attributes: long_name: I/N Maracaibo 10.6427 -71.61250000000001 <xarray.DataArray 'ii' (t: 1)> array([0.16936215]) Coordinates: * t (t) float64 75.0 latitude float64 10.5 longitude float64 -71.88 Attributes: long_name: I/N Delhi 28.7041 77.1025 <xarray.DataArray 'ii' (t: 1)> array([0.21486067]) Coordinates: * t (t) float64 60.0 latitude float64 28.5 longitude float64 76.88 Attributes: long_name: I/N
solve_ivp
backend¶# t instead of y is the first argument required by scipy.integrate.solve_ivp
def model_climSIRSpy(t, y, L, D, R0):
return model_climSIRS(y=y, t=t, L=L, D=D, R0=R0)
# scipy.integrate.solve_ivp backend
from scipy.integrate import solve_ivp
def run_climSIRSpy(ii0=1e-5, ss0=None, T=5*365, dt=1, L=None, D=5, R0=2, dis='HKU1', ode_kws=None):
'''Integrate SIRS model from Baker et al., 2020.
Input:
-------
I0: initial I/N
T: time stop (start is 1; units is 'day')
dt: time step
L: immunity length, 7x66.25(62.5) days for HKU1 (OC43)
D: infection period, 5 days
R0 = beta*D, ignored if q is not None
q: specific humidity, xr.DataArray, dims ('time', ...)
a: climate dependence parameter, -227.5(-32.5) for HKU1(OC43)
Return:
--------
ds: solution for the SIRS model.
'''
if ode_kws is None:
ode_kws = {'method': 'RK45'}
if L is None and dis is not None:
L = Ls[dis]
if hasattr(R0, 'time'): # R0 time-dependent
if R0.ndim > 1:#
R0 = R0.stack(grid=R0.isel(time=0).dims)
grid = R0.grid # grid info is saved
zeros = np.zeros(grid.size) # broadcast array by R0.dims[1:]
else: # only time dimension
zeros = ii0*L*D*0 # broadcast array by ii0*L*D*a
else: # R0 time-independent
zeros = ii0*L*D*R0*0
# default initial S/N value determined by initial I/N value
if ss0 is None:
ss0 = 1 - ii0
# broadcast initial values by adding zeros
ii0 = ii0 + zeros
ss0 = ss0 + zeros
y0 = np.hstack([ss0, ii0])
t = np.arange(0, T, dt)
# # scipy.integrate.odeint backend; call FORTRAN code ultimately
# sol = odeint(model_climSIRS, y0, t, args=(L, D, R0))
# ss = sol[:, 0:y0.size//2]
# ii = sol[:, y0.size//2:]
# da_ss = xr.DataArray(ss, dims=['t', 'grid'],coords=[t, np.arange(1, y0.size//2+1)])
# da_ss.attrs['long_name'] = 'S/N'
# da_ii = xr.DataArray(ii, dims=['t', 'grid'],coords=[t, np.arange(1, y0.size//2+1)])
# da_ii.attrs['long_name'] = 'I/N'
# scipy.integrate.solve_ivp backend, pure Python code
# print(t)
sol = solve_ivp(model_climSIRSpy,[0, T], y0, t_eval=t, args=(L, D, R0), **ode_kws)
if sol.status == -1:
method = ode_kws['method']
print(f'[failed]: solve_ivp(method="{method}")')
sys.exit()
# print(sol)
ss = sol.y[0:y0.size//2, :]
ii = sol.y[y0.size//2:, :]
# print(ss.shape)
da_ss = xr.DataArray(ss, dims=['grid', 't'],coords=[np.arange(1, y0.size//2+1), t])
da_ss.attrs['long_name'] = 'S/N'
da_ii = xr.DataArray(ii, dims=['grid', 't'],coords=[np.arange(1, y0.size//2+1), t])
da_ii.attrs['long_name'] = 'I/N'
if hasattr(R0, 'time') and R0.ndim > 1: # R0 has more than "time" dimensions
da_ss = da_ss.assign_coords(grid=grid).unstack()
da_ii = da_ii.assign_coords(grid=grid).unstack()
ds = xr.Dataset(dict(ss=da_ss, ii=da_ii, year=da_ss.t/365))
ds.t.attrs['units'] = 'day'
return ds
latx, lonx = regions['NYC']
# q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
# q = get_q()
ds = run_climSIRSpy(R0=2, T=2*365, ii0=1/8e6, L=66.25*7)
ds.ii.plot()
ds
array([1])
array([ 0, 1, 2, ..., 727, 728, 729])
array([[0.99999987, 0.99999982, 0.99999975, 0.99999967, 0.99999957, 0.99999945, 0.9999993 , 0.99999912, 0.99999889, 0.99999862, 0.99999828, 0.99999759, 0.99999655, 0.99999532, 0.99999402, 0.99999274, 0.99999152, 0.99999037, 0.99998927, 0.99998817, 0.99998695, 0.99998549, 0.99998361, 0.99998111, 0.99997775, 0.99997324, 0.99996727, 0.99995949, 0.99994951, 0.9999369 , 0.9999212 , 0.99990191, 0.9998785 , 0.99985039, 0.99981686, 0.99977532, 0.99972498, 0.99966494, 0.99959325, 0.99950688, 0.99940173, 0.99927265, 0.99911341, 0.99891669, 0.99867414, 0.99837631, 0.99801269, 0.99757172, 0.99703497, 0.99638306, 0.99559457, 0.99463889, 0.99347627, 0.99205781, 0.99032546, 0.98821199, 0.98564104, 0.9825271 , 0.97877697, 0.97430619, 0.96893988, 0.96247412, 0.95470613, 0.94543425, 0.93445792, 0.92157773, 0.90659538, 0.88931372, 0.86954328, 0.84720061, 0.82227781, 0.79485339, 0.76510636, 0.73331627, 0.69986319, 0.66522774, 0.62999107, 0.59483485, 0.5605413 , 0.52774357, 0.49661044, 0.46741788, 0.44037125, 0.41560042, 0.39315987, 0.3730286 , 0.35511017, 0.33923273, 0.32514893, 0.31259936, 0.30157045, 0.2919114 , 0.28346155, 0.27607873, 0.26963921, 0.26403774, 0.2591875 , 0.25502015, 0.25148582, 0.24854481, 0.24609014, 0.24406254, 0.24242309, 0.24113415, 0.24015934, 0.23946361, 0.23901315, 0.23877544, 0.23871925, 0.23881771, 0.23906182, 0.23944099, 0.23994385, 0.24055919, 0.24127595, 0.24208319, 0.24297013, 0.24392613, 0.24494071, 0.24600505, 0.24711769, 0.2482749 , 0.2494726 , 0.25070687, 0.25197393, 0.25327015, 0.25459204, 0.25593627, 0.25729971, 0.25868054, 0.26007733, 0.26148854, 0.26291269, 0.26434835, 0.26579415, 0.26724878, 0.26871097, 0.27017953, 0.27165337, 0.27313192, 0.27461461, 0.2761009 , 0.27759025, 0.27908214, 0.28057606, 0.28207154, 0.28356811, 0.28506533, 0.28656277, 0.28806009, 0.28955713, 0.29105369, 0.2925496 , 0.29404466, 0.29553871, 0.29703157, 0.29852307, 0.30001307, 0.30150139, 0.30298788, 0.30447242, 0.30595485, 0.30743514, 0.30891325, 0.3103891 , 0.31186267, 0.31333389, 0.31480272, 0.3162691 , 0.317733 , 0.31919436, 0.32065313, 0.32210928, 0.32356275, 0.32501351, 0.3264615 , 0.3279067 , 0.3293491 , 0.33078872, 0.33222552, 0.33365952, 0.33509069, 0.33651905, 0.33794456, 0.33936724, 0.34078706, 0.34220403, 0.34361814, 0.34502937, 0.34643772, 0.34784318, 0.34924575, 0.35064541, 0.35204216, 0.35343599, 0.35482688, 0.35621486, 0.35759993, 0.3589821 , 0.36036136, 0.36173773, 0.3631112 , 0.36448178, 0.36584948, 0.36721429, 0.36857622, 0.36993528, 0.37129147, 0.37264478, 0.37399524, 0.37534283, 0.37668756, 0.37802944, 0.37936847, 0.38070464, 0.38203798, 0.38336846, 0.38469611, 0.38602092, 0.3873429 , 0.38866205, 0.38997836, 0.39129186, 0.39260253, 0.3939104 , 0.39521546, 0.39651773, 0.39781722, 0.39911391, 0.40040783, 0.40169898, 0.40298735, 0.40427297, 0.40555583, 0.40683593, 0.4081133 , 0.40938792, 0.4106598 , 0.41192896, 0.41319539, 0.41445911, 0.41572011, 0.41697841, 0.418234 , 0.4194869 , 0.4207371 , 0.42198462, 0.42322946, 0.42447163, 0.42571112, 0.42694796, 0.42818213, 0.42941365, 0.43064252, 0.43186875, 0.43309235, 0.43431331, 0.43553164, 0.43674736, 0.43796046, 0.43917095, 0.44037883, 0.44158412, 0.44278681, 0.44398691, 0.44518443, 0.44637938, 0.44757174, 0.44876155, 0.44994879, 0.45113347, 0.45231561, 0.4534952 , 0.45467225, 0.45584677, 0.45701876, 0.45818822, 0.45935517, 0.46051961, 0.46168154, 0.46284097, 0.46399791, 0.46515235, 0.46630431, 0.46745379, 0.4686008 , 0.46974533, 0.47088741, 0.47202702, 0.47316419, 0.4742989 , 0.47543117, 0.47656101, 0.47768842, 0.47881339, 0.47993595, 0.48105609, 0.48217382, 0.48328915, 0.48440207, 0.4855126 , 0.48662074, 0.4877265 , 0.48882987, 0.48993087, 0.4910295 , 0.49212577, 0.49321967, 0.49431122, 0.49540043, 0.49648728, 0.4975718 , 0.49865399, 0.49973384, 0.50081137, 0.50188658, 0.50295948, 0.50403007, 0.50509835, 0.50616434, 0.50722803, 0.50828942, 0.50934854, 0.51040537, 0.51145993, 0.51251222, 0.51356224, 0.51461001, 0.51565551, 0.51669877, 0.51773978, 0.51877855, 0.51981508, 0.52084937, 0.52188145, 0.52291129, 0.52393893, 0.52496434, 0.52598755, 0.52700856, 0.52802736, 0.52904397, 0.53005839, 0.53107063, 0.53208068, 0.53308856, 0.53409427, 0.53509781, 0.53609919, 0.53709841, 0.53809547, 0.53909039, 0.54008316, 0.54107379, 0.54206229, 0.54304866, 0.5440329 , 0.54501501, 0.54599501, 0.5469729 , 0.54794867, 0.54892234, 0.54989392, 0.55086339, 0.55183078, 0.55279607, 0.55375929, 0.55472042, 0.55567948, 0.55663647, 0.5575914 , 0.55854426, 0.55949507, 0.56044382, 0.56139052, 0.56233518, 0.5632778 , 0.56421838, 0.56515693, 0.56609345, 0.56702795, 0.56796043, 0.56889089, 0.56981934, 0.57074579, 0.57167023, 0.57259267, 0.57351311, 0.57443157, 0.57534803, 0.57626252, 0.57717502, 0.57808555, 0.57899411, 0.5799007 , 0.58080532, 0.58170799, 0.5826087 , 0.58350746, 0.58440427, 0.58529914, 0.58619206, 0.58708305, 0.58797211, 0.58885924, 0.58974445, 0.59062773, 0.5915091 , 0.59238855, 0.59326609, 0.59414173, 0.59501547, 0.5958873 , 0.59675724, 0.59762529, 0.59849142, 0.59935561, 0.60021786, 0.6010782 , 0.60193664, 0.60279318, 0.60364783, 0.60450061, 0.60535152, 0.60620057, 0.60704777, 0.60789312, 0.60873664, 0.60957832, 0.61041817, 0.6112562 , 0.6120924 , 0.61292679, 0.61375937, 0.61459013, 0.61541907, 0.61624621, 0.61707153, 0.61789505, 0.61871675, 0.61953663, 0.62035469, 0.62117094, 0.62198536, 0.62279795, 0.62360871, 0.62441762, 0.62522469, 0.62602991, 0.62683327, 0.62763476, 0.62843438, 0.6292321 , 0.63002794, 0.63082186, 0.63161387, 0.63240395, 0.63319209, 0.63397827, 0.63476249, 0.63554472, 0.63632495, 0.63710318, 0.63787937, 0.63865352, 0.63942561, 0.64019561, 0.64096352, 0.64172931, 0.64249296, 0.64325446, 0.64401377, 0.64477088, 0.64552577, 0.64627842, 0.64702879, 0.64777687, 0.64852264, 0.64926606, 0.65000711, 0.65074577, 0.65148199, 0.65221538, 0.65294573, 0.65367312, 0.6543976 , 0.65511921, 0.65583795, 0.65655381, 0.65726675, 0.65797672, 0.65868363, 0.65938738, 0.66008785, 0.66078488, 0.66147831, 0.66216793, 0.66285354, 0.66353489, 0.66421173, 0.66488377, 0.6655507 , 0.6662122 , 0.66686791, 0.66751746, 0.66816045, 0.66879647, 0.66942506, 0.67004578, 0.67065813, 0.67126161, 0.67185567, 0.67243977, 0.67301333, 0.67357576, 0.67412642, 0.67466469, 0.67518988, 0.67570131, 0.67619827, 0.67668002, 0.67714581, 0.67759485, 0.67802622, 0.67843884, 0.67883138, 0.67920236, 0.67955005, 0.67987256, 0.68016776, 0.68043336, 0.68066682, 0.68086543, 0.68102628, 0.68114624, 0.68122199, 0.68125 , 0.68122654, 0.68114769, 0.6810093 , 0.68080706, 0.68053642, 0.68019264, 0.67977078, 0.67926571, 0.67867207, 0.67798433, 0.67719672, 0.67630331, 0.67529794, 0.67417425, 0.67292569, 0.6715455 , 0.67002672, 0.66836219, 0.66654453, 0.6645662 , 0.6624194 , 0.66009619, 0.65758847, 0.65489168, 0.65199864, 0.64890119, 0.64559261, 0.64206771, 0.63832277, 0.63435554, 0.6301653 , 0.62575277, 0.62112019, 0.61627127, 0.61121121, 0.60594671, 0.60048594, 0.59483855, 0.58901571, 0.58302916, 0.5768909 , 0.57062126, 0.56424127, 0.55777175, 0.5512333 , 0.54464631, 0.53803095, 0.53140717, 0.52479473, 0.51821313, 0.51168168, 0.50521947, 0.49884538, 0.49257806, 0.48643596, 0.48043728, 0.47459003, 0.46889516, 0.46336593, 0.45801426, 0.45285063, 0.44788409, 0.44312221, 0.43857115, 0.43423558, 0.43011875, 0.42622247, 0.42254707, 0.41909147, 0.41585312, 0.41282801, 0.41001072, 0.40739436, 0.40497058, 0.40272961, 0.40066021, 0.39874971, 0.39698398, 0.39534744, 0.39382479, 0.39242623, 0.39115331, 0.39000061, 0.38896288, 0.388035 , 0.38721203, 0.38648919, 0.38586182, 0.38532546, 0.38487578, 0.38450862, 0.38421995, 0.38400593, 0.38386286, 0.3837872 , 0.38377555, 0.38382468, 0.38393153, 0.38409317, 0.38430684, 0.38456993, 0.38487884, 0.38523067, 0.38562367, 0.3860561 , 0.38652625, 0.38703246, 0.38757308, 0.3881465 , 0.38875113, 0.38938543, 0.39004786, 0.39073695, 0.39145123, 0.39218926, 0.39294965, 0.39373103, 0.39453205, 0.3953514 , 0.39618781, 0.39704002, 0.39790682, 0.39878701, 0.39968024, 0.40058624, 0.4015044 , 0.40243411, 0.40337479, 0.40432588, 0.40528682, 0.40625708, 0.40723615, 0.40822351, 0.40921869, 0.4102212 , 0.4112306 , 0.41224644, 0.41326831, 0.41429579, 0.4153285 , 0.41636605, 0.4174081 , 0.41845429, 0.41950429, 0.42055781, 0.42161459, 0.42267442, 0.42373712, 0.42480249, 0.42587034, 0.42694048, 0.42801273, 0.42908693, 0.43016289, 0.43124046, 0.43231947, 0.43339977, 0.43448122, 0.43556365, 0.43664694, 0.43773094, 0.43881553, 0.43990058, 0.44098597, 0.44207159, 0.44315731, 0.44424304, 0.44532867, 0.44641411, 0.44749926, 0.44858404, 0.44966836, 0.45075215, 0.45183534, 0.45291785, 0.45399963, 0.45508062, 0.45616075, 0.45723997, 0.45831822, 0.45939544, 0.46047159, 0.4615466 , 0.46262043, 0.46369303, 0.46476435, 0.46583435, 0.46690298, 0.4679702 , 0.46903597, 0.47010025, 0.47116301, 0.47222421]])
array([[1.25000000e-07, 1.52677327e-07, 1.86581367e-07, 2.27863469e-07, 2.78026260e-07, 3.39152469e-07, 4.13904920e-07, 5.05526539e-07, 6.17840347e-07, 7.55249468e-07, 9.26957863e-07, 1.27447241e-06, 1.79631906e-06, 2.41359541e-06, 3.06569019e-06, 3.71028323e-06, 4.32334552e-06, 4.89913913e-06, 5.45021728e-06, 6.00742431e-06, 6.61989565e-06, 7.35505790e-06, 8.29862873e-06, 9.55461697e-06, 1.12453226e-05, 1.35113365e-05, 1.65115411e-05, 2.04231096e-05, 2.54415063e-05, 3.17804869e-05, 3.96720980e-05, 4.93666775e-05, 6.11328541e-05, 7.52575479e-05, 9.21105724e-05, 1.12974717e-04, 1.38259311e-04, 1.68418981e-04, 2.04441330e-04, 2.47846934e-04, 3.00689345e-04, 3.65555090e-04, 4.45563670e-04, 5.44367561e-04, 6.66152213e-04, 8.15636052e-04, 9.98070479e-04, 1.21924103e-03, 1.48788717e-03, 1.81378583e-03, 2.20813863e-03, 2.68634309e-03, 3.26799261e-03, 3.97687649e-03, 4.84097991e-03, 5.89248395e-03, 7.16776559e-03, 8.70739768e-03, 1.05547956e-02, 1.27364458e-02, 1.53415468e-02, 1.84723674e-02, 2.22182838e-02, 2.66557795e-02, 3.18484453e-02, 3.78469797e-02, 4.46891883e-02, 5.23999841e-02, 6.09940996e-02, 7.04427005e-02, 8.05619218e-02, 9.11208228e-02, 1.01861092e-01, 1.12497047e-01, 1.22715637e-01, 1.32176438e-01, 1.40511656e-01, 1.47326129e-01, 1.52197322e-01, 1.54883189e-01, 1.55604561e-01, 1.54499930e-01, 1.51729418e-01, 1.47478505e-01, 1.41958024e-01, 1.35404168e-01, 1.28078485e-01, 1.20267880e-01, 1.12284614e-01, 1.04413094e-01, 9.66679474e-02, 8.91272674e-02, 8.18729048e-02, 7.49690426e-02, 6.84621967e-02, 6.23812151e-02, 5.67372789e-02, 5.15239015e-02, 4.67169290e-02, 4.22794615e-02, 3.82147813e-02, 3.45081004e-02, 3.11351303e-02, 2.80723677e-02, 2.52970945e-02, 2.27873774e-02, 2.05220683e-02, 1.84808044e-02, 1.66440077e-02, 1.49916649e-02, 1.35021915e-02, 1.21609977e-02, 1.09548342e-02, 9.87117000e-03, 8.89819265e-03, 8.02480793e-03, 7.24064007e-03, 6.53603166e-03, 5.90204369e-03, 5.33064021e-03, 4.81585760e-03, 4.35255470e-03, 3.93586204e-03, 3.56120647e-03, 3.22431112e-03, 2.92119544e-03, 2.64817520e-03, 2.40186243e-03, 2.17918540e-03, 1.97782377e-03, 1.79592015e-03, 1.63169516e-03, 1.48347354e-03, 1.34968414e-03, 1.22885993e-03, 1.11963800e-03, 1.02075955e-03, 9.31069903e-04, 8.49545669e-04, 7.75472913e-04, 7.08228889e-04, 6.47215784e-04, 5.91868919e-04, 5.41656754e-04, 4.96080886e-04, 4.54676050e-04, 4.17010117e-04, 3.82684096e-04, 3.51332134e-04, 3.22650902e-04, 2.96438695e-04, 2.72500792e-04, 2.50651400e-04, 2.30713979e-04, 2.12521231e-04, 1.95915110e-04, 1.80746817e-04, 1.66876798e-04, 1.54174751e-04, 1.42519619e-04, 1.31799592e-04, 1.21917460e-04, 1.12814970e-04, 1.04438766e-04, 9.67365291e-05, 8.96580653e-05, 8.31553075e-05, 7.71823143e-05, 7.16952704e-05, 6.66524867e-05, 6.20144000e-05, 5.77435731e-05, 5.38046951e-05, 5.01645809e-05, 4.67921717e-05, 4.36585344e-05, 4.07401805e-05, 3.80273691e-05, 3.55082271e-05, 3.31708592e-05, 3.10037515e-05, 2.89957717e-05, 2.71361689e-05, 2.54145740e-05, 2.38209992e-05, 2.23458383e-05, 2.09798666e-05, 1.97142409e-05, 1.85404997e-05, 1.74505627e-05, 1.64367315e-05, 1.54916889e-05, 1.46084995e-05, 1.37806093e-05, 1.30018457e-05, 1.22667262e-05, 1.15748955e-05, 1.09252364e-05, 1.03156031e-05, 9.74390838e-06, 9.20812416e-06, 8.70628111e-06, 8.23646875e-06, 7.79683551e-06, 7.38558866e-06, 7.00099435e-06, 6.64137757e-06, 6.30512221e-06, 5.99067101e-06, 5.69652557e-06, 5.42124638e-06, 5.16345276e-06, 4.92182292e-06, 4.69509394e-06, 4.48206174e-06, 4.28158115e-06, 4.09256582e-06, 3.91398828e-06, 3.74487996e-06, 3.58433110e-06, 3.43149084e-06, 3.28556719e-06, 3.14582842e-06, 3.01253427e-06, 2.88605952e-06, 2.76609169e-06, 2.65232679e-06, 2.54446944e-06, 2.44223279e-06, 2.34533855e-06, 2.25351699e-06, 2.16650694e-06, 2.08405577e-06, 2.00591943e-06, 1.93186242e-06, 1.86165777e-06, 1.79508710e-06, 1.73194058e-06, 1.67201693e-06, 1.61512342e-06, 1.56107589e-06, 1.50969873e-06, 1.46082488e-06, 1.41429585e-06, 1.36996171e-06, 1.32768106e-06, 1.28732109e-06, 1.24875752e-06, 1.21187463e-06, 1.17656528e-06, 1.14273086e-06, 1.11028133e-06, 1.07913519e-06, 1.04921953e-06, 1.02046997e-06, 9.92830683e-07, 9.66254416e-07, 9.40702464e-07, 9.16144677e-07, 8.92559466e-07, 8.69933796e-07, 8.48263189e-07, 8.27551722e-07, 8.07812032e-07, 7.89065309e-07, 7.71341303e-07, 7.54671126e-07, 7.38782331e-07, 7.23499272e-07, 7.08797455e-07, 6.94652919e-07, 6.81042239e-07, 6.67942521e-07, 6.55331408e-07, 6.43187075e-07, 6.31488233e-07, 6.20214125e-07, 6.09344530e-07, 5.98859758e-07, 5.88740657e-07, 5.78968606e-07, 5.69525520e-07, 5.60393846e-07, 5.51556567e-07, 5.42997198e-07, 5.34699791e-07, 5.26648929e-07, 5.18829730e-07, 5.11227847e-07, 5.03829466e-07, 4.96621308e-07, 4.89590626e-07, 4.82725210e-07, 4.76013382e-07, 4.69443998e-07, 4.63006448e-07, 4.56690658e-07, 4.50487086e-07, 4.44386725e-07, 4.38381100e-07, 4.32462274e-07, 4.26622840e-07, 4.20855928e-07, 4.15155199e-07, 4.09514852e-07, 4.03929616e-07, 3.98394757e-07, 3.92906074e-07, 3.87459899e-07, 3.82053100e-07, 3.76683077e-07, 3.71347766e-07, 3.66045635e-07, 3.60775689e-07, 3.55537463e-07, 3.50331029e-07, 3.45156992e-07, 3.40016492e-07, 3.34911201e-07, 3.29843327e-07, 3.24815612e-07, 3.19831331e-07, 3.14894293e-07, 3.10008841e-07, 3.05179853e-07, 3.00412741e-07, 2.95713449e-07, 2.91088459e-07, 2.86544782e-07, 2.82089967e-07, 2.77732096e-07, 2.73479783e-07, 2.69342180e-07, 2.65328969e-07, 2.61450368e-07, 2.57717130e-07, 2.54140540e-07, 2.50732417e-07, 2.47505117e-07, 2.44471526e-07, 2.41645066e-07, 2.39039695e-07, 2.36669901e-07, 2.34550709e-07, 2.32697677e-07, 2.31126897e-07, 2.29854995e-07, 2.28899132e-07, 2.28277001e-07, 2.28006831e-07, 2.28107385e-07, 2.28597958e-07, 2.29498381e-07, 2.30829018e-07, 2.32610768e-07, 2.34865063e-07, 2.37613870e-07, 2.40879689e-07, 2.44685555e-07, 2.49055036e-07, 2.54012235e-07, 2.59581788e-07, 2.65788867e-07, 2.72659176e-07, 2.80218954e-07, 2.88494973e-07, 2.97514540e-07, 3.07305497e-07, 3.17896218e-07, 3.29315611e-07, 3.41593121e-07, 3.54758723e-07, 3.68842929e-07, 3.83876785e-07, 3.99891868e-07, 4.16920292e-07, 4.34994704e-07, 4.54148286e-07, 4.74414753e-07, 4.95828353e-07, 5.18423870e-07, 5.42236622e-07, 5.67302459e-07, 5.93657768e-07, 6.21339466e-07, 6.50385009e-07, 6.80832383e-07, 7.12720110e-07, 7.46087245e-07, 7.80973378e-07, 8.17418633e-07, 8.55463666e-07, 8.95149671e-07, 9.36518371e-07, 9.79612028e-07, 1.02447343e-06, 1.07114592e-06, 1.11967334e-06, 1.17010010e-06, 1.22247113e-06, 1.27683188e-06, 1.33322836e-06, 1.39170710e-06, 1.45231516e-06, 1.51510015e-06, 1.58011020e-06, 1.64739398e-06, 1.71700068e-06, 1.78898005e-06, 1.86338236e-06, 1.94025840e-06, 2.01965953e-06, 2.10163760e-06, 2.18624503e-06, 2.27360752e-06, 2.37413517e-06, 2.49352733e-06, 2.62950243e-06, 2.77993740e-06, 2.94286764e-06, 3.11648703e-06, 3.29914795e-06, 3.48936125e-06, 3.68579627e-06, 3.88728085e-06, 4.09280128e-06, 4.30150236e-06, 4.51268738e-06, 4.72581809e-06, 4.94051475e-06, 5.15655609e-06, 5.37387932e-06, 5.59258015e-06, 5.81291277e-06, 6.03528984e-06, 6.26028252e-06, 6.48862045e-06, 6.72119176e-06, 6.95904306e-06, 7.20337943e-06, 7.45556446e-06, 7.71712022e-06, 7.98972725e-06, 8.27522457e-06, 8.57560972e-06, 8.89303869e-06, 9.22982597e-06, 9.58844452e-06, 9.97152580e-06, 1.03818598e-05, 1.08223948e-05, 1.12962379e-05, 1.18066543e-05, 1.23570681e-05, 1.29510615e-05, 1.35923753e-05, 1.42849090e-05, 1.50327203e-05, 1.58400256e-05, 1.67111996e-05, 1.76507756e-05, 1.86634453e-05, 1.97540590e-05, 2.09276254e-05, 2.21893118e-05, 2.35444437e-05, 2.49985055e-05, 2.65571397e-05, 2.82261475e-05, 3.00114885e-05, 3.19192809e-05, 3.39558012e-05, 3.61274845e-05, 3.84409245e-05, 4.09028731e-05, 4.35202409e-05, 4.63000969e-05, 4.92496687e-05, 5.23763421e-05, 5.56876618e-05, 5.91913306e-05, 6.28963733e-05, 6.69232610e-05, 7.13290388e-05, 7.60909037e-05, 8.11923960e-05, 8.66233992e-05, 9.23801398e-05, 9.84651874e-05, 1.04887455e-04, 1.11662198e-04, 1.18811016e-04, 1.26361851e-04, 1.34348988e-04, 1.42813057e-04, 1.51801027e-04, 1.61366214e-04, 1.71568276e-04, 1.82473214e-04, 1.94153371e-04, 2.06687436e-04, 2.20160437e-04, 2.34663750e-04, 2.50295089e-04, 2.67158516e-04, 2.85364432e-04, 3.05029584e-04, 3.26277061e-04, 3.49236296e-04, 3.74043062e-04, 4.00839479e-04, 4.29774009e-04, 4.61001456e-04, 4.94682968e-04, 5.30986036e-04, 5.70084493e-04, 6.12158519e-04, 6.57394631e-04, 7.05985695e-04, 7.58130917e-04, 8.14035846e-04, 8.73912375e-04, 9.37286605e-04, 1.00388856e-03, 1.07439282e-03, 1.14949295e-03, 1.22990084e-03, 1.31634670e-03, 1.40957901e-03, 1.51036459e-03, 1.61948856e-03, 1.73775436e-03, 1.86598371e-03, 2.00501666e-03, 2.15571158e-03, 2.31894512e-03, 2.49561225e-03, 2.68662627e-03, 2.89291875e-03, 3.11543959e-03, 3.35515702e-03, 3.61305753e-03, 3.89014596e-03, 4.18744543e-03, 4.50599740e-03, 4.84686161e-03, 5.21111613e-03, 5.59985731e-03, 6.01419984e-03, 6.45527671e-03, 6.92423921e-03, 7.42225694e-03, 7.95051782e-03, 8.51022806e-03, 9.10261220e-03, 9.72891307e-03, 1.03903918e-02, 1.10883279e-02, 1.18240191e-02, 1.25987132e-02, 1.34106037e-02, 1.42583984e-02, 1.51416822e-02, 1.60594393e-02, 1.70100533e-02, 1.79913076e-02, 1.90003848e-02, 2.00338672e-02, 2.10877367e-02, 2.21573743e-02, 2.32375611e-02, 2.43224772e-02, 2.54057024e-02, 2.64802161e-02, 2.75383972e-02, 2.85720238e-02, 2.95729287e-02, 3.05353155e-02, 3.14508707e-02, 3.23115406e-02, 3.31100342e-02, 3.38398230e-02, 3.44951409e-02, 3.50709842e-02, 3.55631118e-02, 3.59680452e-02, 3.62830682e-02, 3.65062271e-02, 3.66363307e-02, 3.66729503e-02, 3.66164198e-02, 3.64678354e-02, 3.62290559e-02, 3.59092752e-02, 3.55203756e-02, 3.50643036e-02, 3.45432988e-02, 3.39599869e-02, 3.33173790e-02, 3.26188719e-02, 3.18682480e-02, 3.10696753e-02, 3.02277074e-02, 2.93472838e-02, 2.84337292e-02, 2.74927544e-02, 2.65304553e-02, 2.55533140e-02, 2.45681978e-02, 2.35823598e-02, 2.26034387e-02, 2.16394589e-02, 2.06988303e-02, 1.97903486e-02, 1.89231950e-02, 1.81069363e-02, 1.73492110e-02, 1.66238618e-02, 1.59208766e-02, 1.52404059e-02, 1.45825429e-02, 1.39473226e-02, 1.33347225e-02, 1.27446623e-02, 1.21770040e-02, 1.16315518e-02, 1.11080519e-02, 1.06061933e-02, 1.01256067e-02, 9.66586535e-03, 9.22648468e-03, 8.80692235e-03, 8.40657826e-03, 8.02479460e-03, 7.66085575e-03, 7.31398839e-03, 6.98336141e-03, 6.66808715e-03, 6.36768686e-03, 6.08174500e-03, 5.80956731e-03, 5.55048746e-03, 5.30386706e-03, 5.06909564e-03, 4.84559070e-03, 4.63279764e-03, 4.43018982e-03, 4.23726852e-03, 4.05356298e-03, 3.87863033e-03, 3.71205570e-03, 3.55345210e-03, 3.40246051e-03, 3.25874983e-03, 3.12201690e-03, 2.99198651e-03, 2.86841136e-03, 2.75107210e-03, 2.63977732e-03, 2.53435834e-03, 2.43422720e-03, 2.33888445e-03, 2.24809355e-03, 2.16162707e-03, 2.07926675e-03, 2.00080348e-03, 1.92603727e-03, 1.85477728e-03, 1.78684183e-03, 1.72205836e-03, 1.66026346e-03, 1.60130288e-03, 1.54503150e-03, 1.49131333e-03, 1.44002155e-03, 1.39103847e-03, 1.34425554e-03, 1.29957336e-03, 1.25690166e-03, 1.21615934e-03, 1.17727441e-03, 1.14018206e-03, 1.10474895e-03, 1.07086761e-03, 1.03846757e-03, 1.00748078e-03, 9.77841590e-04, 9.49486748e-04, 9.22355412e-04, 8.96389144e-04, 8.71531909e-04, 8.47730080e-04, 8.24932432e-04, 8.03090145e-04, 7.82156805e-04, 7.62088401e-04, 7.42843329e-04, 7.24382387e-04, 7.06668779e-04, 6.89668114e-04, 6.73348406e-04, 6.57680073e-04, 6.42635937e-04, 6.28191226e-04, 6.14323572e-04, 6.01013012e-04, 5.88241987e-04, 5.75995345e-04, 5.64260335e-04, 5.53026615e-04, 5.42286243e-04, 5.32032925e-04, 5.22219203e-04, 5.12807689e-04, 5.03783491e-04, 4.95132262e-04, 4.86840205e-04, 4.78894068e-04, 4.71281147e-04, 4.63989284e-04, 4.57006868e-04, 4.50322836e-04, 4.43926672e-04, 4.37808406e-04, 4.31958616e-04, 4.26368424e-04, 4.21029504e-04, 4.15934073e-04, 4.11074897e-04, 4.06445288e-04]])
array([0. , 0.00273973, 0.00547945, 0.00821918, 0.0109589 , 0.01369863, 0.01643836, 0.01917808, 0.02191781, 0.02465753, 0.02739726, 0.03013699, 0.03287671, 0.03561644, 0.03835616, 0.04109589, 0.04383562, 0.04657534, 0.04931507, 0.05205479, 0.05479452, 0.05753425, 0.06027397, 0.0630137 , 0.06575342, 0.06849315, 0.07123288, 0.0739726 , 0.07671233, 0.07945205, 0.08219178, 0.08493151, 0.08767123, 0.09041096, 0.09315068, 0.09589041, 0.09863014, 0.10136986, 0.10410959, 0.10684932, 0.10958904, 0.11232877, 0.11506849, 0.11780822, 0.12054795, 0.12328767, 0.1260274 , 0.12876712, 0.13150685, 0.13424658, 0.1369863 , 0.13972603, 0.14246575, 0.14520548, 0.14794521, 0.15068493, 0.15342466, 0.15616438, 0.15890411, 0.16164384, 0.16438356, 0.16712329, 0.16986301, 0.17260274, 0.17534247, 0.17808219, 0.18082192, 0.18356164, 0.18630137, 0.1890411 , 0.19178082, 0.19452055, 0.19726027, 0.2 , 0.20273973, 0.20547945, 0.20821918, 0.2109589 , 0.21369863, 0.21643836, 0.21917808, 0.22191781, 0.22465753, 0.22739726, 0.23013699, 0.23287671, 0.23561644, 0.23835616, 0.24109589, 0.24383562, 0.24657534, 0.24931507, 0.25205479, 0.25479452, 0.25753425, 0.26027397, 0.2630137 , 0.26575342, 0.26849315, 0.27123288, 0.2739726 , 0.27671233, 0.27945205, 0.28219178, 0.28493151, 0.28767123, 0.29041096, 0.29315068, 0.29589041, 0.29863014, 0.30136986, 0.30410959, 0.30684932, 0.30958904, 0.31232877, 0.31506849, 0.31780822, 0.32054795, 0.32328767, 0.3260274 , 0.32876712, 0.33150685, 0.33424658, 0.3369863 , 0.33972603, 0.34246575, 0.34520548, 0.34794521, 0.35068493, 0.35342466, 0.35616438, 0.35890411, 0.36164384, 0.36438356, 0.36712329, 0.36986301, 0.37260274, 0.37534247, 0.37808219, 0.38082192, 0.38356164, 0.38630137, 0.3890411 , 0.39178082, 0.39452055, 0.39726027, 0.4 , 0.40273973, 0.40547945, 0.40821918, 0.4109589 , 0.41369863, 0.41643836, 0.41917808, 0.42191781, 0.42465753, 0.42739726, 0.43013699, 0.43287671, 0.43561644, 0.43835616, 0.44109589, 0.44383562, 0.44657534, 0.44931507, 0.45205479, 0.45479452, 0.45753425, 0.46027397, 0.4630137 , 0.46575342, 0.46849315, 0.47123288, 0.4739726 , 0.47671233, 0.47945205, 0.48219178, 0.48493151, 0.48767123, 0.49041096, 0.49315068, 0.49589041, 0.49863014, 0.50136986, 0.50410959, 0.50684932, 0.50958904, 0.51232877, 0.51506849, 0.51780822, 0.52054795, 0.52328767, 0.5260274 , 0.52876712, 0.53150685, 0.53424658, 0.5369863 , 0.53972603, 0.54246575, 0.54520548, 0.54794521, 0.55068493, 0.55342466, 0.55616438, 0.55890411, 0.56164384, 0.56438356, 0.56712329, 0.56986301, 0.57260274, 0.57534247, 0.57808219, 0.58082192, 0.58356164, 0.58630137, 0.5890411 , 0.59178082, 0.59452055, 0.59726027, 0.6 , 0.60273973, 0.60547945, 0.60821918, 0.6109589 , 0.61369863, 0.61643836, 0.61917808, 0.62191781, 0.62465753, 0.62739726, 0.63013699, 0.63287671, 0.63561644, 0.63835616, 0.64109589, 0.64383562, 0.64657534, 0.64931507, 0.65205479, 0.65479452, 0.65753425, 0.66027397, 0.6630137 , 0.66575342, 0.66849315, 0.67123288, 0.6739726 , 0.67671233, 0.67945205, 0.68219178, 0.68493151, 0.68767123, 0.69041096, 0.69315068, 0.69589041, 0.69863014, 0.70136986, 0.70410959, 0.70684932, 0.70958904, 0.71232877, 0.71506849, 0.71780822, 0.72054795, 0.72328767, 0.7260274 , 0.72876712, 0.73150685, 0.73424658, 0.7369863 , 0.73972603, 0.74246575, 0.74520548, 0.74794521, 0.75068493, 0.75342466, 0.75616438, 0.75890411, 0.76164384, 0.76438356, 0.76712329, 0.76986301, 0.77260274, 0.77534247, 0.77808219, 0.78082192, 0.78356164, 0.78630137, 0.7890411 , 0.79178082, 0.79452055, 0.79726027, 0.8 , 0.80273973, 0.80547945, 0.80821918, 0.8109589 , 0.81369863, 0.81643836, 0.81917808, 0.82191781, 0.82465753, 0.82739726, 0.83013699, 0.83287671, 0.83561644, 0.83835616, 0.84109589, 0.84383562, 0.84657534, 0.84931507, 0.85205479, 0.85479452, 0.85753425, 0.86027397, 0.8630137 , 0.86575342, 0.86849315, 0.87123288, 0.8739726 , 0.87671233, 0.87945205, 0.88219178, 0.88493151, 0.88767123, 0.89041096, 0.89315068, 0.89589041, 0.89863014, 0.90136986, 0.90410959, 0.90684932, 0.90958904, 0.91232877, 0.91506849, 0.91780822, 0.92054795, 0.92328767, 0.9260274 , 0.92876712, 0.93150685, 0.93424658, 0.9369863 , 0.93972603, 0.94246575, 0.94520548, 0.94794521, 0.95068493, 0.95342466, 0.95616438, 0.95890411, 0.96164384, 0.96438356, 0.96712329, 0.96986301, 0.97260274, 0.97534247, 0.97808219, 0.98082192, 0.98356164, 0.98630137, 0.9890411 , 0.99178082, 0.99452055, 0.99726027, 1. , 1.00273973, 1.00547945, 1.00821918, 1.0109589 , 1.01369863, 1.01643836, 1.01917808, 1.02191781, 1.02465753, 1.02739726, 1.03013699, 1.03287671, 1.03561644, 1.03835616, 1.04109589, 1.04383562, 1.04657534, 1.04931507, 1.05205479, 1.05479452, 1.05753425, 1.06027397, 1.0630137 , 1.06575342, 1.06849315, 1.07123288, 1.0739726 , 1.07671233, 1.07945205, 1.08219178, 1.08493151, 1.08767123, 1.09041096, 1.09315068, 1.09589041, 1.09863014, 1.10136986, 1.10410959, 1.10684932, 1.10958904, 1.11232877, 1.11506849, 1.11780822, 1.12054795, 1.12328767, 1.1260274 , 1.12876712, 1.13150685, 1.13424658, 1.1369863 , 1.13972603, 1.14246575, 1.14520548, 1.14794521, 1.15068493, 1.15342466, 1.15616438, 1.15890411, 1.16164384, 1.16438356, 1.16712329, 1.16986301, 1.17260274, 1.17534247, 1.17808219, 1.18082192, 1.18356164, 1.18630137, 1.1890411 , 1.19178082, 1.19452055, 1.19726027, 1.2 , 1.20273973, 1.20547945, 1.20821918, 1.2109589 , 1.21369863, 1.21643836, 1.21917808, 1.22191781, 1.22465753, 1.22739726, 1.23013699, 1.23287671, 1.23561644, 1.23835616, 1.24109589, 1.24383562, 1.24657534, 1.24931507, 1.25205479, 1.25479452, 1.25753425, 1.26027397, 1.2630137 , 1.26575342, 1.26849315, 1.27123288, 1.2739726 , 1.27671233, 1.27945205, 1.28219178, 1.28493151, 1.28767123, 1.29041096, 1.29315068, 1.29589041, 1.29863014, 1.30136986, 1.30410959, 1.30684932, 1.30958904, 1.31232877, 1.31506849, 1.31780822, 1.32054795, 1.32328767, 1.3260274 , 1.32876712, 1.33150685, 1.33424658, 1.3369863 , 1.33972603, 1.34246575, 1.34520548, 1.34794521, 1.35068493, 1.35342466, 1.35616438, 1.35890411, 1.36164384, 1.36438356, 1.36712329, 1.36986301, 1.37260274, 1.37534247, 1.37808219, 1.38082192, 1.38356164, 1.38630137, 1.3890411 , 1.39178082, 1.39452055, 1.39726027, 1.4 , 1.40273973, 1.40547945, 1.40821918, 1.4109589 , 1.41369863, 1.41643836, 1.41917808, 1.42191781, 1.42465753, 1.42739726, 1.43013699, 1.43287671, 1.43561644, 1.43835616, 1.44109589, 1.44383562, 1.44657534, 1.44931507, 1.45205479, 1.45479452, 1.45753425, 1.46027397, 1.4630137 , 1.46575342, 1.46849315, 1.47123288, 1.4739726 , 1.47671233, 1.47945205, 1.48219178, 1.48493151, 1.48767123, 1.49041096, 1.49315068, 1.49589041, 1.49863014, 1.50136986, 1.50410959, 1.50684932, 1.50958904, 1.51232877, 1.51506849, 1.51780822, 1.52054795, 1.52328767, 1.5260274 , 1.52876712, 1.53150685, 1.53424658, 1.5369863 , 1.53972603, 1.54246575, 1.54520548, 1.54794521, 1.55068493, 1.55342466, 1.55616438, 1.55890411, 1.56164384, 1.56438356, 1.56712329, 1.56986301, 1.57260274, 1.57534247, 1.57808219, 1.58082192, 1.58356164, 1.58630137, 1.5890411 , 1.59178082, 1.59452055, 1.59726027, 1.6 , 1.60273973, 1.60547945, 1.60821918, 1.6109589 , 1.61369863, 1.61643836, 1.61917808, 1.62191781, 1.62465753, 1.62739726, 1.63013699, 1.63287671, 1.63561644, 1.63835616, 1.64109589, 1.64383562, 1.64657534, 1.64931507, 1.65205479, 1.65479452, 1.65753425, 1.66027397, 1.6630137 , 1.66575342, 1.66849315, 1.67123288, 1.6739726 , 1.67671233, 1.67945205, 1.68219178, 1.68493151, 1.68767123, 1.69041096, 1.69315068, 1.69589041, 1.69863014, 1.70136986, 1.70410959, 1.70684932, 1.70958904, 1.71232877, 1.71506849, 1.71780822, 1.72054795, 1.72328767, 1.7260274 , 1.72876712, 1.73150685, 1.73424658, 1.7369863 , 1.73972603, 1.74246575, 1.74520548, 1.74794521, 1.75068493, 1.75342466, 1.75616438, 1.75890411, 1.76164384, 1.76438356, 1.76712329, 1.76986301, 1.77260274, 1.77534247, 1.77808219, 1.78082192, 1.78356164, 1.78630137, 1.7890411 , 1.79178082, 1.79452055, 1.79726027, 1.8 , 1.80273973, 1.80547945, 1.80821918, 1.8109589 , 1.81369863, 1.81643836, 1.81917808, 1.82191781, 1.82465753, 1.82739726, 1.83013699, 1.83287671, 1.83561644, 1.83835616, 1.84109589, 1.84383562, 1.84657534, 1.84931507, 1.85205479, 1.85479452, 1.85753425, 1.86027397, 1.8630137 , 1.86575342, 1.86849315, 1.87123288, 1.8739726 , 1.87671233, 1.87945205, 1.88219178, 1.88493151, 1.88767123, 1.89041096, 1.89315068, 1.89589041, 1.89863014, 1.90136986, 1.90410959, 1.90684932, 1.90958904, 1.91232877, 1.91506849, 1.91780822, 1.92054795, 1.92328767, 1.9260274 , 1.92876712, 1.93150685, 1.93424658, 1.9369863 , 1.93972603, 1.94246575, 1.94520548, 1.94794521, 1.95068493, 1.95342466, 1.95616438, 1.95890411, 1.96164384, 1.96438356, 1.96712329, 1.96986301, 1.97260274, 1.97534247, 1.97808219, 1.98082192, 1.98356164, 1.98630137, 1.9890411 , 1.99178082, 1.99452055, 1.99726027])
#R0 is a ndarray
dis='HKU1'
R0 = np.arange(2.4,1.1,-0.4)
ds = run_climSIRSpy(dis=dis, ii0=1/8e6, R0=R0, T=3*365)
ds = ds.assign_coords(grid=[f'{r:.1f}' for r in R0]).rename(grid='R0')
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(hue='R0')
[<matplotlib.lines.Line2D at 0x7f81fa6ec490>, <matplotlib.lines.Line2D at 0x7f81fa6ec6d0>, <matplotlib.lines.Line2D at 0x7f81fa6ec890>, <matplotlib.lines.Line2D at 0x7f81fa6eca50>]
# NYC q vs. idealized q for 'HKU1'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'HKU1'
T = 2*365
ii0 = 1e-5
# q is from ERA5 NYC location
cities = ['NYC', 'Johannesburg']
colors = ['k', 'k']
# city = 'NYC'
for city,c in zip(cities, colors):
latx, lonx = regions[city]
color = c
if city == 'NYC':
label = f'{city}({dis})'
ls = '-'
else:
label = f'{city}'
ls = '--'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color, ls=ls)
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color, ls=ls)
ds = run_climSIRS(R0=R0, T=T, ii0=ii0, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=label,
ls=ls
)
#q is idealized
from numpy import pi as Pi
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
labels = ['qpeakJul', 'qpeakOct', 'qpeakOct', 'qpeakApr']
for phi0,label in zip(phi0s, labels):
q = get_q(phi0=phi0)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds = run_climSIRS(R0=R0, T=T, ii0=ii0, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=label)
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
# NYC q vs. idealized q for 'HKU1'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'HKU1'
T = 2*365
ii0 = 1e-5
# q is from ERA5 NYC location
cities = ['NYC', 'Johannesburg']
colors = ['k', 'k']
# city = 'NYC'
for city,c in zip(cities, colors):
latx, lonx = regions[city]
color = c
if city == 'NYC':
label = f'{city}({dis})'
ls = '-'
else:
label = f'{city}'
ls = '--'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color, ls=ls)
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color, ls=ls)
ds = run_climSIRSpy(R0=R0, T=T, ii0=ii0, dis=dis, ode_kws=None)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=label,
ls=ls
)
#q is idealized
from numpy import pi as Pi
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
labels = ['qpeakJul', 'qpeakOct', 'qpeakOct', 'qpeakApr']
for phi0,label in zip(phi0s, labels):
q = get_q(phi0=phi0)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds = run_climSIRSpy(R0=R0, T=T, ii0=ii0, dis=dis, ode_kws=None)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=label)
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
[failed]: solve_ivp(method="RK45")
An exception has occurred, use %tb to see the full traceback.
SystemExit
# NYC q vs. idealized q for 'HKU1'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'HKU1'
T = 2*365
ii0 = 1e-5
# q is from ERA5 NYC location
cities = ['NYC', 'Johannesburg']
colors = ['k', 'k']
# city = 'NYC'
for city,c in zip(cities, colors):
latx, lonx = regions[city]
color = c
if city == 'NYC':
label = f'{city}({dis})'
ls = '-'
else:
label = f'{city}'
ls = '--'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color, ls=ls)
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color, ls=ls)
ds = run_climSIRSpy(R0=R0, T=T, ii0=ii0, dis=dis, ode_kws={'method': 'LSODA'})
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=label,
ls=ls
)
#q is idealized
from numpy import pi as Pi
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
labels = ['qpeakJul', 'qpeakOct', 'qpeakOct', 'qpeakApr']
for phi0,label in zip(phi0s, labels):
q = get_q(phi0=phi0)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds = run_climSIRSpy(R0=R0, T=T, ii0=ii0, dis=dis, ode_kws={'method': 'LSODA'})
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=label)
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
# NYC q vs. idealized q for 'HKU1'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'HKU1'
T = 2*365
ii0 = 1e-5
# q is from ERA5 NYC location
cities = ['NYC', 'Johannesburg']
colors = ['k', 'k']
# city = 'NYC'
for city,c in zip(cities, colors):
latx, lonx = regions[city]
color = c
if city == 'NYC':
label = f'{city}({dis})'
ls = '-'
else:
label = f'{city}'
ls = '--'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color, ls=ls)
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color, ls=ls)
ds = run_climSIRSpy(R0=R0, T=T, ii0=ii0, dis=dis, ode_kws={'method': 'DOP853'})
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=label,
ls=ls
)
#q is idealized
from numpy import pi as Pi
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
labels = ['qpeakJul', 'qpeakOct', 'qpeakOct', 'qpeakApr']
for phi0,label in zip(phi0s, labels):
q = get_q(phi0=phi0)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds = run_climSIRSpy(R0=R0, T=T, ii0=ii0, dis=dis, ode_kws={'method': 'DOP853'})
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=label)
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
# NYC q vs. idealized q for 'HKU1'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'HKU1'
T = 2*365
# q is from ERA5 NYC location
cities = ['NYC', 'Johannesburg']
colors = ['k', 'k']
# city = 'NYC'
for city,c in zip(cities, colors):
latx, lonx = regions[city]
color = c
if city == 'NYC':
label = f'{city}({dis})'
ls = '-'
else:
label = f'{city}'
ls = '--'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color, ls=ls)
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color, ls=ls)
ds = run_climSIRSpy(R0=R0, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=label,
ls=ls
)
#q is idealized
from numpy import pi as Pi
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
labels = ['qpeakJul', 'qpeakOct', 'qpeakOct', 'qpeakApr']
for phi0,label in zip(phi0s, labels):
q = get_q(phi0=phi0)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds = run_climSIRSpy(R0=R0, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=label)
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
# NYC q vs. idealized q for 'HKU1'
fig, axes = plt.subplots(3, 1, figsize=(6,6))
dis = 'HKU1'
T = 1*365
# q is from ERA5 NYC location
cities = ['NYC', 'Johannesburg']
colors = ['k', 'k']
# city = 'NYC'
for city,c in zip(cities, colors):
latx, lonx = regions[city]
color = c
if city == 'NYC':
label = f'{city}({dis})'
ls = '-'
else:
label = f'{city}'
ls = '--'
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
q.plot(ax=axes[0], color=color, ls=ls)
R0 = q2R0(q, **climdepens[dis])
R0.plot(ax=axes[1], color=color, ls=ls)
ds = run_climSIRSpy(R0=R0, T=T, ii0=1/8e6, dis=dis)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
color=color,
label=label,
ls=ls
)
#q is idealized
from numpy import pi as Pi
qpeakmons = ['Jul', 'Oct', 'Jan', 'Apr']
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
phi0s = xr.DataArray(phi0s, dims='qpeakmon', coords=[qpeakmons])
qs = get_q(phi0=phi0s)
R0s = q2R0(qs, **climdepens[dis])
ds = run_climSIRSpy(R0=R0s, T=T, ii0=1/8e6, dis=dis)
for mon in qpeakmons:
q = qs.sel(qpeakmon=mon)
q.plot(ax=axes[0], lw=1)
axes[0].set_ylabel('q[kg/kg] annual cycle')
R0 = R0s.sel(qpeakmon=mon)
R0.plot(ax=axes[1], lw=1)
axes[1].set_ylabel('R0 annual cycle')
ds.sel(qpeakmon=mon).ii.assign_coords(t=ds.year).rename(t='year').plot(ax=axes[2],
lw=1,
label=f'qpeak{mon}')
axes[2].set_title('')
for i in range(2):
axes[i].set_title('')
axes[2].legend(loc='upper right')
plt.tight_layout()
city = 'NYC'
latx, lonx = regions[city]
qyears = range(2010, 2020)
q = [get_q('era5_single_year', qyear=qyear)
.sel(latitude=latx, longitude=lonx, method='nearest')
.isel(time=slice(0, 365))
.pipe(lambda x: x.assign_coords(time=x.time.dt.dayofyear))
.load()
for qyear in qyears]
q = xr.concat(q, dim=pd.Index(qyears, name='qyear'))
qclim = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest').isel(time=slice(0, 365))
qclim
# q.rename(time='day_of_year').plot(hue='qyear')
# qclim.rename(time='day_of_year').plot(color='k', lw=2)
array([0.00298383, 0.00285021, 0.00279633, 0.0026232 , 0.00249139, 0.00244834, 0.00247756, 0.00253146, 0.00278112, 0.00289252, 0.00296091, 0.00301259, 0.0030684 , 0.0031 , 0.00310943, 0.00293562, 0.00287054, 0.00285219, 0.00282139, 0.00278855, 0.00281523, 0.00276455, 0.00271965, 0.00272953, 0.00274707, 0.00275541, 0.00274354, 0.00261775, 0.00258906, 0.00261268, 0.00255315, 0.00256932, 0.00262775, 0.00262192, 0.00269351, 0.00276731, 0.00269903, 0.00266943, 0.00266811, 0.00262026, 0.00257257, 0.00253425, 0.00253323, 0.00267819, 0.00269291, 0.0026987 , 0.00272116, 0.0028233 , 0.00296684, 0.0029939 , 0.00302629, 0.0032451 , 0.00343834, 0.00343027, 0.00338666, 0.00333835, 0.00337992, 0.00336824, 0.00318758, 0.00299252, 0.00298523, 0.00297473, 0.00293393, 0.00287977, 0.002873 , 0.00301059, 0.00319288, 0.00336579, 0.00346135, 0.00361224, 0.00371678, 0.00374277, 0.00369648, 0.0035979 , 0.00354492, 0.0035714 , 0.00359213, 0.00363137, 0.00363051, 0.00362291, 0.00366346, 0.0037292 , 0.00370551, 0.00363743, 0.00367925, 0.00382889, 0.00393062, 0.00402769, 0.00411019, 0.00430024, 0.0044209 , 0.00437195, 0.00430771, 0.00438187, 0.00450932, 0.00452559, 0.00448783, 0.00456437, 0.00472051, 0.00492918, 0.00510272, 0.00510014, 0.00519037, 0.00538268, 0.00539052, 0.00544057, 0.00549308, 0.00542517, 0.00550712, 0.00559975, 0.00564346, 0.00573824, 0.00586848, 0.00597063, 0.00609938, 0.00607843, 0.00598045, 0.00598353, 0.0061977 , 0.0063144 , 0.00644392, 0.0065402 , 0.00676817, 0.00701586, 0.00721704, 0.00719994, 0.00726655, 0.00728235, 0.00731255, 0.00719592, 0.00721992, 0.00736933, 0.00760355, 0.00773339, 0.00781016, 0.00800058, 0.00832558, 0.00844975, 0.00849005, 0.00859783, 0.00874655, 0.00892145, 0.00918967, 0.00948166, 0.00989131, 0.01025824, 0.0105838 , 0.01090292, 0.01125845, 0.01130643, 0.01119524, 0.0109133 , 0.01077728, 0.01060782, 0.01023766, 0.0099617 , 0.00990987, 0.01001441, 0.01031724, 0.01036136, 0.01056542, 0.01078143, 0.01072756, 0.01078174, 0.01098623, 0.01118382, 0.01136664, 0.01131971, 0.01148064, 0.01180747, 0.0121467 , 0.01225646, 0.0122347 , 0.01225388, 0.01229249, 0.01234406, 0.01246966, 0.01237108, 0.01235381, 0.01254093, 0.01275897, 0.01295836, 0.01305358, 0.01329406, 0.01356693, 0.01382581, 0.01387897, 0.01385755, 0.01391336, 0.01402459, 0.0139499 , 0.01394221, 0.01398067, 0.0140339 , 0.01416924, 0.01428529, 0.0144612 , 0.01463841, 0.01466296, 0.01458733, 0.01464051, 0.014631 , 0.01444313, 0.01413336, 0.01390837, 0.01391606, 0.01392933, 0.01370429, 0.01351061, 0.01365661, 0.01382541, 0.01386655, 0.01384586, 0.01374391, 0.01378906, 0.01389483, 0.01377601, 0.01371613, 0.01363686, 0.01353133, 0.01360953, 0.01373505, 0.01366582, 0.01365621, 0.01366529, 0.01378994, 0.01389873, 0.01385606, 0.0137314 , 0.01379114, 0.01394298, 0.01374797, 0.01329587, 0.01297569, 0.01270335, 0.01260903, 0.01251966, 0.01223417, 0.01218839, 0.01241615, 0.01254056, 0.01277539, 0.01291791, 0.0129063 , 0.01292148, 0.01296604, 0.01283056, 0.01270987, 0.0124273 , 0.01219967, 0.01212194, 0.01212507, 0.01196113, 0.01182092, 0.01160805, 0.01140808, 0.01107915, 0.01073387, 0.01048678, 0.01042214, 0.01041515, 0.01047954, 0.01048504, 0.01058835, 0.01063359, 0.01055985, 0.01053594, 0.0106807 , 0.01071155, 0.01072162, 0.01059966, 0.0104521 , 0.01024613, 0.01010307, 0.00973915, 0.00940753, 0.00936124, 0.00927971, 0.00927077, 0.00924642, 0.0091296 , 0.00893104, 0.00871158, 0.00847014, 0.00829788, 0.00810115, 0.0078265 , 0.00747684, 0.00730121, 0.00731439, 0.00711373, 0.00700222, 0.00682969, 0.00679187, 0.00685345, 0.00680081, 0.00670139, 0.0066748 , 0.00667486, 0.00657382, 0.00658131, 0.00648684, 0.00647207, 0.00634179, 0.00610777, 0.00590697, 0.00596324, 0.00582966, 0.00555605, 0.00531352, 0.00519838, 0.00509774, 0.00495738, 0.00465495, 0.00443468, 0.00442723, 0.00449963, 0.00444945, 0.00443073, 0.00439212, 0.00442283, 0.00439132, 0.00440861, 0.00424705, 0.00412554, 0.00409017, 0.00407872, 0.00412035, 0.00416685, 0.00411738, 0.00415 , 0.004297 , 0.00437403, 0.00437578, 0.00427223, 0.00430755, 0.00444595, 0.00440173, 0.00413143, 0.00401931, 0.00397831, 0.00392137, 0.00382088, 0.00364447, 0.00367903, 0.00381641, 0.00373187, 0.00365768, 0.00361897, 0.00356612, 0.00345909, 0.0034393 , 0.00356116, 0.00377187, 0.00386057, 0.00393001, 0.00393223, 0.00402173, 0.0040508 , 0.0038275 , 0.00363359, 0.00349167, 0.00330802, 0.0032594 , 0.00313164], dtype=float32)
array(40.75, dtype=float32)
array(286., dtype=float32)
array([ 1, 2, 3, ..., 363, 364, 365])
q.rename(time='day_of_year').plot(hue='qyear', lw=1)
qclim.rename(time='day_of_year').plot(color='k', lw=2)
[<matplotlib.lines.Line2D at 0x7f81f3d04b50>]
dis = 'HKU1'
R0 = q2R0(q, **climdepens[dis])
R0.rename(time='day_of_year').plot(hue='qyear', lw=1)
R0clim = q2R0(qclim, **climdepens[dis])
R0clim.rename(time='day_of_year').plot(color='k', lw=2)
[<matplotlib.lines.Line2D at 0x7f81cc33a7d0>]
dis = 'HKU1'
T = 365
ii0 = 1/8e6
ds = run_climSIRSpy(R0=R0, T=T, ii0=ii0, dis=dis)
ds_clim = run_climSIRSpy(R0=R0clim, T=T, ii0=ii0, dis=dis)
tspan = slice(0,150)
ds.ii.sel(t=tspan).plot(hue='qyear', lw=1)
ds.ii.sel(t=tspan).mean('qyear').plot(color='k', ls='--', label='ens_mean')
ds_clim.ii.sel(t=tspan).plot(color='k', lw=2, label='2010-2019_clim_q')
plt.legend()
plt.title(f'{city} {dis}')
Text(0.5, 1.0, 'NYC HKU1')
ds.ii.max('t').pipe(lambda x: x.sortby(x)).to_dataframe().rename(columns={'ii':'I/N peak'})
longitude | latitude | I/N peak | |
---|---|---|---|
qyear | |||
2012 | 286.0 | 40.75 | 0.114647 |
2016 | 286.0 | 40.75 | 0.120275 |
2011 | 286.0 | 40.75 | 0.127920 |
2010 | 286.0 | 40.75 | 0.130802 |
2019 | 286.0 | 40.75 | 0.142942 |
2013 | 286.0 | 40.75 | 0.148758 |
2015 | 286.0 | 40.75 | 0.152011 |
2018 | 286.0 | 40.75 | 0.152466 |
2017 | 286.0 | 40.75 | 0.156920 |
2014 | 286.0 | 40.75 | 0.162966 |
ds.ii.argmax('t').pipe(lambda x: x.sortby(x)+1).to_dataframe().rename(columns={'ii':'I/N peak day'})
longitude | latitude | I/N peak day | |
---|---|---|---|
qyear | |||
2015 | 286.0 | 40.75 | 74 |
2010 | 286.0 | 40.75 | 78 |
2014 | 286.0 | 40.75 | 78 |
2011 | 286.0 | 40.75 | 80 |
2019 | 286.0 | 40.75 | 80 |
2013 | 286.0 | 40.75 | 83 |
2017 | 286.0 | 40.75 | 83 |
2018 | 286.0 | 40.75 | 84 |
2016 | 286.0 | 40.75 | 88 |
2012 | 286.0 | 40.75 | 89 |
city = 'Wuhan'
latx, lonx = regions[city]
qyears = range(2010, 2020)
q = [get_q('era5_single_year', qyear=qyear)
.sel(latitude=latx, longitude=lonx, method='nearest')
.isel(time=slice(0, 365))
.pipe(lambda x: x.assign_coords(time=x.time.dt.dayofyear))
.load()
for qyear in qyears]
q = xr.concat(q, dim=pd.Index(qyears, name='qyear'))
qclim = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest').isel(time=slice(0, 365))
qclim
# q.rename(time='day_of_year').plot(hue='qyear')
# qclim.rename(time='day_of_year').plot(color='k', lw=2)
array([0.00384996, 0.0039108 , 0.00396541, 0.00396307, 0.00395205, 0.00391889, 0.00387438, 0.00383735, 0.00381875, 0.00382306, 0.00388626, 0.00391503, 0.00393172, 0.00394593, 0.00401043, 0.00410113, 0.0041013 , 0.00401649, 0.00395115, 0.00386708, 0.00382464, 0.0037199 , 0.00365428, 0.00369913, 0.00384173, 0.00396997, 0.00412374, 0.00422879, 0.00435451, 0.00442368, 0.00440288, 0.00434718, 0.00433435, 0.00431745, 0.00425412, 0.0041962 , 0.00411805, 0.00407051, 0.00406043, 0.00404898, 0.00401627, 0.00405741, 0.00414838, 0.00428756, 0.00441097, 0.00445234, 0.00450543, 0.00455471, 0.00463519, 0.00471951, 0.00484009, 0.00505468, 0.00529486, 0.00549488, 0.00568399, 0.00579704, 0.00573618, 0.00564946, 0.00556006, 0.00553768, 0.00554225, 0.0054817 , 0.00546671, 0.00564948, 0.00572215, 0.00566538, 0.00565144, 0.00567487, 0.005853 , 0.00598109, 0.00603175, 0.00619931, 0.00654893, 0.00683868, 0.00711363, 0.00713937, 0.00717249, 0.00723806, 0.00728204, 0.00715414, 0.00694373, 0.00676188, 0.00689906, 0.00715784, 0.00741637, 0.00765254, 0.00798636, 0.00835469, 0.00857449, 0.00871476, 0.00869505, 0.00866334, 0.00858696, 0.00845183, 0.00847593, 0.00848362, 0.00848194, 0.00864285, 0.00870671, 0.00877133, 0.00895137, 0.00909177, 0.0093564 , 0.00963205, 0.00981403, 0.00994658, 0.01020619, 0.01034047, 0.01031488, 0.01028643, 0.01034132, 0.01041152, 0.01048678, 0.01044185, 0.01050339, 0.01073979, 0.01105092, 0.01112098, 0.01112334, 0.01129035, 0.01151918, 0.01183238, 0.01194634, 0.01201998, 0.0122097 , 0.01240856, 0.01252815, 0.01257031, 0.01253231, 0.01250316, 0.01261722, 0.01260217, 0.01264037, 0.01283118, 0.01304882, 0.0132553 , 0.01347077, 0.01340064, 0.01335973, 0.01333084, 0.01342168, 0.01355568, 0.01359165, 0.01356292, 0.01366283, 0.01375375, 0.01394483, 0.0140325 , 0.01418591, 0.01430564, 0.01440433, 0.0144713 , 0.01476181, 0.01499403, 0.01512287, 0.01530661, 0.0155499 , 0.01588971, 0.01607925, 0.01615192, 0.01613336, 0.01614031, 0.0161065 , 0.01609515, 0.01615035, 0.01644783, 0.01683641, 0.01725201, 0.01751891, 0.01776231, 0.01805865, 0.01829231, 0.0182891 , 0.01816111, 0.01811236, 0.01826091, 0.01838889, 0.01847037, 0.0185464 , 0.01876002, 0.01900109, 0.01920494, 0.01924849, 0.01919977, 0.01912993, 0.01915605, 0.01917076, 0.01920425, 0.01926471, 0.01932807, 0.01944965, 0.01956671, 0.01959944, 0.01960965, 0.01966114, 0.01966151, 0.01971671, 0.01978462, 0.01994552, 0.02017635, 0.02041342, 0.02054929, 0.02067195, 0.0208062 , 0.02090543, 0.02088418, 0.02081405, 0.02071447, 0.02066008, 0.02058296, 0.02050532, 0.02037441, 0.02029664, 0.02029199, 0.02036418, 0.02031861, 0.02023637, 0.02017793, 0.0201592 , 0.02007518, 0.01994652, 0.01980468, 0.01978154, 0.019794 , 0.0197068 , 0.01968314, 0.01970389, 0.01963492, 0.01957898, 0.01951839, 0.01936146, 0.0192409 , 0.0189236 , 0.01865689, 0.01847629, 0.01827631, 0.01801163, 0.01778408, 0.01743499, 0.01724254, 0.01709413, 0.01696677, 0.01669925, 0.01641185, 0.01619044, 0.01611168, 0.01601595, 0.0157966 , 0.01565691, 0.01556407, 0.0155923 , 0.01563768, 0.01564743, 0.01565 , 0.01565729, 0.0155642 , 0.0154402 , 0.01523413, 0.0150273 , 0.01475264, 0.01438931, 0.01399675, 0.01363965, 0.01338767, 0.01322121, 0.01312092, 0.01314725, 0.01320297, 0.01303107, 0.01287117, 0.01269304, 0.01242866, 0.0119828 , 0.01154264, 0.01124177, 0.01123203, 0.01124135, 0.0113008 , 0.0113511 , 0.01139181, 0.01136164, 0.01119908, 0.0110256 , 0.0107394 , 0.010419 , 0.01018723, 0.01001457, 0.00984796, 0.00980664, 0.00985171, 0.00994064, 0.01007627, 0.0100907 , 0.0100717 , 0.01000659, 0.00974984, 0.009393 , 0.00911422, 0.00875764, 0.00844768, 0.00824416, 0.00810408, 0.0080731 , 0.00809514, 0.00806193, 0.00806805, 0.00810057, 0.008039 , 0.00797968, 0.00793945, 0.0078195 , 0.0076629 , 0.00750322, 0.00735444, 0.0073238 , 0.00736559, 0.00741939, 0.00744461, 0.00732479, 0.00726426, 0.00726942, 0.00724636, 0.00709801, 0.00685384, 0.00658375, 0.00648584, 0.00638247, 0.00619096, 0.00603817, 0.00593836, 0.0058708 , 0.00586869, 0.00583336, 0.00571238, 0.00558259, 0.00540299, 0.00520421, 0.00502213, 0.00487062, 0.00472002, 0.00461028, 0.0044898 , 0.00441945, 0.00440583, 0.00444166, 0.00437731, 0.00428358, 0.00421722, 0.0042081 , 0.00418991, 0.00420388, 0.00421938, 0.00429102, 0.0043707 , 0.00439542, 0.00440566, 0.00434589, 0.00424379, 0.00414334, 0.00407297, 0.00399193, 0.00388142, 0.00374956, 0.00378234, 0.00381002], dtype=float32)
array(30.5, dtype=float32)
array(114.25, dtype=float32)
array([ 1, 2, 3, ..., 363, 364, 365])
q.rename(time='day_of_year').plot(hue='qyear', lw=1)
qclim.rename(time='day_of_year').plot(color='k', lw=2)
[<matplotlib.lines.Line2D at 0x7f81ec11ef50>]
dis = 'HKU1'
R0 = q2R0(q, **climdepens[dis])
R0.rename(time='day_of_year').plot(hue='qyear', lw=1)
R0clim = q2R0(qclim, **climdepens[dis])
R0clim.rename(time='day_of_year').plot(color='k', lw=2)
[<matplotlib.lines.Line2D at 0x7f81cc1b7610>]
dis = 'HKU1'
T = 365
ii0 = 1/8e6
ds = run_climSIRSpy(R0=R0, T=T, ii0=ii0, dis=dis)
ds_clim = run_climSIRSpy(R0=R0clim, T=T, ii0=ii0, dis=dis)
tspan = slice(0,365)
ds.ii.sel(t=tspan).plot(hue='qyear', lw=1)
ds.ii.sel(t=tspan).mean('qyear').plot(color='k', ls='--', label='ens_mean')
ds_clim.ii.sel(t=tspan).plot(color='k', lw=2, label='2010-2019_clim_q')
plt.legend()
plt.title(f'{city} {dis}')
Text(0.5, 1.0, 'Wuhan HKU1')
ds.ii.max('t').pipe(lambda x: x.sortby(x)).to_dataframe().rename(columns={'ii':'I/N peak'})
longitude | latitude | I/N peak | |
---|---|---|---|
qyear | |||
2014 | 114.25 | 30.5 | 0.073773 |
2016 | 114.25 | 30.5 | 0.074505 |
2017 | 114.25 | 30.5 | 0.077028 |
2019 | 114.25 | 30.5 | 0.077278 |
2018 | 114.25 | 30.5 | 0.080127 |
2013 | 114.25 | 30.5 | 0.086065 |
2015 | 114.25 | 30.5 | 0.086778 |
2010 | 114.25 | 30.5 | 0.090946 |
2012 | 114.25 | 30.5 | 0.093187 |
2011 | 114.25 | 30.5 | 0.110028 |
ds.ii.argmax('t').pipe(lambda x: x.sortby(x)+1).to_dataframe().rename(columns={'ii':'I/N peak day'})
longitude | latitude | I/N peak day | |
---|---|---|---|
qyear | |||
2011 | 114.25 | 30.5 | 90 |
2012 | 114.25 | 30.5 | 95 |
2018 | 114.25 | 30.5 | 101 |
2013 | 114.25 | 30.5 | 103 |
2014 | 114.25 | 30.5 | 104 |
2016 | 114.25 | 30.5 | 104 |
2019 | 114.25 | 30.5 | 104 |
2017 | 114.25 | 30.5 | 105 |
2010 | 114.25 | 30.5 | 106 |
2015 | 114.25 | 30.5 | 106 |
# idealized q for 'HKU1'
dis = 'HKU1'
T = 2*365
#q is idealized
from numpy import pi as Pi
qpeakmons = ['Jul', 'Oct', 'Jan', 'Apr']
phi0s = [-Pi, -Pi*3/2, 0, -Pi/2,]
phi0s = xr.DataArray(phi0s, dims='qpeakmon', coords=[qpeakmons])
qmin = np.arange(0, 0.023, 0.002)
qmin = xr.DataArray(qmin, dims='qmin', coords=[qmin])
qmax = np.arange(0, 0.023, 0.002)
qmax = xr.DataArray(qmax, dims='qmax', coords=[qmax])
qs = get_q(qmin=qmin, qmax=qmax, phi0=phi0s)
R0s = q2R0(qs, **climdepens[dis])
ds = run_climSIRSpy(R0=R0s, T=T, ii0=1/8e6, dis=dis)
ds.ii.max('t') \
.where(lambda x: x.qmax>=qmin).transpose() \
.assign_attrs(long_name='I/N peak') \
.plot.contourf(col='qpeakmon', col_wrap=2, cmap='plasma', levels=10)
<xarray.plot.facetgrid.FacetGrid at 0x7fb57de725d0>
# qpeamon mean and anomaly
plt.figure()
ds.ii.max('t') \
.where(lambda x: x.qmax>=qmin).transpose() \
.mean('qpeakmon') \
.assign_attrs(long_name='I/N peak mean over qpeakmon') \
.plot.contourf(cmap='plasma', levels=21)
plt.tight_layout()
plt.figure()
ds.ii.max('t') \
.where(lambda x: x.qmax>=qmin).transpose() \
.pipe(lambda x: x - x.mean('qpeakmon')) \
.assign_attrs(long_name='I/N peak anomaly') \
.plot.contourf(col='qpeakmon', col_wrap=2, levels=21)
<xarray.plot.facetgrid.FacetGrid at 0x7fb57db1b510>
<Figure size 819.2x460.8 with 0 Axes>
I/N peak day of year:
ds.ii.sel(t=slice(0, 365)).argmax('t').pipe(lambda x: x+1) \
.where(lambda x: x.qmax>=qmin).transpose() \
.assign_attrs(long_name='I/N peak day of year') \
.plot.contourf(col='qpeakmon', col_wrap=2, cmap='plasma', levels=11)
<xarray.plot.facetgrid.FacetGrid at 0x7fb57d4174d0>
# qpeamon mean and anomaly
plt.figure()
ds.ii.sel(t=slice(0, 365)).argmax('t').pipe(lambda x: x+1) \
.where(lambda x: x.qmax>=qmin).transpose() \
.mean('qpeakmon') \
.assign_attrs(long_name='I/N peak day of year: mean over qpeakmon') \
.plot.contourf(cmap='plasma', levels=11)
plt.tight_layout()
plt.figure()
ds.ii.sel(t=slice(0, 365)).argmax('t').pipe(lambda x: x+1) \
.where(lambda x: x.qmax>=qmin).transpose() \
.pipe(lambda x: x - x.mean('qpeakmon')) \
.assign_attrs(long_name='I/N peak day of year anomaly') \
.plot.contourf(col='qpeakmon', col_wrap=2, levels=13)
<xarray.plot.facetgrid.FacetGrid at 0x7fb57ce86990>
<Figure size 819.2x460.8 with 0 Axes>
q = get_q('era5')
R0 = q2R0(q, **climdepens[dis])
R0.mean('time').plot(cmap='plasma')
<matplotlib.collections.QuadMesh at 0x7f08d0f58250>
dis = 'HKU1'
T = 5
ds = run_climSIRSpy(R0=R0, T=T, ii0=1/8e6, dis=dis)
--------------------------------------------------------------------------- KeyboardInterrupt Traceback (most recent call last) /tiger/scratch/gpfs/GEOCLIM/wenchang/wython/wystart.py in <module> 1 dis = 'HKU1' 2 T = 5 ----> 3 ds = run_climSIRSpy(R0=R0, T=T, ii0=1/8e6, dis=dis) /tiger/scratch/gpfs/GEOCLIM/wenchang/wython/wystart.py in run_climSIRSpy(ii0, ss0, T, dt, L, D, R0, dis) 49 50 # scipy.integrate.solve_ivp backend, pure Python code ---> 51 sol = solve_ivp(model_climSIRSp,[0, T], y0, t_eval=t, args=(L, D, R0)) 52 ss = sol.y[0:y0.size//2, :] 53 ii = sol.y[y0.size//2:, :] ~/anaconda3/lib/python3.7/site-packages/scipy/integrate/_ivp/ivp.py in solve_ivp(fun, t_span, y0, method, t_eval, dense_output, events, vectorized, args, **options) 575 status = None 576 while status is None: --> 577 message = solver.step() 578 579 if solver.status == 'finished': ~/anaconda3/lib/python3.7/site-packages/scipy/integrate/_ivp/base.py in step(self) 180 else: 181 t = self.t --> 182 success, message = self._step_impl() 183 184 if not success: ~/anaconda3/lib/python3.7/site-packages/scipy/integrate/_ivp/rk.py in _step_impl(self) 144 145 y_new, f_new = rk_step(self.fun, t, y, self.f, h, self.A, --> 146 self.B, self.C, self.K) 147 scale = atol + np.maximum(np.abs(y), np.abs(y_new)) * rtol 148 error_norm = self._estimate_error_norm(self.K, h, scale) ~/anaconda3/lib/python3.7/site-packages/scipy/integrate/_ivp/rk.py in rk_step(fun, t, y, f, h, A, B, C, K) 63 for s, (a, c) in enumerate(zip(A[1:], C[1:]), start=1): 64 dy = np.dot(K[:s].T, a[:s]) * h ---> 65 K[s] = fun(t + c * h, y + dy) 66 67 y_new = y + h * np.dot(K[:-1].T, B) ~/anaconda3/lib/python3.7/site-packages/scipy/integrate/_ivp/base.py in fun(t, y) 137 def fun(t, y): 138 self.nfev += 1 --> 139 return self.fun_single(t, y) 140 141 self.fun = fun ~/anaconda3/lib/python3.7/site-packages/scipy/integrate/_ivp/base.py in fun_wrapped(t, y) 19 20 def fun_wrapped(t, y): ---> 21 return np.asarray(fun(t, y), dtype=dtype) 22 23 return fun_wrapped, y0 ~/anaconda3/lib/python3.7/site-packages/scipy/integrate/_ivp/ivp.py in <lambda>(t, x, fun) 513 # additional parameters. Pass in the original fun as a keyword 514 # argument to keep it in the scope of the lambda. --> 515 fun = lambda t, x, fun=fun: fun(t, x, *args) 516 jac = options.get('jac') 517 if callable(jac): /tiger/scratch/gpfs/GEOCLIM/wenchang/wython/wystart.py in model_climSIRSp(t, y, L, D, R0) 1 # t instead of y is the first argument required by scipy.integrate.solve_ivp 2 def model_climSIRSp(t, y, L, D, R0): ----> 3 return model_climSIRS(y=y, t=t, L=L, D=D, R0=R0) /tiger/scratch/gpfs/GEOCLIM/wenchang/wython/wystart.py in model_climSIRS(y, t, L, D, R0) 26 dydt = np.array([ 27 (1-ss-ii)/L - _R0*ii*ss/D, ---> 28 _R0*ii*ss/D - ii/D 29 ]).ravel() 30 ~/anaconda3/lib/python3.7/site-packages/xarray/core/common.py in _iter(self) 142 def _iter(self: Any) -> Iterator[Any]: 143 for n in range(len(self)): --> 144 yield self[n] 145 146 def __iter__(self: Any) -> Iterator[Any]: ~/anaconda3/lib/python3.7/site-packages/xarray/core/dataarray.py in __getitem__(self, key) 629 else: 630 # xarray-style array indexing --> 631 return self.isel(indexers=self._item_key_to_dict(key)) 632 633 def __setitem__(self, key: Any, value: Any) -> None: ~/anaconda3/lib/python3.7/site-packages/xarray/core/dataarray.py in isel(self, indexers, drop, **indexers_kwargs) 1018 } 1019 if coord_indexers: -> 1020 coord_value = coord_value.isel(coord_indexers) 1021 if drop and coord_value.ndim == 0: 1022 continue ~/anaconda3/lib/python3.7/site-packages/xarray/core/variable.py in isel(self, indexers, **indexers_kwargs) 1058 1059 key = tuple(indexers.get(dim, slice(None)) for dim in self.dims) -> 1060 return self[key] 1061 1062 def squeeze(self, dim=None): ~/anaconda3/lib/python3.7/site-packages/xarray/core/variable.py in __getitem__(self, key) 705 if new_order: 706 data = duck_array_ops.moveaxis(data, range(len(new_order)), new_order) --> 707 return self._finalize_indexing_result(dims, data) 708 709 def _finalize_indexing_result(self: VariableType, dims, data) -> VariableType: ~/anaconda3/lib/python3.7/site-packages/xarray/core/variable.py in _finalize_indexing_result(self, dims, data) 2132 if getattr(data, "ndim", 0) != 1: 2133 # returns Variable rather than IndexVariable if multi-dimensional -> 2134 return Variable(dims, data, self._attrs, self._encoding) 2135 else: 2136 return type(self)(dims, data, self._attrs, self._encoding, fastpath=True) ~/anaconda3/lib/python3.7/site-packages/xarray/core/variable.py in __init__(self, dims, data, attrs, encoding, fastpath) 301 unrecognized encoding items. 302 """ --> 303 self._data = as_compatible_data(data, fastpath=fastpath) 304 self._dims = self._parse_dimensions(dims) 305 self._attrs = None ~/anaconda3/lib/python3.7/site-packages/xarray/core/variable.py in as_compatible_data(data, fastpath) 224 if isinstance(data, np.ndarray): 225 if data.dtype.kind == "O": --> 226 data = _possibly_convert_objects(data) 227 elif data.dtype.kind == "M": 228 data = np.asarray(data, "datetime64[ns]") ~/anaconda3/lib/python3.7/site-packages/xarray/core/variable.py in _possibly_convert_objects(values) 160 datetime64 and timedelta64, according to the pandas convention. 161 """ --> 162 return np.asarray(pd.Series(values.ravel())).reshape(values.shape) 163 164 ~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath) 282 if not is_list_like(data): 283 data = [data] --> 284 index = ibase.default_index(len(data)) 285 elif is_list_like(data): 286 ~/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in default_index(n) 5388 from pandas.core.indexes.range import RangeIndex 5389 -> 5390 return RangeIndex(0, n, name=None) 5391 5392 ~/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/range.py in __new__(cls, start, stop, step, dtype, copy, name) 81 # Constructors 82 ---> 83 def __new__( 84 cls, start=None, stop=None, step=None, dtype=None, copy=False, name=None, 85 ): KeyboardInterrupt:
def model_climSIRSwy(ss, ii, t, L, D, R0):
'''SIRS model right hand side from Baker et al., 2020.
Input:
-------
ss: S/N
ii: I/N
t: time (units is 'day')
L: immunity length, 7x66.25(62.5) days for HKU1 (OC43)
D: infection period, 5 days
R0 = beta*D, ignored if q is not None
q: specific humidity, xr.DataArray, dims ('time', ...)
a: climate dependence parameter, -227.5(-32.5) for HKU1(OC43)
Return:
--------
tuple (dsdt, didt)
dsdt: S/N tendency
didt: I/N tendency
'''
if hasattr(R0, 'time'): # R0 is time-dependent
_R0 = R0_at_t(R0, t)
if _R0.ndim < 1:
_R0 = _R0.item()
else:
_R0 = R0
dsdt = (1-ss-ii)/L - _R0*ii*ss/D
didt = _R0*ii*ss/D - ii/D
return dsdt, didt
def rk4_climSIRSwy(ss, ii, t, dt, L, D, R0):
'''Step change from classic Runge–Kutta (RK4) method for SIRS model of Baker et al., 2020.
Input:
-------
ss: S/N
ii: I/N
t: time (units is 'day')
dt: time step
L: immunity length, 7x66.25(62.5) days for HKU1 (OC43)
D: infection period, 5 days
R0 = beta*D, ignored if q is not None
q: specific humidity, xr.DataArray, dims ('time', ...)
a: climate dependence parameter, -227.5(-32.5) for HKU1(OC43)
Return:
--------
tuple (dss, dii)
dss: S/N step increase
dii: I/N step increase
'''
model_climSIRS = model_climSIRSwy
k1s, k1i = model_climSIRS(ss=ss, ii=ii, t=t, L=L, D=D, R0=R0)
k2s, k2i = model_climSIRS(ss=ss+k1s*dt/2, ii=ii+k1i*dt/2, t=t+dt/2, L=L, D=D, R0=R0)
k3s, k3i = model_climSIRS(ss=ss+k2s*dt/2, ii=ii+k2i*dt/2, t=t+dt/2, L=L, D=D, R0=R0)
k4s, k4i = model_climSIRS(ss=ss+k3s*dt, ii=ii+k3i*dt, t=t+dt, L=L, D=D, R0=R0)
dss = dt*(k1s + 2*k2s + 2*k3s + k4s)/6
dii = dt*(k1i + 2*k2i + 2*k3i + k4i)/6
return dss, dii
# def run_climSIRS(ii0=1e-5, ss0=None, T=5*365, dt=1, L=None, D=5, R0=2, dis='HKU1'):
def run_climSIRSwy(ii0=1e-5, ss0=None, T=1*365, dt=1, L=None, D=5, R0=2, dis='HKU1'):
'''Integrate SIRS model from Baker et al., 2020.
Input:
-------
I0: initial I/N
T: time stop (start is 1; units is 'day')
dt: time step
L: immunity length, 7x66.25(62.5) days for HKU1 (OC43)
D: infection period, 5 days
R0 = beta*D, ignored if q is not None
q: specific humidity, xr.DataArray, dims ('time', ...)
a: climate dependence parameter, -227.5(-32.5) for HKU1(OC43)
Return:
--------
ds: solution for the xclimSIRS model.
'''
t_vec = np.arange(0, T, dt)
if L is None and dis is not None:
L = Ls[dis]
if hasattr(R0, 'time'): # R0 time-dependent
zeros = ii0*L*D*R0.isel(time=0, drop=True)*0 # broadcast array by R0.dims[1:]
else: # R0 time-independent
zeros = ii0*L*D*R0*0
# default initial S/N value determined by initial I/N value
if ss0 is None:
ss0 = 1 - ii0
# broadcast initial values by adding zeros
ii = ii0 + zeros
ss = ss0 + zeros
ss_vec = [ss,]
ii_vec = [ii,]
print('time step (units: day): ', end='')
for t in t_vec[1:]:
if np.mod(t, 365) == 0:
print(f'365x{t//365}', end='; ')
dss, dii = rk4_climSIRSwy(ss=ss, ii=ii, t=t, dt=dt, L=L, D=D, R0=R0)
ss = ss + dss
ii = ii + dii
ss_vec.append(ss)
ii_vec.append(ii)
print()
if isinstance(ss, xr.DataArray):
try:
da_ss = xr.concat(ss_vec, dim=pd.Index(t_vec, name='t'))
da_ii = xr.concat(ii_vec, dim=pd.Index(t_vec, name='t'))
except MemoryError:
ss_vec = [_ss.expand_dims('dum').chunk({'dum':1}).squeeze() for _ss in ss_vec]
ii_vec = [_ii.expand_dims('dum').chunk({'dum':1}).squeeze() for _ii in ii_vec]
da_ss = xr.concat(ss_vec, dim=pd.Index(t_vec, name='t'))
da_ii = xr.concat(ii_vec, dim=pd.Index(t_vec, name='t'))
else:
da_ss = xr.DataArray(ss_vec, dims=['t'], coords=[t_vec])
da_ii = xr.DataArray(ii_vec, dims=['t'], coords=[t_vec])
da_ss.attrs['long_name'] = 'S/N'
da_ii.attrs['long_name'] = 'I/N'
ds = xr.Dataset(dict(ss=da_ss, ii=da_ii, year=da_ss.t/365))
ds.t.attrs['units'] = 'day'
return ds
ds = run_climSIRSwy()
# ds.ii.sel(latitude=latx, longitude=lonx, method='nearest').plot()
ds.ii.assign_coords(t=ds.year).rename(t='year').plot()
# da.sel(si='I/N').plot()
time step (units: day):
[<matplotlib.lines.Line2D at 0x7f0898743650>]
dis = 'HKU1'
T = 15*365
ii0 = 1/8e6
q = get_q()
# q.plot()
R0 = q2R0(q, **climdepens[dis])
plt.figure()
# R0.plot()
# plt.figure()
ds = run_climSIRS(dis=dis, R0=R0, T=T, ii0=ii0)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot()
ds = run_climSIRSpy(dis=dis, R0=R0, T=T, ii0=ii0)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot()
ds = run_climSIRSwy(dis=dis, R0=R0, T=T, ii0=ii0)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot()
plt.legend(['odeint', 'solve_ivp', 'RK4'])
time step (units: day): 365x1; 365x2; 365x3; 365x4; 365x5; 365x6; 365x7; 365x8; 365x9; 365x10; 365x11; 365x12; 365x13; 365x14;
<matplotlib.legend.Legend at 0x7f08bf938ad0>
dis = 'HKU1'
city = 'NYC'
latx, lonx = regions[city]
q = get_q('era5').sel(latitude=latx, longitude=lonx, method='nearest')
# q.plot()
R0 = q2R0(q, **climdepens[dis])
plt.figure()
# R0.plot()
ds = run_climSIRSwy(dis=dis, R0=R0, T=10*365)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot()
ds = run_climSIRS(dis=dis, R0=R0, T=10*365)
ds.ii.assign_coords(t=ds.year).rename(t='year').plot()
time step (units: day): 365x1; 365x2; 365x3; 365x4; 365x5; 365x6; 365x7; 365x8; 365x9;
[<matplotlib.lines.Line2D at 0x7f08cd13f610>]
ifiles = '/tigress/wenchang/data/era5/analysis_wy/2m_specific_humidity/daily/clim/q2m.run7clim.2010-2019.nc'
ds = xr.open_dataset(ifiles)
q2m = ds.q2m.load().rename(dayofyear='time')
q2m
array([[[0.00047765, 0.00047765, 0.00047765, ..., 0.00047765, 0.00047765, 0.00047765], [0.00047971, 0.00047973, 0.00047975, ..., 0.0004796 , 0.00047963, 0.00047967], [0.00048245, 0.0004825 , 0.00048255, ..., 0.00048217, 0.00048224, 0.00048233], ..., [0.00049061, 0.0004906 , 0.00049058, ..., 0.00049068, 0.00049066, 0.00049064], [0.00048719, 0.00048718, 0.00048716, ..., 0.00048722, 0.00048721, 0.0004872 ], [0.00047952, 0.00047952, 0.00047952, ..., 0.00047952, 0.00047952, 0.00047952]], [[0.00048481, 0.00048481, 0.00048481, ..., 0.00048481, 0.00048481, 0.00048481], [0.00048764, 0.00048765, 0.00048766, ..., 0.00048757, 0.00048759, 0.00048761], [0.00049198, 0.00049201, 0.00049203, ..., 0.00049179, 0.00049184, 0.0004919 ], ..., [0.00048531, 0.0004853 , 0.00048528, ..., 0.00048539, 0.00048537, 0.00048534], [0.00048243, 0.00048242, 0.0004824 , ..., 0.00048246, 0.00048245, 0.00048244], [0.0004755 , 0.0004755 , 0.0004755 , ..., 0.0004755 , 0.0004755 , 0.0004755 ]], [[0.00047514, 0.00047514, 0.00047514, ..., 0.00047514, 0.00047514, 0.00047514], [0.00047989, 0.00047989, 0.00047989, ..., 0.00047985, 0.00047986, 0.00047987], [0.0004862 , 0.00048621, 0.00048621, ..., 0.00048606, 0.00048609, 0.00048613], ..., [0.00048336, 0.00048335, 0.00048333, ..., 0.00048343, 0.00048341, 0.00048339], [0.00048104, 0.00048103, 0.00048102, ..., 0.00048107, 0.00048106, 0.00048105], [0.00047475, 0.00047475, 0.00047475, ..., 0.00047475, 0.00047475, 0.00047475]], ..., [[0.00049022, 0.00049022, 0.00049022, ..., 0.00049022, 0.00049022, 0.00049022], [0.00049472, 0.00049475, 0.00049478, ..., 0.00049463, 0.00049466, 0.00049469], [0.00049776, 0.00049782, 0.00049787, ..., 0.00049751, 0.00049758, 0.00049765], ..., [0.00050307, 0.00050308, 0.00050307, ..., 0.00050312, 0.00050311, 0.00050309], [0.00049993, 0.00049993, 0.00049992, ..., 0.00049995, 0.00049994, 0.00049994], [0.00049273, 0.00049273, 0.00049273, ..., 0.00049273, 0.00049273, 0.00049273]], [[0.00048698, 0.00048698, 0.00048698, ..., 0.00048698, 0.00048698, 0.00048698], [0.00048996, 0.00048999, 0.00049002, ..., 0.00048986, 0.00048989, 0.00048993], [0.00049317, 0.00049324, 0.0004933 , ..., 0.00049291, 0.00049298, 0.00049307], ..., [0.0004991 , 0.0004991 , 0.00049909, ..., 0.00049915, 0.00049914, 0.00049912], [0.0004961 , 0.00049609, 0.00049608, ..., 0.00049612, 0.00049612, 0.00049611], [0.00048855, 0.00048855, 0.00048855, ..., 0.00048855, 0.00048855, 0.00048855]], [[0.00067848, 0.00067848, 0.00067848, ..., 0.00067848, 0.00067848, 0.00067848], [0.00070442, 0.00070443, 0.00070444, ..., 0.00070436, 0.00070438, 0.0007044 ], [0.00072884, 0.00072889, 0.00072891, ..., 0.00072859, 0.00072864, 0.00072871], ..., [0.00051024, 0.00051024, 0.00051024, ..., 0.00051025, 0.00051025, 0.00051025], [0.00050557, 0.00050557, 0.00050557, ..., 0.00050557, 0.00050557, 0.00050557], [0.00049649, 0.00049649, 0.00049649, ..., 0.00049649, 0.00049649, 0.00049649]]], dtype=float32)
array([ 90. , 89.75, 89.5 , ..., -89.5 , -89.75, -90. ], dtype=float32)
array([0.0000e+00, 2.5000e-01, 5.0000e-01, ..., 3.5925e+02, 3.5950e+02, 3.5975e+02], dtype=float32)
array([ 1, 2, 3, ..., 364, 365, 366])
# use ERA5 clim q
city = 'NYC'
latx, lonx = regions[city]
ds = run_climSIRSwy(L=66.25*7, D=5, I0=1e-5, T=10*365, dt=1,
q=q2m.sel(latitude=latx, longitude=lonx, method='nearest'),
R0=2)
# ds.ii.sel(latitude=latx, longitude=lonx, method='nearest').plot()
ds.ii.assign_coords(t=ds.year).rename(t='year').plot()
time step (units: day): 365x1; 365x2; 365x3; 365x4; 365x5; 365x6; 365x7; 365x8; 365x9; 365x10;
[<matplotlib.lines.Line2D at 0x7f58fb16e310>]
ds
array(40.75, dtype=float32)
array(286., dtype=float32)
array([ 0, 1, 2, ..., 3648, 3649, 3650])
array([0.99999 , 0.99998564, 0.99998031, ..., 0.65203405, 0.65074105, 0.64932186])
array([1.00000000e-05, 1.21562844e-05, 1.48065148e-05, ..., 7.80145116e-03, 8.22670180e-03, 8.69115770e-03])
array([0.00000000e+00, 2.73972603e-03, 5.47945205e-03, ..., 9.99452055e+00, 9.99726027e+00, 1.00000000e+01])
# sensitivity to time step
dss = []
for i,dt in enumerate([2, 1, 1/2]):
ds = run_climSIRSwy(I0=1e-5, T=5*365, dt=dt, L=66.25*7, D=5, R0=None,
q=q2m.sel(latitude=latx, longitude=lonx, method='nearest'), a=-227.5)
ds.ii.plot(color=f'C{i}', label=f'dt = {dt}')
dss.append(ds)
plt.legend()
time step (units: day): 365x1; 365x3; 365x5; time step (units: day): 365x1; 365x2; 365x3; 365x4; 365x5; time step (units: day): 365x1.0; 365x2.0; 365x3.0; 365x4.0; 365x5.0;
<matplotlib.legend.Legend at 0x7ff4f07db290>
# sensitivity to time step
for i,dt in enumerate([2, 1, 1/2]):
# ds = run_climSIRSwy(L=66.25*7, D=5, I0=1e-5, T=5*365, dt=dt,
# q=q2m.sel(latitude=latx, longitude=lonx, method='nearest'), R0=2)
ds = dss[i]
ds.ii.sel(t=slice(0,365)).plot(color=f'C{i}', label=f'dt = {dt}')
dss.append(ds)
plt.legend()
plt.title('RK4', loc='left')
Text(0.0, 1.0, 'RK4')
# sensitivity to time step
for i,dt in enumerate([2, 1, 1/2]):
# ds = run_climSIRSwy(L=66.25*7, D=5, I0=1e-5, T=5*365, dt=dt,
# q=q2m.sel(latitude=latx, longitude=lonx, method='nearest'), R0=2)
ds = dss[i]
ds.ii.sel(t=slice(63,69)).plot(color=f'C{i}', label=f'dt = {dt}')
dss.append(ds)
plt.legend()
plt.title('RK4', loc='left')
Text(0.0, 1.0, 'RK4')
ds.ii.sel(latitude=30.5928, longitude=114.3055, method='nearest').plot()
[<matplotlib.lines.Line2D at 0x7fe622b8ca58>]
ds.ii.sel(longitude=lonx, method='nearest').plot()
[<matplotlib.lines.Line2D at 0x7fe6231c9c88>]
ds.ii.plot()
da.sel(si='I/N').plot()
[<matplotlib.lines.Line2D at 0x7fe6232a4d30>]
ds = xr.open_dataset('/tigress/wenchang/analysis/climate_and_disease/climSIRS/HKU1.q2019.nc')
ds
<xarray.Dataset> Dimensions: (latitude: 721, longitude: 1440, t: 3650) Coordinates: * latitude (latitude) float32 90.0 89.75 89.5 89.25 ... -89.5 -89.75 -90.0 * longitude (longitude) float32 0.0 0.25 0.5 0.75 ... 359.25 359.5 359.75 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t, latitude, longitude) float32 ... ii (t, latitude, longitude) float32 ...
ds2018 = xr.open_dataset('/tigress/wenchang/analysis/climate_and_disease/climSIRS/HKU1.q2018.nc')
ds2018
<xarray.Dataset> Dimensions: (latitude: 721, longitude: 1440, t: 3650) Coordinates: * longitude (longitude) float32 0.0 0.25 0.5 0.75 ... 359.25 359.5 359.75 * latitude (latitude) float32 90.0 89.75 89.5 89.25 ... -89.5 -89.75 -90.0 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t, latitude, longitude) float32 ... ii (t, latitude, longitude) float32 ...
ds.ii.sel(latitude=latx, longitude=lonx, method='nearest').assign_coords(t=ds.t.values/365).rename(t='year').plot()
ds2018.ii.sel(latitude=latx, longitude=lonx, method='nearest').assign_coords(t=ds.t.values/365).rename(t='year').plot()
plt.xlim(0, 4)
(0, 4)
ds.sel(longitude=lonx, latitude=latx, method='nearest').to_dataframe().plot(x='ss', y='ii')
<matplotlib.axes._subplots.AxesSubplot at 0x7fe621b2b240>
da = ds.ii.stack(grid=['latitude', 'longitude'])
da
<xarray.DataArray 'ii' (t: 3650, grid: 1038240)> array([[9.9999997e-06, 9.9999997e-06, 9.9999997e-06, ..., 9.9999997e-06, 9.9999997e-06, 9.9999997e-06], [1.3074646e-05, 1.3074646e-05, 1.3074646e-05, ..., 1.3151950e-05, 1.3151950e-05, 1.3151950e-05], [1.7212880e-05, 1.7212880e-05, 1.7212880e-05, ..., 1.7302013e-05, 1.7302013e-05, 1.7302013e-05], ..., [7.2539071e-05, 7.2539071e-05, 7.2539071e-05, ..., 5.4199803e-03, 5.4199803e-03, 5.4199803e-03], [7.7993653e-05, 7.7993653e-05, 7.7993653e-05, ..., 5.3909491e-03, 5.3909491e-03, 5.3909491e-03], [8.4108389e-05, 8.4108389e-05, 8.4108389e-05, ..., 5.3762808e-03, 5.3762808e-03, 5.3762808e-03]], dtype=float32) Coordinates: * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * grid (grid) MultiIndex - latitude (grid) float64 90.0 90.0 90.0 90.0 ... -90.0 -90.0 -90.0 -90.0 - longitude (grid) float64 0.0 0.25 0.5 0.75 1.0 ... 359.0 359.2 359.5 359.8 Attributes: long_name: I/N
# NYC = (40.7128, -74.0060+360)
dis = 'OC43'
city = 'NYC'
latx, lonx = regions[city]
qyears = range(2010, 2020)
dss = []
for qyear in qyears:
ifile = f'/tigress/wenchang/analysis/climate_and_disease/climSIRS/{dis}.{qyear}q.nc'
ds = xr.open_dataset(ifile).sel(latitude=latx, longitude=lonx, method='nearest')
dss.append(ds)
ds = xr.concat(dss, dim=pd.Index(qyears, name='qyear'))
# ifile = f'/tigress/wenchang/analysis/climate_and_disease/climSIRS/{dis}.climq.nc'
# ds_clim = xr.open_dataset(ifile).sel(latitude=latx, longitude=lonx, method='nearest')
ifile = f'/tigress/wenchang/analysis/climate_and_disease/climSIRS/{dis}.run7climq.nc'
ds_run7clim = xr.open_dataset(ifile).sel(latitude=latx, longitude=lonx, method='nearest')
for qyear in qyears:
ds.ii.sel(qyear=qyear).plot(color='C0', alpha=0.5, lw=0.5)
ds.ii.mean('qyear').plot(color='C0')
# ds_clim.ii.plot(color='C1')
ds_run7clim.ii.plot(color='C1')
plt.xlim(0, 365*2)
plt.title(f'{city} {dis}')
Text(0.5, 1.0, 'NYC OC43')
# NYC = (40.7128, -74.0060+360)
dis = 'HKU1'
city = 'NYC'
latx, lonx = regions[city]
qyears = range(2010, 2020)
dss = []
for qyear in qyears:
ifile = f'/tigress/wenchang/analysis/climate_and_disease/climSIRS/{dis}.{qyear}q.nc'
ds = xr.open_dataset(ifile).sel(latitude=latx, longitude=lonx, method='nearest')
dss.append(ds)
ds = xr.concat(dss, dim=pd.Index(qyears, name='qyear'))
# ifile = f'/tigress/wenchang/analysis/climate_and_disease/climSIRS/{dis}.climq.nc'
# ds_clim = xr.open_dataset(ifile).sel(latitude=latx, longitude=lonx, method='nearest')
ifile = f'/tigress/wenchang/analysis/climate_and_disease/climSIRS/{dis}.run7climq.nc'
ds_run7clim = xr.open_dataset(ifile).sel(latitude=latx, longitude=lonx, method='nearest')
for qyear in qyears:
ds.ii.sel(qyear=qyear).plot(color='C0', alpha=0.5, lw=0.5)
ds.ii.mean('qyear').plot(color='C0')
# ds_clim.ii.plot(color='C1')
ds_run7clim.ii.plot(color='C1')
plt.xlim(0, 365*3)
plt.title(f'{city} {dis}')
Text(0.5, 1.0, 'NYC HKU1')
for qyear in qyears:
ds.ii.sel(qyear=qyear).plot(color='C0', alpha=0.5, lw=0.5)
ds.ii.mean('qyear').plot(color='C0')
# ds_clim.ii.plot(color='C1')
ds_run7clim.ii.plot(color='C1')
plt.xlim(0, 365)
plt.title(f'{city} {dis}')
Text(0.5, 1.0, 'NYC HKU1')
regions = dict(
London=(51.5074, 0.1278),
NYC=(40.7128, -74.0060+360),
LA=(34.0522, -118.2437+360),
Wuhan=(30.5928, 114.3055),
Delhi=(28.7041, 77.1025),
Maracaibo=(10.6427, -71.6125+360),
Kinshasa=(-4.4419, 15.2663),
Jakarta=(-6.2088, 106.8456),
Johannesburg=(-26.2041, 28.0473),
Buenos_Aires=(-34.6037, -58.3816+360),
Melbourne=(-37.8136, 144.9631)
)
def do_region_sirs(region_name, dis='OC43', do_plot=False):
latx, lonx = regions[region_name]
qyears = range(2010, 2020)
dss = []
for qyear in qyears:
ifile = f'/tigress/wenchang/analysis/climate_and_disease/climSIRS/{dis}.{qyear}q.nc'
ds = xr.open_dataset(ifile).sel(latitude=latx, longitude=lonx, method='nearest')
dss.append(ds)
ds = xr.concat(dss, dim=pd.Index(qyears, name='qyear'))
ifile = f'/tigress/wenchang/analysis/climate_and_disease/climSIRS/{dis}.run7climq.nc'
ds_clim = xr.open_dataset(ifile).sel(latitude=latx, longitude=lonx, method='nearest')
# fig
if do_plot:
for qyear in qyears:
ds.ii.sel(qyear=qyear).plot(color='C0', alpha=0.5, lw=0.5)
ds.ii.mean('qyear').plot(color='C0', label='single-year-q ensemble')
ds_clim.ii.plot(color='C1', label='climq')
plt.xlim(0, 365*2)
plt.title(f'{region_name}({latx:.1f}, {lonx:.1f}) {dis}')
plt.legend()
return ds, ds_clim
#
do_region_sirs(region_name='London', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 0.25 latitude float32 51.5 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.9999845 ... 0.41685742 0.4165671 ii (qyear, t) float32 1e-05 1.31814895e-05 ... 0.008281448, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 51.5 longitude float32 0.25 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='London', dis='HKU1', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 0.25 latitude float32 51.5 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.9999858 ... 0.6685567 0.66908866 ii (qyear, t) float32 1e-05 1.1958771e-05 ... 0.00080141873, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 51.5 longitude float32 0.25 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='NYC', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 286.0 latitude float32 40.75 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.9999844 ... 0.376664 0.37640247 ii (qyear, t) float32 1e-05 1.3283939e-05 ... 0.009299738, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 40.75 longitude float32 286.0 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='NYC', dis='HKU1', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 286.0 latitude float32 40.75 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.99998546 ... 0.66516936 0.6649421 ii (qyear, t) float32 1e-05 1.23389145e-05 ... 0.0040116212, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 40.75 longitude float32 286.0 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='LA', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 241.75 latitude float32 34.0 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.9999846 ... 0.412506 0.4123191 ii (qyear, t) float32 1e-05 1.3059735e-05 ... 0.0077307476, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 34.0 longitude float32 241.75 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='LA', dis='HKU1', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 241.75 latitude float32 34.0 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.99998623 ... 0.6856362 0.68545973 ii (qyear, t) float32 1e-05 1.162454e-05 ... 0.0034230368, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 34.0 longitude float32 241.75 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='Wuhan', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 114.25 latitude float32 30.5 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.99998665 ... 0.8827582 0.8830247 ii (qyear, t) float32 1e-05 1.1219222e-05 ... 3.9486004e-06, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 30.5 longitude float32 114.25 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='Delhi', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 77.0 latitude float32 28.75 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.9999872 ... 0.895116 0.8946375 ii (qyear, t) float32 1e-05 1.0739206e-05 ... 0.0027466281, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 28.75 longitude float32 77.0 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='Maracaibo', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 288.5 latitude float32 10.75 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.99998766 ... 0.8850004 0.8850432 ii (qyear, t) float32 1e-05 1.0278916e-05 ... 0.0010715513, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 10.75 longitude float32 288.5 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='Kinshasa', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 15.25 latitude float32 -4.5 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.9999877 ... 0.8767824 0.87676954 ii (qyear, t) float32 1e-05 1.0252332e-05 ... 0.0014819218, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 -4.5 longitude float32 15.25 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='Jakarta', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 106.75 latitude float32 -6.25 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.9999877 ... 0.88639516 0.88637114 ii (qyear, t) float32 1e-05 1.0246806e-05 ... 0.0014117584, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 -6.25 longitude float32 106.75 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='Johannesburg', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 28.0 latitude float32 -26.25 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.99998766 ... 0.5247395 0.52582014 ii (qyear, t) float32 1e-05 1.0323673e-05 ... 3.4278935e-05, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 -26.25 longitude float32 28.0 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='Buenos_Aires', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 301.5 latitude float32 -34.5 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.9999876 ... 0.62869155 0.6295276 ii (qyear, t) float32 1e-05 1.0336555e-05 ... 7.819701e-05, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 -34.5 longitude float32 301.5 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#
do_region_sirs(region_name='Melbourne', dis='OC43', do_plot=True)
(<xarray.Dataset> Dimensions: (qyear: 10, t: 3650) Coordinates: longitude float32 145.0 latitude float32 -37.75 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 * qyear (qyear) int64 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Data variables: ss (qyear, t) float32 0.99999 0.9999871 ... 0.6695969 0.66961473 ii (qyear, t) float32 1e-05 1.0805876e-05 ... 0.003868763, <xarray.Dataset> Dimensions: (t: 3650) Coordinates: latitude float32 -37.75 longitude float32 145.0 * t (t) int64 1 2 3 4 5 6 7 8 ... 3644 3645 3646 3647 3648 3649 3650 Data variables: ss (t) float32 ... ii (t) float32 ...)
#ERA5 q
ds_sp = xr.open_dataset('/tigress/wenchang/analysis/climate_and_disease/climSIRS/ClimSIRS.OC43.run7climq.cities.nc')
ds_wy = xr.open_dataset('/tigress/wenchang/analysis/climate_and_disease/climSIRS/xClimSIRS.OC43.run7climq.cities.nc')
cities = ds_sp.city.values
colors = [f'C{i}' for i in range(cities.size)]
peaks = []
peak_days = []
for city,c in zip(cities,colors):
ds_sp.ii.sel(city=city).plot(color=c, label=f'{city} (odeint)')
ds_wy.ii.sel(city=city).plot(color='k', ls=':', label=f'{city} (RK4)')
da_sp = ds_sp.sel(city=city).ii.squeeze().isel(t=ds_sp.sel(city=city).ii.squeeze()==ds_sp.sel(city=city).ii.max())
da_wy = ds_wy.sel(city=city).ii.squeeze().isel(t=ds_wy.sel(city=city).ii.squeeze()==ds_wy.sel(city=city).ii.max())
peaks.append([da_sp.item(), da_wy.item()])
peak_days.append([da_sp.t.astype('int').item(), da_wy.t.item()])
plt.xlim(0, 365*2)
plt.legend()
plt.title('OC43')
df_peaks = pd.DataFrame(peaks, index=cities, columns=['odeint', 'RK4'])
print('I/N peak')
print(df_peaks)
print()
df_peak_days = pd.DataFrame(peak_days, index=cities, columns=['odeint', 'RK4'])
print('I/N peak day')
print(df_peak_days)
peaks odeint RK4 NYC 0.218072 0.218362 Maracaibo 0.163862 0.163689 Delhi 0.190519 0.190240 peak days odeint RK4 NYC 59 59 Maracaibo 75 76 Delhi 65 65
#MERRA2 q
ds_sp = xr.open_dataset('/tigress/wenchang/analysis/climate_and_disease/climSIRS/ClimSIRS.OC43.merra2wclimq.cities.nc')
ds_wy = xr.open_dataset('/tigress/wenchang/analysis/climate_and_disease/climSIRS/xClimSIRS.OC43.merra2wclimq.cities.nc')
#plot
dis = 'OC43'
qsource = 'MERRA2'
cities = ds_sp.city.values
colors = [f'C{i}' for i in range(cities.size)]
peaks = []
peak_days = []
for city,c in zip(cities,colors):
ds_sp.ii.sel(city=city).plot(color=c, label=f'{city} (odeint)')
ds_wy.ii.sel(city=city).plot(color='k', ls=':', label=f'{city} (RK4)')
da_sp = ds_sp.sel(city=city).ii.squeeze().isel(t=ds_sp.sel(city=city).ii.squeeze()==ds_sp.sel(city=city).ii.max())
da_wy = ds_wy.sel(city=city).ii.squeeze().isel(t=ds_wy.sel(city=city).ii.squeeze()==ds_wy.sel(city=city).ii.max())
peaks.append([da_sp.item(), da_wy.item()])
peak_days.append([da_sp.t.astype('int').item(), da_wy.t.item()])
plt.xlim(0, 365*2)
plt.legend()
plt.title(f'{dis} {qsource}')
df_peaks = pd.DataFrame(peaks, index=cities, columns=['odeint', 'RK4'])
print('I/N peak')
print(df_peaks)
print()
df_peak_days = pd.DataFrame(peak_days, index=cities, columns=['odeint', 'RK4'])
print('I/N peak day')
print(df_peak_days)
I/N peak odeint RK4 NYC 0.217644 0.217615 Maracaibo 0.169362 0.169373 Delhi 0.214861 0.214796 I/N peak day odeint RK4 NYC 60 60 Maracaibo 75 75 Delhi 60 60
ifiles = '/tigress/wenchang/data/era5/analysis_wy/2m_specific_humidity/daily/clim/q2m.run7clim.2010-2019.nc'
ds = xr.open_dataset(ifiles)
q2m = ds.q2m.load().rename(dayofyear='time')
q2m
array([[[0.00047765, 0.00047765, 0.00047765, ..., 0.00047765, 0.00047765, 0.00047765], [0.00047971, 0.00047973, 0.00047975, ..., 0.0004796 , 0.00047963, 0.00047967], [0.00048245, 0.0004825 , 0.00048255, ..., 0.00048217, 0.00048224, 0.00048233], ..., [0.00049061, 0.0004906 , 0.00049058, ..., 0.00049068, 0.00049066, 0.00049064], [0.00048719, 0.00048718, 0.00048716, ..., 0.00048722, 0.00048721, 0.0004872 ], [0.00047952, 0.00047952, 0.00047952, ..., 0.00047952, 0.00047952, 0.00047952]], [[0.00048481, 0.00048481, 0.00048481, ..., 0.00048481, 0.00048481, 0.00048481], [0.00048764, 0.00048765, 0.00048766, ..., 0.00048757, 0.00048759, 0.00048761], [0.00049198, 0.00049201, 0.00049203, ..., 0.00049179, 0.00049184, 0.0004919 ], ..., [0.00048531, 0.0004853 , 0.00048528, ..., 0.00048539, 0.00048537, 0.00048534], [0.00048243, 0.00048242, 0.0004824 , ..., 0.00048246, 0.00048245, 0.00048244], [0.0004755 , 0.0004755 , 0.0004755 , ..., 0.0004755 , 0.0004755 , 0.0004755 ]], [[0.00047514, 0.00047514, 0.00047514, ..., 0.00047514, 0.00047514, 0.00047514], [0.00047989, 0.00047989, 0.00047989, ..., 0.00047985, 0.00047986, 0.00047987], [0.0004862 , 0.00048621, 0.00048621, ..., 0.00048606, 0.00048609, 0.00048613], ..., [0.00048336, 0.00048335, 0.00048333, ..., 0.00048343, 0.00048341, 0.00048339], [0.00048104, 0.00048103, 0.00048102, ..., 0.00048107, 0.00048106, 0.00048105], [0.00047475, 0.00047475, 0.00047475, ..., 0.00047475, 0.00047475, 0.00047475]], ..., [[0.00049022, 0.00049022, 0.00049022, ..., 0.00049022, 0.00049022, 0.00049022], [0.00049472, 0.00049475, 0.00049478, ..., 0.00049463, 0.00049466, 0.00049469], [0.00049776, 0.00049782, 0.00049787, ..., 0.00049751, 0.00049758, 0.00049765], ..., [0.00050307, 0.00050308, 0.00050307, ..., 0.00050312, 0.00050311, 0.00050309], [0.00049993, 0.00049993, 0.00049992, ..., 0.00049995, 0.00049994, 0.00049994], [0.00049273, 0.00049273, 0.00049273, ..., 0.00049273, 0.00049273, 0.00049273]], [[0.00048698, 0.00048698, 0.00048698, ..., 0.00048698, 0.00048698, 0.00048698], [0.00048996, 0.00048999, 0.00049002, ..., 0.00048986, 0.00048989, 0.00048993], [0.00049317, 0.00049324, 0.0004933 , ..., 0.00049291, 0.00049298, 0.00049307], ..., [0.0004991 , 0.0004991 , 0.00049909, ..., 0.00049915, 0.00049914, 0.00049912], [0.0004961 , 0.00049609, 0.00049608, ..., 0.00049612, 0.00049612, 0.00049611], [0.00048855, 0.00048855, 0.00048855, ..., 0.00048855, 0.00048855, 0.00048855]], [[0.00067848, 0.00067848, 0.00067848, ..., 0.00067848, 0.00067848, 0.00067848], [0.00070442, 0.00070443, 0.00070444, ..., 0.00070436, 0.00070438, 0.0007044 ], [0.00072884, 0.00072889, 0.00072891, ..., 0.00072859, 0.00072864, 0.00072871], ..., [0.00051024, 0.00051024, 0.00051024, ..., 0.00051025, 0.00051025, 0.00051025], [0.00050557, 0.00050557, 0.00050557, ..., 0.00050557, 0.00050557, 0.00050557], [0.00049649, 0.00049649, 0.00049649, ..., 0.00049649, 0.00049649, 0.00049649]]], dtype=float32)
array([ 90. , 89.75, 89.5 , ..., -89.5 , -89.75, -90. ], dtype=float32)
array([0.0000e+00, 2.5000e-01, 5.0000e-01, ..., 3.5925e+02, 3.5950e+02, 3.5975e+02], dtype=float32)
array([ 1, 2, 3, ..., 364, 365, 366])
def func_R0(t, q, a=-227.5, R0_min=1.4, R0_max=2.5, cycle=True):
'''R0 as function of t (time) and specific humidity (q).
q has dims of (n_time, ...).'''
#R0_min, R0_max = 1.4, 2.5
#a = -227.5 for HKU1 and -32.5 for OC43
if cycle:# cycle through the first 365 daily specific humidity
dayofyear = int( np.mod(t-1, 365) + 1 )
qt = q.isel(time=dayofyear-1, drop=True)
else:
qt = q.isel(time=int(t)-1, drop=True)
R0t = (R0_max - R0_min) * np.exp(a*qt) + R0_min
return R0t
# func_R0(365, q2m)
def model_climSIRSp(t, y, L, D, R0, q, a):
'''SIRS model right hand side from Baker et al., 2020.
Input:
-------
y: y[0:y.size//2] is S/N; y[y.size//2:] is I/N
t: time (units is 'day')
L: immunity length, 7x66.25(62.5) days for HKU1 (OC43)
D: infection period, 5 days
R0 = beta*D, ignored if q is not None
q: specific humidity, xr.DataArray, dims ('time', ...)
a: climate dependence parameter, -227.5(-32.5) for HKU1(OC43)
Return:
--------
dydy: half d(S/N)/dt, half d(I/N)/dt
'''
N = y.size
ss = y[:N//2]
ii = y[N//2:]
if q is not None:
R0 = func_R0(t=t, q=q, a=a, R0_min=1.4, R0_max=2.5)
if R0.ndim < 1:
R0 = R0.item()
dydt = np.array([
(1-ss-ii)/L - R0*ii*ss/D,
R0*ii*ss/D - ii/D
]).ravel()
return dydt
from scipy.integrate import solve_ivp
def run_climSIRSp(I0=1e-5, T=5*365, dt=1, L=66.25*7, D=5, R0=2, q=None, a=-227.5):
'''Integrate SIRS model from Baker et al., 2020.
Input:
-------
I0: initial I/N
T: time stop (start is 1; units is 'day')
dt: time step
L: immunity length, 7x66.25(62.5) days for HKU1 (OC43)
D: infection period, 5 days
R0 = beta*D, ignored if q is not None
q: specific humidity, xr.DataArray, dims ('time', ...)
a: climate dependence parameter, -227.5(-32.5) for HKU1(OC43)
Return:
--------
ds: solution for the SIRS model.
'''
if q is not None and q.ndim > 1:
grid = q.stack(grid=q.isel(time=0).dims).grid
zeros = np.zeros(grid.size)
else:
zeros = I0*L*D*R0*0
y0 = np.hstack([1.0-I0+zeros, I0+zeros])
t = np.linspace(1, T, int(T/dt))
sol = solve_ivp(model_climSIRS_RH,[1, T], y0, t_eval=t, args=(L, D, R0, q, a))
ss = sol.y[0:y0.size//2, :]
ii = sol.y[y0.size//2:, :]
da_ss = xr.DataArray(ss, dims=['grid', 't'],coords=[np.arange(1, y0.size//2+1), t])
da_ss.attrs['long_name'] = 'S/N'
da_ii = xr.DataArray(ii, dims=['grid', 't'],coords=[np.arange(1, y0.size//2+1), t])
da_ii.attrs['long_name'] = 'I/N'
if q is not None and q.ndim > 1:
da_ss = da_ss.assign_coords(grid=grid).unstack()
da_ii = da_ii.assign_coords(grid=grid).unstack()
ds = xr.Dataset(dict(ss=da_ss, ii=da_ii))
ds.t.attrs['units'] = 'day'
return ds
latx, lonx = regions['NYC']
if lonx > 180:
lonx -= 360
# q = q2m.sel(latitude=[latx,], longitude=[lonx,], method='nearest')
# R0 = np.arange(2, 1.3, -0.2)
# ds = pclimSIRS_int(R0=R0, q=None, T=2*365, I0=1/8e6, L=62.5*7, a=-32.5)
# ds.ii.rename(grid='R0').assign_coords(R0=R0).plot(hue='R0')
# ds
city = 'NYC'
latx, lonx = regions[city]
q = q2m.sel(latitude=[latx], longitude=[lonx], method='nearest')
ds = pclimSIRS_int(q=q, T=2*365, I0=1/8e6, L=62.5*7, a=-32.5)
ds.ii.plot()
ds
array([ 1., 2., 3., ..., 728., 729., 730.])
array([40.75])
array([286.])
array([[[0.99999987]], [[0.99999981]], [[0.99999971]], [[0.99999959]], [[0.99999944]], [[0.99999923]], [[0.99999895]], [[0.99999857]], [[0.99999807]], [[0.99999741]], [[0.99999627]], [[0.9999944 ]], [[0.9999922 ]], [[0.99998991]], [[0.99998758]], [[0.9999851 ]], [[0.99998214]], [[0.99997823]], [[0.99997268]], [[0.99996465]], [[0.99995309]], [[0.99993678]], [[0.99991432]], [[0.99988414]], [[0.99984445]], [[0.99979318]], [[0.99972505]], [[0.99963644]], [[0.99952155]], [[0.99937027]], [[0.99916823]], [[0.99889674]], [[0.99853285]], [[0.99804931]], [[0.99741314]], [[0.99657464]], [[0.99547719]], [[0.99403429]], [[0.99212473]], [[0.98959259]], [[0.98624727]], [[0.98186372]], [[0.97617978]], [[0.96877341]], [[0.9591372 ]], [[0.94672248]], [[0.93093936]], [[0.91115669]], [[0.88673822]], [[0.8572279 ]], [[0.82210765]], [[0.78131649]], [[0.73534077]], [[0.68521414]], [[0.63251755]], [[0.57923955]], [[0.52695074]], [[0.47693419]], [[0.43025065]], [[0.3877299 ]], [[0.34997075]], [[0.3173093 ]], [[0.28935335]], [[0.26551499]], [[0.2453013 ]], [[0.22826213]], [[0.21399016]], [[0.20212082]], [[0.19229649]], [[0.18418096]], [[0.17750052]], [[0.17202036]], [[0.16754459]], [[0.16391626]], [[0.1610173 ]], [[0.15875555]], [[0.15702322]], [[0.15575792]], [[0.15490436]], [[0.15440933]], [[0.15422172]], [[0.1542925 ]], [[0.15457474]], [[0.15503312]], [[0.1556569 ]], [[0.15643035]], [[0.15733765]], [[0.15836315]], [[0.15949132]], [[0.1607068 ]], [[0.1619944 ]], [[0.16334418]], [[0.16475149]], [[0.16621037]], [[0.16771505]], [[0.16925995]], [[0.17083965]], [[0.17244895]], [[0.17408302]], [[0.17573945]], [[0.17741602]], [[0.17911034]], [[0.18082016]], [[0.18254329]], [[0.18427763]], [[0.18602118]], [[0.18777208]], [[0.18952929]], [[0.19129198]], [[0.19305932]], [[0.19483047]], [[0.19660466]], [[0.19838112]], [[0.2001591 ]], [[0.20193789]], [[0.20371685]], [[0.20549565]], [[0.20727398]], [[0.20905156]], [[0.21082812]], [[0.21260338]], [[0.21437707]], [[0.21614893]], [[0.21791872]], [[0.21968617]], [[0.22145113]], [[0.22321349]], [[0.22497316]], [[0.22673004]], [[0.22848404]], [[0.23023505]], [[0.231983 ]], [[0.23372779]], [[0.23546933]], [[0.23720755]], [[0.23894235]], [[0.24067369]], [[0.24240157]], [[0.24412597]], [[0.24584687]], [[0.24756426]], [[0.24927811]], [[0.25098841]], [[0.25269513]], [[0.25439825]], [[0.25609775]], [[0.2577936 ]], [[0.25948579]], [[0.26117429]], [[0.26285907]], [[0.26454013]], [[0.26621747]], [[0.26789109]], [[0.26956102]], [[0.27122724]], [[0.27288977]], [[0.27454861]], [[0.27620377]], [[0.27785523]], [[0.27950302]], [[0.28114712]], [[0.28278755]], [[0.28442429]], [[0.28605736]], [[0.28768675]], [[0.28931245]], [[0.29093447]], [[0.29255281]], [[0.29416746]], [[0.29577845]], [[0.29738579]], [[0.29898949]], [[0.30058955]], [[0.30218598]], [[0.3037788 ]], [[0.305368 ]], [[0.3069536 ]], [[0.30853561]], [[0.31011402]], [[0.31168886]], [[0.31326012]], [[0.31482781]], [[0.31639194]], [[0.31795252]], [[0.31950956]], [[0.32106305]], [[0.322613 ]], [[0.32415943]], [[0.32570234]], [[0.32724173]], [[0.32877761]], [[0.33030998]], [[0.33183885]], [[0.33336422]], [[0.33488611]], [[0.33640453]], [[0.33791949]], [[0.33943099]], [[0.34093905]], [[0.34244366]], [[0.34394485]], [[0.34544261]], [[0.34693695]], [[0.34842789]], [[0.34991542]], [[0.35139957]], [[0.35288032]], [[0.35435771]], [[0.35583172]], [[0.35730237]], [[0.35876967]], [[0.36023362]], [[0.36169423]], [[0.36315151]], [[0.36460546]], [[0.3660561 ]], [[0.36750343]], [[0.36894746]], [[0.37038819]], [[0.37182564]], [[0.37325981]], [[0.3746907 ]], [[0.37611833]], [[0.37754271]], [[0.37896383]], [[0.38038171]], [[0.38179635]], [[0.38320776]], [[0.38461595]], [[0.38602093]], [[0.3874227 ]], [[0.38882127]], [[0.39021664]], [[0.39160883]], [[0.39299783]], [[0.39438367]], [[0.39576634]], [[0.39714586]], [[0.39852223]], [[0.39989546]], [[0.40126555]], [[0.40263252]], [[0.40399636]], [[0.4053571 ]], [[0.40671472]], [[0.40806925]], [[0.40942069]], [[0.41076904]], [[0.41211431]], [[0.41345651]], [[0.41479565]], [[0.41613173]], [[0.41746476]], [[0.41879475]], [[0.4201217 ]], [[0.42144562]], [[0.42276652]], [[0.42408441]], [[0.42539928]], [[0.42671116]], [[0.42802004]], [[0.42932593]], [[0.43062884]], [[0.43192877]], [[0.43322574]], [[0.43451974]], [[0.4358108 ]], [[0.4370989 ]], [[0.43838406]], [[0.43966629]], [[0.44094559]], [[0.44222197]], [[0.44349544]], [[0.444766 ]], [[0.44603366]], [[0.44729842]], [[0.4485603 ]], [[0.44981929]], [[0.45107541]], [[0.45232866]], [[0.45357905]], [[0.45482659]], [[0.45607128]], [[0.45731312]], [[0.45855213]], [[0.45978832]], [[0.46102167]], [[0.46225222]], [[0.46347995]], [[0.46470488]], [[0.46592701]], [[0.46714636]], [[0.46836292]], [[0.4695767 ]], [[0.47078771]], [[0.47199595]], [[0.47320144]], [[0.47440417]], [[0.47560416]], [[0.47680141]], [[0.47799593]], [[0.47918771]], [[0.48037678]], [[0.48156313]], [[0.48274677]], [[0.48392771]], [[0.48510596]], [[0.48628151]], [[0.48745438]], [[0.48862457]], [[0.48979209]], [[0.49095695]], [[0.49211914]], [[0.49327868]], [[0.49443558]], [[0.49558983]], [[0.49674145]], [[0.49789044]], [[0.4990368 ]], [[0.50018055]], [[0.50132168]], [[0.50246021]], [[0.50359614]], [[0.50472948]], [[0.50586023]], [[0.5069884 ]], [[0.50811399]], [[0.50923701]], [[0.51035746]], [[0.51147536]], [[0.51259071]], [[0.51370351]], [[0.51481377]], [[0.51592149]], [[0.51702668]], [[0.51812936]], [[0.51922951]], [[0.52032715]], [[0.52142228]], [[0.52251492]], [[0.52360505]], [[0.52469269]], [[0.52577783]], [[0.52686048]], [[0.52794066]], [[0.52901836]], [[0.5300936 ]], [[0.53116638]], [[0.53223671]], [[0.53330459]], [[0.53437003]], [[0.53543305]], [[0.53649363]], [[0.5375518 ]], [[0.53860755]], [[0.53966089]], [[0.54071184]], [[0.54176038]], [[0.54280654]], [[0.54385032]], [[0.54489171]], [[0.54593074]], [[0.5469674 ]], [[0.54800169]], [[0.54903363]], [[0.55006322]], [[0.55109047]], [[0.55211537]], [[0.55313794]], [[0.55415817]], [[0.55517608]], [[0.55619167]], [[0.55720495]], [[0.55821591]], [[0.55922457]], [[0.56023092]], [[0.56123497]], [[0.56223673]], [[0.56323621]], [[0.56423339]], [[0.56522829]], [[0.56622092]], [[0.56721127]], [[0.56819935]], [[0.56918516]], [[0.57016871]], [[0.57115 ]], [[0.57212904]], [[0.57310582]], [[0.57408035]], [[0.57505264]], [[0.57602268]], [[0.57699048]], [[0.57795604]], [[0.57891937]], [[0.57988047]], [[0.58083934]], [[0.58179598]], [[0.58275039]], [[0.58370259]], [[0.58465256]], [[0.58560032]], [[0.58654586]], [[0.58748919]], [[0.58843031]], [[0.58936922]], [[0.59030592]], [[0.59124041]], [[0.5921727 ]], [[0.59310279]], [[0.59403067]], [[0.59495636]], [[0.59587985]], [[0.59680114]], [[0.59772023]], [[0.59863682]], [[0.5995508 ]], [[0.60046227]], [[0.60137134]], [[0.60227807]], [[0.60318256]], [[0.60408485]], [[0.60498499]], [[0.60588301]], [[0.60677895]], [[0.6076728 ]], [[0.60856457]], [[0.60945423]], [[0.61034176]], [[0.61122712]], [[0.61211024]], [[0.61299108]], [[0.61386954]], [[0.61474554]], [[0.61561897]], [[0.61648971]], [[0.61735763]], [[0.6182226 ]], [[0.61908445]], [[0.61994303]], [[0.62079814]], [[0.6216496 ]], [[0.62249721]], [[0.62334074]], [[0.62417997]], [[0.62501464]], [[0.62584452]], [[0.62666932]], [[0.62748878]], [[0.62830258]], [[0.62911044]], [[0.62991203]], [[0.63070702]], [[0.63149506]], [[0.63227581]], [[0.63304889]], [[0.63381392]], [[0.63457051]], [[0.63531607]], [[0.63604639]], [[0.63676291]], [[0.6374669 ]], [[0.63815924]], [[0.63884038]], [[0.63951037]], [[0.64016887]], [[0.6408151 ]], [[0.6414479 ]], [[0.64206569]], [[0.6426665 ]], [[0.64324793]], [[0.64380719]], [[0.64434108]], [[0.64484598]], [[0.64531789]], [[0.64575237]], [[0.6461446 ]], [[0.64648935]], [[0.64678096]], [[0.64701339]], [[0.64718018]], [[0.64727447]], [[0.64728898]], [[0.64721605]], [[0.64704758]], [[0.64677508]], [[0.64638966]], [[0.64588201]], [[0.64524242]], [[0.64446077]], [[0.64352654]], [[0.64242879]], [[0.64115618]], [[0.63969698]], [[0.63803902]], [[0.63616974]], [[0.63407619]], [[0.63174498]], [[0.62916234]], [[0.62631408]], [[0.62318561]], [[0.61976174]], [[0.61602755]], [[0.61197413]], [[0.60759649]], [[0.60289309]], [[0.5978658 ]], [[0.59251993]], [[0.58686421]], [[0.58091079]], [[0.57467528]], [[0.56817668]], [[0.56143745]], [[0.55448345]], [[0.54734399]], [[0.5400415 ]], [[0.53256309]], [[0.52493647]], [[0.51719491]], [[0.50937146]], [[0.50149892]], [[0.49360983]], [[0.48573651]], [[0.47791103]], [[0.4701652 ]], [[0.46253061]], [[0.45503859]], [[0.44772025]], [[0.44060643]], [[0.43372262]], [[0.42707847]], [[0.4206896 ]], [[0.4145698 ]], [[0.40873031]], [[0.40317977]], [[0.3979243 ]], [[0.39296743]], [[0.38831011]], [[0.38395076]], [[0.37988519]], [[0.37610668]], [[0.37260592]], [[0.36937104]], [[0.36638762]], [[0.36363864]], [[0.36110455]], [[0.35876989]], [[0.35664747]], [[0.35472933]], [[0.35300424]], [[0.35146146]], [[0.35009072]], [[0.34888222]], [[0.34782665]], [[0.34691515]], [[0.34613935]], [[0.34549135]], [[0.34496373]], [[0.34454953]], [[0.34424227]], [[0.34403595]], [[0.34392504]], [[0.34390449]], [[0.34396968]], [[0.34411181]], [[0.34432394]], [[0.34460263]], [[0.34494456]], [[0.34534645]], [[0.34580513]], [[0.34631748]], [[0.34688048]], [[0.34749116]], [[0.34814666]], [[0.34884417]], [[0.34958097]], [[0.3503544 ]], [[0.35116191]], [[0.35200098]], [[0.35286922]], [[0.35376427]], [[0.35468388]], [[0.35562586]], [[0.35658873]], [[0.35757205]], [[0.35857482]], [[0.3595961 ]], [[0.3606349 ]], [[0.36169029]], [[0.36276132]], [[0.36384707]], [[0.36494663]], [[0.3660591 ]], [[0.36718358]], [[0.36831919]], [[0.36946507]], [[0.37062037]], [[0.37178423]], [[0.37295582]], [[0.37413433]], [[0.37531894]], [[0.37650885]], [[0.37770371]], [[0.37890415]], [[0.38010979]], [[0.38132021]], [[0.38253501]], [[0.38375379]], [[0.38497617]], [[0.38620178]], [[0.38743028]], [[0.38866133]], [[0.38989461]], [[0.39112982]], [[0.39236666]], [[0.39360488]], [[0.3948442 ]], [[0.39608438]], [[0.3973252 ]], [[0.39856645]], [[0.39980792]], [[0.40104944]], [[0.40229083]], [[0.40353196]], [[0.40477267]], [[0.40601284]], [[0.40725238]], [[0.40849119]], [[0.4097292 ]], [[0.4109664 ]], [[0.41220271]], [[0.41343801]], [[0.41467222]], [[0.41590522]], [[0.41713692]], [[0.41836721]], [[0.41959601]], [[0.42082321]], [[0.42204871]], [[0.42327244]], [[0.42449428]], [[0.42571416]], [[0.42693198]], [[0.42814766]], [[0.42936111]], [[0.43057224]], [[0.43178097]], [[0.43298721]], [[0.43419089]], [[0.43539193]], [[0.43659024]], [[0.43778575]], [[0.43897839]], [[0.44016808]], [[0.44135474]], [[0.44253831]], [[0.44371872]], [[0.44489589]], [[0.44606976]], [[0.44724026]], [[0.44840733]], [[0.4495709 ]], [[0.45073092]], [[0.45188731]], [[0.45304003]], [[0.45418902]], [[0.45533421]], [[0.45647555]], [[0.45761299]], [[0.45874634]], [[0.45987495]], [[0.46099875]], [[0.46211774]], [[0.46323192]], [[0.46434127]], [[0.46544575]], [[0.46654532]], [[0.4676399 ]], [[0.46872942]], [[0.46981379]], [[0.4708929 ]], [[0.47196663]], [[0.47303485]], [[0.47409741]], [[0.47515414]], [[0.47620487]], [[0.47724941]], [[0.47828756]], [[0.47931908]], [[0.48034377]], [[0.48136135]], [[0.48237158]], [[0.48337418]], [[0.48436885]], [[0.48535531]], [[0.48633322]], [[0.48730225]], [[0.48826207]], [[0.48921231]], [[0.4901526 ]], [[0.49108254]], [[0.49200175]], [[0.49290979]], [[0.49380625]], [[0.49469067]], [[0.4955626 ]], [[0.49642157]], [[0.49726709]], [[0.49809866]], [[0.49891577]], [[0.49971787]], [[0.50050445]], [[0.50127493]], [[0.50202874]], [[0.50276531]], [[0.50348402]], [[0.50418428]], [[0.50486543]], [[0.50552675]], [[0.50616737]], [[0.50678635]], [[0.5073826 ]], [[0.50795495]], [[0.50850211]], [[0.50902267]], [[0.50951512]], [[0.50997783]], [[0.51040907]], [[0.510807 ]], [[0.51116966]]])
array([[[ 1.25000000e-07]], [[ 1.65350459e-07]], [[ 2.18917314e-07]], [[ 2.89076380e-07]], [[ 3.81392991e-07]], [[ 5.04338661e-07]], [[ 6.69291076e-07]], [[ 8.90534100e-07]], [[ 1.18525777e-06]], [[ 1.57355831e-06]], [[ 2.24118000e-06]], [[ 3.33652485e-06]], [[ 4.62323825e-06]], [[ 5.96194161e-06]], [[ 7.32008289e-06]], [[ 8.77193657e-06]], [[ 1.04986037e-05]], [[ 1.27880118e-05]], [[ 1.60349151e-05]], [[ 2.07408942e-05]], [[ 2.75143564e-05]], [[ 3.70705353e-05]], [[ 5.02314913e-05]], [[ 6.79261112e-05]], [[ 9.11901084e-05]], [[ 1.21245715e-04]], [[ 1.61150292e-04]], [[ 2.13076660e-04]], [[ 2.80495027e-04]], [[ 3.69354005e-04]], [[ 4.88080610e-04]], [[ 6.47580267e-04]], [[ 8.61236801e-04]], [[ 1.14491245e-03]], [[ 1.51769409e-03]], [[ 2.00801004e-03]], [[ 2.64949705e-03]], [[ 3.49276059e-03]], [[ 4.60781333e-03]], [[ 6.08407505e-03]], [[ 8.03037271e-03]], [[ 1.05746160e-02]], [[ 1.38545106e-02]], [[ 1.81143189e-02]], [[ 2.36337889e-02]], [[ 3.06844253e-02]], [[ 3.95294894e-02]], [[ 5.04239990e-02]], [[ 6.35940022e-02]], [[ 7.90793403e-02]], [[ 9.68256096e-02]], [[ 1.16463329e-01]], [[ 1.37264207e-01]], [[ 1.58141145e-01]], [[ 1.77648236e-01]], [[ 1.94129207e-01]], [[ 2.06733938e-01]], [[ 2.15111322e-01]], [[ 2.19092680e-01]], [[ 2.18694822e-01]], [[ 2.14120043e-01]], [[ 2.05797279e-01]], [[ 1.94835517e-01]], [[ 1.82197049e-01]], [[ 1.68607315e-01]], [[ 1.54656744e-01]], [[ 1.40800753e-01]], [[ 1.27359760e-01]], [[ 1.14578111e-01]], [[ 1.02618117e-01]], [[ 9.15554460e-02]], [[ 8.14324871e-02]], [[ 7.22583563e-02]], [[ 6.40088943e-02]], [[ 5.66266667e-02]], [[ 5.00285626e-02]], [[ 4.41518910e-02]], [[ 3.89332186e-02]], [[ 3.43106447e-02]], [[ 3.02255947e-02]], [[ 2.66228202e-02]], [[ 2.34503987e-02]], [[ 2.06597340e-02]], [[ 1.82037363e-02]], [[ 1.60411611e-02]], [[ 1.41397498e-02]], [[ 1.24696105e-02]], [[ 1.10031126e-02]], [[ 9.71488647e-03]], [[ 8.58182338e-03]], [[ 7.58308088e-03]], [[ 6.70224042e-03]], [[ 5.92686614e-03]], [[ 5.24494224e-03]], [[ 4.64537025e-03]], [[ 4.11796902e-03]], [[ 3.65347467e-03]], [[ 3.24354064e-03]], [[ 2.88078386e-03]], [[ 2.55955347e-03]], [[ 2.27544021e-03]], [[ 2.02435626e-03]], [[ 1.80250978e-03]], [[ 1.60640496e-03]], [[ 1.43284202e-03]], [[ 1.27891717e-03]], [[ 1.14205333e-03]], [[ 1.02035022e-03]], [[ 9.12263008e-04]], [[ 8.16334613e-04]], [[ 7.31204673e-04]], [[ 6.55609544e-04]], [[ 5.88382305e-04]], [[ 5.28452752e-04]], [[ 4.74847405e-04]], [[ 4.26798634e-04]], [[ 3.83859166e-04]], [[ 3.45520209e-04]], [[ 3.11299989e-04]], [[ 2.80748175e-04]], [[ 2.53445878e-04]], [[ 2.29005652e-04]], [[ 2.07071492e-04]], [[ 1.87318837e-04]], [[ 1.69459470e-04]], [[ 1.53332815e-04]], [[ 1.38808203e-04]], [[ 1.25744465e-04]], [[ 1.14006730e-04]], [[ 1.03466426e-04]], [[ 9.40012806e-05]], [[ 8.54953187e-05]], [[ 7.78388657e-05]], [[ 7.09285453e-05]], [[ 6.46672801e-05]], [[ 5.89644741e-05]], [[ 5.37591523e-05]], [[ 4.90189999e-05]], [[ 4.47099504e-05]], [[ 4.07989452e-05]], [[ 3.72539346e-05]], [[ 3.40438771e-05]], [[ 3.11387398e-05]], [[ 2.85094982e-05]], [[ 2.61281362e-05]], [[ 2.39676463e-05]], [[ 2.20020293e-05]], [[ 2.02062945e-05]], [[ 1.85564597e-05]], [[ 1.70296576e-05]], [[ 1.56223729e-05]], [[ 1.43357263e-05]], [[ 1.31614645e-05]], [[ 1.20915791e-05]], [[ 1.11183067e-05]], [[ 1.02341294e-05]], [[ 9.43177395e-06]], [[ 8.70421262e-06]], [[ 8.04466258e-06]], [[ 7.44658620e-06]], [[ 6.90369094e-06]], [[ 6.40992941e-06]], [[ 5.95949930e-06]], [[ 5.54684346e-06]], [[ 5.16664984e-06]], [[ 4.81385153e-06]], [[ 4.48362671e-06]], [[ 4.17139871e-06]], [[ 3.87562190e-06]], [[ 3.59922662e-06]], [[ 3.34153835e-06]], [[ 3.10177720e-06]], [[ 2.87916147e-06]], [[ 2.67290763e-06]], [[ 2.48223035e-06]], [[ 2.30634246e-06]], [[ 2.14445498e-06]], [[ 1.99577712e-06]], [[ 1.85951625e-06]], [[ 1.73487795e-06]], [[ 1.62106595e-06]], [[ 1.51728219e-06]], [[ 1.42272676e-06]], [[ 1.33659796e-06]], [[ 1.25809226e-06]], [[ 1.18640431e-06]], [[ 1.12072695e-06]], [[ 1.06025117e-06]], [[ 1.00416619e-06]], [[ 9.51659372e-07]], [[ 9.01916275e-07]], [[ 8.54120639e-07]], [[ 8.07454382e-07]], [[ 7.61169188e-07]], [[ 7.16997118e-07]], [[ 6.75841805e-07]], [[ 6.37504662e-07]], [[ 6.01794744e-07]], [[ 5.68528746e-07]], [[ 5.37531003e-07]], [[ 5.08633493e-07]], [[ 4.81675832e-07]], [[ 4.56505277e-07]], [[ 4.32976726e-07]], [[ 4.10952718e-07]], [[ 3.90303433e-07]], [[ 3.70906689e-07]], [[ 3.52647947e-07]], [[ 3.35420308e-07]], [[ 3.19124514e-07]], [[ 3.03668947e-07]], [[ 2.88969628e-07]], [[ 2.74950223e-07]], [[ 2.61542033e-07]], [[ 2.48684005e-07]], [[ 2.36322722e-07]], [[ 2.24412411e-07]], [[ 2.12914937e-07]], [[ 2.01799807e-07]], [[ 1.91044168e-07]], [[ 1.80632809e-07]], [[ 1.70558157e-07]], [[ 1.60820282e-07]], [[ 1.51426894e-07]], [[ 1.42393342e-07]], [[ 1.33742618e-07]], [[ 1.25505352e-07]], [[ 1.17719817e-07]], [[ 1.10431925e-07]], [[ 1.03695230e-07]], [[ 9.75709240e-08]], [[ 9.21278425e-08]], [[ 8.74424600e-08]], [[ 8.35988920e-08]], [[ 8.06424098e-08]], [[ 7.79447632e-08]], [[ 7.52802886e-08]], [[ 7.26496581e-08]], [[ 7.00535307e-08]], [[ 6.74925514e-08]], [[ 6.49673517e-08]], [[ 6.24785494e-08]], [[ 6.00267486e-08]], [[ 5.76125398e-08]], [[ 5.52364999e-08]], [[ 5.28991922e-08]], [[ 5.06011661e-08]], [[ 4.83429577e-08]], [[ 4.61250891e-08]], [[ 4.39480690e-08]], [[ 4.18123925e-08]], [[ 3.97185407e-08]], [[ 3.76669815e-08]], [[ 3.56581689e-08]], [[ 3.36925432e-08]], [[ 3.17705312e-08]], [[ 2.98925461e-08]], [[ 2.80589871e-08]], [[ 2.62702403e-08]], [[ 2.45266777e-08]], [[ 2.28286578e-08]], [[ 2.11765255e-08]], [[ 1.95706121e-08]], [[ 1.80112351e-08]], [[ 1.64986984e-08]], [[ 1.50332923e-08]], [[ 1.36152934e-08]], [[ 1.22449648e-08]], [[ 1.09225558e-08]], [[ 9.64830196e-09]], [[ 8.42242547e-09]], [[ 7.24513469e-09]], [[ 6.11662437e-09]], [[ 5.03707560e-09]], [[ 4.00665586e-09]], [[ 3.02551895e-09]], [[ 2.09380503e-09]], [[ 1.21164063e-09]], [[ 3.79138618e-10]], [[-4.03601788e-10]], [[-1.13649501e-09]], [[-1.81946911e-09]], [[-2.45246581e-09]], [[-3.03544047e-09]], [[-3.56836211e-09]], [[-4.05121337e-09]], [[-4.48399057e-09]], [[-4.86670365e-09]], [[-5.19937621e-09]], [[-5.48204550e-09]], [[-5.71476240e-09]], [[-5.89759145e-09]], [[-6.03061084e-09]], [[-6.11391240e-09]], [[-6.14760160e-09]], [[-6.13179758e-09]], [[-6.06663310e-09]], [[-5.95225458e-09]], [[-5.78882210e-09]], [[-5.57650935e-09]], [[-5.31550370e-09]], [[-5.00600616e-09]], [[-4.64823138e-09]], [[-4.24240765e-09]], [[-3.78877693e-09]], [[-3.28759481e-09]], [[-2.73913052e-09]], [[-2.14366696e-09]], [[-1.50150066e-09]], [[-8.12941794e-10]], [[-7.83141978e-11]], [[ 7.02044658e-10]], [[ 1.52778365e-09]], [[ 2.39853802e-09]], [[ 3.31392933e-09]], [[ 4.27356555e-09]], [[ 5.27704095e-09]], [[ 6.32393618e-09]], [[ 7.41381823e-09]], [[ 8.54624047e-09]], [[ 9.72074259e-09]], [[ 1.09368507e-08]], [[ 1.21940771e-08]], [[ 1.34919206e-08]], [[ 1.48298664e-08]], [[ 1.62073858e-08]], [[ 1.76239368e-08]], [[ 1.90789635e-08]], [[ 2.05718964e-08]], [[ 2.21021525e-08]], [[ 2.36691349e-08]], [[ 2.52722332e-08]], [[ 2.69108234e-08]], [[ 2.85842678e-08]], [[ 3.02919151e-08]], [[ 3.20331001e-08]], [[ 3.38071444e-08]], [[ 3.56133555e-08]], [[ 3.74510276e-08]], [[ 3.93194410e-08]], [[ 4.20575623e-08]], [[ 4.83827799e-08]], [[ 5.80589786e-08]], [[ 7.06061073e-08]], [[ 8.55673737e-08]], [[ 1.02509245e-07]], [[ 1.21021446e-07]], [[ 1.40716963e-07]], [[ 1.61232038e-07]], [[ 1.82226176e-07]], [[ 2.03382138e-07]], [[ 2.24405945e-07]], [[ 2.45026877e-07]], [[ 2.64997473e-07]], [[ 2.84093531e-07]], [[ 3.02114108e-07]], [[ 3.18881520e-07]], [[ 3.34241343e-07]], [[ 3.48062409e-07]], [[ 3.60236814e-07]], [[ 3.70679908e-07]], [[ 3.79330303e-07]], [[ 3.86149870e-07]], [[ 3.91123736e-07]], [[ 3.94260292e-07]], [[ 3.95591183e-07]], [[ 3.95171317e-07]], [[ 3.93078858e-07]], [[ 3.89415231e-07]], [[ 3.84305120e-07]], [[ 3.77896466e-07]], [[ 3.70360471e-07]], [[ 3.61891596e-07]], [[ 3.52707561e-07]], [[ 3.43049343e-07]], [[ 3.33181180e-07]], [[ 3.23390568e-07]], [[ 3.13988264e-07]], [[ 3.05308282e-07]], [[ 2.97707895e-07]], [[ 2.91567637e-07]], [[ 2.87291298e-07]], [[ 2.85305930e-07]], [[ 2.86061841e-07]], [[ 2.90032602e-07]], [[ 2.97715039e-07]], [[ 3.09629240e-07]], [[ 3.26318550e-07]], [[ 3.48349574e-07]], [[ 3.76312176e-07]], [[ 4.10819479e-07]], [[ 4.52507864e-07]], [[ 5.02036973e-07]], [[ 5.60089706e-07]], [[ 6.27372220e-07]], [[ 7.04613936e-07]], [[ 7.92567529e-07]], [[ 8.92008935e-07]], [[ 1.00373735e-06]], [[ 1.12857523e-06]], [[ 1.26736828e-06]], [[ 1.42098548e-06]], [[ 1.59031906e-06]], [[ 1.77628451e-06]], [[ 1.97982058e-06]], [[ 2.20188927e-06]], [[ 2.44347586e-06]], [[ 2.70558887e-06]], [[ 2.98926009e-06]], [[ 3.29554455e-06]], [[ 3.62552057e-06]], [[ 3.98028970e-06]], [[ 4.36097677e-06]], [[ 4.76872985e-06]], [[ 5.20553195e-06]], [[ 5.77060699e-06]], [[ 6.50545036e-06]], [[ 7.37545838e-06]], [[ 8.35023155e-06]], [[ 9.40357463e-06]], [[ 1.05134966e-05]], [[ 1.16622106e-05]], [[ 1.28361341e-05]], [[ 1.40258887e-05]], [[ 1.52263003e-05]], [[ 1.64363989e-05]], [[ 1.76594189e-05]], [[ 1.89027987e-05]], [[ 2.01781812e-05]], [[ 2.15014133e-05]], [[ 2.28925461e-05]], [[ 2.43758351e-05]], [[ 2.59797400e-05]], [[ 2.77369246e-05]], [[ 2.96842569e-05]], [[ 3.18628093e-05]], [[ 3.43178583e-05]], [[ 3.70988847e-05]], [[ 4.02595734e-05]], [[ 4.38578136e-05]], [[ 4.79556987e-05]], [[ 5.26195264e-05]], [[ 5.79197985e-05]], [[ 6.39312212e-05]], [[ 7.07327046e-05]], [[ 7.84073634e-05]], [[ 8.70425163e-05]], [[ 9.67296862e-05]], [[ 1.07564600e-04]], [[ 1.19647190e-04]], [[ 1.33081592e-04]], [[ 1.47976144e-04]], [[ 1.64443392e-04]], [[ 1.82600083e-04]], [[ 2.02567170e-04]], [[ 2.24469810e-04]], [[ 2.48437364e-04]], [[ 2.74603397e-04]], [[ 3.02790501e-04]], [[ 3.32415065e-04]], [[ 3.63647957e-04]], [[ 3.96765369e-04]], [[ 4.32119626e-04]], [[ 4.70139188e-04]], [[ 5.11328651e-04]], [[ 5.56268746e-04]], [[ 6.05616336e-04]], [[ 6.60104423e-04]], [[ 7.20542139e-04]], [[ 7.87814755e-04]], [[ 8.62883675e-04]], [[ 9.46786437e-04]], [[ 1.04063672e-03]], [[ 1.14562432e-03]], [[ 1.26301519e-03]], [[ 1.39415141e-03]], [[ 1.54045119e-03]], [[ 1.70340887e-03]], [[ 1.88459494e-03]], [[ 2.08565603e-03]], [[ 2.30831486e-03]], [[ 2.55437035e-03]], [[ 2.82569750e-03]], [[ 3.12424748e-03]], [[ 3.45204757e-03]], [[ 3.81120121e-03]], [[ 4.20388795e-03]], [[ 4.63236348e-03]], [[ 5.09895965e-03]], [[ 5.60608440e-03]], [[ 6.15622186e-03]], [[ 6.75193224e-03]], [[ 7.39585192e-03]], [[ 8.09069340e-03]], [[ 8.83924533e-03]], [[ 9.64437248e-03]], [[ 1.05090157e-02]], [[ 1.14361922e-02]], [[ 1.24289950e-02]], [[ 1.34905934e-02]], [[ 1.46242330e-02]], [[ 1.58327121e-02]], [[ 1.71119075e-02]], [[ 1.84544804e-02]], [[ 1.98525507e-02]], [[ 2.12973316e-02]], [[ 2.27791299e-02]], [[ 2.42873454e-02]], [[ 2.58104713e-02]], [[ 2.73360943e-02]], [[ 2.88508944e-02]], [[ 3.03406447e-02]], [[ 3.17902120e-02]], [[ 3.31835562e-02]], [[ 3.45037306e-02]], [[ 3.57420648e-02]], [[ 3.69229937e-02]], [[ 3.80357395e-02]], [[ 3.90657683e-02]], [[ 4.00000011e-02]], [[ 4.08268137e-02]], [[ 4.15360369e-02]], [[ 4.21189561e-02]], [[ 4.25683117e-02]], [[ 4.28782991e-02]], [[ 4.30445682e-02]], [[ 4.30642240e-02]], [[ 4.29358264e-02]], [[ 4.26593898e-02]], [[ 4.22407802e-02]], [[ 4.16974120e-02]], [[ 4.10376084e-02]], [[ 4.02694756e-02]], [[ 3.94016345e-02]], [[ 3.84432211e-02]], [[ 3.74038862e-02]], [[ 3.62937952e-02]], [[ 3.51236287e-02]], [[ 3.39045820e-02]], [[ 3.26483652e-02]], [[ 3.13672032e-02]], [[ 3.00738361e-02]], [[ 2.87815184e-02]], [[ 2.75040197e-02]], [[ 2.62556244e-02]], [[ 2.50511319e-02]], [[ 2.38983828e-02]], [[ 2.27727675e-02]], [[ 2.16738411e-02]], [[ 2.06049362e-02]], [[ 1.95689260e-02]], [[ 1.85682253e-02]], [[ 1.76047897e-02]], [[ 1.66801158e-02]], [[ 1.57952417e-02]], [[ 1.49507460e-02]], [[ 1.41467490e-02]], [[ 1.33829116e-02]], [[ 1.26584361e-02]], [[ 1.19720658e-02]], [[ 1.13220849e-02]], [[ 1.07063190e-02]], [[ 1.01221346e-02]], [[ 9.56646871e-03]], [[ 9.04067276e-03]], [[ 8.54583974e-03]], [[ 8.08012124e-03]], [[ 7.64175828e-03]], [[ 7.22908125e-03]], [[ 6.84050993e-03]], [[ 6.47455354e-03]], [[ 6.12981067e-03]], [[ 5.80496931e-03]], [[ 5.49880686e-03]], [[ 5.21019010e-03]], [[ 4.93807523e-03]], [[ 4.68150784e-03]], [[ 4.43962292e-03]], [[ 4.21164486e-03]], [[ 3.99688744e-03]], [[ 3.79475385e-03]], [[ 3.60473667e-03]], [[ 3.42641789e-03]], [[ 3.25897064e-03]], [[ 3.10114501e-03]], [[ 2.95231295e-03]], [[ 2.81189054e-03]], [[ 2.67933128e-03]], [[ 2.55412604e-03]], [[ 2.43580311e-03]], [[ 2.32392814e-03]], [[ 2.21810421e-03]], [[ 2.11797177e-03]], [[ 2.02320869e-03]], [[ 1.93353021e-03]], [[ 1.84868898e-03]], [[ 1.76847503e-03]], [[ 1.69271582e-03]], [[ 1.62127616e-03]], [[ 1.55405828e-03]], [[ 1.49100180e-03]], [[ 1.43208375e-03]], [[ 1.37690783e-03]], [[ 1.32425322e-03]], [[ 1.27398827e-03]], [[ 1.22605807e-03]], [[ 1.18040599e-03]], [[ 1.13697369e-03]], [[ 1.09570110e-03]], [[ 1.05652645e-03]], [[ 1.01938622e-03]], [[ 9.84215211e-04]], [[ 9.50946477e-04]], [[ 9.19511366e-04]], [[ 8.89839506e-04]], [[ 8.61858806e-04]], [[ 8.35495458e-04]], [[ 8.10673934e-04]], [[ 7.87316990e-04]], [[ 7.65345664e-04]], [[ 7.44679275e-04]], [[ 7.25235423e-04]], [[ 7.06929991e-04]], [[ 6.89677144e-04]], [[ 6.73389330e-04]], [[ 6.57977277e-04]], [[ 6.43349994e-04]], [[ 6.29414776e-04]], [[ 6.16079546e-04]], [[ 6.03307856e-04]], [[ 5.91099307e-04]], [[ 5.79450080e-04]], [[ 5.68356186e-04]], [[ 5.57813467e-04]], [[ 5.47817592e-04]], [[ 5.38364061e-04]], [[ 5.29448203e-04]], [[ 5.21065176e-04]], [[ 5.13209968e-04]], [[ 5.05877396e-04]], [[ 4.99062107e-04]], [[ 4.92758576e-04]], [[ 4.86961109e-04]], [[ 4.81663841e-04]], [[ 4.76860736e-04]], [[ 4.72545586e-04]], [[ 4.68712016e-04]], [[ 4.65353477e-04]], [[ 4.62463252e-04]], [[ 4.60034451e-04]], [[ 4.58060015e-04]], [[ 4.56532714e-04]], [[ 4.55445147e-04]], [[ 4.54789743e-04]], [[ 4.54558759e-04]], [[ 4.54744285e-04]], [[ 4.55338236e-04]], [[ 4.56332359e-04]], [[ 4.57718229e-04]], [[ 4.59487253e-04]], [[ 4.61630663e-04]], [[ 4.64139525e-04]], [[ 4.67004731e-04]], [[ 4.70217005e-04]], [[ 4.73766898e-04]], [[ 4.77644791e-04]], [[ 4.81840897e-04]], [[ 4.86345255e-04]], [[ 4.91147735e-04]], [[ 4.96313895e-04]], [[ 5.02179942e-04]], [[ 5.08761390e-04]], [[ 5.16031659e-04]], [[ 5.23968155e-04]], [[ 5.32552279e-04]], [[ 5.41769419e-04]], [[ 5.51608955e-04]], [[ 5.62064256e-04]], [[ 5.73132683e-04]], [[ 5.84815585e-04]], [[ 5.97118305e-04]], [[ 6.10050172e-04]], [[ 6.23624508e-04]], [[ 6.37858625e-04]], [[ 6.52773824e-04]], [[ 6.68395399e-04]], [[ 6.84752631e-04]], [[ 7.01878794e-04]], [[ 7.19811150e-04]], [[ 7.38590954e-04]], [[ 7.58263448e-04]], [[ 7.78877869e-04]], [[ 8.00487438e-04]], [[ 8.23149373e-04]], [[ 8.46924877e-04]], [[ 8.71879147e-04]], [[ 8.98081367e-04]], [[ 9.25604714e-04]], [[ 9.54526355e-04]], [[ 9.84927445e-04]], [[ 1.01689313e-03]], [[ 1.05051255e-03]], [[ 1.08587884e-03]], [[ 1.12308910e-03]], [[ 1.16224445e-03]], [[ 1.20344999e-03]], [[ 1.24681481e-03]], [[ 1.29245198e-03]], [[ 1.34047857e-03]], [[ 1.39101565e-03]], [[ 1.44418826e-03]], [[ 1.50012545e-03]], [[ 1.55896024e-03]], [[ 1.62082966e-03]], [[ 1.68587472e-03]], [[ 1.75424041e-03]], [[ 1.82592757e-03]], [[ 1.90042058e-03]], [[ 1.97788064e-03]], [[ 2.05859295e-03]], [[ 2.14287389e-03]], [[ 2.23107108e-03]], [[ 2.32356331e-03]], [[ 2.42076058e-03]], [[ 2.52310412e-03]], [[ 2.63106634e-03]], [[ 2.74515085e-03]], [[ 2.86589249e-03]], [[ 2.99385728e-03]], [[ 3.12964246e-03]]])
q2m = (
xr.open_dataset('/tigress/gvecchi/ANALYSIS/DISEASE/COVID-19/merra_weekly_clim.nc')
.rename(WEEK_QV2M='q2m', TT='time', LAT='latitude', LON='longitude')['q2m']
)
q2m
<xarray.DataArray 'q2m' (time: 52, latitude: 361, longitude: 576)> [10812672 values with dtype=float64] Coordinates: * longitude (longitude) float64 -180.0 -179.4 -178.8 ... 178.1 178.8 179.4 * latitude (latitude) float64 -90.0 -89.5 -89.0 -88.5 ... 89.0 89.5 90.0 * time (time) datetime64[ns] 1981-01-04 1981-01-11 ... 1981-12-27 Attributes: long_name: Weekly-mean 2-meter specific humidity from MERRA2 units: kg/kg history: From /tigress/samueltb/MERRA2/Daily/merged/QV2M/... climatology_time_range: JAN-1980:AUG-2018 long_name_mod: regrid: 7 day on T@MOD
np.arange(1, 365, 7)
array([ 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 120, 127, 134, 141, 148, 155, 162, 169, 176, 183, 190, 197, 204, 211, 218, 225, 232, 239, 246, 253, 260, 267, 274, 281, 288, 295, 302, 309, 316, 323, 330, 337, 344, 351, 358])
q2m.assign_coords(time=q2m.time.dt.dayofyear)[:, 0, 0].plot()
q2m.assign_coords(time=q2m.time.dt.dayofyear)[:, 0, 0].reindex(time=np.arange(1, 366), method='nearest').plot()
[<matplotlib.lines.Line2D at 0x7f296577fc18>]
q2m.assign_coords(time=q2m.time.dt.dayofyear).reindex(time=np.arange(1, 366), method='nearest')
<xarray.DataArray 'q2m' (time: 365, latitude: 361, longitude: 576)> [75896640 values with dtype=float64] Coordinates: * time (time) int64 1 2 3 4 5 6 7 8 ... 358 359 360 361 362 363 364 365 * longitude (longitude) float64 -180.0 -179.4 -178.8 ... 178.1 178.8 179.4 * latitude (latitude) float64 -90.0 -89.5 -89.0 -88.5 ... 89.0 89.5 90.0 Attributes: long_name: Weekly-mean 2-meter specific humidity from MERRA2 units: kg/kg history: From /tigress/samueltb/MERRA2/Daily/merged/QV2M/... climatology_time_range: JAN-1980:AUG-2018 long_name_mod: regrid: 7 day on T@MOD
%%html
<script src="https://cdn.rawgit.com/parente/4c3e6936d0d7a46fd071/raw/65b816fb9bdd3c28b4ddf3af602bfd6015486383/code_toggle.js">
</script>