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, CAMP) 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
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:
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.25-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7212ec66706493a0475381adbd1f5c75b0fe928c32c4d556802c7dc64f6c8e9 |
|
MD5 | a63a44562e0071b8185f38bcf8ddbdf1 |
|
BLAKE2b-256 | 62e5cf803fe13c06c4c7f7f9d5c3294750383aaf6c44d7607cdecfd611085938 |
Hashes for PyPartMC-0.0.25-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de2fac869b040c47fef36c24b235c0309c2069e0c0d35665a596fb69df572865 |
|
MD5 | e16dff216cad5be0133148b484213c2a |
|
BLAKE2b-256 | ec8198beb1133714ca61d9c5d414acb81c781d720333b6b147b40068e58f5356 |
Hashes for PyPartMC-0.0.25-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2b83a76d1e0072e42ce2906bc3f7be876b9e683063534243b73353c01ea2085 |
|
MD5 | 36315180f03caf8b7c2a70b9eb3ea5f9 |
|
BLAKE2b-256 | 8fa794a6e42ba93d232eea204efbb7ae6fdc11619757312dd31ca09c313c3a41 |
Hashes for PyPartMC-0.0.25-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69126903a7f635e901a4b7db28dfb98467eba8245e16040d1d2fdda0c72ae343 |
|
MD5 | 4eeb1ffcada246950c80a4bfdd79deb1 |
|
BLAKE2b-256 | b35f222445c59978f3204abd1c58ea799f4c90258b9d70e42a5544147773a865 |
Hashes for PyPartMC-0.0.25-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22d9ad76c99ada04174898093caabb4a896f3c8b29a39a7c71a86f5a8eb2b0e7 |
|
MD5 | 43f1dfb6e88e6b2eca45a2fbaaaaf6dd |
|
BLAKE2b-256 | 8dc0c86e73eadd60309f1be193fa1d7739720c2b6ee7bbdd5208ccc0e76e938e |
Hashes for PyPartMC-0.0.25-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 937c3ae34398359b619d7c4527635d585664b7ec03e2ced90e3bdb32f1b78f76 |
|
MD5 | f669e021f0bc53a14fc4209aa6b41cfd |
|
BLAKE2b-256 | f48bf07cac40ba815d4f49f3789bd99cbdec656cb1eea249c4a7763acfdd73da |
Hashes for PyPartMC-0.0.25-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfc5664fae02fd3e6ca1f3cc5bf4422595387710b206696224bbb5e43e21babf |
|
MD5 | 64174e23c7c152be19ec4026e1e68e87 |
|
BLAKE2b-256 | 67cf2652e0e10445e6a5b40b593c37c8a1df46432e07ea8f4c38fa5a07f68d2b |
Hashes for PyPartMC-0.0.25-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8de697afb5201610e54bdac0bcf04f57f75dc2f4561be60e4348257dcd84aa0 |
|
MD5 | 632a089c8bf8352e988b01b4325f4c3d |
|
BLAKE2b-256 | 5c7782e4fde09a2d7ac933ba88c50a55935765b08ac4d86223e47dedb2fc2bf3 |
Hashes for PyPartMC-0.0.25-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7fa536e150572274761cda73aea0df75261408fdd03a8497ac6d4c7a1f7a43c |
|
MD5 | 33d3dcb1c7bd4ec48b98b6471871f228 |
|
BLAKE2b-256 | d618c0549cdf30f42eeeb38df29713e9622c8b7cd88339a98c1aae863ff0747c |
Hashes for PyPartMC-0.0.25-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26b13eb9792f44e6c819f8cdef80a6f9ed2446eec380fbe091d9cf1e23c63f74 |
|
MD5 | c8039291516f18c0c15454a2b51acdd1 |
|
BLAKE2b-256 | e1e6b09ad8796a353cdc5001995171e5c74293e83a36d813299464e8eef4b08d |
Hashes for PyPartMC-0.0.25-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cc9f0671cc1fa9c72806b983411c3511082f7d803dbba774091ddfe50879c66 |
|
MD5 | 7863ee22c9ed6d3a518d8da7cee41317 |
|
BLAKE2b-256 | 4424724129d9fff763f9f04f642d982c9bfbd6e957be733fc343f0002b54295d |
Hashes for PyPartMC-0.0.25-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf1f1f2c4bb39d9441b7c855b64c0aa64c44e71dc6399a6a5dd37c12ca970ec0 |
|
MD5 | 9516968e597f55c4ca6873abc9e71d24 |
|
BLAKE2b-256 | ca0744532da7f6982a4a0dd0d380c69421a951e38f55dfcec3c36cb97f8e20b5 |
Hashes for PyPartMC-0.0.25-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 322bab0c62d3794d424a1d3bc7914a9c7544f91ad3bcbc09ef4456ed02efe4b1 |
|
MD5 | 253938afc457c1b31606e8b58e989bc5 |
|
BLAKE2b-256 | 79319c2449e3dea2353f70348a8ca79192f5a7994a6cae9b924841a9577261b4 |
Hashes for PyPartMC-0.0.25-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83c94b104fb0e9a234eaae0f34a20606cf7e8cf771c3a6c42f98d919954b4139 |
|
MD5 | b3e9cad6e086c86fa7d3b4d06125cae0 |
|
BLAKE2b-256 | a2449ad7655ddbec84b35292093a13d5850579017a5966e26d4c2f9265808b48 |
Hashes for PyPartMC-0.0.25-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff357f2a22c0baa7e8376f41f2a020c33206b992b7b1d2c0fed7e492280705d1 |
|
MD5 | 379ad2828284df4d388c9d30e9cdff30 |
|
BLAKE2b-256 | c4ed7e3e4371ee852a59ede3b60a40b356eda1d688a4dcd0df6de50ae1d58880 |