Skip to content

earth-system-radiation/pyRTE-RRTMGP

Repository files navigation

CI passing Documentation Status DOI

pyRTE-RRTMGP

This is the repository for the pyRTE-RRTMGP project.

This project provides a Python interface to the RTE+RRTMGP Fortran software package.

The RTE+RRTMGP package is a set of libraries for for computing radiative fluxes in planetary atmospheres. RTE+RRTMGP is described in a paper in Journal of Advances in Modeling Earth Systems.

Documentation

Documentation for the pyRTE-RRTMGP package is available on Read the Docs.

Project Status

This project is currently in an early stage of development.

See CONTRIBUTING.md for information on how to contribute to this project!

Functions Currently Available

The goal of this project is to provide a Python interface to the most important Fortran functions in the RTE+RRTMGP package.

Currently, the following functions are available in the pyrte_rrtmgp package:

RTE Functions (WIP)

Function name Covered
SHORTWAVE SOLVERS
rte_sw_solver_noscat
rte_sw_solver_2stream
LONGWAVE SOLVERS
rte_lw_solver_noscat
rte_lw_solver_2stream
OPTICAL PROPS - INCREMENT
rte_increment_1scalar_by_1scalar
rte_increment_1scalar_by_2stream
rte_increment_1scalar_by_nstream
rte_increment_2stream_by_1scalar
rte_increment_2stream_by_2stream
rte_increment_2stream_by_nstream
rte_increment_nstream_by_1scalar
rte_increment_nstream_by_2stream
rte_increment_nstream_by_nstream
OPTICAL PROPS - INCREMENT BYBND
rte_inc_1scalar_by_1scalar_bybnd
rte_inc_1scalar_by_2stream_bybnd
rte_inc_1scalar_by_nstream_bybnd
rte_inc_2stream_by_1scalar_bybnd
rte_inc_2stream_by_2stream_bybnd
rte_inc_2stream_by_nstream_bybnd
rte_inc_nstream_by_1scalar_bybnd
rte_inc_nstream_by_2stream_bybnd
rte_inc_nstream_by_nstream_bybnd
OPTICAL PROPS - DELTA SCALING
rte_delta_scale_2str_k
rte_delta_scale_2str_f_k
OPTICAL PROPS - SUBSET
rte_extract_subset_dim1_3d
rte_extract_subset_dim2_4d
rte_extract_subset_absorption_tau
Fluxes - Reduction
rte_sum_broadband
rte_net_broadband_full
rte_net_broadband_precalc
rte_sum_byband 🔲
rte_net_byband_full 🔲
Array Utilities
zero_array_1D
zero_array_2D
zero_array_3D
zero_array_4D

RRTMGP Functions

Function name Covered
rrtmgp_interpolation
rrtmgp_compute_tau_absorption
rrtmgp_compute_tau_rayleigh
rrtmgp_compute_Planck_source

Setup Instructions

Note: The code in this repository is a work in progress. The Python API is not yet stable and is subject to change.

Prerequisites

pyRTE-RRTMGP is built on install time. Building the package requires a compatible Fortran compiler, a C++ compiler and CMake to be installed on your system. The package is compatible with POSIX systems and is tested on Linux and macOS using the GNU Fortran compiler (gfortran) and the GNU C++ compiler (g++). The package should also work with the Intel Fortran compiler (ifort) but was not tested with it. If you use conda, the system packages are installed automatically. If you use pip, you need to install those packages yourself (see below).

The package source code is hosted on GitHub. The easiest way to install pyRTE-RRTMGP is to use git. You can install git from here.

Installation with conda (recommended)

Using conda is the recommended method because conda will take care of the system dependencies for you.

  1. Clone the repository:

    git clone git@github.com:earth-system-radiation/pyRTE-RRTMGP.git

    or

    git clone https://github.com/earth-system-radiation/pyRTE-RRTMGP.git

    After cloning the repository, enter the repository directory:

    cd pyRTE-RRTMGP
  2. Make sure you have conda installed. If not, you can install it from here. To make sure your conda setup is working, run the command below:

    conda --version

    If this runs without errors, you are good to go.

  3. Install the conda build requirements (if you haven't already):

    conda install conda-build conda-verify
  4. Build the conda package locally:

    conda build conda.recipe
  5. Install the package in your current conda environment:

    conda install -c ${CONDA_PREFIX}/conda-bld/ pyrte_rrtmgp

    Note: This will install the package in your current conda environment. If you want to install the package in a different environment, activate your environment before running the conda install command above.

Installation with pip

You also have the option to build and install the package with pip. This should work with macOS and Linux systems but requires you to install the system dependencies manually.

Mac OS

  1. Install the requirements On MacOS systems you can use brew to install the dependencies as following brew install git gcc cmake, but you can also install de requirements using other package managers, such as conda.

  2. Install the package Then you can install the package directly from the git repository pip install git+https://github.com/earth-system-radiation/pyRTE-RRTMGP

Debian/Ubuntu

  1. Install the requirements On Debian/Ubuntu systems you can use apt to install the dependencies as following sudo apt install build-essential gfortran cmake git, but you can also install de requirements using other package managers, such as conda.

  2. Install the package Then you can install the package directly from the git repository pip install git+https://github.com/earth-system-radiation/pyRTE-RRTMGP

Other linux distributions should also support the installation of the package, you just need to install the dependencies using the package manager of your distribution.

For development purposes, you can install the package in editable mode: pip install -e ..

Once built, the module will be located in a folder called pyrte_rrtmgp

Pytest Setup Instructions

  • Go to the 'tests' folder: cd tests/
  • Install the test prerequisites (if you haven't already) by running pip3 install -r requirements-test.txt
  • Run pytest tests