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
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
Credits
PyPartMC:
author: Sylwester Arabas et al.
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.4-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e90d515bcf3f6f384e6c41711cdf85f1c90bc6ab808923c744e4b6b64305c3a3 |
|
MD5 | 84f83986e184a66a738c5badcf1b4c36 |
|
BLAKE2b-256 | 5477a2ebc640912f40f03356cb45b7794e39d87e5ea9fa4b649ac4c85f638195 |
Hashes for PyPartMC-0.0.4-cp310-cp310-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f89c39afaf3b52dce5d7263c450b315821ca276703f39ab6510db837e7a39f1 |
|
MD5 | 19b31e924dfcd760e0bd6601bccfc79e |
|
BLAKE2b-256 | 46699832c3e6efaba764dab84422814ac2b0f4182b9c2949286a133c2405ab61 |
Hashes for PyPartMC-0.0.4-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e45c076454d8cb5c4173a4d541ec789412da79870927b32e603067b62c3e807 |
|
MD5 | d8a2f82b10621065ca1734de8496d0db |
|
BLAKE2b-256 | 11ab300d9266273c2c874cdab7e967d640806c520399d7cac3e0640724698d4b |
Hashes for PyPartMC-0.0.4-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b400d63d09c28103009dc7548e1b1a118af1ebc4d781bfdbb9c027e6fc68aa1 |
|
MD5 | b7c5a7d29caa341c2072895d3fbb4080 |
|
BLAKE2b-256 | bebaea559f53f3e9efc1d66213bf2348ccba7093d416ec58eed3234d086f2989 |
Hashes for PyPartMC-0.0.4-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d43175c2b3340193344b9102c5f918f3ccaf3e78faee4e80b2e0752faf479e9 |
|
MD5 | 586f3d11120defc0933a7de1fa846ad0 |
|
BLAKE2b-256 | 21f5854708c98cc020664ceee59a57415a62860e96f838c30e8f42c1d07839cc |
Hashes for PyPartMC-0.0.4-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8ee8edc0ef917adbaf08bdff9038b4b20a6c991a6e1ca608a0d23816f81271d |
|
MD5 | 6878f0b943ae43013fbd8181fb2d80e0 |
|
BLAKE2b-256 | 6e64c16abceb58c1de0702331f9a0aa5ff9a5c8ea47e34a2b494c47e1bb893ec |
Hashes for PyPartMC-0.0.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d9eac5d88f452621ba0936a8cce11e975538ac4159e818caa46b5a59c2b8dc0 |
|
MD5 | f6d0095fff16dbf0c4c74a7f625ca48d |
|
BLAKE2b-256 | 0d8a282f8ffa1bd867006973633646ce9febed98973e277c3b059b68091f02cc |
Hashes for PyPartMC-0.0.4-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c28b61f71b707c6aace10c40b486a2b38be89c1ad0e404ef29c82866631d271c |
|
MD5 | a1468886df26af7ffa6f54fb3d326c6a |
|
BLAKE2b-256 | 2faf882282438210ebddf4a57cc28b30a27cd2a9f22294e007ad159f564699a2 |
Hashes for PyPartMC-0.0.4-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 270a73299aececb427470db32a562ade166041a371d2cc75de00d146f9000719 |
|
MD5 | 23ea23c685d584cc40327e53394c4709 |
|
BLAKE2b-256 | a4688547eba033533bd04e411db6eca0ab1a5366a7cf3325217e983a6d8d664f |