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.9-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe0e3aa98cf40fc0a30d4043c17e5556913847808daffc81a4d4374d512d5124 |
|
MD5 | 997e1654c8a610bb9ec32538572b4a7a |
|
BLAKE2b-256 | cb5cb22a7cb15e99cd57f4cd5133a015a9d1f1f830f9b9150c7890e3b1072611 |
Hashes for PyPartMC-0.0.9-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | beea9d6801fc386e7e4b9ab4705c1a01a73ebe9f281617a4fe192643d91b075e |
|
MD5 | 7a21d967ae34777b928c94d8a65ee2a3 |
|
BLAKE2b-256 | 03daeb1d1acfe26014c6e9c294fea6f50023d1ccad44aedccf9f98a5f90dd6e5 |
Hashes for PyPartMC-0.0.9-cp310-cp310-macosx_12_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd15700f78f90a510d20444badd8a69dbe05348f190eb84c9d152bf6b9508e45 |
|
MD5 | d9bf361fa4aa08512ce53e2bac8a934f |
|
BLAKE2b-256 | 97b472e1f1b00bf8b1921ff9c78d0d5e108708b46850f17f856c183398c2ce03 |
Hashes for PyPartMC-0.0.9-cp310-cp310-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae15904a9be91095f438f66778b5297f8820c1aa969aa47a25da7d13393d0e81 |
|
MD5 | 6708d6cfb1d731b9213d78a8de626cdf |
|
BLAKE2b-256 | b6381b06dcb642f9cc82c5b4dcce641f58ecc710db4c485108b31b65491980e2 |
Hashes for PyPartMC-0.0.9-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49c1cdde1cdc9062c42ed46212cbe4b20be244c3a96fb4ebddaea150096cb119 |
|
MD5 | 27785db8dad138d9e9cc27c724154610 |
|
BLAKE2b-256 | 52b64a1f6d0ea8335d018cfc72e2c7a5559f38098e01818eb4518f0de0cce644 |
Hashes for PyPartMC-0.0.9-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 436d1eaca1750f5bec1daad82ad3c978989ed315bcb084ba16b3c7ba1baedb31 |
|
MD5 | 07d2b166939663df682be77632072d08 |
|
BLAKE2b-256 | 69eb0c8e11d90d39dc9c4960bb9418df3c19765958c02cad732a1343cb1e67b2 |
Hashes for PyPartMC-0.0.9-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfe79ab7021ed35d05b18abd094406eec95d13f43f4f9a3da10bc16b6da110bc |
|
MD5 | b0f6408a9d6db300987b472dfaba5c2e |
|
BLAKE2b-256 | c93d6b5d410da33d2975acde2a3daddc2d42b031a1c6d924dfe2e90735e18b99 |
Hashes for PyPartMC-0.0.9-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 380c0b2ff83d4baa9ce6b2501dbe4060a35b17a462c71afe7b40d97f2b22fa16 |
|
MD5 | 5b75c62d7a0be0e405a903c7b00ab95b |
|
BLAKE2b-256 | 96c77aa5829e9fbb8966767c0c15d75c018cdfc28a16344971c2aa97c57b1af2 |
Hashes for PyPartMC-0.0.9-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33c1e1d4bdd4ba76ee3f220a9da18bcef50004442a49efc57068eb3027f9a523 |
|
MD5 | a3b8ea74f2a40dc1c72ffa8623f54969 |
|
BLAKE2b-256 | cb856f8fc631b04328b51ebe1ad7bccc80af09a4c23813651cd3b0c52bc4c076 |
Hashes for PyPartMC-0.0.9-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbac7a6a438f01694b56d85ef694263ab4ea70cd505838b28b935a5724547f63 |
|
MD5 | 0a3c1d53af3d619e03d1c0ec511a6384 |
|
BLAKE2b-256 | 9895d09556f9c31d1147bb2002b115a358e2bd420a4608707ee7b336e0771ff0 |
Hashes for PyPartMC-0.0.9-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c7ba1d91b7c89241f565898c25f8c1c63f6a5469c031f95ba8e383c5481ae90 |
|
MD5 | 583feb5724a55ddbe7b1bb01a44bcf96 |
|
BLAKE2b-256 | 827e13fce29b925758a1e1ceb607b607d77d08486b4fb95a7d39f5265944cb80 |
Hashes for PyPartMC-0.0.9-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bc451bd051e9576cabfdf97c17b59e1157593c4d01d547545dfa60d98f425e3 |
|
MD5 | 08ae5355204f7327766e708e6d077c94 |
|
BLAKE2b-256 | 6354706de589810e6016fa0c329c4c15d9dd785ab756856b81109f52c2e0335f |
Hashes for PyPartMC-0.0.9-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d4b8b08a29ac0d5cf24cf62bd482e4a12a5fc0f44873e4c384a8cd5b1c372b0 |
|
MD5 | ef9f77807739df166b699581568db640 |
|
BLAKE2b-256 | a9b40032d2b14ae8cd0c6363926b08c7ebfb606227d58dd194902f0cdace1575 |