Code Duplication    Length = 19-19 lines in 3 locations

metpy/calc/tests/test_thermo.py 3 locations

@@ 540-558 (lines=19) @@
537
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
538
    trueprs = 936.18057 * units.hPa
539
    assert_almost_equal(isentprs[0][1], trueprs, 3)
540
541
542
def test_isentropic_pressure_adition_args_interp():
543
    """Test calculation of isentropic pressure function, additional args."""
544
    lev = [100000., 95000., 90000., 85000.] * units.Pa
545
    tmp = np.ones((4, 5, 5))
546
    tmp[0, :] = 296.
547
    tmp[1, :] = 292.
548
    tmp[2, :] = 290.
549
    tmp[3, :] = 288.
550
    rh = np.ones((4, 5, 5))
551
    rh[0, :] = 100.
552
    rh[1, :] = 80.
553
    rh[2, :] = 40.
554
    rh[3, :] = 20.
555
    relh = rh * units.percent
556
    tmpk = tmp * units.kelvin
557
    isentlev = [296., 297.] * units.kelvin
558
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, relh)
559
    truerh = 69.171 * units.percent
560
    assert_almost_equal(isentprs[1][1], truerh, 3)
561
@@ 504-522 (lines=19) @@
501
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, tmpk_out=True)
502
    truetmp = 296. * units.kelvin
503
    assert_almost_equal(isentprs[1], truetmp, 3)
504
505
506
def test_isentropic_pressure_p_increase_rh_out():
507
    """Test calculation of isentropic pressure function, p increasing order."""
508
    lev = [85000., 90000., 95000., 100000.] * units.Pa
509
    tmp = np.ones((4, 5, 5))
510
    tmp[0, :] = 288.
511
    tmp[1, :] = 290.
512
    tmp[2, :] = 292.
513
    tmp[3, :] = 296.
514
    tmpk = tmp * units.kelvin
515
    rh = np.ones((4, 5, 5))
516
    rh[0, :] = 20.
517
    rh[1, :] = 40.
518
    rh[2, :] = 80.
519
    rh[3, :] = 100.
520
    relh = rh * units.percent
521
    isentlev = 296. * units.kelvin
522
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, relh)
523
    truerh = 100. * units.percent
524
    assert_almost_equal(isentprs[1], truerh, 3)
525
@@ 468-486 (lines=19) @@
465
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
466
    trueprs = 1000. * units.hPa
467
    assert_almost_equal(isentprs[0], trueprs, 3)
468
469
470
def test_isentropic_pressure_adition_args():
471
    """Test calculation of isentropic pressure function, additional args."""
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
    rh = np.ones((4, 5, 5))
479
    rh[0, :] = 100.
480
    rh[1, :] = 80.
481
    rh[2, :] = 40.
482
    rh[3, :] = 20.
483
    relh = rh * units.percent
484
    tmpk = tmp * units.kelvin
485
    isentlev = [296.] * units.kelvin
486
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, relh)
487
    truerh = 100. * units.percent
488
    assert_almost_equal(isentprs[1], truerh, 3)
489