Code Duplication    Length = 8-11 lines in 3 locations

metpy/calc/tests/test_thermo.py 3 locations

@@ 199-209 (lines=11) @@
196
    assert assert_nan(lfc_temperature, temperatures.units)
197
198
199
def test_lfc_inversion():
200
    """Test LFC when there is an inversion to be sure we don't pick that."""
201
    levels = np.array([963., 789., 782.3, 754.8, 728.1, 727., 700.,
202
                       571., 450., 300., 248.]) * units.mbar
203
    temperatures = np.array([25.4, 18.4, 17.8, 15.4, 12.9, 12.8,
204
                             10., -3.9, -16.3, -41.1, -51.5]) * units.celsius
205
    dewpoints = np.array([20.4, 0.4, -0.5, -4.3, -8., -8.2, -9.,
206
                          -23.9, -33.3, -54.1, -63.5]) * units.celsius
207
    l = lfc(levels, temperatures, dewpoints)
208
    assert_almost_equal(l[0], 706.0103 * units.mbar, 2)
209
    assert_almost_equal(l[1], 10.6232 * units.celsius, 2)
210
211
212
def test_saturation_mixing_ratio():
@@ 330-338 (lines=9) @@
327
    assert_almost_equal(rh, 82.7145 * units.percent, 3)
328
329
330
def test_cape_cin():
331
    """Tests the basic CAPE and CIN calculation."""
332
    p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar
333
    T = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius
334
    Td = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius
335
    parcel_prof = parcel_profile(p, T[0], Td[0]).to('degC')
336
    cape, cin = cape_cin(p, T, Td, parcel_prof)
337
    assert_almost_equal(cape, 58.0368212 * units('joule / kilogram'), 6)
338
    assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6)
339
340
def test_find_append_zero_crossings():
341
    """Tests finding and appending zero crossings of an x, y series."""
@@ 179-186 (lines=8) @@
176
        lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC, max_iters=2)
177
178
179
def test_lfc_basic():
180
    """Test LFC calculation."""
181
    levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar
182
    temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -49.]) * units.celsius
183
    dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius
184
    l = lfc(levels, temperatures, dewpoints)
185
    assert_almost_equal(l[0], 727.468 * units.mbar, 2)
186
    assert_almost_equal(l[1], 9.705 * units.celsius, 2)
187
188
189
def test_no_lfc():