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.29-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b70a5e1f8f4ce5182beb2c04566b3a0aec0207bad6113365e1d6107349307467 |
|
MD5 | 3b73ae4785e64672726b443ae53e5858 |
|
BLAKE2b-256 | 33bda93cbd822b1e2e8a878da16fbfcaf3d96ad8b754bd6c690f9f25123ce04c |
Hashes for PyPartMC-0.0.29-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a75950c7e17be197e59aca97a46de7b6c1e2ddcd759ff953f172e39e15e0cbc8 |
|
MD5 | 6dfa37d4446d6a00f7d049bb01628957 |
|
BLAKE2b-256 | b02e51a1855d1d928ea088c58188ed3cc4ffdf8526c17c7e7487ae19e01998c1 |
Hashes for PyPartMC-0.0.29-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 877ed65cad9221749cd39f991f86721bed441472440873c2fcb3a46e97e6afd6 |
|
MD5 | 9d37aaf6336c47e61fee63ee4266774f |
|
BLAKE2b-256 | a21005c92e7c1876ba0ebd623da74b42cd1fd8ed8fd8ee7630f4b1eb1b30150f |
Hashes for PyPartMC-0.0.29-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdcb82bb89ede6530d9df40bc040c707929805e1e9cbd1b4103519d304120e06 |
|
MD5 | 85a8bb0191c908660a10bdb49c75dbed |
|
BLAKE2b-256 | 57fce99d90f25e36e84074e286333277272988e4c26fb5bdbc0df7f701d10868 |
Hashes for PyPartMC-0.0.29-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 960eed35938934d60b3060efc1e94aa18a36493b157fe0cd4b9bc584c7488905 |
|
MD5 | cd2ae8deca61e549ff74145e507123d2 |
|
BLAKE2b-256 | 794f76f634ea6d393ebf1bb3bcabb5095976091c914d1d805758dda7720d6abd |
Hashes for PyPartMC-0.0.29-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cb75d4a70d7717c055c091d94525f92721b5ad0c3853745e3c7c4dc41336744 |
|
MD5 | fde98938314c43863c3c18a953c979ab |
|
BLAKE2b-256 | 54b23212b876dd2d061ad495de54faa3566bbabc52f27bedf92bce3c59cfb914 |
Hashes for PyPartMC-0.0.29-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b603a4bba8df8642760dbd89808132e1aadc6b49c5822f4052d4bcb3760a672 |
|
MD5 | 8e4f71cd8b0b4cb4e1f6018a622bdc93 |
|
BLAKE2b-256 | 15c402cbf8213362c1f4436e53c80b0f642a479babe25a23053b6d9a6120195b |
Hashes for PyPartMC-0.0.29-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adcd3d2b15fb7bc8d07f1e265ff5348a4cdab42f494335371288b15640d61de0 |
|
MD5 | 868556e4c55b34ed7cd31837620762af |
|
BLAKE2b-256 | f973e59c39c580bc279fd7f30faaa589eb795c33ce567de9eb7cdfa6b310d5aa |
Hashes for PyPartMC-0.0.29-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81b62128dd9fce75a359e0fd7a204c8b70ca670fffe44f44fd7c1f7b7a68c1bf |
|
MD5 | ba84b85d24b2c721d9e853d9c00c7237 |
|
BLAKE2b-256 | edf8db65b1b0e3660db0c8e989e26549c81737affd9f6c5423fd181779e01067 |
Hashes for PyPartMC-0.0.29-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba7d006055dfde92cc12afdebe467caef025bfd74b3b6dee7e34731d95d124c4 |
|
MD5 | b53025d9fb5ecd420297aa6427f0dd58 |
|
BLAKE2b-256 | d81642f800b1e31f488c55c0d025fa56d9cf778433376c1d36e121a95125a23b |
Hashes for PyPartMC-0.0.29-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe76b2f93a3030a9c945917f154f9be5e1995c3d0b999fcaf6116ba6e49e0628 |
|
MD5 | 07ed468fd97bf090d5518a2b8025caa7 |
|
BLAKE2b-256 | c4a5f54bb31af501f0c21873b294343b0432035cea20bb9bf5c32f5edb9c7c05 |
Hashes for PyPartMC-0.0.29-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f9bf144a23161ee9c7bb8c0acaa028bf9e0db20cab70362b515646a915da77f |
|
MD5 | ac8364086729a3955a8f34abfce78aee |
|
BLAKE2b-256 | ef567760ecbca0884d0ac5d62fb8d0c9ef68f441a26e836de0442c41259ba7f2 |
Hashes for PyPartMC-0.0.29-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 012f0451437a8ecc0645bd65176bd1bd87ccad600e1010072862df9438bfa543 |
|
MD5 | f8a09433edd5357c607cf0d71796affc |
|
BLAKE2b-256 | ee6234f9209bf9bdc106f804218b57e31ae43b955acbac7f13f8147eb43b5b9a |
Hashes for PyPartMC-0.0.29-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78699aaff87e9e3eb680fb67ddaf4037b1ce928d7f8db8546790d0ccd1bd30f8 |
|
MD5 | ad967f6462791ce25e1e7faaf6fbebc4 |
|
BLAKE2b-256 | 73c71fd16a54be96069c8dcb43ec16b2a01ab76072036420df7f4a8b178e02c9 |
Hashes for PyPartMC-0.0.29-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1731e195c8a0639030780913e901eb726a25ac004c8acf655b2fedbc9b0b1eba |
|
MD5 | a66e756a5aa8cc3e394de712b225198f |
|
BLAKE2b-256 | c5f3feaccafd2aaf506cf6fff72919d5a416b2d43d2a66c73dcab538901b9110 |