Skip to content

Add Boyden Index calculation - #4190

Open
magatrons wants to merge 2 commits into
Unidata:mainfrom
magatrons:issue-3210-boyden-index
Open

magatrons wants to merge 2 commits into
Unidata:mainfrom
magatrons:issue-3210-boyden-index

Conversation

@magatrons

Copy link
Copy Markdown

Closes #3210

Description Of Changes

Adds metpy.calc.boyden_index, the Boyden Index from Boyden (1963), requested in #3210.
It sits alongside the other sounding indices (total_totals_index, k_index,
sweat_index) and follows the same pattern: same decorators, xarray support through
vertical_dim, and units stripped for the final arithmetic the way sweat_index does
it, as suggested in the issue discussion.

I = (Z700 - Z1000) - T700 - 200

where Z700 - Z1000 is the 1000-700 hPa thickness in decameters and T700 is the
700 hPa temperature in °C. The result is returned as a dimensionless pint.Quantity.

Note on the formula in the issue: the issue writes the index as
Z(700-1000) - T700 - 200 without saying what unit the thickness is in. Both the
AMS Glossary and Boyden (1963) define
the thickness in decameters. With meters the index comes out far outside its usual range
of about 90-100 — for the test sounding here, meters gives 2842.0 instead of the expected
97.0. The tests check against the decameter values, so they would catch that mistake.

Why height is an input: I take geopotential height directly rather than deriving
the thickness from temperature with thickness_hydrostatic. The index is defined in
terms of the observed 1000-700 hPa thickness, and taking height directly keeps the
function simple and leaves out moisture assumptions. If you'd prefer
thickness_hydrostatic (for example, so it can be called with only pressure and
temperature, like the other indices), I'm happy to change it.

Changes:

  • src/metpy/calc/thermo.py: new boyden_index(pressure, height, temperature, vertical_dim=0), with docstring and example
  • docs/_templates/overrides/metpy.calc.rst: added to the Soundings list
  • docs/api/references.rst: added [Boyden1963]
  • tests/calc/test_thermo.py: test_boyden_index and test_boyden_index_xarray

Testing:

  • The new tests use expected values worked by hand, with sounding levels placed exactly
    on 1000 and 700 hPa so interpolation doesn't affect them. The xarray test uses
    temperatures in kelvin, so it also exercises the conversion to °C.
  • Full suite locally: 1626 passed, 2 xfailed, 8 failed. The 8 failures are all in
    tests/remote/test_aws.py and fail identically on unmodified main. They come from my
    local environment, not this change: a non-default AWS region in my config makes the
    requests miss the recorded cassettes, and test_goes_single makes a live download that
    fails on my machine. With my AWS config disabled, only test_goes_single fails.
  • ruff check, flake8, doc8 docs and codespell all pass, and the doctest passes.

Checklist

Add the Boyden Index from Boyden (1963), a thunderstorm instability
index computed from the 1000-700 hPa thickness in decameters and the
700 hPa temperature in degrees Celsius. List it with the sounding
calculations in the API docs and add the reference.
Test a single sounding and an xarray grid. Expected values are worked
by hand, with sounding levels placed exactly on 1000 and 700 hPa so no
interpolation is involved.
@magatrons
magatrons requested a review from a team as a code owner October 27, 2026 00:16
@magatrons
magatrons requested review from dopplershift and removed request for a team October 27, 2026 00:16
@CLAassistant

CLAassistant commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

metpy.calc.boyden_index

2 participants