Code Duplication    Length = 13-14 lines in 5 locations

metpy/calc/tests/test_thermo.py 5 locations

@@ 437-450 (lines=14) @@
434
    assert_almost_equal(ret[1], 22.2 * units.degC, 6)
435
    assert_almost_equal(ret[2], 19.0 * units.degC, 6)
436
437
438
<<<<<<< HEAD
439
def test_isentropic_pressure():
440
    """Test calculation of isentropic pressure function."""
441
    lev = [100000., 95000., 90000., 85000.] * units.Pa
442
    tmp = np.ones((4, 5, 5))
443
    tmp[0, :] = 296.
444
    tmp[1, :] = 292.
445
    tmp[2, :] = 290
446
    tmp[3, :] = 288.
447
    tmpk = tmp * units.kelvin
448
    isentlev = [296.] * units.kelvin
449
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
450
    trueprs = 1000. * units.hPa
451
    assert_almost_equal(isentprs[0].shape, (1, 5, 5), 3)
452
    assert_almost_equal(isentprs[0], trueprs, 3)
453
@@ 561-573 (lines=13) @@
558
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, relh)
559
    truerh = 69.171 * units.percent
560
    assert_almost_equal(isentprs[1][1], truerh, 3)
561
562
563
def test_isentropic_pressure_tmp_out_interp():
564
    """Test calculation of isentropic pressure function, temperature output."""
565
    lev = [100000., 95000., 90000., 85000.] * units.Pa
566
    tmp = np.ones((4, 5, 5))
567
    tmp[0, :] = 296.
568
    tmp[1, :] = 292.
569
    tmp[2, :] = 290.
570
    tmp[3, :] = 288.
571
    tmpk = tmp * units.kelvin
572
    isentlev = [296., 297.] * units.kelvin
573
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, tmpk_out=True)
574
    truetmp = 291.4579 * units.kelvin
575
    assert_almost_equal(isentprs[1][1], truetmp, 3)
576
@@ 525-537 (lines=13) @@
522
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, relh)
523
    truerh = 100. * units.percent
524
    assert_almost_equal(isentprs[1], truerh, 3)
525
526
527
def test_isentropic_pressure_interp():
528
    """Test calculation of isentropic pressure function."""
529
    lev = [100000., 95000., 90000., 85000.] * units.Pa
530
    tmp = np.ones((4, 5, 5))
531
    tmp[0, :] = 296.
532
    tmp[1, :] = 292.
533
    tmp[2, :] = 290
534
    tmp[3, :] = 288.
535
    tmpk = tmp * units.kelvin
536
    isentlev = [296., 297] * units.kelvin
537
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
538
    trueprs = 936.18057 * units.hPa
539
    assert_almost_equal(isentprs[0][1], trueprs, 3)
540
@@ 489-501 (lines=13) @@
486
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, relh)
487
    truerh = 100. * units.percent
488
    assert_almost_equal(isentprs[1], truerh, 3)
489
490
491
def test_isentropic_pressure_tmp_out():
492
    """Test calculation of isentropic pressure function, temperature output."""
493
    lev = [100000., 95000., 90000., 85000.] * units.Pa
494
    tmp = np.ones((4, 5, 5))
495
    tmp[0, :] = 296.
496
    tmp[1, :] = 292.
497
    tmp[2, :] = 290.
498
    tmp[3, :] = 288.
499
    tmpk = tmp * units.kelvin
500
    isentlev = [296.] * units.kelvin
501
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, tmpk_out=True)
502
    truetmp = 296. * units.kelvin
503
    assert_almost_equal(isentprs[1], truetmp, 3)
504
@@ 453-465 (lines=13) @@
450
    trueprs = 1000. * units.hPa
451
    assert_almost_equal(isentprs[0].shape, (1, 5, 5), 3)
452
    assert_almost_equal(isentprs[0], trueprs, 3)
453
454
455
def test_isentropic_pressure_p_increase():
456
    """Test calculation of isentropic pressure function, p increasing order."""
457
    lev = [85000, 90000., 95000., 100000.] * units.Pa
458
    tmp = np.ones((4, 5, 5))
459
    tmp[0, :] = 288.
460
    tmp[1, :] = 290.
461
    tmp[2, :] = 292.
462
    tmp[3, :] = 296.
463
    tmpk = tmp * units.kelvin
464
    isentlev = [296.] * units.kelvin
465
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
466
    trueprs = 1000. * units.hPa
467
    assert_almost_equal(isentprs[0], trueprs, 3)
468