space-physics / lowtran

LOWTRAN atmospheric absorption extinction, scatter and irradiance model--in Python and Matlab
MIT License
102 stars 42 forks source link
atmosphere atmospheric-modelling f2py fortran geoscience lowtran matlab matlab-python-interface python

Lowtran in Python

Zenodo DOI Actions Status PyPi Download stats

LOWTRAN7 atmospheric absorption extinction model. Updated to be platform independent and easily accessible from Python and Matlab.

The main LOWTRAN program is accessible from Python by using direct memory transfers instead of the cumbersome and error-prone process of writing/reading text files. xarray.Dataset high-performance, simple N-D array data is passed out, with appropriate metadata.

Gallery

See below for how to make these examples.

Lowtran7 absorption

Install

Lowtran requires a Fortran compiler and CMake. We use f2py (part of numpy) to seamlessly use Fortran libraries from Python by special compilation of the Fortran library with auto-generated shim code. For Python 3.12, make sure to install setuptools using pip, i.e., pip install setuptools and make sure meson is available on the system.

If a Fortran compiler is not already installed, install Gfortran:

Install Python Lowtran code

pip install -e .

Examples

In these examples, optionally write to HDF5 with the -o option.

We present Python examples of:

Matlab

Matlab users can seamlessly access Python modules, as demonstrated in RunLowtran.m.

Here's what's you'll need:

  1. Setup Python ↔ Matlab interface.
  2. Install Lowtran in Python as at the top of this Readme.
  3. From Matlab, verify everything is working by:

    runtests('lowtran')

Notes

LOWTRAN7 User manual Refer to this to understand what parameters are set to default. Currently I don't have any aerosols enabled for example, though it's possible to add them into the code.

Right now a lot of configuration features aren't implemented, please request those you want.

Reference