Python bindings for PHYEX physics package
Project description
PHYEX - Physics Parameterization Package
PHYEX is a Fortran library for atmospheric physics parameterizations with Python bindings.
Features
- Mixed-phase cloud microphysics (ICE_ADJUST, RAIN_ICE)
- Shallow convection schemes
- Python bindings via Cython for easy integration
Building
Fortran Library Only
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
cmake --install .
Python Package with scikit-build-core
The project uses scikit-build-core for building Python wheels.
Requirements
- Python >= 3.11
- gfortran (GNU Fortran compiler)
- CMake >= 3.15
- NumPy < 2.0
- Cython
Installation from source
# Install in editable mode for development
pip install -e .
# Or build a wheel
pip install build
python -m build
Installation from wheel
pip install dist/phyex-0.1.0-*.whl
Installation from spack
The package is installable from a spack repo
- To install the python extensions :
spack install phyex +python +double
- To install fortran package :
spack install phyex ~python +double
Usage
Python
import numpy as np
from phyex import ice_adjust, rain_ice, init_rain_ice
# Initialize microphysics
init_rain_ice(timestep=60.0, dzmin=20.0, krr=6, hcloud="AROME")
# Prepare input arrays (Fortran-contiguous, float32)
nlon, nlev = 10, 50
pabs = np.ones((nlon, nlev), dtype=np.float32, order='F') * 85000.0
# ... initialize other arrays ...
# Call ice_adjust
ice_adjust(
timestep=60.0, krr=6,
sigqsat=sigqsat, pabs=pabs, sigs=sigs, th=th,
exn=exn, exn_ref=exn_ref, rho_dry_ref=rho_dry_ref,
rv=rv, rc=rc, ri=ri, rr=rr, rs=rs, rg=rg,
cf_mf=cf_mf, rc_mf=rc_mf, ri_mf=ri_mf,
rvs=rvs, rcs=rcs, ris=ris, ths=ths,
cldfr=cldfr, icldfr=icldfr, wcldfr=wcldfr
)
Project Structure
PHYEX/
├── aux/ # Auxiliary routines
├── turb/ # Turbulence parameterizations
├── micro/ # Microphysics schemes
├── conv/ # Convection schemes
├── bridge/ # Python-Fortran bridge
│ ├── phyex_bridge.F90 # Fortran C-interop layer
│ ├── _phyex_wrapper.pyx # Cython wrapper (CPU)
│ └── _phyex_wrapper_acc.pyx # Cython wrapper (GPU/OpenACC)
├── CMakeLists.txt # Build configuration
└── pyproject.toml # Python package configuration
Development
Testing
pip install -e ".[dev]"
pytest tests/
Code Formatting
black phyex/
ruff check phyex/
References
Based on the PHYEX physics package from Météo-France.
License
Apache-2.0
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phyex-0.1.0.tar.gz.
File metadata
- Download URL: phyex-0.1.0.tar.gz
- Upload date:
- Size: 961.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
668a1325786403e5542e729f202391b702508cb1da5d611805d3580f4744f1a8
|
|
| MD5 |
65097cff095e68eb979934e927829db7
|
|
| BLAKE2b-256 |
bb098485ac15f41b7af59dcb218325cff7b8410dd0a137101a3fc8210b3504ca
|
File details
Details for the file phyex-0.1.0-cp311-cp311-macosx_26_0_arm64.whl.
File metadata
- Download URL: phyex-0.1.0-cp311-cp311-macosx_26_0_arm64.whl
- Upload date:
- Size: 6.1 MB
- Tags: CPython 3.11, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1055562962ffd3145423a8fa973f1ddd539088a7829c0b3dc4ef210bec089bae
|
|
| MD5 |
d262b0d86e70b23862587db5405421a3
|
|
| BLAKE2b-256 |
943335662fb79bb0fa69b7eff6b6e4f0be17f155db2880a397fe994416592add
|