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.19-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89172a2e4b32b224b0487ff96a8955bec137dabb28fb3effd2fe7bc950dc13ca |
|
MD5 | 341b5367d6f25113c7926a885e73f1e0 |
|
BLAKE2b-256 | 49b95c55c5ecde45c7793e9e4c12679b3040796d921a1d3e0f4970e860b6e097 |
Hashes for PyPartMC-0.0.19-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52a36628d300678d1929993eaa079d03d4684c5c15fabaf8d4eecde6a8405f46 |
|
MD5 | 9d78657b35cfc2162dd6ec633d8d63be |
|
BLAKE2b-256 | 998915ba3fb262b12bc1d081f1aafe7d41c7cfff462e531deba261b6178f384b |
Hashes for PyPartMC-0.0.19-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0235fbbc2e85b12fbdac38c8ab60d72b86387c40b84a2b09963ec392d870a7c |
|
MD5 | d030706aa6bd26e5adf2dbba58efbd62 |
|
BLAKE2b-256 | 3cb915bef26b289d47a55df9eaf5cc0a227337b5ec066b805a1f77c559630901 |
Hashes for PyPartMC-0.0.19-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74cf0acf5da1ec36572da4eb030adab42eefa613a86f0bb0f77840cbfc776101 |
|
MD5 | a596c91d71fa9cba00034c68647eabef |
|
BLAKE2b-256 | 97d66a9b72c78e25da29641e9aae4fdf2839f3a2bc0743737f879ec46c9f7036 |
Hashes for PyPartMC-0.0.19-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 514ff3f9eefa683afe2ea6ad66f58940986ba50b8d40e1959902b7a27eaca396 |
|
MD5 | 7e4845ad5d7388b8f1584747195e6552 |
|
BLAKE2b-256 | 7b728e8eac8b8fbae0257f32326c5be8615b5c65977ef996f962a15107799075 |
Hashes for PyPartMC-0.0.19-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8b155e319f52f8f7e746b0e729ca1853ab4125c27ebe95922175647efed1511 |
|
MD5 | 6c3d6d0cf4327a16ef78c9318d15ecd7 |
|
BLAKE2b-256 | 8bc9f3c2b9455cab14eabe037d6162a19830f2b7c893f56d42f9e5f0f00dee57 |
Hashes for PyPartMC-0.0.19-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b32fd34a9fd4f3867f1c8da286ce924e0dcd4503b72ab507cf7dbd35eb7b578d |
|
MD5 | 942bc13f399ba519f6490bdf47f4a379 |
|
BLAKE2b-256 | 4d01f895682468373d54ddb49c3a6402583abd96fcaa63c8781e5c09b3a241db |
Hashes for PyPartMC-0.0.19-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0317269fbab5fa44329dbecc86567003e781ec0f503edb0269d2325c6b06bf8 |
|
MD5 | b5c459dfa0c54ff41d30dc8a7f96f151 |
|
BLAKE2b-256 | 986bfd923cf41707bbee17ff86d6cc133897516baf6739d0b98e79f739e01e0f |
Hashes for PyPartMC-0.0.19-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d18b41b98f11accbfc137cf9bd3d4b6c65ce2e8e537ef616a6b0b00615419b67 |
|
MD5 | e6ecf3e1b0afad87d059cb96b5af3fef |
|
BLAKE2b-256 | cd3bce39906f492c1d25b4195ef13bb21a7dc2be6a0c596fe3adb001d0428e80 |
Hashes for PyPartMC-0.0.19-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32b030c7e8f4f284335ed5a895638b05a4269b64d6a8887bd952c743f59f41da |
|
MD5 | 60574112f8af893289dbd3d789859498 |
|
BLAKE2b-256 | d5203a140ec53e5b0bc3b09f8223cb9756630feb7bc9aa2ab2600b8bc7f880c0 |
Hashes for PyPartMC-0.0.19-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d282d9f93ba1805fe2d04ae69542bd7634c8849b608129d8f5eeb469ed05ae8 |
|
MD5 | 061dfce5f9b603e43429ea42026c54d3 |
|
BLAKE2b-256 | a5bdd4627fe7e55bd314a0aec1596473bd6bb7a6296286ca726f5ecee63c5f1b |
Hashes for PyPartMC-0.0.19-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 532d71ddc925bc11896257aca77420118cab17c12a7bef13f178e0b1ea800d44 |
|
MD5 | 4422ba646c1d2f57c7d778ca38b5e501 |
|
BLAKE2b-256 | 1654ff99f89f5415c50e9fab999c65e21075c92555968fc35e659893bf0a766b |