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) 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
- a mock of Fortran MPI API is used for error handling using existing MPI API calls within PartMC
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
)
warning: no files found matching 'gitmodules/...
Since git clone was done without recursive option, try: git submodule update --init
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.20-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3551d16408231726fd16636af6dcfcc39224de7938fb7053b46ba213b39c6e1 |
|
MD5 | ae34471048d26d36f2865e235c258dbd |
|
BLAKE2b-256 | 66c725f6213356ad8255e629a90d0cc7bae6ef5b7bb51b8abd20bd1f720185c7 |
Hashes for PyPartMC-0.0.20-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a58f5ed570a5361352c152f0d40dc40915b8ad135ecbb0f4651e5416ca349f9f |
|
MD5 | ab13dc41ef02d63dbfb6a8ac44c078e4 |
|
BLAKE2b-256 | ca9e629039da0ea5f8c87044508f620bedc0ddf39e312a1be80c26c6dd31bfd9 |
Hashes for PyPartMC-0.0.20-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fae1b75cffe9719d27fa9c11d3adcd2178c32abd809c9032be68ff039acfca5 |
|
MD5 | ee65818d269ba17ab4f7a32c10992f6f |
|
BLAKE2b-256 | 7db5d874bca776f6dd5b86298b891e82d03b37609e05461eaeb802f121b3f243 |
Hashes for PyPartMC-0.0.20-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d6e91709176b3d2b0327c19cf6179ba18f3fe5ddca72447c60add043f38cff5 |
|
MD5 | 5b4b6169fbfb18d13ae1974f25bf7ec2 |
|
BLAKE2b-256 | cc04f532d47671b9d8ca8fb9a9838e028f449696a6ec0dcb6b438eb7492fde96 |
Hashes for PyPartMC-0.0.20-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b0f3ff834329c18c2f31f67c860d7298f93cc84b750cb859dcdc836667146c6 |
|
MD5 | 17bad1b78d28f9d52084ab51878c71d2 |
|
BLAKE2b-256 | 9330d7a1e8372f408d33aecc8b43abdd41c7bcbbfd201394bc63da85c790bcef |
Hashes for PyPartMC-0.0.20-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f3c9ca0db507f483e09f8fee40008d71b4f5027e09abcd7f906663d620d9638 |
|
MD5 | d960532e630f192cc7e9730ebcdf9012 |
|
BLAKE2b-256 | 9b76cde2b58bf2a44699b14c942d073c70b5a72e1092717f0fa01b91dcf4968e |
Hashes for PyPartMC-0.0.20-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2f41bfdaf37ef0735249243dce092348bb2b21f62978da89ca659fbe9c9f205 |
|
MD5 | bc20e2ac3ffbdee4333f0e905f78593c |
|
BLAKE2b-256 | d344211c43012534c7107ea43577c848bd9028116adbc28f55cd0c8e7bd15cfe |
Hashes for PyPartMC-0.0.20-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8154ceaa2e31a797804f00f3c38c959d9ea881d6bf115b15aea49dbd2595650d |
|
MD5 | 961f135427b48c78372e4d99d60b810b |
|
BLAKE2b-256 | eddb8a33c88eca473a14c3e701723b8b433867ab3bef75d1ecbc18dd4018e7c8 |
Hashes for PyPartMC-0.0.20-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec5a4baf934e46a54530630b48475e85a11f789004174f6ad2fb27cd6d993198 |
|
MD5 | f13309ad6c628ce320b35f87d743b306 |
|
BLAKE2b-256 | 66fe1de8e627e1f4b755ab574014b02b32b810998f530b9a6dfa6616758fa262 |
Hashes for PyPartMC-0.0.20-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96f3faec5db07d7ba2010cb372489941a924e9af458e7f81d3530be19201cc83 |
|
MD5 | 938772779bb58df4b33f8f7500ae1949 |
|
BLAKE2b-256 | 4b73e7cc9606ca83a46efe60675a794ca12dd77c2764d5da2669779befec2cd0 |
Hashes for PyPartMC-0.0.20-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b672c65a4db0b0235e95a526bd9c1e8042a0946ec2c28f179a46994221c4727b |
|
MD5 | 6d6e7b1e40521b7f16b0ef02d8a29d16 |
|
BLAKE2b-256 | c8b5c1c87fd80c81d82da24cdd1bfd80e45a3cc4551b9eee07f488ea8acbb689 |
Hashes for PyPartMC-0.0.20-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cc21cdc6125a8a1aae83a348252550e499e866017e065278bf7c4de90b4e0b4 |
|
MD5 | 136596c7bd66aae29e35f71dde2f8dcf |
|
BLAKE2b-256 | 3c2e9cc1820c42aba66edc01fbf4e87bf51873a4ca7780fc66c3657f4e560461 |