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+.


Supported opacities

Pyharp has built-in functionalities that work with various opacity sources. The following table summaries off-the-shelf opacities.

Opacity Name Tested Peer Reviewed References
Premix H2 molecule YES NO [1]
H2-He continuum YES YES [2]
CO2 molecule YES NO
CO2 continuum YES NO
H2O molecule YES NO
H2O continuum YES NO
N2 molecule YES NO
N2 continuum YES NO
Grey (user implement) YES NO
(More coming) ... ...

Supported radiative transfer solvers

You can choose the backend radiative transfer solver to use by Pyharp. Here are the available options:

Radiative Transfer Solver Tested Peer Reviewed References
DISORT YES YES [1]
Two-steam (Toon-McKay) NO NO

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:

  • pyharp-plot binary
  • pyharp-plot attenuation
  • pyharp-plot transmission
  • pyharp-plot xsection
  • pyharp-plot overview

The target is selected by argument:

  • --pair selects a CIA pair.
  • --species selects a molecule.
  • --composition selects an atmosphere mixture.

All plot commands use --wn-range=min,max for wavenumber bounds. Default output names use <species_or_cia_name>_<plot_type>_<temperature>_<pressure>_<wavenumber_min>_<wavenumber_max>.

Examples:

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 --pair H2-H2 --temperature-k 300 --pressure-bar 1 --wn-range=20,10000
pyharp-plot attenuation --species CO2 --temperature-k 300 --pressure-bar 1 --wn-range=20,2500
pyharp-plot attenuation --composition H2O:0.1,H2:0.9 --temperature-k 300 --pressure-bar 1 --wn-range=25,2500

pyharp-plot transmission --pair H2-H2 --temperature-k 300 --pressure-bar 1 --path-length-km 1 --wn-range=20,10000
pyharp-plot transmission --species CO2 --temperature-k 300 --pressure-bar 1 --path-length-km 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 --temperature-k 300 --pressure-bar 1 --path-length-km 1 --wn-range=20,2500
pyharp-plot overview --composition H2O:0.1,H2:0.9 --wn-range=25,2500 --temperature-k 300 --pressure-bar 1

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.0-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.0-cp313-cp313-macosx_15_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pyharp-2.3.0-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.0-cp312-cp312-macosx_15_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pyharp-2.3.0-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.0-cp311-cp311-macosx_15_0_arm64.whl (4.8 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pyharp-2.3.0-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.0-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.0-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for pyharp-2.3.0-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 c5c11bb314ac3e93aebd112cf9c386b4a07e284932ae6fe5c5d6f93870bc3b97
MD5 5a82de560a1e60bbf51fa6aab11bedcd
BLAKE2b-256 ebf600d5d24c2c09d924ab66dad3277e92f88547b53e8eaf6de29a3ada380835

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyharp-2.3.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d25662019554ace70ecda65ed0c0008cecb6794863b458ec646491c66dc90f2b
MD5 c36e1c833484d77e95d1dd6e78f4ae87
BLAKE2b-256 f38b7ee9057732a487ad9984f39cd0362ca3adec940ffc1bbb1271f2eb3e4d1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyharp-2.3.0-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 8312a92f71b6da4b714c0cbcfced1ee7f6f41addd58cbeb945f84321b6caf000
MD5 8990a68b4cc83c8063e7c4891405bca3
BLAKE2b-256 5fcb5fc085ee633610dafc97ca63ede3f6991258eef5d5c56f591376b1b95b5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyharp-2.3.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5731928c0e4e04e9b2b921d890031fe5f8934a7c10804c52547a626f514958b2
MD5 889d876315dc797cba353275fb34d5e0
BLAKE2b-256 c6641c5f71991efd536a2ead12072ce3b5dafcc63bd8c39e2941094c152a5ca3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyharp-2.3.0-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 403bd162d3ce901affc1bbdace329f10a656780431441ad1593dc7ab397ea872
MD5 5ff9e55c749b304b6fffc34f42e6b7ca
BLAKE2b-256 c51bba81dd2cbd5352299cdf18778020e5e7914667a591fd310594404d2b512f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyharp-2.3.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 50305060e6a591664e866f47a9ce7b7ffce06b852bcd36fc20e56a896432ee58
MD5 7fcfd241786f1ce8e1fbcf48c869e6d6
BLAKE2b-256 949c0964ede0ed9e9ce86e223fe9371212c1fb5e64b67bfff6e194d137ad4973

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyharp-2.3.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 90c950736f9717fddc2b9441f10487a1a08b2a7a613faf161ef469df58e5efe3
MD5 5b9e84bad0163ebb5c974642a5c36515
BLAKE2b-256 0b7f162ca1378fb4f2abf95caface54722cec5ced16494d9daeae239cf26cd5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyharp-2.3.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4dbea61414ee9b1244e4904b86cb4946e1155d1eccf3d1db120973ed14d9ff2d
MD5 be07c026a22a0833c0b6a307b1473672
BLAKE2b-256 0aecab7159a0e5e6bc804bd496003a096bb3e18e85cd228b53d9c73e2447de2e

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