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
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.34-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0cd43568ab3f20c2977ddfe044986191b3d064268feb13ca41ff1e37dc11bae |
|
MD5 | 0f4fb375e13f173a08e414ab9ddee1f2 |
|
BLAKE2b-256 | b96d883be3f7d382e942b61b87a42df6fe5da8c8a48aa89ed95360503bcb0276 |
Hashes for PyPartMC-0.0.34-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 458fafb9b112367f2e31535cb7199c593fbaf78800dc21294237da5c524ff677 |
|
MD5 | a826b9a2dde36a267bf40ad9d216220b |
|
BLAKE2b-256 | 3256737e49c563e88aa28589f5412a32b6530b771389fb2cd0870590ad2a98c0 |
Hashes for PyPartMC-0.0.34-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33b49a92a4c851c31359cec9182a14f9b7e5bd793feec117e0268d3018fad018 |
|
MD5 | bb864fc3b6895dcd2174ddb526f36884 |
|
BLAKE2b-256 | c1b870ab9cb5562b2a8d8a791de00759c97de54e539fa6e2baa4dfd298f91a61 |
Hashes for PyPartMC-0.0.34-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b2bccbecd5bcbf592fc785a5214df8018413e502835c69a4e56ba51bd93a4b6 |
|
MD5 | 87b3463040eabd2e316abeed14be579b |
|
BLAKE2b-256 | c728718b8c4be506f32c4ca7d845c07151be6074d4af553f3c276640fc2b253e |
Hashes for PyPartMC-0.0.34-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cacfceb17bb9f0e7fc78fda51a5638f509b8d883960887b63f574b1a89e2f04 |
|
MD5 | 2d74104ef5fcf86ff066c10acb6a8e17 |
|
BLAKE2b-256 | 111503c560905df968fcb91bc33465b1ed88f2494cfbd124b9318315eed043f2 |
Hashes for PyPartMC-0.0.34-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7852e928d9e3dba5990d7d65c43da7868bb47ebd5c1b7c0d7c9a3fe02148ab6 |
|
MD5 | e1125872ead4b9743be1b1f67536fd20 |
|
BLAKE2b-256 | 69c0e58c1c2db3268beca03264f31f9dd4b1db2373baa00804a33284f46d28a0 |
Hashes for PyPartMC-0.0.34-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbd85e78300fed43744ac682bf7353dbf110d31a34a8d754d87b6396e32689d2 |
|
MD5 | d05c5933f91c930088cb9fe7e9d767c2 |
|
BLAKE2b-256 | e6393ca6fc8e998e73df49c7a035206aca884d194a98b15a88b9286a7e64383f |
Hashes for PyPartMC-0.0.34-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d612275678ae53644e6a7b1967b4612fb0e9c5b75f83284bae63b775a293a06 |
|
MD5 | 1c57a7ee23f71b6b96d59e6aebd0cb65 |
|
BLAKE2b-256 | c104414d4babafb8a69c5ad11962e6786ef24143049c7df0bef29f7dafdbfd16 |
Hashes for PyPartMC-0.0.34-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 024a87558e135dd2a8753b0d7f273e32e55c4688945a83294e430bf34c409ff0 |
|
MD5 | 51f0a004887c0e960093043269b0574c |
|
BLAKE2b-256 | 1639cb7bdf6ffa6667fb066add177bf6cf68a0db05996428a6a892c39f9cc17e |
Hashes for PyPartMC-0.0.34-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18dd073b8283b0aebd2bbbea1d14bfda551ca061c195ca67b22346883f2c19cf |
|
MD5 | d178abdf237affe3c67555770088a2a1 |
|
BLAKE2b-256 | 0c6328e3a26f9e018d17c31f9ee5300451c351f756f865cce8ddfb43b5fa26d1 |
Hashes for PyPartMC-0.0.34-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1ab1686142f321f0af9dceb3a2eab3009c81632163748f5f1200a5b99b221fe |
|
MD5 | d64fc97f1990751c8ecf09c092da123b |
|
BLAKE2b-256 | cbb446f01d806718106488bae3d42c1ba6c1be161f4628bf28cd5e88fe2158be |
Hashes for PyPartMC-0.0.34-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 079ba5eb1ae37ac1275455b398c5e6b6b341bb69f91e1219c3a08b51fe49e7ae |
|
MD5 | 4fc74ac592e390eaf898cb1645c1a76c |
|
BLAKE2b-256 | ecaffa19108b2cf7cddff1ac789c98fe20cad5da404c538841849f2d733b13fd |
Hashes for PyPartMC-0.0.34-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d220a711d8cd47cfc5ae29ee5904a4add6643354ade9454202bc2dcb21ddb008 |
|
MD5 | 85b9f4ea6956f19070b4b97bf08f7644 |
|
BLAKE2b-256 | 1196dbbe1279f65c1a92b134a4da6698b68a5fe0a0946a8a58a4d05b3d8de9ea |
Hashes for PyPartMC-0.0.34-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b79879d6de385f7233ff180d0572ed2415b45322ebfd0bae85c49c68e9c39d7c |
|
MD5 | 6aac4a018b2067361103a0f1686c7907 |
|
BLAKE2b-256 | bf1674ab96a6125f0aa86657d40f456ee5bb04842001ff8f819cfb46af754818 |
Hashes for PyPartMC-0.0.34-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eae12bab83860bfa2503cac35a65181de3c5fd2813058b1644e25523c3d76a27 |
|
MD5 | 8aa41107d999b319ec4ae80c3be3f763 |
|
BLAKE2b-256 | 2c10a7f1cda97c4ce8a3a863771c69386662558bc9768754686d36917889c0f1 |