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.2-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 377db0e9869fb751c55cebae0e68e931d150f7cca94d076b5bf9c0715103d5dd |
|
MD5 | a5ecc2537b50a47d825ec0022257fe25 |
|
BLAKE2b-256 | 1dd1b268660248823bd90f8a1dddeb3b3bd5690e3f1a45d745230c1953db6718 |
Hashes for PyPartMC-0.0.2-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e26e4c056129d72798935bbfea2a6f6486fa5ad70f01966beb6cbf1902e34502 |
|
MD5 | d1c8450085aaefd04a2ba04ef26f1ce5 |
|
BLAKE2b-256 | 72cc5b61aeb9543119a905e2edb7f7e433474fadee3edcee3e91067918d4823a |
Hashes for PyPartMC-0.0.2-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5012ce14324804df7208bacf02687592f99d5dd35d5a15107d6215a7e0031fea |
|
MD5 | 37408416ffb8451d0add85cb6aeb967c |
|
BLAKE2b-256 | 718bc4fb14dc13a9d5e4ca33a9e9106f4cfc576409308e4f4c4c849edf547420 |
Hashes for PyPartMC-0.0.2-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b9ed01777978f330650358f6cc1c4623cea1ff3a49da776866a8baf25e23028 |
|
MD5 | 1851bc87faa0b0243689ed3595fa0895 |
|
BLAKE2b-256 | 3f29c6a0aeeb9fd0f90400976fcecb803b5d1a69800e3ba8f2b6faf8f341e095 |
Hashes for PyPartMC-0.0.2-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df3047facd5ef1514ac99c16d232ba16d243bd9e683108d6f2b3aa7de1f4866d |
|
MD5 | c0c77a5adbbe346cfd76cc57bfc32def |
|
BLAKE2b-256 | 5448ac633139d330b0565c13d45f347e4597ae093588cd50ca0d1f6499475c4f |
Hashes for PyPartMC-0.0.2-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd976d6556c28ed039e35614d1928136c80696d745ef33bd603df8d3dd3795ef |
|
MD5 | 27f2de3c23274386d44996de4068c62d |
|
BLAKE2b-256 | 9f68c2ba5a5b92dd7eff9c67f3a931a45d8f29e58bce8fe9fd0ff815e54949e4 |
Hashes for PyPartMC-0.0.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14668940e774f93721dbc41956dc6ce6086b6a5538b915227fd9c6e901af38ee |
|
MD5 | c8dcec349a3ef1cf10dd6bfcc9562341 |
|
BLAKE2b-256 | 1ccc33081a6465451a1443e6b8fc937480498e963d1e82bb30c0b94096b61171 |
Hashes for PyPartMC-0.0.2-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab94a3c7871d72d6829ab9323c37be7eb0f8de024c9bfa196cc48c64aaaa74d8 |
|
MD5 | e7ceb81269c4b33fd515e35a8b0f29d1 |
|
BLAKE2b-256 | 251849532f65a4f981c0884167836de99a746df9a372a53457454090dff8205f |
Hashes for PyPartMC-0.0.2-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fb2f8d648af8158098c3d08c7ffdfe7cafc0625a2a127c8c2588d61758a5e83 |
|
MD5 | 886c33a94e656b75d0613d9f1041e653 |
|
BLAKE2b-256 | cbd600ded45975fd65dc56f2f40b4d2f4efdf96c9ef57960fa618c9b7cf0cc69 |