Skip to content

17 - Illumination and atmosphere

The illumination of a scene has two parts: the sun (less.Sun) gives the direction of the sun and the solar spectrum at the top of the atmosphere; the atmosphere model computes the direct sunlight and diffuse skylight reaching the ground, and some models also compute the atmospheric effects between the ground and the sensor.

import less

scene = less.Scene()
scene.size = 20
scene.terrain = less.Terrain(property=less.Lambertian(reflectance=0.2))
scene.illumination = less.Illumination(
    source=less.Sun(zenith=30, azimuth=150),
    atmosphere=less.SimpleSpectralAtmosphere(turbidity=2.5),
)

Without a spectrum, Sun uses the built-in top-of-atmosphere solar spectrum. Sun(wavelengths=..., irradiance=...) supplies your own spectrum in W m⁻² nm⁻¹, as irradiance at the top of the atmosphere on a plane perpendicular to the sun's rays.

Choosing an atmosphere model

Model Use Notes
less.Atmosphere Satellite and airborne images, top-of-atmosphere reflectance Layered radiative transfer; computes ground illumination and transmission to the sensor
Atmosphere3D Views from inside the atmosphere, slant paths and cloud shadows Simulates atmospheric scattering and absorption along 3-D paths
less.SixSAtmosphere When you work with 6S parameters Uses Py6S and the 6S executable
less.PrescribedAtmosphere Known direct and diffuse transmittances Gives the transmittances directly
less.SimpleSpectralAtmosphere Fast broadband simulations Simplified spectral attenuation, isotropic skylight
less.HosekWilkieAtmosphere Visible wavelengths with a realistic sky brightness distribution 320–720 nm
less.NoAtmosphere No atmosphere Sunlight is not attenuated; no skylight

The layered atmosphere Atmosphere

scene.illumination = less.Illumination(
    source=less.Sun(zenith=30, azimuth=150),
    atmosphere=less.Atmosphere.standard(
        "midlatitude_summer",
        aerosol="continental",
        aot550=0.10,
        streams=8,
        sky_mode="anisotropic",
    ),
)

Standard profiles:

Name Typical conditions
"tropical" Tropics
"midlatitude_summer" Mid-latitude summer
"midlatitude_winter" Mid-latitude winter
"subarctic_summer" Subarctic summer
"subarctic_winter" Subarctic winter
"us_standard", "us76" US Standard Atmosphere 1976

Aerosol types are "continental", "maritime", "urban", "desert", "biomass_burning" and "stratospheric". aot550 is the aerosol optical thickness at 550 nm; larger values attenuate direct sunlight more. The terrain supplies the scene elevation. Use Terrain(ground_altitude_m=450) for level ground at 450 m. An absolute-elevation DEM supplies its minimum valid elevation automatically. For a standalone column, pass ground_altitude_m=450 to air.solve(...). sky_mode="anisotropic" keeps the directional variation of sky brightness, while "isotropic" treats skylight as the same from all directions.

By default a scene places the column bottom at the terrain reference elevation (the original DEM minimum for an absolute DEM). Flat terrain also adds the plane's geometric height. An explicitly configured column bottom takes precedence, including zero in previously saved projects.

Custom profiles

profile = less.AtmosphericProfile.standard("us76")
print(profile.surface_pressure(0.0))                       # hPa
print(profile.column("h2o", ground_altitude_km=0.5))

custom = less.Atmosphere(profile=profile, aerosol="maritime", aot550=0.05)

A custom AtmosphericProfile uses heights in km, pressure in hPa, temperature in K and gas number densities in cm⁻³.

Computing the atmosphere on its own

For a station at 1.25 km with an observed total ozone column of 310 Dobson units, profile.scale_ozone(310, ground_altitude_km=1.25) returns a new state profile. The scaling preserves the vertical shape and leaves other constituents unchanged. The current column solver's gas absorption tables use the standard ozone abundance.

To reuse a column model at several sites, pass the site's elevation on each call, for example atmosphere.solve([550], sun_zenith=40, ground_altitude_m=2000). Site elevation is in metres above sea level. Requested output altitudes are in kilometres above sea level. For a site on a terrain, use terrain.altitude_at(x, y).

The illumination and transmittances of an atmosphere can be computed without a scene:

import numpy as np

atmosphere = less.Atmosphere.standard("us76", aot550=0.10)
wavelengths = np.arange(400.0, 1001.0, 5.0)
result = atmosphere.solve(wavelengths, sun_zenith=40, output_altitudes_km=[2.0, 8.0, 20.0])

direct = result.direct_normal_irradiance          # direct irradiance at the ground, normal to the rays
diffuse = result.diffuse_horizontal_irradiance    # diffuse sky irradiance on a horizontal surface
up = result.upward_transmittance(view_zenith=10, observer_altitude_km=8.0)
Result Meaning
direct_normal_irradiance Direct irradiance at the ground on a plane perpendicular to the rays
diffuse_horizontal_irradiance Diffuse sky irradiance on a horizontal surface at the ground
direct_transmittance Direct-beam transmittance
upward_transmittance(...) Directional transmittance from the ground up to a given height
path_radiance(...) Atmospheric path radiance in the viewing direction
to_observer(...) Propagates ground radiance up to a given height
directional_sky_radiance(...) Sky radiance by direction

Irradiance is in W m⁻² nm⁻¹ and radiance in W m⁻² sr⁻¹ nm⁻¹.

Images at airborne and satellite altitude

With Atmosphere, optical sensors can return radiance at a given altitude or at the top of the atmosphere:

projection = less.Orthographic(image_size=64, view_zenith=10, view_azimuth=180)

airborne = scene.simulate(less.OpticalImager(
    projection, bands=less.Sentinel2A(), spectral_resolution=20, quality=16,
    observation_altitude_km=8.0))

top_of_atmosphere = scene.simulate(less.OpticalImager(
    projection, bands=less.Sentinel2A(), spectral_resolution=20, quality=16,
    observation_level="toa"))

observation_altitude_km is an altitude above sea level and is independent of the projection's geometric height in the scene. The atmosphere also affects other sensors: fluorescence images include the upward transmittance at the emission wavelengths, thermal images include downwelling longwave radiation and the atmosphere's own emission, and LiDAR includes the two-way attenuation.

Three-dimensional atmospheric imaging with Atmosphere3D

Use Atmosphere3D to calculate the radiance received by a sensor above or inside the atmosphere. Terrain, atmospheric scattering and absorption, and local cloud fields share the same three-dimensional scene. This example observes a Lambertian surface from the top of the atmosphere with Rayleigh scattering and ozone absorption.

import less
from less.atmosphere.coupled import Atmosphere3D

scene = less.Scene(backend="embree")
scene.terrain = less.Terrain(property=less.Lambertian(reflectance=0.2))
air = Atmosphere3D.standard(
    "us76", absorption_database=["O3"],
    interface_altitudes_m=(0., 1000., 2000., 4000., 8000., 16000., 25000., 40000.,
                           60000., 80000.),
)
scene.illumination = less.Illumination(source=less.Sun(zenith=30.), atmosphere=air)
sensor = less.OpticalImager(
    less.Orthographic(image_size=32), bands=[450., 550., 625.],
    observation_level="toa", quality=32,
)
image = scene.simulate(sensor)
image.save("atmosphere.hdr")

standard("us76") selects a standard temperature and pressure profile. absorption_database selects the gas tables used by the sensor. Add the gases relevant to your bands, or set include_gas_absorption=False for molecular scattering alone. For named gases, LESS looks for the files locally and downloads the missing tables on first use.

Observing a valley from inside the atmosphere

Dry-air molecular scattering covers 230–3125 nm. At 1700–3125 nm the model assumes a depolarization ratio of 0.0273. Gas absorption and aerosol data must also cover the sensor bands when those contributions are enabled.

A perspective sensor can observe the ground and sky in one image. The minimum DEM elevation is 450 m above sea level. A sensor at local height 240 m therefore observes the scene from an altitude of 690 m. Leaving observation_level and observation_altitude_km unset starts the perspective observation at the sensor position.

from less.examples.atmosphere_valley import simulate

image = simulate("embree", "valley-output", resolution=(96, 54), quality=128)

The example simulates molecular scattering in a spherical shell with gas absorption switched off. The ENVI pair valley.hdr and valley.dat stores radiance at 470, 550 and 650 nm. valley.png maps those bands to blue, green and red and applies a display exposure. Use the ENVI data for radiance comparisons. For DEM elevations, see Terrain and surface reflectance.

Select shortwave aerosols by name

This marine mixture uses its recipe humidity of 80% and a total aerosol optical depth of 0.15 at 550 nm.

from less.atmosphere.coupled import Atmosphere3D

air = Atmosphere3D.standard(
    "us76", aerosol="marine", aot550=0.15, include_gas_absorption=False,
)

The 250–3125 nm components are sea_salt, mineral_dust, black_carbon and water_soluble. The mixtures are continental, marine, urban, dust and biomass_burning. Mixtures use their recipe humidity. Standalone sea salt and water-soluble particles default to the dry state. Set aerosol_relative_humidity_percent to 0 or a value from 50 to 99 to select another state. Configure gas absorption separately with absorption_database.

For a manual installation, place the component H5 files and, for mixtures, presets.json in the database's aerosol/ directory. The default database is data/atmospheric-optics-database inside the LESS package. Set aerosol_database to select an external database root. LESS checks local files, then the cache, then the mirror, verifying file size and SHA-256. Set LESS_ATMOSPHERE_MIRROR to the HTTPS URL or absolute directory serving the files. The default mirror is the versioned GitHub data release. Use LESS_ATMOSPHERE_OFFLINE=1 to reuse verified files offline.

Three-dimensional liquid-water clouds

Run the mountain cumulus example to compare a cloud image with a clear-sky image from the same viewpoint. The example writes RGB previews and the three bands of spectral radiance.

python -m less.examples.mountain_cumulus --backend optix --resolution 240 135 --quality 32 --output-dir cloud-preview

To use your own cloud, supply a three-dimensional liquid water content array in kg/m³. Its axes are height, south and east in that order. Give the grid's lower corner and cell sizes in east, south and up order, in scene metres. A cell with zero water is clear, so one grid can hold several separated clouds. The clouds in this grid share the same droplet effective radius and water temperature.

from less.atmosphere.coupled import Atmosphere3D, LocalParticleGrid
from less.atmosphere.liquid_cloud import write_liquid_cloud_optics

bands = [450., 550., 625.]
mass_extinction = write_liquid_cloud_optics(
    "droplet-optics.h5", bands=bands, temperature_k=282.43125,
    effective_radius_um=10.,
)
cloud = LocalParticleGrid(
    lower_m=(500., 500., 1200.), cell_size_m=(50., 50., 50.),
    extinction_550_per_m=liquid_water_kg_m3 * mass_extinction,
    aerosol="droplet-optics.h5",
)
air = Atmosphere3D.standard("us76", local_particles=cloud, include_gas_absorption=False)
scene.illumination = less.Illumination(
    source=less.Sun(zenith=45., azimuth=250.), atmosphere=air,
)

Use the same bands and spectral resolution when creating your optical sensor. LESS downloads and caches the necessary liquid-water files on first use. RGB uses liquid-water-250-900nm.h5. Adding a 1,600 nm band also needs liquid-water-900-3125nm.h5. If you download the files yourself, pass their directory as database to write_liquid_cloud_optics. The grid uses 550 nm as its reference, so choose a water temperature with data at that wavelength. Liquid-water optics files

Use a small preview to set the viewpoint, solar direction and cloud extent. Then raise quality and the image dimensions for the final image. Compare the cloud's sunlit side, shaded side and ground shadow at successive settings before selecting the final quality.

Simulate a clear sunset

Look west from inside a mountain valley with the Sun one degree above the horizon. Download CIE_xyz_1931_2deg.csv from the CIE and run the command in that directory. The example downloads ozone and continental aerosol data on first use. CIE standard observer data

python -m less.examples.atmosphere_sunset CIE_xyz_1931_2deg.csv sunset_output

To use custom ozone and particle optics tables, pass both paths, in that order, before the CSV. The default image averages four independent seeds at 288 × 168 pixels and 79 wavelengths at 5 nm intervals. Use --resolution 96 56 --quality 128 --seeds 5511 to check the view. radiance.npz contains the spectral radiance before exposure. sunset.png uses fixed exposure, luminance compression and sRGB encoding. To generate the display image, the example divides each simulated radiance by its incident solar spectral irradiance, linearly interpolates that transport response and integrates it against the solar spectrum and colour matching functions at 0.01 nm spacing. The scene uses 300 DU ozone, aerosol optical thickness 0.07 at 550 nm, and a surface reflectance of 0.12 at every wavelength. Ozone is the sole gas absorber in this example. Quantitative work in the oxygen A band requires an oxygen absorption table as well.

Ozone column and absorption database

ozone_du specifies the ozone column in Dobson units. LESS adjusts the profile and then looks up each layer’s absorption coefficient on the axes of the selected table. For an ozone sensitivity study, choose a table with multiple x_O3 nodes at the target wavelengths and check that the nodes span the layer mole fractions. The Gecko v2 monochromatic table lacks this axis. It can produce images at different requested columns while returning the same absorption coefficients.

To simulate a 300 DU ozone column, add ozone_du=300 to the example above. The image’s metadata["atmosphere_coupling"]["gas_layer_state"]["mole_fractions"]["x_O3"] contains the ozone mole fraction in each layer.

For a monochromatic simulation with several absorbing gases, pass paths keyed by species, for example absorption_database={"O2": "oxygen.h5", "O3": "ozone_catalog"}. For a local SO₂ table, specify absorption_database={"SO2": "so2.h5"} and mole_fractions={"x_SO2": 2e-8} for a uniform 20 ppb abundance. To prescribe a vertical profile, pass one mole fraction per interval in interface_altitudes_m, ordered from bottom to top. The fractions are relative to total air molecules.

For altitude-resolved CH₄, N₂O or CO, supply ch4_cm3, n2o_cm3 or co_cm3 on an AtmosphericProfile, in molecules/cm³ at each altitude_km node. For example, given dry methane concentrations methane_ppmv_dry at the profile heights:

from dataclasses import replace
from less import AtmosphericProfile
from less.atmosphere.coupled import Atmosphere3D

base = AtmosphericProfile.standard("us76")
profile = replace(base, ch4_cm3=(base.air_cm3 - base.h2o_cm3) * methane_ppmv_dry * 1e-6)
air = Atmosphere3D(profile=profile, absorption_database={"CH4": "methane.h5"})

Changing the layer interfaces reintegrates the node densities. An explicit mole_fractions["x_CH4"] overrides the profile-derived layer abundances.

Use AtmosphericProfile.standard("us76", trace_gas_file="trace-state.h5") to load a local dry-ppmv profile library. Set the root HDF5 attributes altitude_unit="km" and abundance_basis="dry-air mole fraction, ppmv". The increasing altitude_km array must span the standard atmosphere. In the model group (e.g. us_standard), include one dataset per available gas (CH4, N2O, or CO) on that height grid. LESS retains both sets of height nodes and accounts for water vapour when converting to number density. Supply spectroscopy separately via absorption_database. Each entry can name a LESS molecular cross-section file or a shard catalog. Each must cover the requested wavelengths and layer states. LESS sums the volume absorption coefficients at each layer and wavelength. Product metadata identifies the source files by species. For single-gas correlated-k absorption, use a LESS molecular band file, e.g. Atmosphere3D.standard("us76", spectral_mode="correlated_k", absorption_database="oxygen-bands.h5"), and give the sensor its spectral response. The file supplies the group count and probabilities for each band. This example includes gas absorption by oxygen alone. For a premixed catalog, select one built for the intended mixture. An omitted quadrature order uses 16 for these catalogs.

For oxygen and ozone files built with the same wavelength grouping, use absorption_database={"O2": "O2.h5", "O3": "O3.h5"} in correlated-k mode. Vary ozone_du with the same pair of files. LESS checks group membership digests, selected band limits and probabilities. Independently sorted species require regrouping on a common fine-wavelength grid before they can be combined this way.

For overlapping methane and carbon monoxide bands, use absorption_database={"CH4": "CH4.h5", "CO": "CO.h5"} with jointly grouped local tables and a profile containing both gases. N₂O uses the key "N2O".

For monochromatic water continuum, use local collision-pair-cross-section/1 tables with absorption_database={"H2O-H2O": "self.h5", "H2O-dry_air": "foreign.h5"}. LESS multiplies the self coefficient by the squared water number density and the foreign coefficient by the product of the water and dry-air number densities. To add local water lines, include a compatible "H2O" table. MT_CKD includes the 25 cm⁻¹ line pedestal, so the local line table must subtract that contribution.

To represent water self-broadening in the local line table, use humidity-dependent-molecular-cross-section/1 with absorbing_species="H2O". The axes of cross_section_m2_per_molecule are pressure_pa, temperature_k, water_mole_fraction (molecules of water per molecule of moist air), and vacuum_wavelength_nm. LESS uses each layer's water fraction for interpolation and its water number density to convert the cross section to absorption per metre.

For monochromatic oxygen-pair absorption, include "O2-O2": "oxygen-pair.h5" in the gas table mapping. Supply a local collision-pair-cross-section/1 table with absorbing_species="O2-O2". Its cross_section_m5_per_molecule2 array has axes temperature_k and vacuum_wavelength_nm. LESS multiplies the interpolated coefficient by the square of the local O₂ number density. To build a local 297–500 nm table, download the three Finkenzeller–Volkamer (2022) vacuum spectra at 223, 263 and 293 K from the Mainz O₄ atlas. Run python tools/build_oxygen_pair_absorption.py measurements oxygen-pair.h5 from the source checkout. Each layer temperature must be within 223–293 K. Pass the same mapping to prefetch_absorption(sources, bands=[443.]) and the scene's absorption_database when preparing offline work. Prefetch checks spectral coverage. Simulation checks the layer temperatures.

Select monochromatic absorption with O3, O2, H2O, CO2, CO, CH4, N2O, NO2, SO2 or CIA. For example, Atmosphere3D(absorption_database=["H2O", "CO2", "CIA"]) uses each layer's pressure, temperature and mole fractions. H₂O includes lines and both water continua. CIA includes five collision pairs. Provide missing abundances with mole_fractions, for example {"x_SO2": 1e-9} or one value per layer. NO₂ ends at 690 nm and SO₂ at about 399.984 nm. Each measurement has its own valid state range. Set ozone_profile_nir=True to select the near-infrared ozone approximation validated for the standard profiles.

Place files in gas-absorption/ under the database root, optionally supplied as gas_database. Missing files are downloaded once and verified. To prepare an offline cache, call less.atmosphere.prefetch_absorption(["O3", "NO2"], bands=[425]), then set LESS_ATMOSPHERE_OFFLINE=1. The old less:shortwave-v1/O3 identifier resolves to the new O3.h5. Replace the older less:ozone-visible-v1 and less:ozone-visible-v2 identifiers with O3. Data release and attribution

Column measurements at different elevations

Set water_station_altitude_m and ozone_station_altitude_m to the elevations of the respective instruments. Within the transport domain, LESS splits a coarse layer at each measurement station before computing mean gas densities. Each input column extends to the profile top. A lower transport ceiling includes only the modeled portion.

Custom particle optics

For a custom thermal-infrared particle table, pass its path as aerosol to Atmosphere3D.standard(...). When the table excludes 550 nm, set the HDF5 root attribute reference_extinction_550_per_m to the positive 550 nm extinction (m⁻¹) for the same particle population and concentration. LESS uses that value to scale spectral extinction to the scene’s aot550 or local 550 nm extinction. Sensor wavelengths must lie within the table’s wavelength axis.

With a local liquid-cloud manifest, select an available effective radius in µm. Put the HDF5 assets beside the manifest or set LESS_ATMOSPHERE_MIRROR to their HTTPS directory or absolute local directory. Set LESS_ATMOSPHERE_OFFLINE=1 to use a verified cached copy after the first download.

from less.atmosphere import prefetch_liquid_cloud
from less.atmosphere.coupled import Atmosphere3D

cloud = prefetch_liquid_cloud("manifest.json", temperature_k=298.15, effective_radius_um=10)
air = Atmosphere3D.standard(
    "us76", aerosol=str(cloud), aot550=0.4, include_gas_absorption=False,
)

Specify an exact water temperature for a multi-temperature catalog. A single-temperature catalog also accepts a radius alone. A thermal-window table used with aot550 needs a 550 nm reference extinction at that water temperature.

SixSAtmosphere · 6S

This model uses 6S to compute the direct and diffuse shortwave illumination at the surface. Install Py6S and make the sixs executable available on your PATH.

pip install "less3d[atmosphere]"
six_s = less.SixSAtmosphere(
    atmosphere_profile="midlatitude_summer",
    aerosol_type="continental",
    aot550=0.1,
    ground_altitude=0.0,
)

Profiles include tropical, midlatitude_summer, midlatitude_winter, subarctic_summer, subarctic_winter, us_standard (US Standard 1962) and no_absorption. Aerosol types are no_aerosols, continental, maritime, urban, desert, biomass_burning and stratospheric. Pass six_s to Illumination(atmosphere=six_s).

PrescribedAtmosphere · Known transmittances

When the direct and diffuse transmittances of the atmosphere are known:

scene.illumination = less.Illumination(
    source=less.Sun(zenith=40, azimuth=160,
                    wavelengths=[450, 550, 650],
                    irradiance=[1.85, 1.88, 1.55]),
    atmosphere=less.PrescribedAtmosphere(
        wavelengths=[450, 550, 650],
        direct_beam_transmittance=[0.60, 0.70, 0.78],
        diffuse_horizontal_transmittance=[0.20, 0.14, 0.09],
    ),
)

The two coefficients are defined differently:

  • direct_beam_transmittance = direct irradiance at the ground (perpendicular to the rays) / solar irradiance at the top of the atmosphere (perpendicular to the rays);
  • diffuse_horizontal_transmittance = diffuse sky irradiance on a horizontal surface at the ground / top-of-atmosphere solar irradiance on a horizontal surface.

So for a solar zenith angle θ and top-of-atmosphere irradiance E:

direct irradiance at the ground (perpendicular to the rays) = E × direct_beam_transmittance
diffuse irradiance on a horizontal surface                  = E × cos θ × diffuse_horizontal_transmittance

Both coefficients may be numbers or spectral arrays; at each wavelength their sum may not exceed 1.

SimpleSpectralAtmosphere · Fast shortwave illumination

This model estimates direct and diffuse illumination from 300 to 2500 nm. It treats skylight as equally bright in all directions. A turbidity of about 2 represents clear sky, and values of 5 or more represent hazier conditions.

air = less.SimpleSpectralAtmosphere(turbidity=2.5)

HosekWilkieAtmosphere · Directional sky illumination

Use this model for visible-light scenes where sky brightness varies with direction, for example when the horizon or the region around the Sun contributes strongly to the image. It covers 320–720 nm.

air = less.HosekWilkieAtmosphere(turbidity=2.5)

NoAtmosphere · Direct solar illumination

Use this setting for an idealised scene with unattenuated direct sunlight and zero diffuse skylight.

air = less.NoAtmosphere()

The sky in the thermal infrared

Thermal simulations also need the sky's longwave radiation. less.Atmosphere computes it from the atmosphere profile. A shortwave illumination model such as SimpleSpectralAtmosphere can use a specified sky brightness temperature:

clear_sky = less.SimpleSpectralAtmosphere(turbidity=2.0, sky_temperature=260.0)  # K

When the energy balance is used, the downwelling longwave radiation in less.Microclimate (estimated from air temperature and humidity if not given) also serves as the thermal sky. See chapter 27.

Next