pyhector


Namepyhector JSON
Version 3.2.0.0 PyPI version JSON
download
home_pagehttps://github.com/openclimatedata/pyhector
SummaryPython wrapper for the Hector simple climate model
upload_time2024-03-06 10:18:11
maintainer
docs_urlNone
authorSven Willner, Robert Gieseke
requires_python
licenseGNU Affero General Public License v3
keywords climate model climate change
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            pyhector
========

+----------------+------------------------+
| |PyPI Version| | |PyPI Python Versions| |
+----------------+------------------------+
| |Docs|         | |Launch Binder|        |
+----------------+------------------------+
| |JOSS|         | |Zenodo|               |
+----------------+------------------------+

.. sec-begin-index

**pyhector** is a Python interface for the simple global climate
carbon-cycle model `Hector <https://github.com/JGCRI/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 <https://github.com/JGCRI/hector>`_ is written in C++ and
developed at the `Pacific Northwest National Laboratory
<https://www.pnnl.gov/>`_.

See the Hector `repository <https://github.com/JGCRI/hector>`_ and
`documentation website <https://jgcri.github.io/hector/>`_ for further
information.

The Python interface **pyhector** is developed by `Sven Willner
<http://svenwillner.com>`_ and `Robert Gieseke
<https://github.com/rgieseke>`_.

Pyhector uses `pybind11 <https://github.com/pybind/pybind11>`_ to wrap
Hector's API. The version of Hector used can be read using Pyhector's
``__hector_version__`` field.

.. sec-end-index
.. sec-begin-installation

Installation
------------

Prerequisites
~~~~~~~~~~~~~

`Hector <https://github.com/JGCRI/hector>`_ requires `Boost
<http://www.boost.org/>`_, so to install and use **pyhector** you need
to have the filesystem and system modules of *Boost* installed (see also the `Hector build
instructions <https://jgcri.github.io/hector/articles/BuildHector.html#standalone-executable>`_).

On Ubuntu/Debian these can be installed by invoking

.. code:: bash

    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**:

.. code:: bash

    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 <https://pypi.python.org/pypi/pyhector>`_ by invoking

.. code:: bash

    pip install pyhector

.. sec-end-installation
.. sec-begin-usage

Usage
-----

This repository also contains a `Jupyter Notebook
<https://jupyter.readthedocs.io/en/latest/index.html>`_ you can `run
live <http://mybinder.org/repo/openclimatedata/pyhector>`_ and
experiment with, courtesy of the `Binder <http://mybinder.org/>`_
project. The notebook can be viewed as a `static version
<http://nbviewer.jupyter.org/github/openclimatedata/pyhector/blob/main/index.ipynb>`_
using nbviewer.

Basic example
~~~~~~~~~~~~~

.. code:: python

    import pyhector

    output = pyhector.run(pyhector.ssp126)

Advanced example
~~~~~~~~~~~~~~~~

.. code:: python

    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()

.. image-start

.. image:: ./docs/example-plot.png
    :alt: Temperature Plot of RCP scenarios

.. image-end
.. sec-end-usage
.. sec-begin-development

Development
-----------

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

.. code:: bash

    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

.. code:: bash

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

Tests can be run locally with

::

    python setup.py test

.. sec-end-development

.. |PyPI Python Versions| image:: https://img.shields.io/pypi/pyversions/pyhector.svg
   :target: https://pypi.org/project/pyhector/
.. |PyPI Version| image:: https://img.shields.io/pypi/v/pyhector.svg
   :target: https://pypi.org/project/pyhector/
.. |Docs| image:: https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat
   :target: https://pyhector.readthedocs.io/en/latest/
.. |Launch Binder| image:: https://img.shields.io/badge/launch-binder-e66581.svg
   :target: https://mybinder.org/v2/gh/openclimatedata/pyhector/main?filepath=notebooks/index.ipynb
.. |JOSS| image:: https://img.shields.io/badge/JOSS-10.21105%2Fjoss.00248-brightgreen.svg
   :target: https://doi.org/10.21105/joss.00248
.. |Zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1194599.svg
   :target: https://zenodo.org/record/1194599

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/openclimatedata/pyhector",
    "name": "pyhector",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "climate model climate change",
    "author": "Sven Willner, Robert Gieseke",
    "author_email": "sven.willner@gmail.com, rob.g@web.de",
    "download_url": "https://files.pythonhosted.org/packages/a0/ef/edef7010d9d9242a583e0f616f3c1057a3dc87fad45bd8d8e00edd4d0151/pyhector-3.2.0.0.tar.gz",
    "platform": "any",
    "description": "pyhector\n========\n\n+----------------+------------------------+\n| |PyPI Version| | |PyPI Python Versions| |\n+----------------+------------------------+\n| |Docs|         | |Launch Binder|        |\n+----------------+------------------------+\n| |JOSS|         | |Zenodo|               |\n+----------------+------------------------+\n\n.. sec-begin-index\n\n**pyhector** is a Python interface for the simple global climate\ncarbon-cycle model `Hector <https://github.com/JGCRI/hector>`_.\n\n**pyhector** makes the simple climate model Hector easily installable\nand usable from Python and can for example be used in the analysis of\nmitigation scenarios, in integrated assessment models, complex climate\nmodel emulation, and uncertainty analyses.\n\n`Hector <https://github.com/JGCRI/hector>`_ is written in C++ and\ndeveloped at the `Pacific Northwest National Laboratory\n<https://www.pnnl.gov/>`_.\n\nSee the Hector `repository <https://github.com/JGCRI/hector>`_ and\n`documentation website <https://jgcri.github.io/hector/>`_ for further\ninformation.\n\nThe Python interface **pyhector** is developed by `Sven Willner\n<http://svenwillner.com>`_ and `Robert Gieseke\n<https://github.com/rgieseke>`_.\n\nPyhector uses `pybind11 <https://github.com/pybind/pybind11>`_ to wrap\nHector's API. The version of Hector used can be read using Pyhector's\n``__hector_version__`` field.\n\n.. sec-end-index\n.. sec-begin-installation\n\nInstallation\n------------\n\nPrerequisites\n~~~~~~~~~~~~~\n\n`Hector <https://github.com/JGCRI/hector>`_ requires `Boost\n<http://www.boost.org/>`_, so to install and use **pyhector** you need\nto have the filesystem and system modules of *Boost* installed (see also the `Hector build\ninstructions <https://jgcri.github.io/hector/articles/BuildHector.html#standalone-executable>`_).\n\nOn Ubuntu/Debian these can be installed by invoking\n\n.. code:: bash\n\n    sudo apt-get install libboost-filesystem-dev libboost-system-dev\n\nOn macOS *Boost* is available through the Homebrew package manager, it\nmight be advisable to use a Homebrew installed Python for installing\n**pyhector**:\n\n.. code:: bash\n\n    brew install boost\n\nWindows is (as Hector) in principle supported but not yet tested for\n**pyhector**. Pull request with installation notes for Windows are\nwelcome.\n\nInstall using pip\n~~~~~~~~~~~~~~~~~\n\nYou can install **pyhector** from\n`PyPI <https://pypi.python.org/pypi/pyhector>`_ by invoking\n\n.. code:: bash\n\n    pip install pyhector\n\n.. sec-end-installation\n.. sec-begin-usage\n\nUsage\n-----\n\nThis repository also contains a `Jupyter Notebook\n<https://jupyter.readthedocs.io/en/latest/index.html>`_ you can `run\nlive <http://mybinder.org/repo/openclimatedata/pyhector>`_ and\nexperiment with, courtesy of the `Binder <http://mybinder.org/>`_\nproject. The notebook can be viewed as a `static version\n<http://nbviewer.jupyter.org/github/openclimatedata/pyhector/blob/main/index.ipynb>`_\nusing nbviewer.\n\nBasic example\n~~~~~~~~~~~~~\n\n.. code:: python\n\n    import pyhector\n\n    output = pyhector.run(pyhector.ssp126)\n\nAdvanced example\n~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    import pyhector\n    import matplotlib.pyplot as plt\n    from pyhector import ssp119, ssp126, ssp245, ssp370, ssp434, ssp460, ssp534_over, ssp585\n\n    for ssp in [ssp119, ssp126, ssp245, ssp370, ssp434, ssp460, ssp534_over, ssp585]:\n        output = pyhector.run(ssp, {\"core\": {\"endDate\": 2100}})\n        temp = output[\"temperature.global_tas\"]\n        temp = temp.loc[1850:] - temp.loc[1850:1900].mean()\n        temp.plot(label=ssp.name)\n    plt.title(\"Global mean temperature\")\n    plt.ylabel(\"\u00b0C over pre-industrial (1850-1900 mean)\")\n    plt.legend(loc=\"best\")\n    plt.show()\n\n.. image-start\n\n.. image:: ./docs/example-plot.png\n    :alt: Temperature Plot of RCP scenarios\n\n.. image-end\n.. sec-end-usage\n.. sec-begin-development\n\nDevelopment\n-----------\n\nFor local development you can clone the repository, update the\ndependencies and install in a virtual environment with ``pip``.\n\n.. code:: bash\n\n    git clone https://github.com/openclimatedata/pyhector.git --recursive\n    cd pyhector\n    python3 -m venv venv\n    ./venv/bin/pip install --editable --verbose .\n\n\nTo update **pyhector** and all submodules you can run\n\n.. code:: bash\n\n    git pull --recurse-submodules\n    git submodule update --init --recursive\n    ./venv/bin/pip install --editable .\n\nTests can be run locally with\n\n::\n\n    python setup.py test\n\n.. sec-end-development\n\n.. |PyPI Python Versions| image:: https://img.shields.io/pypi/pyversions/pyhector.svg\n   :target: https://pypi.org/project/pyhector/\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/pyhector.svg\n   :target: https://pypi.org/project/pyhector/\n.. |Docs| image:: https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat\n   :target: https://pyhector.readthedocs.io/en/latest/\n.. |Launch Binder| image:: https://img.shields.io/badge/launch-binder-e66581.svg\n   :target: https://mybinder.org/v2/gh/openclimatedata/pyhector/main?filepath=notebooks/index.ipynb\n.. |JOSS| image:: https://img.shields.io/badge/JOSS-10.21105%2Fjoss.00248-brightgreen.svg\n   :target: https://doi.org/10.21105/joss.00248\n.. |Zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1194599.svg\n   :target: https://zenodo.org/record/1194599\n",
    "bugtrack_url": null,
    "license": "GNU Affero General Public License v3",
    "summary": "Python wrapper for the Hector simple climate model",
    "version": "3.2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/openclimatedata/pyhector"
    },
    "split_keywords": [
        "climate",
        "model",
        "climate",
        "change"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a0efedef7010d9d9242a583e0f616f3c1057a3dc87fad45bd8d8e00edd4d0151",
                "md5": "89d0c422e1def3fe4f579cdf4cd590f6",
                "sha256": "9ff94e926b03b65f0f0b806d4f0ccbfdb421142d29256270f36ad91ba29257b4"
            },
            "downloads": -1,
            "filename": "pyhector-3.2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "89d0c422e1def3fe4f579cdf4cd590f6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5626897,
            "upload_time": "2024-03-06T10:18:11",
            "upload_time_iso_8601": "2024-03-06T10:18:11.926378Z",
            "url": "https://files.pythonhosted.org/packages/a0/ef/edef7010d9d9242a583e0f616f3c1057a3dc87fad45bd8d8e00edd4d0151/pyhector-3.2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-06 10:18:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "openclimatedata",
    "github_project": "pyhector",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "pyhector"
}
        
Elapsed time: 0.20847s