Python interface to PartMC
Project description
PyPartMC (pre-alpha!)
PyPartMC is a Python interface to PartMC, a particle-resolved Monte-Carlo code for atmospheric aerosol simulation. Since PyPartMC is implemented in C++, it also constitutes a C++ API to the PartMC Fortran internals; the Python API can be used from other environments - see, e.g., Julia example below.
TL;DR (try in a Jupyter notebook)
! pip install PyPartMC
import PyPartMC
Features
- works on Linux, macOS and Windows (compatibility assured with CI builds)
- hassle-free installation using
pip
(prior PartMC installation not needed) - works out of the box on mybinder.org, Google Colab and alike
- ships with a set of examples maintained in a form of Jupyter notebooks
- Pythonic API (but retaining PartMC jargon) incl. exceptions and GC deallocation of Fortran objects
- code snippets in README depicting how to use PyPartMC from Julia (also executed on CI)
- auto-generated docs on the web
- support for [de]serialization of all exposed structures using JSON
- based on unmodified PartMC code
- does not use or require shell or netCDF Fortran library
- aiming at 100% unit test coverage
Usage examples
example object instantiation in Python
import PyPartMC as ppmc
print(ppmc.__version__)
gas_data = ppmc.GasData(("H2SO4", "HNO3", "HCl", "NH3", "NO", "NO2"))
example object instantiation in Julia
using Pkg
Pkg.add("PyCall")
using PyCall
ppmc = pyimport("PyPartMC")
print(ppmc.__version__)
gas_data = ppmc.GasData(("H2SO4", "HNO3", "HCl", "NH3", "NO", "NO2"))
Jupyter notebooks with examples
See the PyPartMC-examples project.
usage in other projects
PyPartMC is used within the test workflow of the PySDM project.
Implementation outline
- PyPartMC is written in C++, Fortran and uses pybind11 and CMake.
- JSON support is handled with nlohmann::json and pybind11_json
- PartMC and selected parts of SUNDIALS are compiled during
pip install
and statically linked - C (SUNDIALS), C++ (pybind11, ...) and Fortran (PartMC, CAMP) dependencies are linked through git submodules
- a mock of Fortran netCDF API and a mock of PartMC spec file API are used for i/o from/to JSON
Troubleshooting
Common installation issues
error: [Errno 2] No such file or directory: 'cmake'
Try rerunning after installing CMake (e.g., apt-get install cmake
or brew install cmake
)
No CMAKE_Fortran_COMPILER could be found.
Try installing a Fortran compiler (e.g., brew reinstall gcc
)
Notes for developers
How to debug
git clone --recursive git+https://github.com/open-atmos/PyPartMC.git
cd PyPartMC
DEBUG=1 VERBOSE=1 pip --verbose install -e .
gdb python
(gdb) run -m pytest -s -vv -We -p no:unraisableexception tests
Pre-commit hooks
PyPartMC codebase benefits from Pylint, Black and isort code analysis (which are all part of the CI workflows where we also use pre-commit hooks. The pre-commit hooks can be run locally, and then the resultant changes need to be staged before committing. To set up the hooks locally, install pre-commit via pip install pre-commit
and set up the git hooks via pre-commit install
(this needs to be done every time you clone the project). To run all pre-commit hooks, run pre-commit run --all-files
. The .pre-commit-config.yaml
file can be modified in case new hooks are to be added or existing ones need to be altered.
Credits
PyPartMC:
author: PyPartMC developers
funding: US Department of Energy Atmospheric System Research programme
copyright: University of Illinois at Urbana-Champaign
licence: GPL v3
PartMC:
authors: Nicole Riemer, Matthew West, Jeff Curtis et al.
licence: GPL v2 or later
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for PyPartMC-0.0.27-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16f63dafa2fbf70683a6433e91ea193d18c1dca28752cb57fdc6cbf975953c32 |
|
MD5 | ea5637898331cb0ae8d71dafac779c97 |
|
BLAKE2b-256 | 3ba93f3982dae7423c47a3dd5842ee296021389203d8c0687460cfde310d56e7 |
Hashes for PyPartMC-0.0.27-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 616df1cfebda2ba2ad171fffb42b876f1a24b51f5b775412479bee43fc841aa6 |
|
MD5 | 9acd939a8e58ba13a235d2d3c35f25ca |
|
BLAKE2b-256 | b5c6680b72008c7b915464350eacc9b67ff11eaec05706e1acb9c00e07e2eaba |
Hashes for PyPartMC-0.0.27-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14c62b2f8f3e6429ba61812d3359183b0fe470a2c290293623473c1f06353521 |
|
MD5 | 47eecddac8eeb6ed51832aba0e9480d4 |
|
BLAKE2b-256 | ac4084bd3aafb5f59060720609767ef565c8535267b91aa69255d04556dbefcc |
Hashes for PyPartMC-0.0.27-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdf5ac96b082236f62c603017768a7314f6cbe8faf54d74e8a10f6aa1de83e9b |
|
MD5 | 16049ec81a9c2f23b200bf25cc86a075 |
|
BLAKE2b-256 | ced6ffbbe5b8863642942ededce1c5c34dbccb8c79a2ee134b13363c53d8a290 |
Hashes for PyPartMC-0.0.27-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 488c5c9ba008f87b0d7d96fc890a23baec5a3602ff87cadea18df8f05437ea26 |
|
MD5 | e9400eb5cd6bbab02f67b5c4f1d6a4b0 |
|
BLAKE2b-256 | 0c767f0003b576a7d48ec43e03ab014fd20b1e3e589cc11e086c1c8b77b9f201 |
Hashes for PyPartMC-0.0.27-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a512466070602b5859c3eccc57e425393f8ebe5aee9ea64f1b1c261e1ccfae2b |
|
MD5 | f9e229eda32e5cbae34ef6b582f73d0a |
|
BLAKE2b-256 | 92c3f48c451f03a691bbf1e23e7c596a7892bf2dea43c1fcbcbc00ceed3c740b |
Hashes for PyPartMC-0.0.27-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8938a9ead18e85da2342fc83db8e81bdadc7677ff66fda5d64736c9d46a56e39 |
|
MD5 | 010ea5f0569e1418332a82178a638450 |
|
BLAKE2b-256 | dfb1a1ab6a61a278926543a16fed78c986f0cefc4427ab715c863280863d5659 |
Hashes for PyPartMC-0.0.27-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78eb1c79990c4d2224652b63dc714011b301d018c7915a1a1fa379cbcd0ec828 |
|
MD5 | d76a138076bde00e2f1c27419b300d2f |
|
BLAKE2b-256 | 9e0b90c6bd49e7f793727bb6244fd55d2bbf09a6b9f7d2e012df95a56c7c46c1 |
Hashes for PyPartMC-0.0.27-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 950aacdc104c97d16eb863b0a3041eb817b15bd322ef44c171608c488bd44bca |
|
MD5 | 9a95aed9bec88d44288a292e98a3d0a4 |
|
BLAKE2b-256 | da6b2aabfbc696ace319c4483dad1a40228cdb815798c7b83134fbaf893c1070 |
Hashes for PyPartMC-0.0.27-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cbc870cb40c6ecca02cec28fe1591fa9dc6bed509de6ce2b60411d73acbbf5a |
|
MD5 | 884a80de20c213d1c4b0f24c7688bacc |
|
BLAKE2b-256 | 926d5e1f52af577fb80ac0bd014f96802eb8d3a1d75938d8f1cf283882d76041 |
Hashes for PyPartMC-0.0.27-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96ba680706ef5cce6f4d7f538913c6aa5d91f8801f5eaadbffaad82f82bf0630 |
|
MD5 | 80ff5c760c5376865c1378f08f33d457 |
|
BLAKE2b-256 | 6627ec6611c9ee08777d6d8cc4966f9575a2ec08de5695f8ed1c1300d55794a9 |
Hashes for PyPartMC-0.0.27-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b24e5f825aaf2a5e7ff15e386ed359dd5751ac2403c3ec423a2da9abbc87ba40 |
|
MD5 | 044562c4fdf3f805f188e6964f2f710f |
|
BLAKE2b-256 | a7383a92e8c0c3128f7e7c59efa1fb2594830ac207127fa77423ef18365e1a1d |
Hashes for PyPartMC-0.0.27-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a76e35acaf9a253ed56bb4b00e8e3ef08d041027ff4ebc19b967aa013784694f |
|
MD5 | c6afcb59b5d0254a0611b3e76c9ff820 |
|
BLAKE2b-256 | 66f119b190cd3fa091a7cbf79e1bc01b919d956a5550c7ad77f17fa439ebf88d |
Hashes for PyPartMC-0.0.27-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91bfa589474c10ec983f0b8ac64377ce915b9efb761b26bc334f3a986dbebabe |
|
MD5 | a826559fa63aca7ecc8d91bec6f04396 |
|
BLAKE2b-256 | 0b31456cd52a7737087a434b9d3c3538452e5d6c005e33fce9c4567a4d48b519 |
Hashes for PyPartMC-0.0.27-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6ffe0655908839bbeab4b4fd5b100985297d40270fdc454d517d3f8eb7e03d5 |
|
MD5 | fc1e6de44a7c471cf9713557320b877d |
|
BLAKE2b-256 | 43fdcf509aa9df359700527920f0120b4f6b8550345260256e12f774ae9a97e9 |