Code Duplication    Length = 8-9 lines in 4 locations

metpy/calc/tests/test_thermo.py 4 locations

@@ 410-418 (lines=9) @@
407
    p = 1013.25 * units.mbar
408
    dry_bulb_temperature = 20. * units.degC
409
    wet_bulb_temperature = 18. * units.degC
410
    coeff = 6.1e-4 / units.kelvin
411
    psychrometric_rh = relative_humidity_wet_psychrometric(dry_bulb_temperature,
412
                                                           wet_bulb_temperature, p,
413
                                                           psychrometer_coefficient=coeff)
414
    assert_almost_equal(psychrometric_rh, 82.9701 * units.percent, 3)
415
416
417
def test_rh_mixing_ratio():
418
    """Tests relative humidity from mixing ratio."""
419
    p = 1013.25 * units.mbar
420
    temperature = 20. * units.degC
421
    w = 0.012
@@ 386-394 (lines=9) @@
383
384
385
def test_wet_psychrometric_vapor_pressure():
386
    """Test calculation of vapor pressure from wet and dry bulb temperatures."""
387
    p = 1013.25 * units.mbar
388
    dry_bulb_temperature = 20. * units.degC
389
    wet_bulb_temperature = 18. * units.degC
390
    psychrometric_vapor_pressure = psychrometric_vapor_pressure_wet(dry_bulb_temperature,
391
                                                                    wet_bulb_temperature, p)
392
    assert_almost_equal(psychrometric_vapor_pressure, 19.3673 * units.mbar, 3)
393
394
395
def test_wet_psychrometric_rh():
396
    """Test calculation of relative humidity from wet and dry bulb temperatures."""
397
    p = 1013.25 * units.mbar
@@ 179-186 (lines=8) @@
176
def test_vapor_pressure():
177
    """Test vapor pressure calculation."""
178
    assert_almost_equal(vapor_pressure(998. * units.mbar, 0.04963),
179
                        73.74925 * units.mbar, 5)
180
181
182
def test_lcl():
183
    """Test LCL calculation."""
184
    lcl_pressure, lcl_temperature = lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC)
185
    assert_almost_equal(lcl_pressure, 864.761 * units.mbar, 2)
186
    assert_almost_equal(lcl_temperature, 17.676 * units.degC, 2)
187
188
189
def test_lcl_convergence():
@@ 364-372 (lines=9) @@
361
    el_pressure, el_temperature = el(levels, temperatures, dewpoints)
362
    assert assert_nan(el_pressure, levels.units)
363
    assert assert_nan(el_temperature, temperatures.units)
364
365
366
def test_no_el_parcel_colder():
367
    """Tests no EL when parcel stays colder than environment. INL 20170925-12Z."""
368
    levels = np.array([974., 946., 925., 877.2, 866., 850., 814.6, 785.,
369
                       756.6, 739., 729.1, 700., 686., 671., 641., 613.,
370
                       603., 586., 571., 559.3, 539., 533., 500., 491.,
371
                       477.9, 413., 390., 378., 345., 336.]) * units.mbar
372
    temperatures = np.array([10., 8.4, 7.6, 5.9, 7.2, 7.6, 6.8, 7.1, 7.7,
373
                             7.8, 7.7, 5.6, 4.6, 3.4, 0.6, -0.9, -1.1, -3.1,
374
                             -4.7, -4.7, -6.9, -7.5, -11.1, -10.9, -12.1, -20.5, -23.5,
375
                             -24.7, -30.5, -31.7]) * units.celsius