本文整理汇总了Python中importlib.machinery.SourceFileLoader.f_z方法的典型用法代码示例。如果您正苦于以下问题:Python SourceFileLoader.f_z方法的具体用法?Python SourceFileLoader.f_z怎么用?Python SourceFileLoader.f_z使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类importlib.machinery.SourceFileLoader
的用法示例。
在下文中一共展示了SourceFileLoader.f_z方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: example_scipy
# 需要导入模块: from importlib.machinery import SourceFileLoader [as 别名]
# 或者: from importlib.machinery.SourceFileLoader import f_z [as 别名]
def example_scipy(model_id):
# ----------------------
# import odes
# ----------------------
py_file = os.path.join(in_dir, "{}.py".format(model_id))
from importlib.machinery import SourceFileLoader
ode = SourceFileLoader("module.name", py_file).load_module()
# ----------------------
# APAP simulation
# ----------------------
# Simulation time
T = np.arange(0, 24, 0.01)
x0 = np.empty_like(ode.x0)
x0[:] = ode.x0
p = np.empty_like(ode.p)
p[:] = ode.p
# set PODOSE_apap
x0[ode.xids.index("PODOSE_apap")] = 5600
# Integration
X = odeint(ode.f_dxdt, x0, T, args=(p, ))
# Solution DataFrame
s = ode.f_z(X, T, p)
# plot results
fig, (ax1) = plt.subplots(nrows=1, ncols=1, figsize=(5, 5))
fig.subplots_adjust(wspace=0.3, hspace=0.3)
ax1.plot(s.time, s.Mve_apap, color="black", label="scipy")
ax1.set_ylabel('Paracetamol [mg/l]')
for ax in (ax1,):
ax.set_title(model_id)
ax.set_xlabel('time [h]')
ax.legend()
fig.savefig(os.path.join(out_dir, "{}_apap_scipy.png".format(model_id)), dpi=300, bbox_inches="tight")
plt.show()
# ----------------------
# bicarbonate simulation
# ----------------------
T = np.arange(0, 5, 0.01)
# Change parameters & initial amount/concentration (in copy)
x0 = np.empty_like(ode.x0)
x0[:] = ode.x0
p = np.empty_like(ode.p)
p[:] = ode.p
# set PODOSE_apap
x0[ode.xids.index("IVDOSE_co2c13")] = 46.5
# Integration
X = odeint(ode.f_dxdt, x0, T, args=(p,))
# Solution DataFrame
s = ode.f_z(X, T, p)
# plot results
fig, (ax1) = plt.subplots(nrows=1, ncols=1, figsize=(5, 5))
fig.subplots_adjust(wspace=0.3, hspace=0.3)
ax1.plot(s.time*60, s.DOB, color="black", label="bicarbonate scipy")
ax1.set_ylabel('DOB []')
for ax in (ax1,):
ax.set_title(model_id)
ax.set_xlabel('time [min]')
ax.legend()
fig.savefig(os.path.join(out_dir, "{}_bicarbonate_scipy.png".format(model_id)), dpi=300, bbox_inches="tight")
plt.show()
# ----------------------
# MBT simulation
# ----------------------
# Simulation time
T = np.arange(0, 2.5, 0.01)
# Change parameters & initial amount/concentration (in copy)
x0 = np.empty_like(ode.x0)
x0[:] = ode.x0
p = np.empty_like(ode.p)
p[:] = ode.p
# set PODOSE_apap
dose_metc13 = 75
x0[ode.xids.index("PODOSE_metc13")] = dose_metc13
# Integration
X = odeint(ode.f_dxdt, x0, T, args=(p, ))
# Solution DataFrame
s = ode.f_z(X, T, p)
print(ode.pids)
Mr_metc13 = ode.p[ode.pids.index("Mr_metc13")]
recovery = s.Exhalation_co2c13 / (dose_metc13 / Mr_metc13) * 100 # [% dose/h] momentary recovery
cum = s.Abreath_co2c13 / (dose_metc13 / Mr_metc13) * 100 # [% dose] cummulative recovery
# plot results
#.........这里部分代码省略.........