Code Duplication    Length = 19-19 lines in 3 locations

metpy/calc/tests/test_thermo.py 3 locations

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