Code Duplication    Length = 19-19 lines in 3 locations

metpy/calc/tests/test_thermo.py 3 locations

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