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: 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.13-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb0c2929801218cd66272212b9cfcd48cabdf270ae9289b3a23e9179d40d3a61 |
|
MD5 | 65b7d5aefd2ecef8751ddee0e16c402e |
|
BLAKE2b-256 | 19a7861e7f6b173ec9147b2e30d4790a2b63408036cf838a4e3c3935e7dc2296 |
Hashes for PyPartMC-0.0.13-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 346a14c2512fc18604e2abaad14c5ed6c4583f9f3c070e2fbc7c29721f552f37 |
|
MD5 | 3831ebf1fc4b1809d50f916fa947a3cb |
|
BLAKE2b-256 | bbea53504d88ec5a18754e5e33eae3040d0031bccee9788170f58f93364712c1 |
Hashes for PyPartMC-0.0.13-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6610958f95bee6ac0c31bffa0fff53ddf56946dba1a14116781104ce618d49f2 |
|
MD5 | 7935f0e9fb138e75ca848b20cca1ac0d |
|
BLAKE2b-256 | ce202a33583725ec3605fec45f0bc389b111b7997bf8ec89706574e46584fa5d |
Hashes for PyPartMC-0.0.13-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87fa66ff846cd8109dd6d5580a5b9401048f823655b91c270604e1feae31cc43 |
|
MD5 | 1c1f6ec403c8455a945e449d274fe51f |
|
BLAKE2b-256 | 48d6e853cadbe3214628235716f1b21d573b949b08a408fb5cfe4977ae13b387 |
Hashes for PyPartMC-0.0.13-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13b6083b530422304dfc74b4740ca391df49d6b59ebd821dbf685e22ef46571f |
|
MD5 | 27fcce65d5f30753ea1681ccf82530f8 |
|
BLAKE2b-256 | 773fd63ddec2f7575284ad7202185ca4bd8f1a72266359b019a37a9557a9e3be |
Hashes for PyPartMC-0.0.13-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54fd571d0a2c5de9ad839e2996b54271c2a54f2e940d777c9ee422b1510734f5 |
|
MD5 | a00cf448ff9dbfe8548d5fc4e99592f2 |
|
BLAKE2b-256 | 53b019c780e6123609e11c2200befa386619913fe618a5260bf73caf6a7b07b6 |
Hashes for PyPartMC-0.0.13-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11d6f811730f0e05dfd4259b33f3af4a1120ed2d588b0c10ecb891b365cc6160 |
|
MD5 | 62c8070e425401e662224fb7c7c3f3d2 |
|
BLAKE2b-256 | ba4bd436040c1432081692d9a37d92e1b8db671079be65e3eae99bab44112f74 |
Hashes for PyPartMC-0.0.13-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 368b930f4f92c4a41cd487bf04c89648cf68b06d5ac90dac7c0ecad1a0fdcd3d |
|
MD5 | 2d7f74cb5148c0647dd6aa78f59ed692 |
|
BLAKE2b-256 | e3a9d4bc37b3c050272999250f7dcbaeee0f5219b7c05426d6660ab61b0e486d |
Hashes for PyPartMC-0.0.13-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67c6948426cb2e4cea7cfa5c5f67e7f42195690b1816c6ea23059cee30737a01 |
|
MD5 | d828768b71b9d55634ed229daef0bffd |
|
BLAKE2b-256 | bc0d8667ea5eebec8bab0f965d3263eeff843f6e53caa1ed93fc5a0eebdab476 |