当前位置: 首页>>代码示例>>Python>>正文


Python units.units函数代码示例

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


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


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