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.22-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b677f12daaa0577d934e57dbc31af59e902ea9249866cbd95afc8a7a1345a8e |
|
MD5 | 2362f5c32594a9e4b419bdb81894af62 |
|
BLAKE2b-256 | 75638929fb62cb64b9d86995c68ce59967e60b4cd6069ce77c96e78555563992 |
Hashes for PyPartMC-0.0.22-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4ae3c5253715d901978f7ad5d219fffe82dd0b9ffa2a45fde94f579a306807f |
|
MD5 | a610c4e00b38b7e0e04ff745848cadc2 |
|
BLAKE2b-256 | d9204b3d0b3582e6d5176841cd03256f874ae1eac598835cffbdf7246bf6d751 |
Hashes for PyPartMC-0.0.22-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e98a436b1d5d501c22d0ae650c47270e9fdb90a4ab03ddea7021e5ad4ab31b7d |
|
MD5 | d8f1489fb87169d95bf9c46051a40d23 |
|
BLAKE2b-256 | 832db39e45a373b43b830f973034beaa8b4e23903c2569434120e686136d0c71 |
Hashes for PyPartMC-0.0.22-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5feed691fbfc8e9553bdf5d3677b5a94c4246a43a127064c77b5aa808f7bf5da |
|
MD5 | 5def312dda601cb1d8233a447e799a8a |
|
BLAKE2b-256 | 97f97a0c75ae278d261b80ec7ede68f92434b2a3b36413757d5501840ca64bbe |
Hashes for PyPartMC-0.0.22-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6ea5bdf410fffe815583b9bb29729785c5dc0a26ba30b4abd7c39f99169c462 |
|
MD5 | ecc670ccfefe2f1b78b779b20d8bd0c0 |
|
BLAKE2b-256 | 22c9a7448eea7192c9f36b9609752dce65723e9854a5c216f9563d1ae22395a0 |
Hashes for PyPartMC-0.0.22-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e72477f9c4c6790b55f123d4436c6719525caf5affbed5dc6c6344b2ca3bb2f3 |
|
MD5 | 6c2c4fab23dbeae5ac09aa43c8bc031f |
|
BLAKE2b-256 | a740c57e3400200a7d9b2fe26b6af0178030ba6464435aeb3936955f4d3b277d |
Hashes for PyPartMC-0.0.22-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dcfa161cc608fd2a2d2361ccb4e47d8d891c4ce6c577b15c3a7a6dcc2fa650b |
|
MD5 | c631a9c8cbf7614052ed7a7ac22f3d14 |
|
BLAKE2b-256 | 1d24f6a4d39c1e55e3a1ecf3eda1dc45580d5d568c47f198610c7e2c3300b578 |
Hashes for PyPartMC-0.0.22-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a37413d189c185c5e3e558e709700d8690be71339f6d2560df3c2e57a4b12b82 |
|
MD5 | e8ae575de39045d25e7c6ea63e92ec79 |
|
BLAKE2b-256 | aa9772b5c4701ed116ce0e28546c40454dbe7a0fa6913a6a634322971da5637b |
Hashes for PyPartMC-0.0.22-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd51d733625c9dbcd802b1358875a99e7a9dd6128bfbb237fd3cb1963a3cb68b |
|
MD5 | 7abde3f0c22e46b13a4d4f933d0b87f0 |
|
BLAKE2b-256 | e32c15486fc8026caa7348d92d8d844d8d75ba1b4e7623ff25ed8b362b7ed9be |
Hashes for PyPartMC-0.0.22-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b20ba9c809a7cbad89458d08ab68d29cc09fbd9dff24d3649bb5a4a37abd255 |
|
MD5 | 8fcdeeaeefd23da20b9d4f521b459d44 |
|
BLAKE2b-256 | 1ecd0817915deca5259543cc9110299107be715434827535dbb8d9a36ff47bf4 |
Hashes for PyPartMC-0.0.22-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d01e239238830264613ecf847b67c37ae7522397629f07c9a74e13b08b869df3 |
|
MD5 | 4b964b3c4533a51854038a9812f33268 |
|
BLAKE2b-256 | fecd4e362aba220092c99e0f58bdac88b8f678ace1b8f41def9d28a11bd8e5ee |
Hashes for PyPartMC-0.0.22-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e52fa7444f187b52baefefa452b0251d02a57288ccdff2df24b6316070589ff6 |
|
MD5 | 73241ff7ccd2a42fd0703ddd305a7d91 |
|
BLAKE2b-256 | 19d4484fbc2e360133ce0d11858c6ec1af37f611a5f2695aca54bb950a7306b2 |
Hashes for PyPartMC-0.0.22-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7fb443f30b46f19d34a1d70a8a166fc6867f09f76eb7220faacd5ccf4a7e0cf |
|
MD5 | b01428b5605da6e626a1871b7e30906c |
|
BLAKE2b-256 | 005d5e4fd8ecb8832f052c98baabc364cef96d5070ccbda2d553ae698c2a1401 |
Hashes for PyPartMC-0.0.22-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f59768e3dc731ed681d0cef1e5f07ce1c4e6285fb289ddf3b662092785a27f9a |
|
MD5 | ff0a3280dded0a8782e52e8dfae6c5af |
|
BLAKE2b-256 | 432668f8309fbeb52e7a11b61e83983a6f1495b73b4405b4c149191341682544 |
Hashes for PyPartMC-0.0.22-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5b2466cef290b2aa46d1dfef6361da4e952f2b7583df0e085361ffa9d6e3668 |
|
MD5 | d0bf1eed07578a4cf5713e92c1dba903 |
|
BLAKE2b-256 | 3e80eb1caa149328f6b17447552845f725566a19badc213be25e1fb0d5cfe8a7 |