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: 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.15-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09961742be0a4a67d7119297008407d662e230460e72f5f61968a6088c07591a |
|
MD5 | 01d77226c71747a92f48b16130711be5 |
|
BLAKE2b-256 | 5d9f2da393f2e05af74ee25cc4f43743f467e0f638cefedb35d70e34ac0a261c |
Hashes for PyPartMC-0.0.15-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92c20017d996d4cc7d820ac1d3913329de9be37d893b9a9e3f44721155d97ad2 |
|
MD5 | 2619ba0b4206ee53aba2d3beee6e7fbf |
|
BLAKE2b-256 | 415a6204a4169e366bddca6c65b505e46a342ec8542d8c511590715545f5e1bb |
Hashes for PyPartMC-0.0.15-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc333c351ba32215671b5c21dd57d47c302760e527838bc03914b56ebd735824 |
|
MD5 | a24233e080726c3ee63a20e2826d4ead |
|
BLAKE2b-256 | 52eb5dfcbb36ee8ce0581ac3af86b185ed8d5cdc9062d4e432ecaa51250159b7 |
Hashes for PyPartMC-0.0.15-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | deef3324f5fa8f5da24b68611ae867667347a7e49d7418e2b6292763829635ee |
|
MD5 | 482766bcf7f2fb39862a78a514f466c8 |
|
BLAKE2b-256 | e83eeef13ed2d7ad76eebfa59b6722a376aa7dc92b775c0cd554e735b6b2cfef |
Hashes for PyPartMC-0.0.15-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ac83d1aabad0a2e18456058942a8127650852688528829b493166cdcba8e296 |
|
MD5 | 4e4d1551857cd7b8caa1e6e4e1c1397e |
|
BLAKE2b-256 | d97e517041c9c320482dbd945510f6ca5384d7cf3547a11992a7b66b2fff65dc |
Hashes for PyPartMC-0.0.15-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37ea77c6cc0ee7a5e4c949bda5995f4b50c5ac82d851291f5a5b597b20017f6e |
|
MD5 | fe504a1284eb3dd60afd11d18ed64902 |
|
BLAKE2b-256 | 8a461f58de0fad7575cd861462c0f332d084acae13a26252b1ae4beaaf14e323 |
Hashes for PyPartMC-0.0.15-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e617850cc827d2304f0f29c0a40cf5d10badd9688e8300e2c599f74d7a673647 |
|
MD5 | 78302a38fc654d77eaa15cca969e1b54 |
|
BLAKE2b-256 | eab4dc16886f043241a38b1729741b161e6ad48b4363bfc73deaa0ddcc9d6bde |
Hashes for PyPartMC-0.0.15-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 455ad717a565e84913d85f533ce9100efa0271566493d6a5dca00ad8c9505c2d |
|
MD5 | 630817b8982145b00b151032c630287d |
|
BLAKE2b-256 | 989900605c8d383511712ca1b8bc7604a7aa051beb203e0f41094fe04cd393d1 |
Hashes for PyPartMC-0.0.15-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d0a955a775afa11b9af94e7d9ddf328953552ee2efdf5f950108432b6910885 |
|
MD5 | d582270cc47b0ed14bb85d5e3df99fd6 |
|
BLAKE2b-256 | cd4d36e18369b0c9f4b3a8ebfea831b064126f18a0877a6160e7cadd52c89cd5 |
Hashes for PyPartMC-0.0.15-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 753679322f5f7f6cd34ce9fb730a82fa4edffa684158db836d7e769d5b35160f |
|
MD5 | 40cbbdb1880a7ca6e5dbb3c7e38814da |
|
BLAKE2b-256 | 3c349beca7e038af3e0781a9ca2aa4a5d72c8f5907526288d2bd5ada0817d5f6 |
Hashes for PyPartMC-0.0.15-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 746080fca1489f7ba85c51f25c751c8b5cbe5f1d70be89637f8eedf0ed9991e5 |
|
MD5 | ece62fe3021fc3c43163145fe4a99d0e |
|
BLAKE2b-256 | 0938666be4285830aaf4e1095c8816eae9f643529ec577ed2000a391e61fe8c5 |
Hashes for PyPartMC-0.0.15-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebb8aaaad0d34cec1f003c0b117cec7b57b21f8c3881d6f009566ca72825796d |
|
MD5 | 711c99eacb030235d5b093a838b94294 |
|
BLAKE2b-256 | ca12090e60141444157f5de34c76ca20b4f4c48089f2e137e55a2b5c1596f0c3 |