Skip to main content

PyPI Version

PyPI Python Versions

Docs

Launch Binder

JOSS

Zenodo

pyhector is a Python interface for the simple global climate carbon-cycle model Hector.

pyhector makes the simple climate model Hector easily installable and usable from Python and can for example be used in the analysis of mitigation scenarios, in integrated assessment models, complex climate model emulation, and uncertainty analyses.

Hector is written in C++ and developed at the Pacific Northwest National Laboratory.

See the Hector repository and documentation website for further information.

The Python interface pyhector is developed by Sven Willner and Robert Gieseke.

Pyhector uses pybind11 to wrap Hector’s API. The version of Hector used can be read using Pyhector’s __hector_version__ field.

Installation

Prerequisites

Hector requires Boost, so to install and use pyhector you need to have the filesystem and system modules of Boost installed (see also the Hector build instructions).

On Ubuntu/Debian these can be installed by invoking

sudo apt-get install libboost-filesystem-dev libboost-system-dev

On macOS Boost is available through the Homebrew package manager, it might be advisable to use a Homebrew installed Python for installing pyhector:

brew install boost

Windows is (as Hector) in principle supported but not yet tested for pyhector. Pull request with installation notes for Windows are welcome.

Install using pip

You can install pyhector from PyPI by invoking

pip install pyhector

Usage

This repository also contains a Jupyter Notebook you can run live and experiment with, courtesy of the Binder project. The notebook can be viewed as a static version using nbviewer.

Basic example

import pyhector

output = pyhector.run(pyhector.ssp126)

Advanced example

import pyhector
import matplotlib.pyplot as plt
from pyhector import ssp119, ssp126, ssp245, ssp370, ssp434, ssp460, ssp534_over, ssp585

for ssp in [ssp119, ssp126, ssp245, ssp370, ssp434, ssp460, ssp534_over, ssp585]:
    output = pyhector.run(ssp, {"core": {"endDate": 2100}})
    temp = output["temperature.global_tas"]
    temp = temp.loc[1850:] - temp.loc[1850:1900].mean()
    temp.plot(label=ssp.name)
plt.title("Global mean temperature")
plt.ylabel("°C over pre-industrial (1850-1900 mean)")
plt.legend(loc="best")
plt.show()
Temperature Plot of RCP scenarios

Development

For local development you can clone the repository, update the dependencies and install in a virtual environment with pip.

git clone https://github.com/openclimatedata/pyhector.git --recursive
cd pyhector
python3 -m venv venv
./venv/bin/pip install --editable --verbose .

To update pyhector and all submodules you can run

git pull --recurse-submodules
git submodule update --init --recursive
./venv/bin/pip install --editable .

Tests can be run locally with

python setup.py test

Metadata

Release files for pyhector 3.2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyhector 3.2.0.0
File Size Uploaded
pyhector-3.2.0.0.tar.gz 5.6 MB Details

Release files / pyhector-3.2.0.0.tar.gz

Download URL pyhector-3.2.0.0.tar.gz
Size 5.6 MB
Tags Source
SHA-256 checksum
How to use checksums
9ff94e926b03b65f0f0b806d4f0ccbfdb421142d29256270f36ad91ba29257b4
BLAKE2b-256 checksum
How to use checksums
a0efedef7010d9d9242a583e0f616f3c1057a3dc87fad45bd8d8e00edd4d0151
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.8

Release history Release notifications | RSS feed

This release

3.2.0.0 This release

1 release file

2.5.0.2

1 release file

2.4.0.1

1 release file

2.3.0.0

1 release file

2.0.1

1 release file

2.0.0

1 release file

0.9.0

1 release file

0.8.1

1 release file

0.7.0

1 release file

0.6.0

1 release file

0.5.2

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.4

1 release file

0.2.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page