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
)
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.30-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a056d96eb2425f66377312916dbb8ede85f8698c1a46e67ea23b751d1658d98 |
|
MD5 | 7e4a48f58f037abb0908aa3796f7fd27 |
|
BLAKE2b-256 | ea7beb02d0b310ecd80f21ebdd1d3951044ff532bc5543dfa6b60e0d84448eac |
Hashes for PyPartMC-0.0.30-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d6c334dcd4e268cf598ea410ddaca29bb0ffd5f6af960a24eb86fd37f66c824 |
|
MD5 | aa8325324d9705f5d373f18dd8b93f8c |
|
BLAKE2b-256 | cfbc1fbf2b314cd95071f4221be6e805be3e07c0bf3bf2e91d766d6917feafda |
Hashes for PyPartMC-0.0.30-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 833f2ee160a6f6e46e516202db07bd4b0e54ec45d401c1b9d612cb95034ac2e6 |
|
MD5 | 02372737233d4a60497e0e32ffb31859 |
|
BLAKE2b-256 | a93e9f6bb2517ea50d6bdc12772b61b58586548a0be024a444746f525fa4f185 |
Hashes for PyPartMC-0.0.30-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6df3eb31cd5e63284019512f4b72dfe54a9cebef8061c5676b72b042920cdc0 |
|
MD5 | 9595b53b44387ee9adaa6756385d644f |
|
BLAKE2b-256 | 902f30bdf4317284482a064bb4eebc0690be21d63cb0a426ae82d4eebddddb2d |
Hashes for PyPartMC-0.0.30-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5474463645dfbf6e7493e536471d68ccd7db6e6c0604e3bcfa52fc9830e4471b |
|
MD5 | d1f380f092a6bc8282ef9e4c26dc701c |
|
BLAKE2b-256 | 59ae259c0ddaff118069c197a5fb082fbcfa332475e88ee26400e6dbdbeda48e |
Hashes for PyPartMC-0.0.30-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5679501ebb57fffec1f8cdce58588a8014380193108001f66e2b9bf66d27b72 |
|
MD5 | 642d23233ddb22ddfb6be863351ab6c0 |
|
BLAKE2b-256 | 0d21749f2c10066d00e4ef4da2727f7fbc334010173b06d3a82cd569e06475e9 |
Hashes for PyPartMC-0.0.30-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce586aa25a371c261eb6582dc1c87867c91f9a667d545c2c3b039faa1e96e0d4 |
|
MD5 | f3625ebef4514e8f4f41241a74edf817 |
|
BLAKE2b-256 | 92ad455525b1bc4d65aa2a8f5aef8d5b19b426ac27525979dd47a73b3e0990f9 |
Hashes for PyPartMC-0.0.30-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e76e0cd11d8a1c2b8b41052f636254908a937b8380ab7e3ce64623401574b1f5 |
|
MD5 | ecf464194e8d8292fab838474310b56c |
|
BLAKE2b-256 | 7f00444e5d54de5387efb8b73f03436333ac17927e704ad4cdb2864a8726a543 |
Hashes for PyPartMC-0.0.30-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea32f0f4e38725fe710e984a1e2f587d1b9530071aa055b5420a3afa446ed04f |
|
MD5 | f62bcb06d51a236dfd26014f39b4de18 |
|
BLAKE2b-256 | aaae1148af0decf6fd78f88d81d155c1a7155e5698f56efb8e5970f813733fcd |
Hashes for PyPartMC-0.0.30-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3913824e8699bef12028f62896ed95e8b5e32c6f12e0781ce4c08d1ba57aeaef |
|
MD5 | 63717b8a881c4fa68a036dec7d9a8741 |
|
BLAKE2b-256 | fc0ed6e5c84db87cb0c55e36e066a7c5eee4ea01a1f31ae2d43c98185d740014 |
Hashes for PyPartMC-0.0.30-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d21bcb1210b7cc1d96119a8b2bab05c14d42d21a60868d11f6dc434ee7054a65 |
|
MD5 | 5f98e2c5a6ac70d93a32fda87482e495 |
|
BLAKE2b-256 | ee072d1d067c644da95aeea3b826c5888ed14eb8b1d2949b43eef95c83c89da7 |
Hashes for PyPartMC-0.0.30-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92042fa11cea67ba28eaa060a072bff58f35f7cdd3fbc21f4118b0e1c8a460ba |
|
MD5 | 8410be88be6205b04807a5c1aa8f8bed |
|
BLAKE2b-256 | 6ddc5f142b1895fb584c3a5be0ac1fad022e019650cfe33e418c177e34f0fa8f |
Hashes for PyPartMC-0.0.30-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e30bb9a189f636a8a593ec6d576eb166b628dca05bd40a9c9037a2da05bea993 |
|
MD5 | fac71bf7871ce50112b627e2444d7b5a |
|
BLAKE2b-256 | d70a53f705b43b575d8ac454beb3efd9d072128ff96686e234eafa5f434ad709 |
Hashes for PyPartMC-0.0.30-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46db1c3e6d4c21914a5608d9e5d192699e4fa4f2d350d9f54a37c915d479bc7f |
|
MD5 | b5cbcc99d11628a41641b9d3ff53d646 |
|
BLAKE2b-256 | 5624250358feecb39fd86b0f8d73779b7cc6aef1c884e560e628145ea43237dc |
Hashes for PyPartMC-0.0.30-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63626fe817d923f62438e8cdf701a78fb8bff1f4241cbae64fd26e57f03675b9 |
|
MD5 | c9c6b21ccc1e7ac6c9db106019763fa6 |
|
BLAKE2b-256 | b0f81fcd247486f39a9965eaaf7ef7996af3567f2ff73e0b29952ac1819ae550 |