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.18-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7851c6f92e9c832ae81ce6cf819fecd821357b68ba0c215a7765bcc0836ea4ed |
|
MD5 | 30df2520fc23fa11dd1f04176cb1849e |
|
BLAKE2b-256 | 6622cac6d2c018847339d1b67a423246e0ca98ead8f7c65070c627a8727bb11b |
Hashes for PyPartMC-0.0.18-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c5da2332eb3253823d80cae6ed049ad273f31aaa37198035830934363840003 |
|
MD5 | 0f7f769ced9b3e45e0847f0412b79a69 |
|
BLAKE2b-256 | d2a80eef6380fcb965b3ccf457d4de526811902053778e604ffe9fcd6037ff65 |
Hashes for PyPartMC-0.0.18-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ca0960d958f2eb81a6694346bead7b2d6c6cc81cc8237e858eff47058071fe2 |
|
MD5 | 922383b20a78b9b109989cf5bd861e53 |
|
BLAKE2b-256 | b0a6c6587a9e984d6fe2c4316ba14287a3dc90d7250a4f38fa420fc68f255c77 |
Hashes for PyPartMC-0.0.18-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d4a99c8f4e6bcd747ddd50584193a03155479100bed74d59161529becf2e6d7 |
|
MD5 | 1fa61c07c6543c9b28d52d14e55bffe6 |
|
BLAKE2b-256 | 15e8e4813bdfc4267a81e56e9dbf33123eee190a1cdc866bbb04be7ac9c4f5c7 |
Hashes for PyPartMC-0.0.18-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b2a1e37e804772421d3ae9dd454a2efd293e991ee28b21958d78ffef50511f9 |
|
MD5 | 042e7562fb6c0976c348eddd866d4994 |
|
BLAKE2b-256 | 669d7e80d8902d4d5e3a8225b6b99806dbe96aad0313c62c796806f5f524481a |
Hashes for PyPartMC-0.0.18-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35d5f0580586d669f4d4feac159d3ff62ca63d8b8c154908b33bad1115a5f21e |
|
MD5 | 0c730e6dda16d8bb0589b54ff8f5a7e5 |
|
BLAKE2b-256 | 9e82da67a1260d93d595af93b6469d5192dcc9d3fe2645a554f3a461a56df59c |
Hashes for PyPartMC-0.0.18-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb4b39d9767252e4de02aa5bdb6b6c47dd9b948ea5201ea04884a0f32f5a33b9 |
|
MD5 | e295d4bbec78fd5aa29fd465f25ef516 |
|
BLAKE2b-256 | 404c9a4128b33dc7a47e6938537b1afa2c8569e972c22a1c6a796d920d3b4ff1 |
Hashes for PyPartMC-0.0.18-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e1cc261e7e8b9326598564b1f1aa527fc8ab8caa73e3504a2251d38c1c03315 |
|
MD5 | 41e4f5d14c96d42c269076e9a7fa2dcb |
|
BLAKE2b-256 | bbfe5c0d2c18a30b761d7fc7f2d8fa79e69da01297dc1e38a290c5ff671d00a8 |
Hashes for PyPartMC-0.0.18-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13aa563fd4c31fa0a49f3f6f8473daa32cb254f7bdb8fb48f911e7cfb8c5aab3 |
|
MD5 | b4674ad41c236b9a69536d741d731430 |
|
BLAKE2b-256 | 5ab495c9aae5adb7782a933e5321d1dab847c9048e5cd558af5389f844d4b6ad |
Hashes for PyPartMC-0.0.18-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b72ba0bbfc1ebde79a8dbe4e7904ba7d58834556ae3aab94aa9751a9bca034eb |
|
MD5 | 726ab090059bbc0dc8f37d71be13b4d6 |
|
BLAKE2b-256 | 517c23a800f9a51530b756755420cadc4603bd3e217493651062024e74cf5ab8 |
Hashes for PyPartMC-0.0.18-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a32c1e53801cce0a97d6be6119b14f1ccfb5ea141424101c5dffabcb43d8263d |
|
MD5 | 1c53d8d170f29aa41823ed829fc836f3 |
|
BLAKE2b-256 | c4293e4e19c3f2f0b2a10400f06a0a87fa886b21846e2fc0dc09b4f0bf8c8b63 |
Hashes for PyPartMC-0.0.18-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b2b8daa6e712b1c67d86b884e2c6d2b31590a0edadea1171d5b9f609dd43ea6 |
|
MD5 | c0638dd72a542bca09d4a670c56172e6 |
|
BLAKE2b-256 | 5c99a95e03c76a70da83b17bdfcea7aea399d9252ccbbcfac4017dbaca3d77f2 |