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
)
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.24-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0e02d242ff365eeeed2bc57957e1a89ef379683207ac1b4ec286f92e85ce0db |
|
MD5 | 614c3c7df46bae78513f1b7e3178cc38 |
|
BLAKE2b-256 | e2a078b3d7d8b57be5169dea9d8b5e2b61c857e836bc741d680495820481eaee |
Hashes for PyPartMC-0.0.24-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca0e81b763ce966fa56cd4cfb0be6be49cc13a933ae1302405499a8d67a59e3d |
|
MD5 | 5346ba304105b7effb068db4a2490a40 |
|
BLAKE2b-256 | 8c92622202b685ec3558920f5d3d10f7a308116cd5c2061fcd3cb4458c94d391 |
Hashes for PyPartMC-0.0.24-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da88b8fedfe0a0c41d31120beb5eca7a37c979616f37c467bce42ca476a4aab6 |
|
MD5 | 6c4e14fb89e7af0d30791e083ce70152 |
|
BLAKE2b-256 | eb6fb34f3ae808d38c6a5a187f571400dad0926579034187f5daadf19a8faa24 |
Hashes for PyPartMC-0.0.24-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 745f09ce3800f64567791dd3dfc911742ee6483be97cd028162545547f405115 |
|
MD5 | abfc775ab0077823cc23614ffeaaa9dd |
|
BLAKE2b-256 | c8b2cf750cf22a5a49ca4bfa425710344378c60f870eb89be75aaa68dddb2200 |
Hashes for PyPartMC-0.0.24-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03c7577a7735461b633c9735480e7168f233fc60b23e0f17d5ca62525262c4cd |
|
MD5 | b81737deb1a499a9e054cf2f46c77de4 |
|
BLAKE2b-256 | 300fcadfca0ed83fa9dd7c115ab756513a77e9c8e62089924455e35f4fc7f670 |
Hashes for PyPartMC-0.0.24-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcbed053b85ef57d12f0a2f476c5397f8906a66b909db6f43029ef9015198ff6 |
|
MD5 | a6ca688398d47048336489cd6a969127 |
|
BLAKE2b-256 | 5e0f08eb6598fa99d8ddadff1948523210098e3b7067bdaf14ae8f1bb3856d74 |
Hashes for PyPartMC-0.0.24-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8057babaddabab18de234ad4bd6ffb08cb50cdf48f67cf95c412a2abffb0d233 |
|
MD5 | a171cbd4fd20cbcfd22546e91fbe1bad |
|
BLAKE2b-256 | 38489ab95f392bf5b85cdced103b38ec755339aa39ab8b900dbb1250345f1e2c |
Hashes for PyPartMC-0.0.24-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df98a2b74b8f8a0c81c2fbc6f0c13dca2fc4184fd553ca4deb11456fb26a7c58 |
|
MD5 | 71751ef632f872c1c5e3421239ae8218 |
|
BLAKE2b-256 | 8f07a2562c26755c324e46c8bd3f47c54e8e713e36c454853b8f074a457ee298 |
Hashes for PyPartMC-0.0.24-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d46295380614cb9dff1a798bb6e9c5b21879717a4ea92ed34a23cb06af5307d0 |
|
MD5 | 6096abf65b2622b7eaf8623e5f5f733b |
|
BLAKE2b-256 | ae774299821a2b432ecc687866f9dce165c6750b36a8b53c91a2418c143c44c6 |
Hashes for PyPartMC-0.0.24-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bc56e63a10d222de26949d9a772ce3f190c37b7c1b020a8d138f6a09cff7c6a |
|
MD5 | 572700edb7e7f7c30fcd551927a621b9 |
|
BLAKE2b-256 | 03425041977c5e22b7eef9a289a8c89ee2b519d3c7b75758f4c1ac1d49da2502 |
Hashes for PyPartMC-0.0.24-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8dae0d8e9325670d7be232bddd6a8104143dd836d3d4a2ab6cf9e71eee34287 |
|
MD5 | f12e3b022c582642e2cbee03439a2047 |
|
BLAKE2b-256 | eb209a3a7a95498718081e737b0563071fd38533b13706b81d506346d625fc6b |
Hashes for PyPartMC-0.0.24-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94eacc3aa32c2fa42e6a2239ef17491515f82fc21052c38e946010f4f63eca6a |
|
MD5 | 308e773095a1ddc4a826652b34fde9b6 |
|
BLAKE2b-256 | c49d889a1010f89109872849c6ef35e7640acc8b07042e822c88d7bf122795c6 |
Hashes for PyPartMC-0.0.24-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d3130b085e042a191e81da9abdaf8dd2db29abcdadf889b064422e287d08beb |
|
MD5 | f70d88ccd1a19bd79a540f6c54ff82d6 |
|
BLAKE2b-256 | 5a1bee1e0d6fc4da7b8192b84045c18367fbfdb9e7083de280eda0a55bc456fc |
Hashes for PyPartMC-0.0.24-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a39fe9144f57785657f62fc473f7e17d4b4281fdb3e60858dbdcb512f680081 |
|
MD5 | 88dca6d2f8bc87695475ab65d0ada0c0 |
|
BLAKE2b-256 | ea4bb77a2d356b19f226018414178ac93c9bc5d3b711418bf0e28bb8d07839e9 |
Hashes for PyPartMC-0.0.24-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7bba60f97d4ae4dec7eb74151bf0606cb24b52918689d405255483853843366 |
|
MD5 | 0d45db390a91ff32565eb52a8db75ec0 |
|
BLAKE2b-256 | babead382ffe67dfbd030fb2ede7e1054323df3ababa04df9edcbf1c23bf82e0 |