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.32-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2cd8359883495d7107e50702861aba1d2961edf49c1e782a4753ceb57e4f012 |
|
MD5 | 86ff9d825110b878ff9a05249649329c |
|
BLAKE2b-256 | 7e0606307ae58ef815eda1f6c9015a5a6db4308a057d88fd8549506c4037a53b |
Hashes for PyPartMC-0.0.32-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 639579b77948a2236c831600c5596b3b35fceae097418f5e563439682445ebc8 |
|
MD5 | 1efb55744b324bb7e29f1eda2f5006c1 |
|
BLAKE2b-256 | 90fe065d29a45b886ddf578a89fb1b1f803395a950b3bb3893ddf25e77042ad0 |
Hashes for PyPartMC-0.0.32-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7957ba766f749bd04d019727466cd68925e3ce6ecce48b9e99201572694ce474 |
|
MD5 | 77d1e8bc67d478837a5d93087be576b3 |
|
BLAKE2b-256 | b22152469545e98d86fe84036b0885ef2e3cfa71aec35771c2919b5b6dd841a4 |
Hashes for PyPartMC-0.0.32-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d87fc37938e840ee8f889fb0ccb81bc02a8d91be3b266fe80607137c7dc250fb |
|
MD5 | 58566d15eb26fdcb17d0172a9a83fed5 |
|
BLAKE2b-256 | bd0c4c437564152b59c79c99121ac4267185de0246f75ce0428d44b82a9131e6 |
Hashes for PyPartMC-0.0.32-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a00eba733a473a3a9cf3640cc966c3e02e85cd443e2ba89e8a44b731b89e2928 |
|
MD5 | ebae2d7339145b5a33d0dffc350d9739 |
|
BLAKE2b-256 | 6c458d9ae08a2852ac609896909beb5eb1164e4ea1019e44fe8bcbc4a0d4e12b |
Hashes for PyPartMC-0.0.32-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b7d6873f099c4900e7555425a090843084cdaf40f3fb0d1165db25caf912a4a |
|
MD5 | 8327b3239d954a5d8908542f99337b18 |
|
BLAKE2b-256 | 38928361317cc8222cf2fc3ff5a030349a81d1554761c894badbbd6b8849c9a9 |
Hashes for PyPartMC-0.0.32-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 152a168a7c6ebb2064e98c0d9c8a469f7df9eb22949c863930601f47c2590b03 |
|
MD5 | eaa433944266505311115d9eb3e772cd |
|
BLAKE2b-256 | 8b46e33691fe1472637879a834ce36e967466445ee5b5e32a5e2d8b3d3918b29 |
Hashes for PyPartMC-0.0.32-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c322348bc8b9f6a8b9b9570e3a4da614f0ee0451f98ef6d36239b88417ba4b48 |
|
MD5 | 09646f9da3525637e1f9d63a6e3755cd |
|
BLAKE2b-256 | ee8605e5b2acca55aa951ead8ae9973dd17519d3dd89878329a5baf4f2157d86 |
Hashes for PyPartMC-0.0.32-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dcfa7c0ec43e402e3125163d395e67406d9f0a6e48c02a7ceaf208ea01f05a7 |
|
MD5 | a6ea53593870487ba720130e56824408 |
|
BLAKE2b-256 | 4b17c5be69331ebfe01de71792e49cedb34f662c3403256f9495a70bc8041a06 |
Hashes for PyPartMC-0.0.32-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28bde6501b3aecbf16a7035cab4c40f5762ab965479b4cdb8d604facfe15a1ec |
|
MD5 | 8a8e9c2e74cd3d0491f71a379630b694 |
|
BLAKE2b-256 | da24aacade9c48760f05c965962a1f05d226568e6bc411d585ce3c9d3599ad36 |
Hashes for PyPartMC-0.0.32-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2583a6ea09fd6eebeb240e0890425e02cafc7b8f63d4a5086dc701364c140303 |
|
MD5 | 266657f16a91dba948b4bf901382ef37 |
|
BLAKE2b-256 | 6f21f8825071ab710bfc1161b1043dc1a32f13b0cf9927b0f41c1881db15be95 |
Hashes for PyPartMC-0.0.32-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33974ba99e0e03c6dae9fbd0d66309b4d65eb3480d22e6618552ff09b0e5d4a3 |
|
MD5 | a256e849537f82be3b9f167e9812eec1 |
|
BLAKE2b-256 | b353062ee3537cb7c7bd303a1790197a4a33fefb8ce7ecd75ddb0e7eb18a4dae |
Hashes for PyPartMC-0.0.32-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0b3cb252331f64afa9bd40228b29d12c4979215fcfcffee81796013115e7dd8 |
|
MD5 | e5c75afb94f17fa285d06f6506066f1d |
|
BLAKE2b-256 | cb792d7f86efceb95e331c563dd48808f9adc573d6de4242a0dce53fb95e2039 |
Hashes for PyPartMC-0.0.32-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bcbb6030327d9154c3dbadfaad7e374f9adebcfe117c53b7fe0e0c38ede30e0 |
|
MD5 | 92ce0587b47a26add2e143d2acebbf28 |
|
BLAKE2b-256 | ec62d696fef38af4c5473e27bda4746bcc799e8daa3a7e1d737c61b274dbfd1e |
Hashes for PyPartMC-0.0.32-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d0b1726e5375a6b76749a036c0991c7f079c2717be3442d56a04a8b0a7a3a56 |
|
MD5 | e3d978d30d78a2de66dfe76b077f3667 |
|
BLAKE2b-256 | 590bed023c6eb660b846c5c43de6737ac789eaf396390f1ab9c34c724e750efe |