Repository navigation
Conversation
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 throughvertical_dim, and units stripped for the final arithmetic the waysweat_indexdoesit, as suggested in the issue discussion.
where
Z700 - Z1000is the 1000-700 hPa thickness in decameters andT700is the700 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 - 200without saying what unit the thickness is in. Both theAMS 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
heightis an input: I take geopotential height directly rather than derivingthe thickness from temperature with
thickness_hydrostatic. The index is defined interms 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 andtemperature, like the other indices), I'm happy to change it.
Changes:
src/metpy/calc/thermo.py: newboyden_index(pressure, height, temperature, vertical_dim=0), with docstring and exampledocs/_templates/overrides/metpy.calc.rst: added to the Soundings listdocs/api/references.rst: added[Boyden1963]tests/calc/test_thermo.py:test_boyden_indexandtest_boyden_index_xarrayTesting:
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.
tests/remote/test_aws.pyand fail identically on unmodifiedmain. They come from mylocal environment, not this change: a non-default AWS region in my config makes the
requests miss the recorded cassettes, and
test_goes_singlemakes a live download thatfails on my machine. With my AWS config disabled, only
test_goes_singlefails.ruff check,flake8,doc8 docsandcodespellall pass, and the doctest passes.Checklist