Code Duplication    Length = 19-19 lines in 3 locations

metpy/calc/tests/test_thermo.py 3 locations

@@ 540-558 (lines=19) @@
537
def test_isentropic_pressure_p_increase_rh_out():
538
    """Test calculation of isentropic pressure function, p increasing order."""
539
    lev = [85000., 90000., 95000., 100000.] * units.Pa
540
    tmp = np.ones((4, 5, 5))
541
    tmp[0, :] = 288.
542
    tmp[1, :] = 290.
543
    tmp[2, :] = 292.
544
    tmp[3, :] = 296.
545
    tmpk = tmp * units.kelvin
546
    rh = np.ones((4, 5, 5))
547
    rh[0, :] = 20.
548
    rh[1, :] = 40.
549
    rh[2, :] = 80.
550
    rh[3, :] = 100.
551
    relh = rh * units.percent
552
    isentlev = 296. * units.kelvin
553
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, relh)
554
    truerh = 100. * units.percent
555
    assert_almost_equal(isentprs[1], truerh, 3)
556
557
558
def test_isentropic_pressure_interp():
559
    """Test calculation of isentropic pressure function."""
560
    lev = [100000., 95000., 90000., 85000.] * units.Pa
561
    tmp = np.ones((4, 5, 5))
@@ 504-522 (lines=19) @@
501
def test_isentropic_pressure_adition_args():
502
    """Test calculation of isentropic pressure function, additional args."""
503
    lev = [100000., 95000., 90000., 85000.] * units.Pa
504
    tmp = np.ones((4, 5, 5))
505
    tmp[0, :] = 296.
506
    tmp[1, :] = 292.
507
    tmp[2, :] = 290.
508
    tmp[3, :] = 288.
509
    rh = np.ones((4, 5, 5))
510
    rh[0, :] = 100.
511
    rh[1, :] = 80.
512
    rh[2, :] = 40.
513
    rh[3, :] = 20.
514
    relh = rh * units.percent
515
    tmpk = tmp * units.kelvin
516
    isentlev = [296.] * units.kelvin
517
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, relh)
518
    truerh = 100. * units.percent
519
    assert_almost_equal(isentprs[1], truerh, 3)
520
521
522
def test_isentropic_pressure_tmp_out():
523
    """Test calculation of isentropic pressure function, temperature output."""
524
    lev = [100000., 95000., 90000., 85000.] * units.Pa
525
    tmp = np.ones((4, 5, 5))
@@ 468-486 (lines=19) @@
465
    mucape, mucin = mucape_cin(p, temperature, dewpoint)
466
    assert_almost_equal(mucape, 540.9049917 * units('joule / kilogram'), 6)
467
    assert_almost_equal(mucin, 0. * units('joule / kilogram'), 6)
468
469
470
def test_isentropic_pressure():
471
    """Test calculation of isentropic pressure function."""
472
    lev = [100000., 95000., 90000., 85000.] * units.Pa
473
    tmp = np.ones((4, 5, 5))
474
    tmp[0, :] = 296.
475
    tmp[1, :] = 292.
476
    tmp[2, :] = 290
477
    tmp[3, :] = 288.
478
    tmpk = tmp * units.kelvin
479
    isentlev = [296.] * units.kelvin
480
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
481
    trueprs = 1000. * units.hPa
482
    assert_almost_equal(isentprs[0].shape, (1, 5, 5), 3)
483
    assert_almost_equal(isentprs[0], trueprs, 3)
484
485
486
def test_isentropic_pressure_p_increase():
487
    """Test calculation of isentropic pressure function, p increasing order."""
488
    lev = [85000, 90000., 95000., 100000.] * units.Pa
489
    tmp = np.ones((4, 5, 5))