Skip to content

Commit

Permalink
Test for get_layer units bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
23ccozad committed Jun 29, 2021
1 parent 622faba commit c16173b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/calc/test_calc_tools.py
Expand Up @@ -358,6 +358,18 @@ def test_get_layer(pressure, variable, heights, bottom, depth, interp, expected)
assert_array_almost_equal(y_layer, expected[1], 3)


def test_get_layer_units():
"""Test get_layer when height profile has different units from bottom and depth."""
pressure, temperature = layer_test_data()
height = units.Quantity(np.linspace(100, 50000, len(pressure)), 'm')
pres_subset, temp_subset = get_layer(pressure, temperature,
bottom=units.Quantity(1, 'km'),
depth=units.Quantity(5, 'km'),
height=height)
assert_array_almost_equal(pres_subset[1], units.Quantity(900, 'hPa'), 2)
assert_array_almost_equal(temp_subset[1], units.Quantity(16.66666667, 'degC'), 3)


def test_get_layer_masked():
"""Test get_layer with masked arrays as input."""
p = units.Quantity(np.ma.array([1000, 500, 400]), 'hPa')
Expand Down

0 comments on commit c16173b

Please sign in to comment.