Python interface to PartMC
Project description
PyPartMC
PyPartMC is a Python interface to PartMC, a particle-resolved Monte-Carlo code for atmospheric aerosol simulation. PyPartMC is implemented in C++ and it also constitutes a C++ API to the PartMC Fortran internals. The Python API can facilitate using PartMC from other environments - see, e.g., Julia example below.
TL;DR (try in a Jupyter notebook)
! pip install PyPartMC
import PyPartMC
Jupyter notebooks with examples
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. Python GC deallocation of Fortran objects
- specification of parameters using native Python datatypes (lists, dicts) in place of PartMC spec files
- code snippets in README depicting how to use PyPartMC from Julia (also executed on CI)
- auto-generated API docs on the web
- support for [de]serialization of selected wrapped 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 statically linked (and compiled in during
pip install
orpython -m build
) - C (SUNDIALS), C++ (pybind11, ...) and Fortran (PartMC, CAMP) dependencies are linked through git submodules
- MOSAIC dependency is optionally linked through setting the environmental variable MOSAIC_HOME
- 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:
authors: 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.35-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99293cef29b63d4966eb426496c2dd2b0e47b55596116ade6a6fd88c6c19b031 |
|
MD5 | 0cbc63e88ffc3612a839e32e4036f3db |
|
BLAKE2b-256 | a7e7f6cab11cedfa3d63d345eb42c79682c679608c4b6266a128b32bbd232375 |
Hashes for PyPartMC-0.0.35-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd5dcf69473b7c81ce1f3c695d72e3ab5c4dde8ba3ebfc32cae9cf84ab748adc |
|
MD5 | d9fb757fa71a54b38d1d017962b49aec |
|
BLAKE2b-256 | 9ce937a7219328a008866f42aad1f7fd5ecad5f74ecca6cf35073d6c1ab589a8 |
Hashes for PyPartMC-0.0.35-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 960eed9d306dd29fee96f2c712e99318154dff02d8d03ea74b4ded14bcd66fcd |
|
MD5 | cc0cb8265ef94107e00b7bedfd32df0f |
|
BLAKE2b-256 | d87104153f1c640c6d2887c817138a2b542f9534b10ccb7b359727e5e69722c5 |
Hashes for PyPartMC-0.0.35-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea7ac071d767104b5f6b124f80aff7a5afcb6a3d1764ce838526de058ea7f4c2 |
|
MD5 | 5e49991ae80d84309618bf45d76913f1 |
|
BLAKE2b-256 | 1068fe6b4379d807f6607f8f34c443687c72d6d3d33920253198147fe4678763 |
Hashes for PyPartMC-0.0.35-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07ed3378c60b38ed0d913f10eb0948f4c6c61922ede75f07745f2c098f26e145 |
|
MD5 | 845c8c74e5649e65d0ecd227ed511ac0 |
|
BLAKE2b-256 | 31125e918a23e3d342c72bccc6d8bd1e3cbf0ddde5347eccfee939e574682486 |
Hashes for PyPartMC-0.0.35-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40f15b0fdbea6d5c3416c130f99a615c382b1ea45070cfa6451e8e415136d45b |
|
MD5 | 21cbb259d93f88546460b461fa8908cf |
|
BLAKE2b-256 | ccf74ddbdbcb847d0515b0d867e4d4d5787e9894c62270b17508f7b7c9075bcb |
Hashes for PyPartMC-0.0.35-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 071b02e64edf2cda107a0cadd46601375c6fdb8149ee3eec1b6ac480d606c3f8 |
|
MD5 | 381563a77082cfb55a27755860fe2684 |
|
BLAKE2b-256 | feec2d8086bfec37f2c694a1a0c51d97cd78e53733e1d8d8cd79cebddcd50e40 |
Hashes for PyPartMC-0.0.35-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fef0feadfc6e386ab34915e4d1c56bd28dab6eada473207614a3401ef680ba17 |
|
MD5 | 972bb26e3ede48b64376fd6a81b642a5 |
|
BLAKE2b-256 | f073b3510b5b3ea6787e3af86153d66df41056baaa511249bfd4a50940f1d84c |
Hashes for PyPartMC-0.0.35-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecc89429ca5c02e487374442d33c8d26d96191ce276de139428a22c06fdf8abc |
|
MD5 | d92765034476e4a3a742de6277087b51 |
|
BLAKE2b-256 | a8f0f5079b1d7d1b319c8d5feaa683bb6dbf9431ea972ac9f0198b44a3d6c2b3 |
Hashes for PyPartMC-0.0.35-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a11ee20b2caffd6a4c6509e2bdda5739739d99036849ba62048d700b2030824 |
|
MD5 | 8098872b41be401f25503db99a2eae65 |
|
BLAKE2b-256 | cd3cd669970668b1d70ff83f2b4e15f24e594ce68e18b99851ffe3c36219babf |
Hashes for PyPartMC-0.0.35-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82915882be6d27a7a28bde6f5ec9f500a9af115680b64c619debbb83b73021d6 |
|
MD5 | 57a7a68a0a7eb0c88612f391494f1701 |
|
BLAKE2b-256 | 80b687a6495a21fed354e59a58f5357cf323d58fe07162271aec12ea9d1b7f2f |
Hashes for PyPartMC-0.0.35-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 756631899b0c1e8fc17c6acc9c5e663064a4b259a6cb07c1aa3f4a34e168a484 |
|
MD5 | ba0cd1f722d70155135af5d4ee5d6235 |
|
BLAKE2b-256 | c8391ee0502b9309381f35524e9b1d7b6725ce5aede8d2629ddddc3150c76004 |
Hashes for PyPartMC-0.0.35-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27d1894f0221d3ad8d4b1b85c164b7f541d722b768d41ce21ccf3d1ef919b225 |
|
MD5 | 6112ba679434fe5caf567c4fa1f64b57 |
|
BLAKE2b-256 | ab25d40b0cf447dcd1a6ba706da8bef8fed486bba839208fd996a132c6aa2f3f |
Hashes for PyPartMC-0.0.35-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8215ea2aa7e3ccc92088f7b6084afd41e75b37926e8a12efdcf9459b8be26c94 |
|
MD5 | 6c495a5cd7103b9e7c0534822e925da7 |
|
BLAKE2b-256 | e41076bb92552c148c578f1383acd84d8f0af48befc1bb7c4bf4fa91f3c776bf |
Hashes for PyPartMC-0.0.35-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74d1f307b5144d56f691fd964876bb467b06e23f7fb0ff8551f1154b55bedcc6 |
|
MD5 | ebb9244b9e66c153f8ac07c40b9acaf0 |
|
BLAKE2b-256 | 148261ef35d0f64261dafb3abac5f516ca23041d46a2ef43acb49266b4bf7a8c |