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.3-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7d458f614a2e55553fec155c718061253e454a32e5a8be5e04b6f322ba6de34 |
|
MD5 | 17586ad00af6eb13cf80a04c401da95a |
|
BLAKE2b-256 | 986ff281331a6d84718857d5f893dbdeb0aea0a0470d498bb45613ec6bfc6636 |
Hashes for PyPartMC-0.0.3-cp310-cp310-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f94d3f6151856783d3e0defcc35752606b162959dfac773858e74fe3b6cdb37 |
|
MD5 | 6c454efe6d1d5043d437a07aeb2c15af |
|
BLAKE2b-256 | 9268d536dee4ae3107813c963cd837b07a12c1b4f11d96b0528bce71f51705f6 |
Hashes for PyPartMC-0.0.3-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 804f8748ea3f3be2950d556255c53c41bfabe2457f521eaad8862eef876ef5c8 |
|
MD5 | 8177b51e99f2d949cfc96cfcb3c6903f |
|
BLAKE2b-256 | c3b5537e7a145dbc49d073c0db10b7864af14d08da563d4956035640bf97c9b9 |
Hashes for PyPartMC-0.0.3-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d30f3221a7db0282994286105d9443ec762a6fb7157fd59f0f25501382858bfa |
|
MD5 | 33c825fea17ec86d1617cb13f4658ecf |
|
BLAKE2b-256 | c45cfb47d6eac755f02f72636ca69f3f25fc36275e9771fc8ce939e93e06ddd8 |
Hashes for PyPartMC-0.0.3-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d9d08e0b969903d086ffbea67fd52014896a9eae805ebf296ee251857203ac0 |
|
MD5 | 99b114ab7ae834e1d615cdf4a60a1b04 |
|
BLAKE2b-256 | 936bde116e882b9995ed395c0fa0320e16716f04cbf0ebe2b655f98aba06d16f |
Hashes for PyPartMC-0.0.3-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f36457bf96b4032d74b461fb90db35308736ac82406dd9faec877fae77fdda1b |
|
MD5 | 7eeb00bc80434782475906557c072cb9 |
|
BLAKE2b-256 | 7175eeff5445e98977d88898ccb60cc47e6e4c5f26bbd347181e8a4958d1b440 |
Hashes for PyPartMC-0.0.3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 754aba336f1cb769cc36a93d180704bab81366260735f8800cc94844414d5646 |
|
MD5 | 9eec543f0c009bced0c7c023d8e4ad71 |
|
BLAKE2b-256 | be6ec07773bb203cf2836a9589bb1945bc879e46456cb88d9b35830e46e2f557 |
Hashes for PyPartMC-0.0.3-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba3437f658bf4147297add25d695f074b53abf1647673a56dab478162c35718b |
|
MD5 | 3c50f98ced2f2a8ba0d0a4d0eb2dc1ac |
|
BLAKE2b-256 | da256d24ff59f57823dcdd9718cff82afff3e6134df1767677612f7ca176cb11 |
Hashes for PyPartMC-0.0.3-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6199dc3ecad4ebaae6e253dfa620defea4c894ed96e75f1b431ce46eb54e0df2 |
|
MD5 | 8333c3039a20e2f048efa5efe40f80fa |
|
BLAKE2b-256 | 52e25d7fb680dcdcd4dc34a59042a49343ec2326716933f9b46c2ec98498b692 |