本文整理汇总了Python中metpy.testing.assert_almost_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_almost_equal函数的具体用法?Python assert_almost_equal怎么用?Python assert_almost_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_almost_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:akrherz,项目名称:MetPy,代码行数:7,代码来源:test_basic.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:7,代码来源:test_thermo.py
示例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)
开发者ID:akrherz,项目名称:MetPy,代码行数:7,代码来源:test_basic.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:8,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:8,代码来源:test_thermo.py
示例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)
开发者ID:dodolooking,项目名称:MetPy,代码行数:8,代码来源:test_thermo.py
示例16: test_wet_psychrometric_rh
def test_wet_psychrometric_rh():
"""Test calculation of relative humidity from wet and dry bulb temperatures."""
p = 1013.25 * units.mbar
dry_bulb_temperature = 20. * units.degC
wet_bulb_temperature = 18. * units.degC
psychrometric_rh = relative_humidity_wet_psychrometric(dry_bulb_temperature,
wet_bulb_temperature, p)
assert_almost_equal(psychrometric_rh, 82.8747 * units.percent, 3)
开发者ID:dodolooking,项目名称:MetPy,代码行数:8,代码来源:test_thermo.py
示例17: test_critical_angle
def test_critical_angle():
"""Test critical angle with observed sounding."""
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC')
ca = critical_angle(data['pressure'], data['u_wind'],
data['v_wind'], data['height'],
stormu=0 * units('m/s'), stormv=0 * units('m/s'))
truth = [140.0626637513269] * units('degrees')
assert_almost_equal(ca, truth, 8)
开发者ID:dodolooking,项目名称:MetPy,代码行数:8,代码来源:test_indices.py
示例18: test_apparent_temperature_windchill
def test_apparent_temperature_windchill():
"""Test that apparent temperature works when a windchill is calculated."""
temperature = -5. * units.degC
rel_humidity = 50. * units.percent
wind = 35. * units('m/s')
truth = -18.9357 * units.degC
res = apparent_temperature(temperature, rel_humidity, wind)
assert_almost_equal(res, truth, 0)
开发者ID:akrherz,项目名称:MetPy,代码行数:8,代码来源:test_basic.py
示例19: test_apparent_temperature_scalar
def test_apparent_temperature_scalar():
"""Test the apparent temperature calculation with a scalar."""
temperature = 90 * units.degF
rel_humidity = 60 * units.percent
wind = 5 * units.mph
truth = 99.6777178 * units.degF
res = apparent_temperature(temperature, rel_humidity, wind)
assert_almost_equal(res, truth, 6)
开发者ID:akrherz,项目名称:MetPy,代码行数:8,代码来源:test_basic.py
示例20: test_most_unstable_cape_cin
def test_most_unstable_cape_cin():
"""Test the most unstable CAPE/CIN calculation."""
pressure = np.array([1000., 959., 867.9, 850., 825., 800.]) * units.mbar
temperature = np.array([18.2, 22.2, 17.4, 10., 0., 15]) * units.celsius
dewpoint = np.array([19., 19., 14.3, 0., -10., 0.]) * units.celsius
mucape, mucin = most_unstable_cape_cin(pressure, temperature, dewpoint)
assert_almost_equal(mucape, 157.07111 * units('joule / kilogram'), 4)
assert_almost_equal(mucin, -15.74772 * units('joule / kilogram'), 4)
开发者ID:dodolooking,项目名称:MetPy,代码行数:8,代码来源:test_thermo.py
注:本文中的metpy.testing.assert_almost_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论