Skip to main content

High-performance Atmospheric Radiation Package

Project description

Pyharp: Python-first High-performance Atmosphere Radiation Package

build License

Pyharp is the one-stop tool for calculating the radiation flux of planetary atmospheres, from terrestrial to giant planets. Detailed documentation and examples are available at https://pyharp.readthedocs.io.

Installation

Pyharp can be installed via pip:

pip install pyharp

We support Linux and Mac operation systems with Python version 3.10+.


Spectroscopy workflow

Pyharp also includes pyharp.spectra, a pure-Python spectroscopy workflow for HITRAN line data, HITRAN CIA data, single-state absorption spectra, transmittance products, diagnostic plots, and gas-mixture overview figures. The former standalone spectra library now lives under the pyharp.spectra namespace.

The main library entry points are available from pyharp.spectra:

from pathlib import Path

from pyharp.spectra import (
    AbsorptionSpectrum,
    SpectroscopyConfig,
    SpectralBandConfig,
    compute_absorption_spectrum,
)

band = SpectralBandConfig(
    name="single_state",
    wavenumber_min_cm1=20.0,
    wavenumber_max_cm1=2500.0,
    resolution_cm1=1.0,
)
config = SpectroscopyConfig(
    output_path=Path("output/h2o_absorption_300K_1bar.nc"),
    hitran_cache_dir=Path("hitran"),
    species_name="H2O",
)
spectrum: AbsorptionSpectrum = compute_absorption_spectrum(
    config=config,
    band=band,
    temperature_k=300.0,
    pressure_pa=1.0e5,
)

SpectroscopyConfig.hitran_cache_dir stores downloaded HITRAN line and CIA files. SpectroscopyConfig.output_path controls where NetCDF products are written by CLI helpers and is also used to create parent output directories.

H2O continuum calculations use the MT_CKD_H2O coefficient file at external/MT_CKD_H2O/data/absco-ref_wv-mt-ckd.nc relative to the Pyharp repository root. It is tracked as a Git submodule. Clone Pyharp with submodules to fetch it immediately:

git clone --recurse-submodules https://github.com/chengcli/pyharp

If you already cloned Pyharp, initialize the submodule from the repository root:

git submodule update --init --recursive external/MT_CKD_H2O

The top-level spectroscopy CLI computes one pressure-temperature state. Use --wn-range=min,max for the wavenumber bounds:

pyharp-spectra spectrum --species H2O --temperature-k 300 --pressure-bar 1 --wn-range=20,2500
pyharp-spectra transmittance --species H2O --path-length-m 1 --wn-range=20,2500

Plotting diagnostics are available from one entry point, pyharp-plot. It provides CIA binary coefficient, molecular cross-section, attenuation, transmission, and overview plot subcommands:

pyharp-plot binary --pair H2-H2 --temperature-k 300 --wn-range=20,10000
pyharp-plot xsection --species CO2 --temperature-k 300 --pressure-bar 1 --wn-range=20,2500
pyharp-plot attenuation --species CO2 --temperature-k 300 --pressure-bar 1 --wn-range=20,2500
pyharp-plot transmission --composition H2O:0.1,H2:0.9 --temperature-k 300 --pressure-bar 1 --path-length-km 1 --wn-range=25,2500
pyharp-plot overview --species H2O CO2 --temperature-k 300 --pressure-bar 1 --wn-range=20,2500 --wn-range=2500,10000

Use --pair for CIA pairs, --species for molecules, and --composition for gas mixtures such as H2O:0.1,H2:0.9. All plot commands accept --wn-range=min,max; overview accepts multiple --wn-range values for multi-page PDFs. Use --figure to choose the output path. Without --figure, plots are written under output/ with names derived from the target, plot type, temperature, pressure, and wavenumber range.

See the pyharp-plot CLI documentation for command-specific options and more examples.

Supported built-in HITRAN line species are CH4, CO2, H2, H2O, and N2. Built-in CIA pair resolution includes the self pairs for these species where HITRAN CIA data is configured, plus CO2-CH4, CO2-H2, H2-He, and N2-CH4.

pyharp.spectra does not provide a fixed reference-column radiative-transfer experiment. Use the core Pyharp radiative-transfer APIs for column RT calculations, and use pyharp.spectra for spectroscopy inputs, diagnostics, single-state products, and overview plots.


Development

If you want to further develop Pyharp, you will need to install it locally, which allows you to modify the source code and test. Open a Linux or Mac terminal and clone this repo using the following command:

git clone https://github.com/chengcli/pyharp

This will copy all source files into your local computer. You will need to install a few system libraries before installing Pyharp. All following instructions are executed under the pyharp/ directory.

System required for building locally

  • Python 3.10+
  • Linux or macOS
  • netCDF
  • python virtual environment (venv)

MacOS installation

brew install netcdf

RedHat installation

sudo yum install netcdf

Ubuntu installation

sudo apt-get install libnetcdf-dev

Build C++ library

After you completed the installation steps, you can build the pyharp library. We will build the package in-place, meaning that the build (binary files) are located under pyharp/build/bin. To do so, make a new directory named build

mkdir build

All build files will be generated and placed under this directory. It is completely safe to delete the whole directory if you want another build. cd to build and cmake

cd build
cmake ..

This command tells the cmake command to look for CMakeFiles.txt in the parent directory, and start configuring the compile environment. Then compile the code by

make -j4

This comman will use 4 cores to compile the code in parallel. Once complete, all executable files will be placed in build/bin.

Build python package locally (dev mode)

The python library can be installed by running the following command in the root directory:

pip install -e .

Test the installation

To test the installation, import pyharp in a python shell:

import pyharp

The build is successful if you do not see any error messages.


Contributing

Contributions are welcome! Please open an issue or PR if you’d like to:

  • Find a bug
  • Suggest new functions
  • Add examples
  • Improve documentation
  • Expand test coverage

Contact

Maintained by @chengcli — feel free to reach out with ideas, feedback, or collaboration proposals.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyharp-2.3.1-cp313-cp313-manylinux_2_27_x86_64.whl (31.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

pyharp-2.3.1-cp313-cp313-macosx_15_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pyharp-2.3.1-cp312-cp312-manylinux_2_27_x86_64.whl (31.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

pyharp-2.3.1-cp312-cp312-macosx_15_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pyharp-2.3.1-cp311-cp311-manylinux_2_27_x86_64.whl (31.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

pyharp-2.3.1-cp311-cp311-macosx_15_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pyharp-2.3.1-cp310-cp310-manylinux_2_27_x86_64.whl (31.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

pyharp-2.3.1-cp310-cp310-macosx_15_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file pyharp-2.3.1-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for pyharp-2.3.1-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 d0fb1a5fa760356aa1f10c942d28888804d561b2dff8dd63d52afcd355d524ae
MD5 4399ed378cc07711c2cd2cbe48fcfda2
BLAKE2b-256 0ffda0a2babcbbe8515bb92d429cdcac15b9d904d408d44c05fdef401423cdbe

See more details on using hashes here.

File details

Details for the file pyharp-2.3.1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyharp-2.3.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 7721ded538870a36d5b70c236e2d40f69afd91c202e1ea6628a260ce2c728ca5
MD5 8c2ebfccc93e73ac5d3317ad31bc3ee2
BLAKE2b-256 e3776b9bd8aec4547da62d00c718ea435d1f8afa994025c3012fe2bbe7d1f8a4

See more details on using hashes here.

File details

Details for the file pyharp-2.3.1-cp312-cp312-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for pyharp-2.3.1-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 48ccd9bbc062be5d6d918c9d11e35986b37bc361884f7a5d47f925995c68cef7
MD5 21d310c29f8d8a774ef3d43780162796
BLAKE2b-256 a09e5cab940ff2dc9f6effe00e864bd19b29821779385a07e400a992c95d4e09

See more details on using hashes here.

File details

Details for the file pyharp-2.3.1-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyharp-2.3.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0f789b9bfa22638b751f848871e9f93f9a509f595154d7143f4952ebbe7974af
MD5 9644e646b4bfedae8d4d9eb2cedc0df1
BLAKE2b-256 c2ae25ce40a3e1b57e99979223f59d2632e9b7f9dfd659c87aa67fabb0628e8e

See more details on using hashes here.

File details

Details for the file pyharp-2.3.1-cp311-cp311-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for pyharp-2.3.1-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 d5003e97d870aa470943e2cd3dc014f267459ec4b2431793fad55190a1776e80
MD5 791d836e296674be155e54fbdf83547e
BLAKE2b-256 1b403c7a2ab3c0c344e1cc8cbc999958f4c8ac1f115abf6c521b14a31a544351

See more details on using hashes here.

File details

Details for the file pyharp-2.3.1-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyharp-2.3.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dd467819850cf87b36704bad50440308667c412dc23b1d5aa0e212fe929a7763
MD5 846f9b3820b1275d08c3ff544208357b
BLAKE2b-256 2985854cbbb18385674b2e053c513195fd14b0958e2d9ed2b122e8b033c5505c

See more details on using hashes here.

File details

Details for the file pyharp-2.3.1-cp310-cp310-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for pyharp-2.3.1-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 75f8c3f47524ae0eebd36f3a9e9ba4516a960e6e4a14047e532e94658be33f47
MD5 df710c066280cdf4c3298865e88e874f
BLAKE2b-256 25eb4ea43082efadc86e3c003275d29a23a8ea52bc4681920c8a52a181833d7e

See more details on using hashes here.

File details

Details for the file pyharp-2.3.1-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyharp-2.3.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4a13ee2002320ae815dd7ff40a3d35b8d42754b918fe41bca1bddf33c92fe0ec
MD5 8074c7d6ae80390ae21c8734414124b3
BLAKE2b-256 22ebb9dad66e2d389b0991369ea4dfb4849784f3bf9ef4014aa6367b96d16602

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page