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.31-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ac4e4f8be00746f6b6bd4fdc0595689f815a4768ff07e1f5c2b86b474e25f88 |
|
MD5 | 282b544208d50def892e1b8be17546df |
|
BLAKE2b-256 | 806967fe7bb36e8ad522511c630e5fb9187185879ab1933948d2787d91c2b389 |
Hashes for PyPartMC-0.0.31-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 609473503511e505f75bdf275b01273fdc070f504e10ee0ca6d301b2581c1b42 |
|
MD5 | 691aef9b526d21d75636957f4dfd83e8 |
|
BLAKE2b-256 | 4e8a862d565bfd6d3a02524a0d4991b5ee41cb39864bd415671f580e68e8e4cc |
Hashes for PyPartMC-0.0.31-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02e13dc74183c96c2d890a6ca350628c53484d64135fcb2e7e7a33c9a435aeb6 |
|
MD5 | 8906d7811ad066b27cecece8abeadfc8 |
|
BLAKE2b-256 | 718cf2f1a438a920f3ab75ef145586c55c699ded70e2c667840ba55a82de3e13 |
Hashes for PyPartMC-0.0.31-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 393bd377670f468bb2de67a75d6620cb136599c5025fa217bd257d7e366df30c |
|
MD5 | e4ac3162cf4b60f18b30c5fa89809664 |
|
BLAKE2b-256 | 066451ac3b835468455d1b70fc582780effa84d6345f647dc06c2eff47f5054b |
Hashes for PyPartMC-0.0.31-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d0cb168a03bf28dfea74b604392b9e7ec70ff1df8633d2374b17a847b1578b7 |
|
MD5 | c0fc889364e76eabd72847f91b8ff9f7 |
|
BLAKE2b-256 | e117f79243eefd18060ad88213f5889b986c8c24db266ce6cf8f810c145f5b8e |
Hashes for PyPartMC-0.0.31-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 139fe3220a82299752c6f005a3e1b29c09737b5b18f51bed9a0e2cbba546b3a1 |
|
MD5 | bcfdd869d3707399bf263f90d8dab69f |
|
BLAKE2b-256 | 7dc70d484a131c5773d7c99ffc084a58826b16be44f6230d657a21383ab04255 |
Hashes for PyPartMC-0.0.31-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f28fd1560de0646a4c4e932887ebecc159641df8d65948ff2fe1e48092903130 |
|
MD5 | b085d86a7766fe657f56bba01db7373f |
|
BLAKE2b-256 | aa2242dcd4ffa701d73e51af960a9850e2d4ea0d7d4680228152c60c561f1b89 |
Hashes for PyPartMC-0.0.31-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0b0e72bf22111e3f63147909da594806e3e8115622abad1b0b5ca225af04c9c |
|
MD5 | 81f5ccf7be020674085c97065cfe36c7 |
|
BLAKE2b-256 | de75e21f5e96223b52ad37948d3ea218e9b31eeb28a14e04cb31b02abcb2d57e |
Hashes for PyPartMC-0.0.31-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1408b449546a692e1e6e5f3e0302a9bbff559a2541a36dbef882cf5b15e50c81 |
|
MD5 | cb968e4221bf1afe9ab26e8da9c551ce |
|
BLAKE2b-256 | 59a1c2f2fde7b8f009c0832b2baf1b14219c1cea8b6e43bc1bfa3c16fac6fefd |
Hashes for PyPartMC-0.0.31-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8673d497aa661160175911d1780ffd7535c8d4c95c7387e37798b1492c665c2d |
|
MD5 | d3cf02fde5a0d7d323e624b79298ad94 |
|
BLAKE2b-256 | 5f71848043973a54da0b546090ab0295d2a3cfe3f61068dd80ff3d180df681f8 |
Hashes for PyPartMC-0.0.31-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53cd05c78c138a40a3e4598bdcf223885a51d90ab935bba20609464407af68d7 |
|
MD5 | a72c69ac4be745e9d099e95c1b4bae42 |
|
BLAKE2b-256 | 19d6619923d191d1b692ee3785c6b4700075d02e7759e1a2d6c54c6246956333 |
Hashes for PyPartMC-0.0.31-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52b5b14f682023a9e34f35a94d68e99382b4f26b012f2cb703329fdb5c2c7b2d |
|
MD5 | 1999bfabf9bb961bf0bb81760f225ce4 |
|
BLAKE2b-256 | ca20440de768caeddfb34bb1437b104b508ac96db132bde6e2dd864f5a3b2a68 |
Hashes for PyPartMC-0.0.31-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 124d16370d3bd39e9b7606aad6c7b848dd6c0596f740b07c074dd6010b9b1d83 |
|
MD5 | 4d51ae58185e0a654b6f1b1b527dfe4a |
|
BLAKE2b-256 | 8bbfd77bdffb53d2560e244462ed81a024f385829ab3d6ad6840e9e410cf02eb |
Hashes for PyPartMC-0.0.31-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 358a3861a9a3126901e240255847d23b4fab64726501de2002210093ae1c5277 |
|
MD5 | 067a6a3b35a1fe37a0f62a989f4f37a8 |
|
BLAKE2b-256 | 84ab34313835729eec1b3d9d8a433bfa56d97b8988796a6aff19629e53975e31 |
Hashes for PyPartMC-0.0.31-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc7ebfbfb085786777de9210b47f35b461a69153ee0859a5975626b1055eebbd |
|
MD5 | 7d20ff043d2a259286750da14072a697 |
|
BLAKE2b-256 | ad498782e285883258cc007396b16c9dda51a0cd27175b01032dfe66c3003487 |