Code Duplication    Length = 8-11 lines in 4 locations

metpy/calc/tests/test_thermo.py 4 locations

@@ 211-221 (lines=11) @@
208
    assert_almost_equal(l[1], 10.6232 * units.celsius, 2)
209
210
211
def test_lfc_equals_lcl():
212
    """Test LFC when there is no cap and the lfc is equal to the lcl."""
213
    levels = np.array([912., 905.3, 874.4, 850., 815.1, 786.6, 759.1,
214
                       748., 732.2, 700., 654.8]) * units.mbar
215
    temperatures = np.array([29.4, 28.7, 25.2, 22.4, 19.4, 16.8,
216
                             14.3, 13.2, 12.6, 11.4, 7.1]) * units.celsius
217
    dewpoints = np.array([18.4, 18.1, 16.6, 15.4, 13.2, 11.4, 9.6,
218
                          8.8, 0., -18.6, -22.9]) * units.celsius
219
    l = lfc(levels, temperatures, dewpoints)
220
    assert_almost_equal(l[0], 777.0333 * units.mbar, 2)
221
    assert_almost_equal(l[1], 15.8714 * units.celsius, 2)
222
223
224
def test_saturation_mixing_ratio():
@@ 198-208 (lines=11) @@
195
    assert assert_nan(lfc_temperature, temperatures.units)
196
197
198
def test_lfc_inversion():
199
    """Test LFC when there is an inversion to be sure we don't pick that."""
200
    levels = np.array([963., 789., 782.3, 754.8, 728.1, 727., 700.,
201
                       571., 450., 300., 248.]) * units.mbar
202
    temperatures = np.array([25.4, 18.4, 17.8, 15.4, 12.9, 12.8,
203
                             10., -3.9, -16.3, -41.1, -51.5]) * units.celsius
204
    dewpoints = np.array([20.4, 0.4, -0.5, -4.3, -8., -8.2, -9.,
205
                          -23.9, -33.3, -54.1, -63.5]) * units.celsius
206
    l = lfc(levels, temperatures, dewpoints)
207
    assert_almost_equal(l[0], 706.0103 * units.mbar, 2)
208
    assert_almost_equal(l[1], 10.6232 * units.celsius, 2)
209
210
211
def test_lfc_equals_lcl():
@@ 363-371 (lines=9) @@
360
    assert_almost_equal(rh, 82.7145 * units.percent, 3)
361
362
363
def test_most_unstable_parcel():
364
    """Tests calculating the most unstable parcel."""
365
    levels = np.array([1000., 959., 867.9]) * units.mbar
366
    temperatures = np.array([18.2, 22.2, 17.4]) * units.celsius
367
    dewpoints = np.array([19., 19., 14.3]) * units.celsius
368
    ret = most_unstable_parcel(levels, temperatures, dewpoints, depth=100 * units.hPa)
369
    assert_almost_equal(ret[0], 959.0 * units.hPa, 6)
370
    assert_almost_equal(ret[1], 22.2 * units.degC, 6)
371
    assert_almost_equal(ret[2], 19.0 * units.degC, 6)
372
@@ 178-185 (lines=8) @@
175
        lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC, max_iters=2)
176
177
178
def test_lfc_basic():
179
    """Test LFC calculation."""
180
    levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar
181
    temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -49.]) * units.celsius
182
    dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius
183
    l = lfc(levels, temperatures, dewpoints)
184
    assert_almost_equal(l[0], 727.468 * units.mbar, 2)
185
    assert_almost_equal(l[1], 9.705 * units.celsius, 2)
186
187
188
def test_no_lfc():