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.14-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f661822b62ea95b96f2478bdb7bd92e0973b875d7e004a54c3d27fb01b4a80f |
|
MD5 | 3a4759bdf67f05c393d72eb4785edc36 |
|
BLAKE2b-256 | fffca4a789a26e94d84ea8584061eda71a46ce0458865b8d0ffd53e1661fac98 |
Hashes for PyPartMC-0.0.14-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 738c5bda780c299cfd22fdb92b2c7851b84d083e0ca668f0204326285e74bdf8 |
|
MD5 | 0f13a168cc3913ebe00d78270c897ce4 |
|
BLAKE2b-256 | 88e4c0d4b1236f8b4beee10a60872154dcc0aafe094cda68d74eff913dfd5145 |
Hashes for PyPartMC-0.0.14-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c81e547dab0648c88f4da3259b9142bc047b7d8c9def9251048c1f28eb1c79de |
|
MD5 | 396607196ae8a1629fe9645d72401bb1 |
|
BLAKE2b-256 | 3143ac02b52ea90dbbce64e9cb2426403ddbaf6c50154e9b23b694d8fb85263d |
Hashes for PyPartMC-0.0.14-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee90e3d1c3850b283936b8d0560e935aa3dacd7e81b0a043f393251d0ab89503 |
|
MD5 | 55836f34cdec7cd67ad289a79977f832 |
|
BLAKE2b-256 | 53191361cfdad4ebfc6ab55ae36f50092e4b2400c149056e68ad30609dc9022d |
Hashes for PyPartMC-0.0.14-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5904a4f15c47357abd5df2e9ff77397858caaf0bbda1d062fbf9f1988ba22adc |
|
MD5 | ab073031f1c47e6fecf381afb0b54082 |
|
BLAKE2b-256 | a6e649b98cea6bf80bbb893797cfbae18da51a0dd8b84d787d763f6a91a1540d |
Hashes for PyPartMC-0.0.14-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f4e4ef21922980059f1df38878e0b0f951cb88587d69897dcf63a54657ac89d |
|
MD5 | 6e809c3b5ed56de408c0105bb96c9ec7 |
|
BLAKE2b-256 | 59427cef62f7678421e95fbbad11194ebfafb64ade9ce1ea137ad74ec75affbc |
Hashes for PyPartMC-0.0.14-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60f0bf730fd035092b7b7e7f0a51f46d7ea2e4fd209c0b6cb7dc4484dd2b8415 |
|
MD5 | a54d187c2e57363bccd8b78c49204e06 |
|
BLAKE2b-256 | 52880664643599a8f4929aa98bcd2abb79e200854a7f61b5994289bf600b5499 |
Hashes for PyPartMC-0.0.14-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4efa305f0c3afcbd0ab7cb16c7ed94359270ee45afc0e1226f68a61a27465308 |
|
MD5 | 4cb99ce6e9d90b40356c8ad63e0d4176 |
|
BLAKE2b-256 | fdc458d048ad09223ebde39ef7f4bcbace2803c7f975a68ef8685411ca6a5bfb |
Hashes for PyPartMC-0.0.14-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c66d2b9d972f021987c78a570badc3628f4dd88c651387adf7d043c0032be1f6 |
|
MD5 | 6af7962fe9965ed001d9f70bb437fa2e |
|
BLAKE2b-256 | 083a79b7ba1c3dee7ff9c50e84f3f93229acd5c02eb090c08044feb2a603a037 |