Python interface to PartMC
Project description
PyPartMC
PyPartMC is a Python interface to PartMC, a particle-resolved Monte-Carlo code for atmospheric aerosol simulation. PyPartMC is implemented in C++ and it also constitutes a C++ API to the PartMC Fortran internals. The Python API can facilitate using PartMC 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. Python GC deallocation of Fortran objects
- specification of parameters using native Python datatypes (lists, dicts) in place of PartMC spec files
- code snippets in README depicting how to use PyPartMC from Julia (also executed on CI)
- auto-generated API docs on the web
- support for [de]serialization of selected wrapped 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 statically linked (and compiled in during
pip install
orpython -m build
) - C (SUNDIALS), C++ (pybind11, ...) and Fortran (PartMC, CAMP) dependencies are linked through git submodules
- MOSAIC dependency is optionally linked through setting the environmental variable MOSAIC_HOME
- 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:
authors: 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.33-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c70ee996fd4c962a7055635d1b9787b6c86c719ec1eb5dc4b15b944a95efe67 |
|
MD5 | 941e80248cc755763c13cf7d45c40f8d |
|
BLAKE2b-256 | 6e49015aeb04e65cf209b371bdc3375df79437e196e9d115a031fff687920c3b |
Hashes for PyPartMC-0.0.33-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b110f8b427d767c8496416d4672b9f517af313f53836dd0cdb91f0923c2a2973 |
|
MD5 | 5a7a687c650aec641cf2cac025997e43 |
|
BLAKE2b-256 | a33e1cbfa8dae110a18f4093e339958253341dbe75573bc57668795c62358ba0 |
Hashes for PyPartMC-0.0.33-cp311-cp311-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76c46949c5e07a52f27d2794ddf8fb070f7043f71bd010347ceefdcf86ded78f |
|
MD5 | ff8c696714ce79722f7ce8cad9162c56 |
|
BLAKE2b-256 | 56bcae9e6869686ba14ae1cb53bef2af947dac06c24b1b93429e6ccaa819e1ad |
Hashes for PyPartMC-0.0.33-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fe5dbcf9001ac7fe00a43ca870733c16f21c9bc5217c5f97e1fcd173e55d31f |
|
MD5 | 9a6ca9366fb792cba90d777bfd895239 |
|
BLAKE2b-256 | a39b4da9650e318fbebcd7059449d144209c9e61b53cd8b6d794cb82ffaaac55 |
Hashes for PyPartMC-0.0.33-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f012ca54598575d97e9b47d65741be42febeedbbe97ec045c1299422a29fcd34 |
|
MD5 | 3ace711bdd62ead1f7d5098725de802e |
|
BLAKE2b-256 | 48bdb2f9cad44200e07405caf1fe9ebb5151b27ce846b53bbbd1d7b5ab6346a0 |
Hashes for PyPartMC-0.0.33-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b14f736e02da70b5276b73229fc70c479454b9bb9654d38bd17ecd71c6d66702 |
|
MD5 | b3768fc40ffcbadaa116cd58fb43f7ed |
|
BLAKE2b-256 | 695ed53e50196ffd6bf5be32c672f32d203084bcebc605459334ab8a91d4d796 |
Hashes for PyPartMC-0.0.33-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf2be822315e030c9b7bda084d11b2d70212069bb37dcb7e30e3c47107cfdd20 |
|
MD5 | 6fc3aeecf30a94cd78e3a5f03e9ed803 |
|
BLAKE2b-256 | 6baf3c3c64ad3bb886727149a744708cef61f5372394ac77162ea68f02ab6938 |
Hashes for PyPartMC-0.0.33-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4382974894fc934174d1225fb65eb7a9864b98f9950c1ff9ee6a736bde806e6 |
|
MD5 | e11a69e01d7efc178ddb02de209c7d0b |
|
BLAKE2b-256 | 2db943a8195e48110672331ec8162481185ff9e2d5a601fedcd5ac1091b7d9f9 |
Hashes for PyPartMC-0.0.33-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b34f64e5d12ea95e5b18849596e26563368d2af9e62f75d041532f3dd3e20ca |
|
MD5 | 82c124c5ea770cf7f1918511e9886be2 |
|
BLAKE2b-256 | 0cef66432f0cb5c56f040f3e3b0fde3db1d29d7b51bfa976572f1ded7da0a238 |
Hashes for PyPartMC-0.0.33-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b696b453139fd86152c8de416c66767646fd7567dfb185d582a02658649168c |
|
MD5 | 47f005e9b7e14cb996059dc3756d0d0b |
|
BLAKE2b-256 | 275b8a56e08e8b94d0535f4fd2f43357e15bd760908527ce92b5288495574b72 |
Hashes for PyPartMC-0.0.33-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 010a035a6ea5769fbf826b91e9a2d26954f15b2f488c58731222d45f3b8dd617 |
|
MD5 | c33c664b26291edcc5919fb402dcf7ad |
|
BLAKE2b-256 | 579245de0e7e0d8de7fe8e98204a2035ad75b478bbbcb1e074f7eabe36ab9acf |
Hashes for PyPartMC-0.0.33-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c19622da4e62e980fa88c061f67289f99662da1db9f7f609f793ead381268fea |
|
MD5 | c675f2a82da4df720040ab4f58eb7f5b |
|
BLAKE2b-256 | 283b97908471ab52798451482126f26bfb11ab9c993a56aa75c0bd1bbd17bc43 |
Hashes for PyPartMC-0.0.33-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f806bc4bf1776b8f416ae02885a1c59ec96d2ea009ff3f58fcf93e7c69c4f02d |
|
MD5 | 451f56a4cf67521a3c8da77c5d5416f2 |
|
BLAKE2b-256 | fc7495a01bfb3a7db3082d12780ebbdb800b2bb34e8d82b0337763220f8d78dd |
Hashes for PyPartMC-0.0.33-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cf3a490f1c4ddbb5e29e03d67ed27bd8f1217e25c4a4fce33ab8d0f227b9532 |
|
MD5 | f8559578426d5b4328c892d335dbb424 |
|
BLAKE2b-256 | e6b6170cd7be9f5aa9ed65bf4d3b535c001ea8cf0afffe368172b921f40aee7e |
Hashes for PyPartMC-0.0.33-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c9e7fee6d6eb6b3f73b6a8d706261f6683800f8d6f2934d6928b2dcf53da4ad |
|
MD5 | 63c6774a47df42a7203e83ad58d13c91 |
|
BLAKE2b-256 | 9dd74694cce60a846514124aa6d38639898978f945a169348a29fbb08e9daa77 |