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"))
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.1.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61e1e3f5ad63e26dfbb47177e5a474537e75ff5dc6559a5943c5a9dde2838efb |
|
MD5 | 5e1c818572b9a47d6b8a3d4f74fe1785 |
|
BLAKE2b-256 | fe980cd688e32b56f98aa84ce9c16809f324ff031776b1f8eb2d44ec3c30e0c0 |
Hashes for PyPartMC-0.1.0-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f25e6047af1fe5909347ecfd168f3fe9350334c70d68d158070c408f80f8206 |
|
MD5 | 25d1ab2bd6eeffdce57b679f5dfdfe43 |
|
BLAKE2b-256 | 8735045ff6bfca54f86aea8bd5f38cdfd4809a259e256a3cc105bb60fd0c038c |
Hashes for PyPartMC-0.1.0-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30037a0fcd5ef19d14c961a8c77bf742c0e862a40f0343e93320f5c2b58de659 |
|
MD5 | bdd0279209ca5ba7dfae3cac9b040731 |
|
BLAKE2b-256 | d307eccd222377779479d6e09e3a611f93300ce0816a87266eb68308046693a9 |
Hashes for PyPartMC-0.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dc461898a2180002715413f70f101dc467cd2722858d5d37c6e6c8510301344 |
|
MD5 | 49757da1b4b3d83b2aa2c8c4e4247695 |
|
BLAKE2b-256 | cb20b3086624ed2080ce95eb39301b3f7aaec4caa3c630d88c0c74ad40466bc6 |
Hashes for PyPartMC-0.1.0-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9285d10c6c769b46a9e12da05e856b063017636c4dc78c3fe13403f813a6ba27 |
|
MD5 | cef9e885cef87dacf63f5d253dd1eb47 |
|
BLAKE2b-256 | 9385262b44c0e77e5a8bebb9790e5e0ca961d8c3ebedbc1315711f48cae0076c |
Hashes for PyPartMC-0.1.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5da3c02242bde05b7f207adeaac2ce51dae4d63ae3740dce5902850710835550 |
|
MD5 | 136fd695183310e31c853e4608e2f475 |
|
BLAKE2b-256 | e7193e15a55323c3889e30bf7ba40eb913098fe850cba744edf4dacf0bfb209d |
Hashes for PyPartMC-0.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62cf4cb7c5f2f88e7c76eed78fbeba6bd34c170d0ba5f46357a222ebe6adbcb9 |
|
MD5 | 51daf1177204e93230854197ca2eb003 |
|
BLAKE2b-256 | f0dac834e96853d8e74ec687650ea0f5ec34a3664f3a6a8c7cd59b24c2bdde91 |
Hashes for PyPartMC-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51d50e21c75c1ed8d00bcebf9bef62083a20218a1a559c5b293719c3ce5b2cce |
|
MD5 | c1dce3cfa272bb380ad35f553a61a785 |
|
BLAKE2b-256 | 91c71e69d6fdde6389be3399f3c35d59cccb46185db73d6937929f85139253fb |
Hashes for PyPartMC-0.1.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 600f72eec643e76427cc82de649f36c03ef9a71cc369ab1f769cb116f935ca45 |
|
MD5 | 3ca7578ba8ca8bd1474d7171cf84e5df |
|
BLAKE2b-256 | b6021e18fe63cc6b2299921474fa5d09e77daef297f8efb803b9288b782d269a |
Hashes for PyPartMC-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 010dffc5ac0163ab6012c970bd314124ec6e5de251381106ace081216840cf2d |
|
MD5 | 43c53157241bf2f6b5b7fd0b17fb93af |
|
BLAKE2b-256 | b8789275de44755356dd9a9242ce33a446015b4e04c431bb27157999df84abbb |
Hashes for PyPartMC-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7405811eb07292ecf3568d11eec1ed26677b90bc6cb7cfa3445314fb5a85d1b |
|
MD5 | 995af6d6a048c5e0cdf90011f14f1094 |
|
BLAKE2b-256 | ff88a26a7d4cd690f29ef0f40930bf39ed8fc4df4cc0808129a3c29d1c674b15 |
Hashes for PyPartMC-0.1.0-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a238a163bb50b624237c15b688b4ae64671610de2081c4a6a550fc0eff2862e |
|
MD5 | 18d563034df349ceb8a35babcfa4672d |
|
BLAKE2b-256 | 51931198c24cadeefbe0ade12c01005992875f8a721cea60d3e479544c73e6ae |
Hashes for PyPartMC-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1e53ea183b3e757902b16692e08492fdf13fc0fd15cdc4d4c0b3a26b6407e4e |
|
MD5 | c6609f6ca36f1b1ba1725a73b8d55341 |
|
BLAKE2b-256 | ef68e60fe27a967f519feca8c746b726db37bd17cd8e8aefa54c52f8889c08bb |
Hashes for PyPartMC-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 136e9dbb4aa6d5c6cd25b3282c2ab452714cb5fb38a895bb5f0c2c7c0285a89f |
|
MD5 | e42a01466b3a04f8601d5dacac31d08d |
|
BLAKE2b-256 | d091ef2e53ded516b3e5936c23b0dc59d5f4bccbb7c1e113a69db82cb814c341 |
Hashes for PyPartMC-0.1.0-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e390a016e813359cfe1599443f6eee0de9e4240b8e52e4bf204edbf096f0295 |
|
MD5 | bf8cea43c240577f12312ae95bb243ef |
|
BLAKE2b-256 | 695f79721172451f7f1b15c3cfb86d73a23232035fb73b2a2a73124c580e8e62 |