Code Duplication    Length = 13-14 lines in 5 locations

metpy/calc/tests/test_thermo.py 5 locations

@@ 423-436 (lines=14) @@
420
    assert_almost_equal(ret[2], 19.0 * units.degC, 6)
421
422
423
def test_isentropic_pressure():
424
    """Test calculation of isentropic pressure function."""
425
    lev = [100000., 95000., 90000., 85000.] * units.Pa
426
    tmp = np.ones((4, 5, 5))
427
    tmp[0, :] = 296.
428
    tmp[1, :] = 292.
429
    tmp[2, :] = 290
430
    tmp[3, :] = 288.
431
    tmpk = tmp * units.kelvin
432
    isentlev = [296.] * units.kelvin
433
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
434
    trueprs = 1000. * units.hPa
435
    assert_almost_equal(isentprs[0].shape, (1, 5, 5), 3)
436
    assert_almost_equal(isentprs[0], trueprs, 3)
437
438
439
def test_isentropic_pressure_p_increase():
@@ 547-559 (lines=13) @@
544
    assert_almost_equal(isentprs[1][1], truerh, 3)
545
546
547
def test_isentropic_pressure_tmp_out_interp():
548
    """Test calculation of isentropic pressure function, temperature output."""
549
    lev = [100000., 95000., 90000., 85000.] * units.Pa
550
    tmp = np.ones((4, 5, 5))
551
    tmp[0, :] = 296.
552
    tmp[1, :] = 292.
553
    tmp[2, :] = 290.
554
    tmp[3, :] = 288.
555
    tmpk = tmp * units.kelvin
556
    isentlev = [296., 297.] * units.kelvin
557
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, tmpk_out=True)
558
    truetmp = 291.4579 * units.kelvin
559
    assert_almost_equal(isentprs[1][1], truetmp, 3)
560
561
562
def test_isentropic_pressure_data_bounds_error():
@@ 511-523 (lines=13) @@
508
    assert_almost_equal(isentprs[1], truerh, 3)
509
510
511
def test_isentropic_pressure_interp():
512
    """Test calculation of isentropic pressure function."""
513
    lev = [100000., 95000., 90000., 85000.] * units.Pa
514
    tmp = np.ones((4, 5, 5))
515
    tmp[0, :] = 296.
516
    tmp[1, :] = 292.
517
    tmp[2, :] = 290
518
    tmp[3, :] = 288.
519
    tmpk = tmp * units.kelvin
520
    isentlev = [296., 297] * units.kelvin
521
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
522
    trueprs = 936.18057 * units.hPa
523
    assert_almost_equal(isentprs[0][1], trueprs, 3)
524
525
526
def test_isentropic_pressure_adition_args_interp():
@@ 475-487 (lines=13) @@
472
    assert_almost_equal(isentprs[1], truerh, 3)
473
474
475
def test_isentropic_pressure_tmp_out():
476
    """Test calculation of isentropic pressure function, temperature output."""
477
    lev = [100000., 95000., 90000., 85000.] * units.Pa
478
    tmp = np.ones((4, 5, 5))
479
    tmp[0, :] = 296.
480
    tmp[1, :] = 292.
481
    tmp[2, :] = 290.
482
    tmp[3, :] = 288.
483
    tmpk = tmp * units.kelvin
484
    isentlev = [296.] * units.kelvin
485
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, tmpk_out=True)
486
    truetmp = 296. * units.kelvin
487
    assert_almost_equal(isentprs[1], truetmp, 3)
488
489
490
def test_isentropic_pressure_p_increase_rh_out():
@@ 439-451 (lines=13) @@
436
    assert_almost_equal(isentprs[0], trueprs, 3)
437
438
439
def test_isentropic_pressure_p_increase():
440
    """Test calculation of isentropic pressure function, p increasing order."""
441
    lev = [85000, 90000., 95000., 100000.] * units.Pa
442
    tmp = np.ones((4, 5, 5))
443
    tmp[0, :] = 288.
444
    tmp[1, :] = 290.
445
    tmp[2, :] = 292.
446
    tmp[3, :] = 296.
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], trueprs, 3)
452
453
454
def test_isentropic_pressure_adition_args():