hector简单气候模型的python包装器
pyhector的Python项目详细描述
pyhector是用于简单全局气候的python接口 碳循环模型Hector。
pyhector使简单的气候模型hector易于安装 可从python中使用,例如可用于 综合评估模型中的缓解情景,复杂气候 模型仿真和不确定性分析。
{ { } }是用C++编写的,并且 在Pacific Northwest National Laboratory开发。型号说明发布在Hartin, C. A., Patel, P., Schwarber, A., Link, R. P., and Bond-Lamberty, B. P.: A simple object-oriented and open-source model for scientific and policy analyses of the global climate system – Hector v1.0, Geosci. Model Dev., 8, 939-955, doi:10.5194/gmd-8-939-2015, 2015.
见赫克托耳repository和 wiki继续 信息。
python接口pyhector由Sven Willner和Potsdam Institute for Climate Impact Research处的Robert Gieseke开发。
pyhector使用pybind11来包装 赫克托的API。使用的hector版本可以使用pyhector的 __hector_version__字段。
安装
先决条件
Hector需要Boost,因此要安装并使用pyhector 拥有boost版本的文件系统和系统模块 安装1.52或更高版本(另请参见Hector build instructions)。
在ubuntu/debian上,可以通过调用
sudo apt-get install libboost-filesystem-dev libboost-system-dev
在macos上,boost可通过自制包管理器获得,它 建议使用自制安装的python进行安装 pyhector:
brew install boost
原则上支持Windows,但尚未测试 pyhector。带有Windows安装说明的请求是 欢迎。
用法
此存储库还包含一个Jupyter Notebook您可以run live和 实验,由Binder提供 项目。笔记本可以看作是static version 使用nbviewer。
基本示例
importpyhectoroutput=pyhector.run(pyhector.rcp26)
高级示例
importpyhectorfrompyhectorimportrcp26,rcp45,rcp60,rcp85importmatplotlib.pyplotaspltforrcpin[rcp26,rcp45,rcp60,rcp85]:output=pyhector.run(rcp,{"core":{"endDate":2100}})temp=output["temperature.Tgav"]# Adjust to 1850 - 1900 reference periodtemp=temp.loc[1850:]-temp.loc[1850:1900].mean()temp.plot(label=rcp.name.split("_")[0])plt.title("Global mean temperature")plt.ylabel("°C over pre-industrial (1850-1900 mean)")plt.legend(loc="best")plt.show()
开发
对于本地开发,您可以克隆存储库,更新 依赖项并安装在具有pip的虚拟环境中。
git clone https://github.com/openclimatedata/pyhector.git --recursive
cd pyhector
python3 -m venv venv
./venv/bin/pip install --editable .
要更新pyhector和所有可以运行的子模块
git pull --recurse-submodules git submodule update --init --recursive ./venv/bin/pip install --editable .
可以使用
在本地运行测试python setup.py test