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.26-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 803775612841ef1f83e9e63ed5a438891ccb20523733014560a0974e10f5f99b |
|
MD5 | cef71a519b5fb4e98d40116ee5d8091d |
|
BLAKE2b-256 | 7c212651e9383a8db5e9467db77fb2ca2409f5c2a613eba1429101d4de87ac48 |
Hashes for PyPartMC-0.0.26-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e0ddd399fa835be12b64fc0d50ee1108209fef4653f0102abea5ac2fc760310 |
|
MD5 | fbf297d0ca20c4d59543b7cbc4b2c711 |
|
BLAKE2b-256 | 15b7a3ff5771183ef0a2ce32b3987c965193d14efffcb19ca0952103304dabfa |
Hashes for PyPartMC-0.0.26-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d75e207d83cf6ba50a080c5de91d241fdb9d514be4586a11d58d6023226d04fa |
|
MD5 | 6fb04811dabc34cbc0f49f70ff9d2140 |
|
BLAKE2b-256 | 0821e0f463610070bb89e44a28d671b6f6aa1bb4e1ebe738c8e43b34c7dde3d5 |
Hashes for PyPartMC-0.0.26-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d7582281b212a32b3270147197798cc70a863eb2c8676b1d36f3f885c587115 |
|
MD5 | 450915473a7f22c276951ef0533b8b30 |
|
BLAKE2b-256 | 196fd461a9972b28e8ef3078bd6a9714ef3c68ec5fba0119d597a3043f9efb50 |
Hashes for PyPartMC-0.0.26-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 234fe9a7354b5337687982fa22d4207e62d219e61541ccbf77f39faefff056b8 |
|
MD5 | de233d652c7643a69c357dcea2ab0628 |
|
BLAKE2b-256 | eb030a615bfe4ef3262166bd804bca0b7c782abe366c19ac013fcb160aead3ee |
Hashes for PyPartMC-0.0.26-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91a9f456814fed6b4e95c8719db576e17fbd03c30fc1654e7061a80e0f4b5fb3 |
|
MD5 | e164b7cd91d63f34ac1d95dfc25dfde4 |
|
BLAKE2b-256 | a314df53069d169a3bc847a71dbe6c34de81b18f5c77419cf1e9ae4d421965ad |
Hashes for PyPartMC-0.0.26-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef3409efa87e51f8cfe027b1aecc85e23c1a2ad7fa0cb39317aac24e780be2ec |
|
MD5 | c04bbcf6fd7b96a6a896dbd6a3567b1f |
|
BLAKE2b-256 | 76608db318a8b076cbb0ad8d3aefcc3dd096849b43bc6901181cb23b80c95d10 |
Hashes for PyPartMC-0.0.26-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b6522856cd8a39cb60f38713ed4e5b5af2427b34f427754b6e58b7e9e9c24ca |
|
MD5 | 9305f53c03cf5b2aa99a85b1b6aff577 |
|
BLAKE2b-256 | 5046d59bd4b4805f3a7ba83885703071d3355fd674398404423124820d7b3104 |
Hashes for PyPartMC-0.0.26-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbd9b619554aa422a872c192d63b4263122d2b2e126545abd5a017acdd4b1ef0 |
|
MD5 | cbfedfe0127552f8aa6210aaa430b36c |
|
BLAKE2b-256 | 78a404d6b5e766822e4f40521eb7b14cceb31ebe860747b0faffaaee0f3faea2 |
Hashes for PyPartMC-0.0.26-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 493b5fd5cf80dbb4ed716ea9d8c456d7b0710d99ffc91af2b1266c3701aad74f |
|
MD5 | 38c8f4bbd01698a6f4ebe8482dfdf74c |
|
BLAKE2b-256 | c6253eb431ce7851f1cd11b9029e5aba9832dd67d96d2e81a757585aabb09efa |
Hashes for PyPartMC-0.0.26-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4da967f7b54452307068dbf1888f8215c8894d15172a4c52078551caec956984 |
|
MD5 | cfbefa35c7f0453ee879757a05892910 |
|
BLAKE2b-256 | 78e23677901f7d631a10c97ae47b0bc8b497a1f914aca0d74dbcf0dd418356d9 |
Hashes for PyPartMC-0.0.26-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1775a9fa93382cda0537bf8de12b9d739416ae4fd3810f6b99935d984bb785eb |
|
MD5 | 1d1f0ce6f369da5e51bddbf48ca3863c |
|
BLAKE2b-256 | 685115388a2d331dc08f20ac3cb46ef4ccb7562474e786cd3caac807ce994a68 |
Hashes for PyPartMC-0.0.26-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abaaf448947cccc01b4bcea8d60ce361a05fc80fc315a77a3d6143b5112f4805 |
|
MD5 | 55bc052ce2c799dbcdcbb6c2f3bb316a |
|
BLAKE2b-256 | e91f23ac86ec9b81f35e87e5b01e697d211e56a78830c51fe3086acd48b85a11 |
Hashes for PyPartMC-0.0.26-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 997cf0f1e99c51532003c1e71bd4833caeac04ccf64d49714718ba70d0842596 |
|
MD5 | a529d61790b966e57597ba0d747220f7 |
|
BLAKE2b-256 | 927d27dae136654f9b3e083623b9ab0c89a2ecb66d593c000916f295d5d1f322 |
Hashes for PyPartMC-0.0.26-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fbcf393d79ee3f640dbaf6ff9546b44d51e745fe3611835b4000409c67fe835 |
|
MD5 | cc7ef3aaa12698cc482c4eb40eb10198 |
|
BLAKE2b-256 | 449828bb0478daced724cfcf022973f4496832f66ac594fc4d0080fcb059de6c |