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 git+https://github.com/open-atmos/PyPartMC.git
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
usage in other projects
PyPartMC is also used within the tests of PySDM project ... TODO
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
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.1-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cae14fd8badd8f440ead29f3191396835eca5f7f71df44a3e485a3a3b2feeebe |
|
MD5 | 550cf5e31435af0d985292a46068a805 |
|
BLAKE2b-256 | 967832032663a43ad24e6bd0cab3e472b55afc04da2e1d7cced0a15dc770cc75 |
Hashes for PyPartMC-0.0.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb2d894baad77b9f2879b14473351addb6ef83811f22c78eb1cc41553a2c1268 |
|
MD5 | 1df984802c3ccf2bf419e8358f1ed886 |
|
BLAKE2b-256 | e131a555edf29b3e5a60d1217aaf27ec1798c3675c6f896291e762c24fae545f |
Hashes for PyPartMC-0.0.1-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7664417eb2cac663799e51133f4f2c38b94683dc6c54e8a6ec58dee747a7459 |
|
MD5 | fe6598cfab21de17dfc2c0b21a57e85f |
|
BLAKE2b-256 | a2932c010b7a4c490b6ed028c62dd7fddce835c2cdd06f3b474ad5962daad859 |
Hashes for PyPartMC-0.0.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4a322a22289bbc21a79ade476892aa2265b98cfd1240c7960ee03cd86891df2 |
|
MD5 | 675f15474574eff84915650383c08408 |
|
BLAKE2b-256 | 8bc61c4a6e3a6be31237c7d35dc94828f10d58c9d2f5d12702490db5ea9432ea |
Hashes for PyPartMC-0.0.1-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9543deb2311e292388ec12804172e38dc7281cc312a8144e05c729784d49b15a |
|
MD5 | 9cb12d6e084d92e5dcbc7b00c7626946 |
|
BLAKE2b-256 | 18e63a0ef0264528a35e62a334a8d6074b14ca3f573f36070f0a7dcde007d512 |
Hashes for PyPartMC-0.0.1-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cc51df20ebdee35532ee6cc6c3ed84e48798feb74fa511b5dd20674040ecc25 |
|
MD5 | 9f558a4359f0173e22555ee483939750 |
|
BLAKE2b-256 | 68a7e904d5cb1bf3a48fa6e15413664e4a083882d2b262cfb5d540841c3c976e |
Hashes for PyPartMC-0.0.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16d0e758d6fea78de7c98e3e15ada5348f56cab48e814676bd62fde8b2ddbc5e |
|
MD5 | 062845317b92140f16313d0fe0c45b0c |
|
BLAKE2b-256 | 923a5ba584652bfddfb2d0442912bcc9bad31bb31f1c4796e5288022d7ef9398 |
Hashes for PyPartMC-0.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f55491dd7d18241e7e41a130628f5f303eee8f6f7f118cae70973e9b732cd428 |
|
MD5 | 7bf654bd305bf5904c878301ad1a4993 |
|
BLAKE2b-256 | a6ed35aa28c49fb3948ea5ce96b1ea12aab7d50e0da65c30d06cba4c3b1f0d84 |
Hashes for PyPartMC-0.0.1-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a0bb4f737194816f55b6bb6175adee1bd810186bac6f58b4833026d32e5218f |
|
MD5 | 538df842e299bb02d16944ce34c21c02 |
|
BLAKE2b-256 | 5b950d69612dc87ec0b685dad85a005694ee7bd143a29cc8d0c31e60a097e691 |