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) 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
- a mock of Fortran MPI API is used for error handling using existing MPI API calls within PartMC
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
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
Credits
PyPartMC:
author: Sylwester Arabas et al.
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.5-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea5412c10cc396093b7fecefa51244b35a2397994462ac4645ad3192f256f175 |
|
MD5 | dcbef0dec7c06b5fc5e3bc620113d1a4 |
|
BLAKE2b-256 | c5b54432bdbe606ad425ac9bcb8d0cbb3a53a911e17fa27084966f2d7d107d9b |
Hashes for PyPartMC-0.0.5-cp310-cp310-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f39d4994595a72f2edb0e3c009f8d8778bb3dae32e51a6df54a1692845d7eecd |
|
MD5 | 5484d76e201649e00f2932647b291a70 |
|
BLAKE2b-256 | 9c443038a34ceb3f5d46ca8c7fd87adb21036359de64cf9840f235fee2abb4b4 |
Hashes for PyPartMC-0.0.5-cp310-cp310-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a7a7f357fe6f1deca7d6e11224a93d618806e8f506342cc509c3aa0d41a6d51 |
|
MD5 | 186ff9daa9138e1c2693d789b3e5a4f7 |
|
BLAKE2b-256 | 42c1a6c9078530f63ecf2a9cb84403ec1a2cf7b841d29b28fda3c8a1b1220c6f |
Hashes for PyPartMC-0.0.5-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60f75cee8c5ba21d769fff3231072530b13a45d2db0ab1d526b849f3271c2258 |
|
MD5 | 9b20ed62d1da3363e0cfb545028c8510 |
|
BLAKE2b-256 | fa25bbc3f8760fe1c87bc13ec97257bcc6be1b13d34f4d1a4ffa4cb3dfec68ce |
Hashes for PyPartMC-0.0.5-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d2be36a421b14fc16fcf40d8996bdf5f06d13677d6b24fedec4205de48af06a |
|
MD5 | 91899aa88f318e8be0e4e069cbcf7f20 |
|
BLAKE2b-256 | d9477134fa3cd4230e49b62a78f61779863cf4b4499d735df7c80b80d4567ce3 |
Hashes for PyPartMC-0.0.5-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a93b585433214b27061d0803414dcfb1dbdbd8bc356e25e5f22328539af6f893 |
|
MD5 | eb5e1e6bfd0dfd0f9b78cb532c160827 |
|
BLAKE2b-256 | 6e12ae5abf3dd22e35f2c1260173c5f03dfa940f2cbebe946701271db8eeee3a |
Hashes for PyPartMC-0.0.5-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40883569083bb1fc33c76be1c2df07974b45745125a1530924ef171bacb9e423 |
|
MD5 | 27f54cd0fd682e6be385e64aee93f6b2 |
|
BLAKE2b-256 | da1a23351d1728a7eb3190cf2fcb2e13dafccf543cd70b714e78867bc1914ace |
Hashes for PyPartMC-0.0.5-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe0cf0e5cbb642a7b30dd1215239aa4f7935cb0e9264989ef491e95c0bb01f38 |
|
MD5 | 31c217c3add1085975e9f4ed17fd7fb7 |
|
BLAKE2b-256 | 59e2ae88580f387e2e704a891ff013fd17ab81edcf7ccb833b65a1d0e555eea4 |
Hashes for PyPartMC-0.0.5-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16dcb39c110886babca0388d0507c8bb926cb99a812c0d54c52efde79ddded0c |
|
MD5 | 74efa5a0cea9f920a1e35477ad00f740 |
|
BLAKE2b-256 | 55be1e753f3d7e538de64ec4be262e7d95e54f0b7893b8f4faee9272da67f704 |
Hashes for PyPartMC-0.0.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 556ae76259fd45a1999d0b24597b498b36750c05265160f7745178e10c941bcc |
|
MD5 | 96c32642871b0a5f6c34ebd67fd03f58 |
|
BLAKE2b-256 | 8fb608e8c63a307fc52a19cc53c8f4b86c2b7c975aebeaa910bab8389d8e75d0 |
Hashes for PyPartMC-0.0.5-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7e377fc37959fef278fa99a4fb149e624d2dcc96a7e0268149b796a3949a7d0 |
|
MD5 | 815c4e8702a5e8b17a43a9d84a41ffd0 |
|
BLAKE2b-256 | 9a2e71589a06b6e40fb80b3e4a0661578e42320c2123ad591c3bd52c91bcb95c |
Hashes for PyPartMC-0.0.5-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c4b46689601d13e5c134f6e8c75b984781c753c6d484cee4a485ef63b111dc1 |
|
MD5 | 8f0b0907403c70b9dd09cf6ecdc8d070 |
|
BLAKE2b-256 | 50b230a858db07bd1bf0ad0a8afd64acc3db5a11f7aab14714be3210aed0ad8c |
Hashes for PyPartMC-0.0.5-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6458ff611467940cc484060c4c6c8eea1a9986573fd1aa88c1a12106987f0365 |
|
MD5 | 354a6c1a596dfab19b9249a571c2d286 |
|
BLAKE2b-256 | 76fd4c58793d1e7dace32aa77a801614fef4b44a96a55c9b63c83d9474b95c76 |