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
- Urban plum scenario demo (as in PartMC):
- Dry-Wet Particle Size Equilibration with PartMC and PySDM:
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"))
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.2.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b789344b7309649786d78d26b99b27f22010b020287cce9192e3d6107bd8866 |
|
MD5 | c04242ff152325de09d2e43552d75ca1 |
|
BLAKE2b-256 | 93000cf837d472f9d61fb16106105806a89c153a2eb55150e7d9fee8fc949034 |
Hashes for PyPartMC-0.2.0-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f1985c8a2181b904db875c88bb754239c910c12c5a44b55f452220cb768c3bf |
|
MD5 | 59fbe39d16f9d1b392666205496bac9e |
|
BLAKE2b-256 | 12168185fa2d123577fe855f0339c24174eed3c60fdba241422e29c3d899c820 |
Hashes for PyPartMC-0.2.0-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8553494d171ca989428d2423eb5dc3207191efef22558d66ee5c8e081b37b6ff |
|
MD5 | cd2015db71694b2139caeadfc28bb39d |
|
BLAKE2b-256 | 55ba305a313c87a841d9f0323a9390ba7dc4b35b5904407640442d481bc4815f |
Hashes for PyPartMC-0.2.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77c89109d872c6fc0abb551ff86463888fd67c159b9ad3be40e19b508d186cd3 |
|
MD5 | 97d4d8fb1b5d54c65692a26312500547 |
|
BLAKE2b-256 | 00a91332f299977b1c4f1f59cdd2c6a05db50327ab50896c9096fabab0b59d74 |
Hashes for PyPartMC-0.2.0-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b70227d5e19f1184cd5a88168b62a1c30cd9b1938f2e7faa0eb0427c32930d9c |
|
MD5 | 17a72c2adbdbd48fceba5716bb1b9c61 |
|
BLAKE2b-256 | 3711ccf5f63e56abee4026772584619a6a191b0a8ef201cdaa2aba9fa75e4da1 |
Hashes for PyPartMC-0.2.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfd76c90f7f661156015f6acae6cac8585ac4bc6dd7e9f1b47d52fd928117deb |
|
MD5 | 20a0515c041b6357186bd34828a2f65d |
|
BLAKE2b-256 | 0a4fd04e38b46318b3e5666174f51f0812786f0b71948cdfb1a91932c679b62e |
Hashes for PyPartMC-0.2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c112f0debbae2bec6cb566774a9e0ec4b1d457d5c444e4133981fc3e5955b3c |
|
MD5 | 7e5523296a7fa9d69b1fa84babe7ac59 |
|
BLAKE2b-256 | 6d3328acc6d901ec0d8f7dfdc88652825ba23b72ef9c831312b33b655d3ecb52 |
Hashes for PyPartMC-0.2.0-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21dd313bc98b713ed9eb1b5c5bbb467a9d718bc1b39f1976ab940be6631cecb6 |
|
MD5 | da83a09f01bfa2dc26e8630494bbf69d |
|
BLAKE2b-256 | f501ac47c7f22aa32391f2881085b88d768d2467d6191d3de197e0def0e1ed54 |
Hashes for PyPartMC-0.2.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b15c58fa65bf10cd2c28e29d5c55666b48b63b06556377406c21fc34e77c63fd |
|
MD5 | 8eccdfb21a7b4dc44a7a441a9c4aae4e |
|
BLAKE2b-256 | d9bed839902bf3e495578863dd9a9f127a4f34b797bf36631bc117bf96e84d72 |
Hashes for PyPartMC-0.2.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1541f81501ac9a89a3afb29e0dcda149368f55658ca65e2202c4efc666d132db |
|
MD5 | ab512cf45dc312c438e3e8d65fbab364 |
|
BLAKE2b-256 | c4cf612390c6d994626e7694bf37b06e100ce0e2566c8e8de5fb108839100ab6 |
Hashes for PyPartMC-0.2.0-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b47c92c635d9394843e07ef2af56abdb3bfc52ae33fdc1db59eba968c1a22925 |
|
MD5 | f717609c8d3a7581d4d90b76914cadc0 |
|
BLAKE2b-256 | 5f0e5e6ab48ac346100a981f078bfc6e3a62e2e2736a0527017c5a6e4bde0d13 |
Hashes for PyPartMC-0.2.0-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7867be53494d2791630bb970153d33b21318203bbdfcec1619295c58d45d747 |
|
MD5 | f39ce992c071571e469cfecf97e2c1cc |
|
BLAKE2b-256 | 8dd1d61080ab2e7d13701d11e90832ffe378726fb89e0cb4597c6d3daef95c8b |
Hashes for PyPartMC-0.2.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ba8d63a2cef737412dce783cb1931066eb15ff453a1e02c6072f38994b43e0d |
|
MD5 | 18ba1d1b7a1ba99fb9e87db4849561c5 |
|
BLAKE2b-256 | 59cad8ae2f61162094829e9a04cfeb039623d758eca1f67c4275ee5791bf3126 |
Hashes for PyPartMC-0.2.0-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fc745cf1e97a0d91f1689f6a2d384e5f147827627128dd4104c18b663d74ce5 |
|
MD5 | 1404dcc9a9f5ba3a4ebe88e39da9387e |
|
BLAKE2b-256 | 913859f6a5ba093eee8372d4467e8097eb7fa892a02798280dc7dc6fd21a0f39 |
Hashes for PyPartMC-0.2.0-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ce9de42a588d1fe4dd98339409c098de69b4c9fa7b1089b2fc7af3b60c08fee |
|
MD5 | 35952034875318d6255eb1f834b2c1dc |
|
BLAKE2b-256 | 4f93f50e6f209a34319db9c74facbc2f9125015ff6de8f0fae552a668c8fa875 |