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.17-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0daaecd13d93f8f44769d78f95ce50bade67837f60e9dfefe87fdb380358da92 |
|
MD5 | f583a2acf84822ae8cb31dbaf6c147c0 |
|
BLAKE2b-256 | f68749728ce82460d3a291a54851b91ae541945fc3e6c4205bd17ee6ab5a5f81 |
Hashes for PyPartMC-0.0.17-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54faa9048c0a20263415fd78f405a602d884f18e656eb159963e4fc1b7c52650 |
|
MD5 | 42f60fe2a1f6bfc407162ed0909f0d2f |
|
BLAKE2b-256 | 75d99d53161a317dfb5cead9d6e32f583dbafd7c3786f5ed8a3fe505f64d7352 |
Hashes for PyPartMC-0.0.17-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bc3b37608221547e0e391cd8c98a0b5c10166eff8b7f5173909e93110d32bfc |
|
MD5 | 9584b685832cb53c01bbb504a7e055c6 |
|
BLAKE2b-256 | 0c6f341b82dd731f8796e8159f2960e18c3e95d3faabb98a585b2533d2edb925 |
Hashes for PyPartMC-0.0.17-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2db2faa13b6fc7c91db1ee501a4f24294bee39c6c66d6f9b2b200054f9c21dbf |
|
MD5 | d562e39c37acbf94e2a9f1f593a6eab6 |
|
BLAKE2b-256 | 2a1dc09cbb2a30a75793608ba1ce908af163d0071658e2fb7a66305d31abd819 |
Hashes for PyPartMC-0.0.17-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be3c729459ef67c18ef949e73aaed973ca5a4dce9ebb08277d11f846784c4597 |
|
MD5 | 532b5fb72399ca203d8f1e581a4cb14f |
|
BLAKE2b-256 | ddc5c669328fbcd1aa227c8ce79abd0c6cf883bc1b2d64762ba964a7a32251f7 |
Hashes for PyPartMC-0.0.17-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b1bb53eeb8fc61379b4b131b804c12f5395bde6bc7a24c2907b88c16b897388 |
|
MD5 | 94bc5bcd72209cebec3d3a864b059bdb |
|
BLAKE2b-256 | 856a0933d64b6e6f08ef75874ed17df8e03d5e622436f44a7d1eecde64fd7f48 |
Hashes for PyPartMC-0.0.17-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f55b1257ca862df426a0eb15b445be28019983d9717a3a5042ee45d9c1773463 |
|
MD5 | 396ce5efe68ed19e8d35aa57175b4874 |
|
BLAKE2b-256 | 5905aaad2b6cfbf9af3c2b0ec0b308fa570b27579abfa2376a7ccf44690e2313 |
Hashes for PyPartMC-0.0.17-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d05faaa09e6a31cdd951d55e85b1fb4c75e9e6030669b698251da625096df760 |
|
MD5 | 1b353d1d61b38fab2f7ad5d794b4d31c |
|
BLAKE2b-256 | 47a364809fe0cd41c29eba7d511233fb347baf7a4c0421d1bc80c12e97ae36ca |
Hashes for PyPartMC-0.0.17-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e74fbc8b41eba97ff4f73a6fd9aa58884922c4b65841ac7135a23b1c3b7d667 |
|
MD5 | e54c6779e0439f2d7b137faccaf013d3 |
|
BLAKE2b-256 | 60b0f7c562302aa8958f5dd02f82db6802d5773b84da344dd2e44e7e7674329e |
Hashes for PyPartMC-0.0.17-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f3e3976be294f4ef7b26076b93ed47a59c218a415ea4618eb0c72789fd074dd |
|
MD5 | 1207686d52ffa5eebb670932ff82196d |
|
BLAKE2b-256 | b835e9031d1f9b71c2720c15ac5a3c0f81b3f0b70508c7c3826c1e99531279de |
Hashes for PyPartMC-0.0.17-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 140c5468ac1e3e1e61b3e493b32ffc369030b18122ee8e4b2a0de14500f6fa01 |
|
MD5 | 05a75af1eaa013e00983eeb84b49a1f9 |
|
BLAKE2b-256 | 250493e5fe8d5cccfda44b8619199f625b3e4799c1c273019ccaab044ac31ac6 |
Hashes for PyPartMC-0.0.17-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb11de14429eb5aebb4f2ff2df15915b8ca1a8c41c39080ef6080f4292251aa4 |
|
MD5 | c44a53e7b405fdea46f1de41f864eecf |
|
BLAKE2b-256 | effe6ccc97eda3a4aadc970cb8d5e96f2ddbb614c5f29b39cf36f50f94166a5a |