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.28-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34cfc0c0f0e54094c482c687fa2c711db85212eae5c1afcf20eba13e4fffabdc |
|
MD5 | 9e5ec9a172fb514ad15cc8c8acca8572 |
|
BLAKE2b-256 | 627a335b7654269084fc2432e1a5fe3c194075d31c964f883a6e03b67d49c76c |
Hashes for PyPartMC-0.0.28-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79ab91d70391dc8743df380f32e13134a2ee20c770a3be27bbd812c4fe3b3473 |
|
MD5 | 13dcbf646700fb88316803655e00c31c |
|
BLAKE2b-256 | f784c1bbd748eaf54f04f8b4c5aa12f1d86c4d1ab14a2b879796e26a84ed6cc1 |
Hashes for PyPartMC-0.0.28-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5baf513ed080801f9244dee22ae9dd315d9a4e59428c55dad01bdffe58cb6fe0 |
|
MD5 | ec2a022bf73d5eb702bae30b3d7b7864 |
|
BLAKE2b-256 | b86be989e98d8eb77ab70b70c6536537b4a9fbc3880333e0d20b79e7c24ecf01 |
Hashes for PyPartMC-0.0.28-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd5cf2b95bdb5acb9596d8b9136000667f68c026527701ad85028d66904f2100 |
|
MD5 | a703c9c51341a589850c49def00c9efc |
|
BLAKE2b-256 | 9a5e9698029c73e116a756d53e7a5c3f0ec29a648bd8106be71baaf5133aba1a |
Hashes for PyPartMC-0.0.28-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a744e5ea07c5598151f46d3666d3c802dfda094904a6d4011c67ac49f9954bb |
|
MD5 | 0664e24137234d59e8ca1717c8e5ea91 |
|
BLAKE2b-256 | 5dd96cc28dfef425b966a7b8d9d3e8dbaa58acf6f9775998e15e4a8a23c2e456 |
Hashes for PyPartMC-0.0.28-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b979459b7cdc58c5835f836c75cbae1db14a6da79f209283d4cc8513495ceeb7 |
|
MD5 | df8e62c41ac136cd9df524208d9ceb38 |
|
BLAKE2b-256 | cb5c9e3701d262dc1861d6eb9b91f3e47ca77f6d33d3f502075009332caef930 |
Hashes for PyPartMC-0.0.28-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa5e36bad239b179cf6e53f67f74f8e0eb9ae04f5cfd172cf5d47e0de85dfffe |
|
MD5 | e3b9cd360769c8c0aff88d66d8cc1b78 |
|
BLAKE2b-256 | 7ac8dc56d0341a528112c3184a1c07997c5a19e0a2b1f07acfe530dc521b2d05 |
Hashes for PyPartMC-0.0.28-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 782b3517005f6c22f0bd1a4dd2c138e3371834ae4c5bccbc450858e363ca461d |
|
MD5 | f3c19d25e35924422c8bbe6cdb314d9c |
|
BLAKE2b-256 | 455536be28754536c838662cd3d869fc070d5ff1e50172eb0b6ff95d04c3539b |
Hashes for PyPartMC-0.0.28-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a2ad26cc9fd66673524a47d56db9d30bfb62722e518ae9abc044087887869a0 |
|
MD5 | 91677dde407428dc323b58c30a4bf2e4 |
|
BLAKE2b-256 | e97672f91a843827d4b61061148e2b90029cf9961837cd59a5b7f19271913db5 |
Hashes for PyPartMC-0.0.28-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55066d91f870b6851c93f9c99fd068c718c813b521f6f405dcb50920e9fa2b3b |
|
MD5 | 05026dfe0c4b6207359fcb3931e53fcb |
|
BLAKE2b-256 | ea8d535efcc7269832e564539df4f3a731d7c7f63d9640dff6e83b121531ed6f |
Hashes for PyPartMC-0.0.28-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efce38fdd76e88cfa5d8971a74e67e15e5323a5d45830da21c9ff1a2b9d82957 |
|
MD5 | e6dae7bb7d70e5b0e5ea74c75aeae207 |
|
BLAKE2b-256 | f5a22ee6d556031de01677922ed9009319f8e546c4ff05b07887081a8e0d849e |
Hashes for PyPartMC-0.0.28-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ed9ca6617f307bd3a206dc9972ce7efbbaa15ada78965d3a351dcb30c6bbb5d |
|
MD5 | ccb72a6fe230693f9349d573ae5b2fc4 |
|
BLAKE2b-256 | d928d47dc5d2b555455bf3103080d43d08a6dd8915ed2a5a715822b12871d20f |
Hashes for PyPartMC-0.0.28-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07810fc3d82ca76180b01b4476ce360732ef169fd1011ece9fb3320306c22d8a |
|
MD5 | 23b2bba0349dd30b77587ff64ad21563 |
|
BLAKE2b-256 | 01b836cd163fe97d1a998312cb2fda89ebda8f805b7a7a27617b15370192b7c9 |
Hashes for PyPartMC-0.0.28-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cabf0e8528939382b46ca7990e3f1aa030e95211f3cdd780fefd83a68434ef7a |
|
MD5 | 59d7168e6e53459b3af3caeb5846cf3c |
|
BLAKE2b-256 | 3da599c9d96184d3606f65af3721cd7da110808b18c9d6abf3a36dc77855ec3f |
Hashes for PyPartMC-0.0.28-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07e8031fccf73389bb9db8df1157d739dde0d61332c35c8dc4bdb521785c7cde |
|
MD5 | 7e7ee81a040a26b580f094be56272d97 |
|
BLAKE2b-256 | d347f5aa4df48f6da5b433d361f8fb5e5dac801c4c72ce9d874d7807f4126db2 |