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, CAMP) 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
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
Notes for developers
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
Pre-commit hooks
PyPartMC codebase benefits from Pylint, Black and isort code analysis (which are all part of the CI workflows where we also use pre-commit hooks. The pre-commit hooks can be run locally, and then the resultant changes need to be staged before committing. To set up the hooks locally, install pre-commit via pip install pre-commit
and set up the git hooks via pre-commit install
(this needs to be done every time you clone the project). To run all pre-commit hooks, run pre-commit run --all-files
. The .pre-commit-config.yaml
file can be modified in case new hooks are to be added or existing ones need to be altered.
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.23-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5243de6eb733e66f003d43e9ba93fbe91277b25b809e4bb2f4fc92eb363ef132 |
|
MD5 | 944963c28cd73ad1af271e97c7f78ae9 |
|
BLAKE2b-256 | 91f54395905f04e09ba60972bc161e40830c20295d68451538e9eb7d7047073d |
Hashes for PyPartMC-0.0.23-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d8de380f39f823ec45136e99dd96daf3a38f826a54acabdf933c41737aa98cb |
|
MD5 | 7870778a9a014252fccb6f9ba0fd62df |
|
BLAKE2b-256 | d3ab6193ea9ddc150b40539d41f64058541ff731c07eaff9a58459cdd32a278b |
Hashes for PyPartMC-0.0.23-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab24341ea4cd34c2864b2fa7013b5299a8ef1711ac549952dc1103bc8ab2376e |
|
MD5 | 03548b1d6e681eac8e98b770bce323f6 |
|
BLAKE2b-256 | ef804a131e782650ce78f4554bb12e916e225dd2ab6d41836d020a93c1ce2043 |
Hashes for PyPartMC-0.0.23-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 031c8110a2da91f10fcc607585ab03eca60856f09b279e9cad038e0a5e99e161 |
|
MD5 | 53c5fd6b61ce88cddf2c35fc60c00f35 |
|
BLAKE2b-256 | f0456228387d6e380f1d72f2f77be819b62e93ac1948263785104bbeb0df296f |
Hashes for PyPartMC-0.0.23-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6a883d6ef0e7f63f9e8bebe3837f40a8267e3bd6f0142dcc45da22ed97db385 |
|
MD5 | edea922d2f9dad68d02a50f58e0f6f62 |
|
BLAKE2b-256 | 9f634d33a2bcaf8b33c424e13a2a74f966aef80c28bff6a6e02c069a8ece165d |
Hashes for PyPartMC-0.0.23-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d45582f2a5382b7dbb90de7e736f00d8365524a0694e7a1fe81b5090b5d5ba4 |
|
MD5 | dfa5a041309a70b8c22e42cbfd93f552 |
|
BLAKE2b-256 | f36a42bf78e9e5b96a6864f401a6feaf8207c2c387ce47d5a90a94a6676ab5f7 |
Hashes for PyPartMC-0.0.23-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3efffe38bda469631e949320a3ef826ae57c267a0393f3360b45a0d5602e93d |
|
MD5 | e0ad8486ae9e416120c247aa1c2960d1 |
|
BLAKE2b-256 | aa488ac06a58bc3980ae91b3a09a383fa8e1f97b7d894fdf44ae3aca2e30d2d2 |
Hashes for PyPartMC-0.0.23-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c43781e3b8b0fd37e9299c9236420d9008e39878d172b45824f7747a5e9e27c |
|
MD5 | 40cd9ba1079ba2099a044fb85cf7da5a |
|
BLAKE2b-256 | 4e9050054d7096a90494c73110dd84ad73b51bacc65b57295a61311eda8ca536 |
Hashes for PyPartMC-0.0.23-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca467f2e3be79b6861c378efd2ba758de1a0b0dda81b5123f7fbe8ac3ebf80b9 |
|
MD5 | 8550b7c6077be44e9a931fbf09122d9d |
|
BLAKE2b-256 | f16548b230a651866b04e4143ad90b14ae877a17de25a96b0b153051b4a2d2f9 |
Hashes for PyPartMC-0.0.23-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecab3897e89b048045220635c79bbf14ed7dd2898cca2a0f0f4e554dd4b3d7cd |
|
MD5 | 945d4e8ee5c62c141a430583d5f55f52 |
|
BLAKE2b-256 | fc1938855ec56f1ee677308a5fc50b3f55c2d84bb734f26a718552f9d8ce5636 |
Hashes for PyPartMC-0.0.23-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c84b1b30711d497bc3bb7df92ae27c36bcd90d548f75abc03e78278b91fa2f34 |
|
MD5 | aa5bd7ca91ef3b438ba42f06571048d7 |
|
BLAKE2b-256 | 4d21f3992e2af9abf1c282345973a2135e82f9df10539266c89f16443da48e82 |
Hashes for PyPartMC-0.0.23-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec838164f0e81367692b83ab164da74ba0f35212c329141e1b9fceba3a97051d |
|
MD5 | 69a8bd1ab9f07ef40700f8bb85ed3ab9 |
|
BLAKE2b-256 | abc17513c8a8e380d6e10982e4cc57382d656e5337587f9f5cd9d304781e6cb2 |
Hashes for PyPartMC-0.0.23-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d452df45470693a0e065bf0869c76c614f61a32a0f68fcb4b5cb214facaaf562 |
|
MD5 | 408d2916c43dfcc2bc7156f3af1cf4d3 |
|
BLAKE2b-256 | 876d54fee0cd9d057ce5fa361eeaa0891ad4ecbf60d5f8c182556508e30aca1a |
Hashes for PyPartMC-0.0.23-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afb6ad7e5a44a57629191305f46997b709f56c2355b3badc1aad3d4718e32197 |
|
MD5 | bd492ea3d77fe096050c92e540868caa |
|
BLAKE2b-256 | d7df117bdebb5f74e60f2816e91e7a10bd7c7b463582110e473a13b080c01e7a |
Hashes for PyPartMC-0.0.23-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67df7664c2d14a26d55542a4c1e47cd06a7fe9e1c56cd88e8580c810b9ed3bf2 |
|
MD5 | dcaa264cf156ab38e09cd990a6c8c8bc |
|
BLAKE2b-256 | 0a8d1d7145c397b19ac7d3ea25c9d30f73524439c30cd963ec4a874e259895f9 |