本文整理汇总了Python中metpy.testing.assert_almost_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_almost_equal函数的具体用法?Python assert_almost_equal怎么用?Python assert_almost_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_almost_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_virtual_potential_temperature
def test_virtual_potential_temperature():
"""Test virtual potential temperature calculation."""
p = 999. * units.mbar
t = 288. * units.kelvin
qv = .0016 * units.dimensionless # kg/kg
theta_v = virtual_potential_temperature(p, t, qv)
assert_almost_equal(theta_v, 288.3620 * units.kelvin, 3)
示例2: test_density
def test_density():
"""Test density calculation."""
p = 999. * units.mbar
t = 288. * units.kelvin
qv = .0016 * units.dimensionless # kg/kg
rho = density(p, t, qv).to(units.kilogram / units.meter ** 3)
assert_almost_equal(rho, 1.2072 * (units.kilogram / units.meter ** 3), 3)
示例3: test_equivalent_potential_temperature
def test_equivalent_potential_temperature():
"""Test equivalent potential temperature calculation."""
p = 1000 * units.mbar
t = 293. * units.kelvin
td = 280. * units.kelvin
ept = equivalent_potential_temperature(p, t, td)
assert_almost_equal(ept, 311.18586467284007 * units.kelvin, 3)
示例4: test_thickness_hydrostatic_isothermal_subset
def test_thickness_hydrostatic_isothermal_subset():
"""Test the thickness calculation for a dry isothermal layer subset at 0 degC."""
pressure = np.arange(1000, 500 - 1e-10, -10) * units.hPa
temperature = np.zeros_like(pressure) * units.degC
thickness = thickness_hydrostatic(pressure, temperature, bottom=850 * units.hPa,
depth=350 * units.hPa)
assert_almost_equal(thickness, 4242.68 * units.m, 2)
示例5: test_dewpoint_specific_humidity
def test_dewpoint_specific_humidity():
"""Test relative humidity from specific humidity."""
p = 1013.25 * units.mbar
temperature = 20. * units.degC
q = 0.012 * units.dimensionless
td = dewpoint_from_specific_humidity(q, temperature, p)
assert_almost_equal(td, 16.973 * units.degC, 3)
示例6: test_rh_mixing_ratio
def test_rh_mixing_ratio():
"""Test relative humidity from mixing ratio."""
p = 1013.25 * units.mbar
temperature = 20. * units.degC
w = 0.012 * units.dimensionless
rh = relative_humidity_from_mixing_ratio(w, temperature, p)
assert_almost_equal(rh, 81.7219 * units.percent, 3)
示例7: test_rh_specific_humidity
def test_rh_specific_humidity():
"""Test relative humidity from specific humidity."""
p = 1013.25 * units.mbar
temperature = 20. * units.degC
q = 0.012 * units.dimensionless
rh = relative_humidity_from_specific_humidity(q, temperature, p)
assert_almost_equal(rh, 82.7145 * units.percent, 3)
示例8: test_mixing_ratio_from_relative_humidity
def test_mixing_ratio_from_relative_humidity():
"""Test relative humidity from mixing ratio."""
p = 1013.25 * units.mbar
temperature = 20. * units.degC
rh = 81.7219 * units.percent
w = mixing_ratio_from_relative_humidity(rh, temperature, p)
assert_almost_equal(w, 0.012 * units.dimensionless, 3)
示例9: test_coriolis_force
def test_coriolis_force():
"""Test basic coriolis force calculation."""
lat = np.array([-90., -30., 0., 30., 90.]) * units.degrees
cor = coriolis_parameter(lat)
values = np.array([-1.4584232E-4, -.72921159E-4, 0, .72921159E-4,
1.4584232E-4]) * units('s^-1')
assert_almost_equal(cor, values, 7)
示例10: test_vertical_velocity_pressure_moist_air
def test_vertical_velocity_pressure_moist_air():
"""Test conversion of w to omega assuming moist air."""
w = -1 * units('cm/s')
omega_truth = 1.032100858 * units('microbar/second')
omega_test = vertical_velocity_pressure(w, 850. * units.mbar, 280. * units.K,
8 * units('g/kg'))
assert_almost_equal(omega_test, omega_truth, 6)
示例11: test_thickness_hydrostatic
def test_thickness_hydrostatic():
"""Test the thickness calculation for a moist layer."""
pressure = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.hPa
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.degC
mixing = np.array([0.01458, 0.00209, 0.00224, 0.00240, 0.00256, 0.00010])
thickness = thickness_hydrostatic(pressure, temperature, mixing=mixing)
assert_almost_equal(thickness, 9892.07 * units.m, 2)
示例12: test_heat_index_kelvin
def test_heat_index_kelvin():
"""Test heat_index when given Kelvin temperatures."""
temp = 308.15 * units.degK
rh = 0.7
hi = heat_index(temp, rh)
# NB rounded up test value here vs the above two tests
assert_almost_equal(hi.to('degC'), 50.3406 * units.degC, 4)
示例13: test_thickness_hydrostatic_subset
def test_thickness_hydrostatic_subset():
"""Test the thickness calculation with a subset of the moist layer."""
pressure = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.hPa
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.degC
mixing = np.array([0.01458, 0.00209, 0.00224, 0.00240, 0.00256, 0.00010])
thickness = thickness_hydrostatic(pressure, temperature, mixing=mixing,
bottom=850 * units.hPa, depth=150 * units.hPa)
assert_almost_equal(thickness, 1630.81 * units.m, 2)
示例14: test_brunt_vaisala_period
def test_brunt_vaisala_period():
"""Test Brunt-Vaisala period function."""
truth = [[540.24223556, 441.10593821, 360.16149037, 483.20734521],
[542.10193894, 443.38165033, 627.03634320, 625.96540075],
[543.95528431, 771.88106656, np.nan, 543.02940230],
[545.80233643, np.nan, np.nan, 385.94053328]] * units('s')
bv_period = brunt_vaisala_period(bv_data()[0], bv_data()[1])
assert_almost_equal(bv_period, truth, 6)
示例15: test_brunt_vaisala_frequency
def test_brunt_vaisala_frequency():
"""Test Brunt-Vaisala frequency function."""
truth = [[0.01163031, 0.01424416, 0.01744547, 0.01300308],
[0.01159041, 0.01417105, 0.01002045, 0.01003759],
[0.01155092, 0.00814010, 0., 0.01157062],
[0.01151183, np.nan, 0., 0.01628019]] * units('s^-1')
bv_freq = brunt_vaisala_frequency(bv_data()[0], bv_data()[1])
assert_almost_equal(bv_freq, truth, 6)