Skip to content

Commit

Permalink
Broadcast like specific_humidity
Browse files Browse the repository at this point in the history
and test xarray inputs.
  • Loading branch information
dcamron committed Nov 2, 2023
1 parent 22a9b60 commit 163702b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3945,7 +3945,7 @@ def dewpoint_from_specific_humidity(*args, **kwargs):

@preprocess_and_wrap(
wrap_like='specific_humidity',
broadcast=('pressure', 'specific_humidity')
broadcast=('specific_humidity', 'pressure')
)
@check_units(pressure='[pressure]', specific_humidity='[dimensionless]')
def _dewpoint_from_specific_humidity(pressure, specific_humidity):
Expand Down
8 changes: 8 additions & 0 deletions tests/calc/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,14 @@ def test_dewpoint_specific_humidity_arrays():
assert_almost_equal(td, np.tile(17.036 * units.degC, (3, 2)), 3)


def test_dewpoint_specific_humidity_xarray(index_xarray_data):
"""Test function arg handling processes xarray inputs."""
p = index_xarray_data.isobaric
q = specific_humidity_from_dewpoint(p, index_xarray_data.dewpoint)
td = dewpoint_from_specific_humidity(p, specific_humidity=q)
assert_array_almost_equal(td, index_xarray_data.dewpoint)


def test_lfc_not_below_lcl():
"""Test sounding where LFC appears to be (but isn't) below LCL."""
levels = np.array([1002.5, 1001.7, 1001., 1000.3, 999.7, 999., 998.2, 977.9,
Expand Down

0 comments on commit 163702b

Please sign in to comment.