Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

LibRadtran Input Generator

LibRadtran_input_generator is a Codex skill and lightweight command-line helper for creating libRadtran uvspec and mie input files from high-level radiative-transfer simulation goals.

The package is designed for cases where small convention mistakes can change the physical meaning of a run: viewing geometry, umu sign, satellite zout, cloud optical thickness, cloud-file format, spectral model choice, solver choice, and batch sweep bookkeeping.

Purpose

Use this package to:

  • Generate runnable libRadtran .INP files for radiance, irradiance, TOA reflectance, BRDF, cloud, aerosol, and satellite-band simulations.
  • Choose appropriate uvspec settings such as mol_abs_param, rte_solver, number_of_streams, output_quantity, and output_user.
  • Create companion files such as water-cloud .wc files and discrete wavelength grids.
  • Build parameter sweeps and lookup-table inputs for HPC job arrays.
  • Review or debug existing libRadtran inputs for common geometry, path, cloud, and solver mistakes.
  • Generate mie inputs for cloud optical-property files used by uvspec.

The repository contains:

SKILL.md                  Codex skill instructions
agents/openai.yaml        Codex Desktop UI metadata
scripts/libradtran_gen.py JSON spec to libRadtran input generator
references/               Solver, geometry, option, and CLI guidance
assets/templates/         Commented starting-point .INP templates

Prerequisites

Required for using the Codex skill

  • Codex Desktop or Codex CLI with local skill support.
  • This repository installed under Codex's skills directory.

Install with:

git clone https://github.com/zzbatmos/LibRadtran_input_generator.git \
  ~/.codex/skills/libradtran-input-generator

Start a new Codex Desktop thread or CLI session after installation so the skill is discovered.

Required for generating input files

  • Python 3 for the command-line generator.
  • No third-party Python packages are required.

Required for running generated libRadtran inputs

A working libRadtran installation, ideally libRadtran 2.0.x, including:

  • compiled bin/uvspec and bin/mie,
  • the data/ directory,
  • the examples/ directory,
  • optionally doc/libRadtran.pdf for detailed option lookup.

The package writes input files. It does not require libRadtran to generate .INP files, but libRadtran is required to execute them.

Path convention matters: relative paths inside a libRadtran .INP are resolved from the directory where uvspec is launched. For portable runs, especially on HPC systems, set libradtran_root in the JSON spec so generated inputs use absolute paths.

How To Use

Use as a Codex skill

Invoke the skill explicitly in Codex:

Use $libradtran-input-generator to create a DISORT uvspec input for satellite-view
water-cloud BRDF at 865 nm, SZA 30, VZA 45, cloud tau 20, reff 10 um, and Cox-Munk ocean
surface with wind speed 7 m/s.

Codex will use the workflow in SKILL.md to:

  1. Map the request onto atmosphere, source, surface, scatterers, geometry, solver, and output settings.
  2. Ask only for missing parameters that are physically decisive and unsafe to default.
  3. Write the .INP and any companion files.
  4. State assumptions such as cloud layer, view azimuth, or path convention.
  5. Suggest convergence and sanity checks.

Useful request patterns:

Use $libradtran-input-generator to review this uvspec input for geometry and path errors.
Use $libradtran-input-generator to generate a Nakajima-King lookup-table sweep over cloud
tau and effective radius at 865 and 2100 nm.
Use $libradtran-input-generator to create a MYSTIC polarized Stokes-vector input for a
water cloud and explain which Mie optical-property file I need.

Use the command-line generator

Create a template JSON spec:

python3 scripts/libradtran_gen.py --example > spec.json

Edit spec.json, then generate input files:

python3 scripts/libradtran_gen.py spec.json --outdir out --print

Example minimal spec:

{
  "output": "water_cloud_brdf.INP",
  "libradtran_root": "/path/to/libRadtran-2.0.6",
  "atmosphere": "tropical",
  "wavelength": 865,
  "spectral_model": "crs",
  "surface": {"albedo": 0.05},
  "cloud": {
    "type": "water",
    "tau": 20,
    "reff": 10,
    "base_km": 2.0,
    "top_km": 3.0,
    "properties": "hu"
  },
  "geometry": {
    "sza": 30,
    "sun_azimuth": "north",
    "sensor": "satellite",
    "vza": 45,
    "view_azimuth": "east"
  },
  "solver": "disort",
  "streams": 16,
  "output_quantity": "reflectivity",
  "output_user": ["lambda", "uu"]
}

Run the generated file:

/path/to/libRadtran-2.0.6/bin/uvspec < out/water_cloud_brdf.INP > out/water_cloud_brdf.OUT

Generate sweeps for lookup tables or HPC

List-valued fields create a cross product of cases and a manifest CSV. Supported sweep fields include cloud.tau, cloud.lwp, cloud.reff, geometry.sza, and geometry.vza.

{
  "output": "nk.INP",
  "libradtran_root": "/path/to/libRadtran-2.0.6",
  "wavelength_list": [865, 2100],
  "spectral_model": "crs",
  "surface": {"albedo": 0.05},
  "cloud": {
    "type": "water",
    "tau": [1, 3, 10, 30, 100],
    "reff": [5, 10, 15, 20, 25, 30],
    "properties": "hu"
  },
  "geometry": {
    "sza": 30,
    "sun_azimuth": "north",
    "sensor": "satellite",
    "vza": 45,
    "view_azimuth": "east"
  },
  "solver": "disort",
  "streams": 16,
  "output_quantity": "reflectivity",
  "output_user": ["lambda", "uu"]
}

Generate the sweep:

python3 scripts/libradtran_gen.py spec.json --outdir out

Run cases in parallel:

tail -n +2 out/nk_manifest.csv | cut -d, -f2 \
  | xargs -P 8 -I {} sh -c '/path/to/libRadtran-2.0.6/bin/uvspec < out/{} > out/{}.out'

Accuracy And Sanity Checks

For DISORT radiance or BRDF runs, rerun with doubled number_of_streams and confirm the result is stable. Clouds and aerosols with sharp forward scattering often need more streams.

For MYSTIC runs, rerun with 3-10x more mc_photons and confirm the Monte Carlo noise is acceptable. For polarization on the principal plane, Stokes U should be close to zero within Monte Carlo noise.

Always confirm:

  • zout matches the sensor location, especially zout toa for satellite output.
  • umu sign matches viewing direction: positive for upwelling/satellite-looking-down, negative for ground-looking-up.
  • cloud and aerosol optical-property files cover the requested wavelengths and effective radius range.
  • relative paths are valid from the directory where uvspec is launched.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages