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.11-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92c132ed674f89f975b5e6cffc6538ebea8e6000fbbff24b43ef4e966f26233c |
|
MD5 | 8fab04006b0053f6fde6b8db8ddeaa06 |
|
BLAKE2b-256 | b852e58ae0afbcc8226ca919c7eda8755ff51cb904ffca1e05dc2e798f3b3a75 |
Hashes for PyPartMC-0.0.11-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccf3bb13f83a68c6091c277cb3fa16128cec72d6583147f04b7e965ed0f890b7 |
|
MD5 | 291446a48cfb40282f4ed03492d34750 |
|
BLAKE2b-256 | 1b2717fcafc11b45fc26abdfe0c19f72a559857acf8c886ad6d254e37463427a |
Hashes for PyPartMC-0.0.11-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05195082de308e325a17492e29ea77f014f13e4c425221bb172ee488ca0878d4 |
|
MD5 | 442f07b4c4e5436fbb185c14e0b0735b |
|
BLAKE2b-256 | f12b480385443faebf21ac4ef72f20b195b635ea3077a770a6a75870a685282c |
Hashes for PyPartMC-0.0.11-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c0104920b4fff973a2d6131075c4e115d4dbddd36cce56bec6652b763af5117 |
|
MD5 | 46b2bb79cea1ec65bac2c4c4dcc40e9c |
|
BLAKE2b-256 | 147c63a91b6474bea83fdd8185b2638c163475f1bc958c1be8680efc1dea1cf2 |
Hashes for PyPartMC-0.0.11-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3da299d0f1eca1f17b218a95c7d942825d1c6528ca24aad2a159094ad02405b |
|
MD5 | c9d41f2b20f44d3f20429189650f0f95 |
|
BLAKE2b-256 | 5cfe0fc6858c3e9e2eb87e3a9c344cb09cf13909b26f797412e868a4f4496add |
Hashes for PyPartMC-0.0.11-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0ed13719c1af4ea70f87920ef7bef6402400167ebe6e43085bba57042859979 |
|
MD5 | cd2bb8c7f78491bc961a3cd3af5459bb |
|
BLAKE2b-256 | 6905b4cf77c521ec1ca1701294bedcda140243714a544566b9e5e38fc4c5865b |
Hashes for PyPartMC-0.0.11-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 548a2c6be5cea59c1a9cd574569396d2c9ea5c81aae4098e3fc129432d5641ad |
|
MD5 | 58c043527768d78ce3d1f6338728019d |
|
BLAKE2b-256 | 66d70b0baa6892adca6aebb554a16a0d47191a572f6e25601e665c21d05c489d |
Hashes for PyPartMC-0.0.11-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 653b8db11c9be5c6e7f5340a36ca5c897d86b04a4b2dc9e795881125606f684f |
|
MD5 | df4c3952688c69741adbe3e150043619 |
|
BLAKE2b-256 | e56269fa1def45dace1a002c2a1416dbf8d588a46e0dca2fa6f7a86096c504d1 |