• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python units.units函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中metpy.units.units函数的典型用法代码示例。如果您正苦于以下问题:Python units函数的具体用法?Python units怎么用?Python units使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了units函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: 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


示例2: test_basic3

 def test_basic3(self):
     'Basic test of advection'
     u = np.array([1, 2, 3]) * units('m/s')
     s = np.array([1, 2, 3]) * units('Pa')
     a = advection(s, u, (1 * units.meter,))
     truth = np.array([-1, -2, -3]) * units('Pa/sec')
     assert_array_equal(a, truth)
开发者ID:DBaryudin,项目名称:MetPy,代码行数:7,代码来源:test_kinematics.py


示例3: test_nws_layout

def test_nws_layout():
    """Test metpy's NWS layout for station plots."""
    fig = plt.figure(figsize=(3, 3))

    # testing data
    x = np.array([1])
    y = np.array([2])
    data = dict()
    data["air_temperature"] = np.array([77]) * units.degF
    data["dew_point_temperature"] = np.array([71]) * units.degF
    data["air_pressure_at_sea_level"] = np.array([999.8]) * units("mbar")
    data["eastward_wind"] = np.array([15.0]) * units.knots
    data["northward_wind"] = np.array([15.0]) * units.knots
    data["cloud_coverage"] = [7]
    data["present_weather"] = [80]
    data["high_cloud_type"] = [1]
    data["medium_cloud_type"] = [3]
    data["low_cloud_type"] = [2]
    data["visibility_in_air"] = np.array([5.0]) * units.mile
    data["tendency_of_air_pressure"] = np.array([-0.3]) * units("mbar")
    data["tendency_of_air_pressure_symbol"] = [8]

    # Make the plot
    sp = StationPlot(fig.add_subplot(1, 1, 1), x, y, fontsize=12, spacing=16)
    nws_layout.plot(sp, data)

    sp.ax.set_xlim(0, 3)
    sp.ax.set_ylim(0, 3)

    return fig
开发者ID:metpy,项目名称:MetPy,代码行数:30,代码来源:test_station_plot.py


示例4: test_advection_1d

def test_advection_1d():
    """Test advection calculation with varying wind and field."""
    u = np.array([1, 2, 3]) * units('m/s')
    s = np.array([1, 2, 3]) * units('Pa')
    a = advection(s, u, (1 * units.meter,))
    truth = np.array([-1, -2, -3]) * units('Pa/sec')
    assert_array_equal(a, truth)
开发者ID:ahill818,项目名称:MetPy,代码行数:7,代码来源:test_kinematics.py


示例5: test_advection_2d_uniform

def test_advection_2d_uniform():
    """Test advection for uniform 2D field."""
    u = np.ones((3, 3)) * units('m/s')
    s = np.ones_like(u) * units.kelvin
    a = advection(s, [u, u], (1 * units.meter, 1 * units.meter))
    truth = np.zeros_like(u) * units('K/sec')
    assert_array_equal(a, truth)
开发者ID:ahill818,项目名称:MetPy,代码行数:7,代码来源:test_kinematics.py


示例6: test_basic

 def test_basic(self):
     'Basic braindead test of advection'
     u = np.ones((3,)) * units('m/s')
     s = np.ones_like(u) * units.kelvin
     a = advection(s, u, (1 * units.meter,))
     truth = np.zeros_like(u) * units('K/sec')
     assert_array_equal(a, truth)
开发者ID:DBaryudin,项目名称:MetPy,代码行数:7,代码来源:test_kinematics.py


示例7: main

def main():
    """Go Main Go"""
    pgconn = get_dbconn('scan')
    for station in ['S2004', 'S2196', 'S2002', 'S2072', 'S2068',
                    'S2031', 'S2001', 'S2047']:
        df = read_sql("""
        select extract(year from valid + '2 months'::interval) as wy,
        tmpf, dwpf from alldata where station = %s and tmpf is not null
        and dwpf is not null
        """, pgconn, params=(station, ), index_col=None)
        df['mixingratio'] = meteorology.mixing_ratio(
            temperature(df['dwpf'].values, 'F')).value('KG/KG')
        df['vapor_pressure'] = mcalc.vapor_pressure(
            1000. * units.mbar,
            df['mixingratio'].values * units('kg/kg')).to(units('kPa'))
        df['saturation_mixingratio'] = (
            meteorology.mixing_ratio(
                temperature(df['tmpf'].values, 'F')).value('KG/KG'))
        df['saturation_vapor_pressure'] = mcalc.vapor_pressure(
            1000. * units.mbar,
            df['saturation_mixingratio'].values * units('kg/kg')).to(units('kPa'))
        df['vpd'] = df['saturation_vapor_pressure'] - df['vapor_pressure']
        means = df.groupby('wy').mean()
        counts = df.groupby('wy').count()
        for yr, row in means.iterrows():
            print(("%s,%s,%.0f,%.3f"
                   ) % (yr, station, counts.at[yr, 'vpd'], row['vpd']))
开发者ID:akrherz,项目名称:DEV,代码行数:27,代码来源:compute_vpd.py


示例8: test_grid_deltas_from_dataarray_xy

def test_grid_deltas_from_dataarray_xy(test_da_xy):
    """Test grid_deltas_from_dataarray with a xy grid."""
    dx, dy = grid_deltas_from_dataarray(test_da_xy)
    true_dx = np.array([[[[500] * 3]]]) * units('km')
    true_dy = np.array([[[[500]] * 3]]) * units('km')
    assert_array_almost_equal(dx, true_dx, 5)
    assert_array_almost_equal(dy, true_dy, 5)
开发者ID:dopplershift,项目名称:MetPy,代码行数:7,代码来源:test_calc_tools.py


示例9: test_nws_layout

def test_nws_layout():
    """Test metpy's NWS layout for station plots."""
    fig = plt.figure(figsize=(3, 3))

    # testing data
    x = np.array([1])
    y = np.array([2])
    data = {'air_temperature': np.array([77]) * units.degF,
            'dew_point_temperature': np.array([71]) * units.degF,
            'air_pressure_at_sea_level': np.array([999.8]) * units('mbar'),
            'eastward_wind': np.array([15.]) * units.knots,
            'northward_wind': np.array([15.]) * units.knots, 'cloud_coverage': [7],
            'present_weather': [80], 'high_cloud_type': [1], 'medium_cloud_type': [3],
            'low_cloud_type': [2], 'visibility_in_air': np.array([5.]) * units.mile,
            'tendency_of_air_pressure': np.array([-0.3]) * units('mbar'),
            'tendency_of_air_pressure_symbol': [8]}

    # Make the plot
    sp = StationPlot(fig.add_subplot(1, 1, 1), x, y, fontsize=12, spacing=16)
    nws_layout.plot(sp, data)

    sp.ax.set_xlim(0, 3)
    sp.ax.set_ylim(0, 3)

    return fig
开发者ID:akrherz,项目名称:MetPy,代码行数:25,代码来源:test_station_plot.py


示例10: test_nws_layout

def test_nws_layout():
    'Test metpy\'s NWS layout for station plots'
    setup_font()
    fig = make_figure(figsize=(3, 3))

    # testing data
    x = np.array([1])
    y = np.array([2])
    data = dict()
    data['air_temperature'] = np.array([77]) * units.degF
    data['dew_point_temperature'] = np.array([71]) * units.degF
    data['air_pressure_at_sea_level'] = np.array([999.8]) * units('mbar')
    data['eastward_wind'] = np.array([15.]) * units.knots
    data['northward_wind'] = np.array([15.]) * units.knots
    data['cloud_coverage'] = [7]
    data['present_weather'] = [80]
    data['high_cloud_type'] = [1]
    data['medium_cloud_type'] = [3]
    data['low_cloud_type'] = [2]
    data['visibility_in_air'] = np.array([5.]) * units.mile
    data['tendency_of_air_pressure'] = np.array([-0.3]) * units('mbar')
    data['tendency_of_air_pressure_symbol'] = [8]

    # Make the plot
    sp = StationPlot(fig.add_subplot(1, 1, 1), x, y, fontsize=12, spacing=16)
    nws_layout.plot(sp, data)

    sp.ax.set_xlim(0, 3)
    sp.ax.set_ylim(0, 3)
    hide_tick_labels(sp.ax)

    return fig
开发者ID:ajoros,项目名称:MetPy,代码行数:32,代码来源:test_station_plot.py


示例11: test_basic2

 def test_basic2(self):
     'Basic test of advection'
     u = np.ones((3,)) * units('m/s')
     s = np.array([1, 2, 3]) * units('kg')
     a = advection(s, u, (1 * units.meter,))
     truth = -np.ones_like(u) * units('kg/sec')
     assert_array_equal(a, truth)
开发者ID:DBaryudin,项目名称:MetPy,代码行数:7,代码来源:test_kinematics.py


示例12: test_advection_1d_uniform_wind

def test_advection_1d_uniform_wind():
    """Test advection for simple 1D case with uniform wind."""
    u = np.ones((3,)) * units('m/s')
    s = np.array([1, 2, 3]) * units('kg')
    a = advection(s, u, (1 * units.meter,))
    truth = -np.ones_like(u) * units('kg/sec')
    assert_array_equal(a, truth)
开发者ID:ahill818,项目名称:MetPy,代码行数:7,代码来源:test_kinematics.py


示例13: test_advection_uniform

def test_advection_uniform():
    """Test advection calculation for a uniform 1D field."""
    u = np.ones((3,)) * units('m/s')
    s = np.ones_like(u) * units.kelvin
    a = advection(s, u, (1 * units.meter,))
    truth = np.zeros_like(u) * units('K/sec')
    assert_array_equal(a, truth)
开发者ID:ahill818,项目名称:MetPy,代码行数:7,代码来源:test_kinematics.py


示例14: bv_data

def bv_data():
    """Return height and potential temperature data for testing Brunt-Vaisala functions."""
    heights = [1000., 1500., 2000., 2500.] * units('m')
    potential_temperatures = [[290., 290., 290., 290.],
                              [292., 293., 293., 292.],
                              [294., 296., 293., 293.],
                              [296., 295., 293., 296.]] * units('K')
    return heights, potential_temperatures
开发者ID:dodolooking,项目名称:MetPy,代码行数:8,代码来源:test_thermo.py


示例15: 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


示例16: test_most_unstable_cape_cin_surface

def test_most_unstable_cape_cin_surface():
    """Test the most unstable CAPE/CIN calculation when surface is most unstable."""
    pressure = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar
    temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius
    dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius
    mucape, mucin = most_unstable_cape_cin(pressure, temperature, dewpoint)
    assert_almost_equal(mucape, 58.0368212 * units('joule / kilogram'), 6)
    assert_almost_equal(mucin, -89.8073512 * units('joule / kilogram'), 6)
开发者ID:dodolooking,项目名称:MetPy,代码行数:8,代码来源:test_thermo.py


示例17: test_surface_based_cape_cin

def test_surface_based_cape_cin():
    """Test the surface-based CAPE and CIN calculation."""
    p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar
    temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius
    dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius
    cape, cin = surface_based_cape_cin(p, temperature, dewpoint)
    assert_almost_equal(cape, 58.0368212 * units('joule / kilogram'), 6)
    assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6)
开发者ID:dodolooking,项目名称:MetPy,代码行数:8,代码来源:test_thermo.py


示例18: test_advection_2d

def test_advection_2d():
    """Test advection in varying 2D field."""
    u = np.ones((3, 3)) * units('m/s')
    v = 2 * np.ones((3, 3)) * units('m/s')
    s = np.array([[1, 2, 1], [2, 4, 2], [1, 2, 1]]) * units.kelvin
    a = advection(s, [u, v], (1 * units.meter, 1 * units.meter))
    truth = np.array([[-3, -2, 1], [-4, 0, 4], [-1, 2, 3]]) * units('K/sec')
    assert_array_equal(a, truth)
开发者ID:ahill818,项目名称:MetPy,代码行数:8,代码来源:test_kinematics.py


示例19: test_2dbasic2

 def test_2dbasic2(self):
     'Basic 2D test of advection'
     u = np.ones((3, 3)) * units('m/s')
     v = 2 * np.ones((3, 3)) * units('m/s')
     s = np.array([[1, 2, 1], [2, 4, 2], [1, 2, 1]]) * units.kelvin
     a = advection(s, [u, v], (1 * units.meter, 1 * units.meter))
     truth = np.array([[-3, -2, 1], [-4, 0, 4], [-1, 2, 3]]) * units('K/sec')
     assert_array_equal(a, truth)
开发者ID:DBaryudin,项目名称:MetPy,代码行数:8,代码来源:test_kinematics.py


示例20: test_geopotential

 def test_geopotential(self):
     'Test of geostrophic wind calculation with geopotential'
     z = np.array([[48, 49, 48], [49, 50, 49], [48, 49, 48]]) * 100. * units('m^2/s^2')
     ug, vg = geostrophic_wind(z, 1 / units.sec, 100. * units.meter, 100. * units.meter)
     true_u = np.array([[-1, 0, 1]] * 3) * units('m/s')
     true_v = -true_u.T
     assert_array_equal(ug, true_u)
     assert_array_equal(vg, true_v)
开发者ID:DBaryudin,项目名称:MetPy,代码行数:8,代码来源:test_kinematics.py



注:本文中的metpy.units.units函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python metrics.size函数代码示例发布时间:2022-05-27
下一篇:
Python testing.assert_array_equal函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap