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


Python shorts.ov函数代码示例

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


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

示例1: _make_complex_group

def _make_complex_group():
    g = og(
        'temp',
        aa=[oa('a_root_attr_num', _long(1)),
            oa('c_root_attr_str', 'xyz'),
            oa('b_root_attr_vec', np.array([1.2, 3, 4]))],
        dd=[od('root_dim_x', 2)],
        vv=[ov('root_var_1',
               dd=[od('root_dim_x')],
               aa=[oa('root_var_attr_1', _long(11))],
               data=np.zeros((2))),
            ov('root_var_2_scalar',
               data=np.array(3.15, dtype=np.float32))],
        gg=[og('subgroup',
               aa=[oa('subgroup_attr', 'qq')],
               dd=[od('subgroup_dim_y', 3)],
               vv=[ov('subgroup_var',
                      dd=[od('root_dim_x'), od('subgroup_dim_y')],
                      aa=[oa('subgroup_var_attr', 57.5)],
                      data=np.zeros((2, 3)))],
               gg=[og('sub_sub_group',
                      aa=[oa('sub_sub_group_attr', 'this')],
                      vv=[ov('sub_sub_group_var',
                             dd=[od('subgroup_dim_y')],
                             data=np.zeros((3)))])]),
            og('sg_2_empty')])
    ncg.complete(g)
    return g
开发者ID:pp-mo,项目名称:ncobj,代码行数:28,代码来源:test_cdl.py

示例2: eg_simple_flat

def eg_simple_flat():
    """Produce a flat version of the simple containers example."""
    d_lat = od('lat', 10)
    d_lon = od('lon', 5)
    d_time = od('time', u=True)
    dims = [d_lat, d_lon, d_time]

    collection_vars = [
        ov('instrument', data=np.array(0),
           aa=[oa('container_type', 'simple'),
               oa('members',
                  ('instrument___lat instrument___lon instrument___rh '
                   'instrument___time')),
               oa('measurement_platform', 'aircraft')]),
        ov('model', data=np.array(0),
           aa=[oa('container_type', 'simple'),
               oa('members',
                  'model___lat model___lon model___rh model___time'),
               oa('measurement_platform', 'global circulation model')])]

    data_vars = [
        ov('instrument___lat', dd=[d_lat], aa=[oa('units', 'degrees_north')]),
        ov('instrument___lon', dd=[d_lon], aa=[oa('units', 'degrees_east')]),
        ov('instrument___time', dd=[d_time], aa=[oa('units', 'seconds')]),
        ov('instrument___rh', dd=dims, aa=[oa('_FillValue', -1)]),
        ov('model___lat', dd=[d_lat], aa=[oa('units', 'degrees_north')]),
        ov('model___lon', dd=[d_lon], aa=[oa('units', 'degrees_east')]),
        ov('model___time', dd=[d_time], aa=[oa('units', 'seconds')]),
        ov('model___rh', dd=dims, aa=[oa('_FillValue', -1)])]

    g = og('foo', dd=dims, vv=collection_vars + data_vars)
    _fake_complete(g)
    return g
开发者ID:pp-mo,项目名称:ncobj,代码行数:33,代码来源:simple_semantic_containers.py

示例3: eg_simple_grouped

def eg_simple_grouped():
    """Produce a grouped version of the simple containers example."""
    d_lat = od('lat', 10)
    d_lon = od('lon', 5)
    d_time = od('time', u=True)
    dims = [d_lat, d_lon, d_time]

    c_lat = ov('lat', dd=[d_lat], aa=[oa('units', 'degrees_north')])
    c_lon = ov('lon', dd=[d_lon], aa=[oa('units', 'degrees_east')])
    c_time = ov('time', dd=[d_time], aa=[oa('units', 'seconds')])
    coords = [c_lat, c_lon, c_time]

    g = og('foo',
           dd=dims,
           gg=[og('instrument',
                  vv=(coords +
                      [ov('rh', dd=dims, aa=[oa('_FillValue', -1)])]),
                  aa=[oa('container_type', 'simple'),
                      oa('measurement_platform', 'aircraft')]),
               og('model',
                  vv=(coords +
                      [ov('rh', dd=dims, aa=[oa('_FillValue', -1)])]),
                  aa=[oa('container_type', 'simple'),
                      oa('measurement_platform',
                         'global circulation model')])])
    _fake_complete(g)
    return g
开发者ID:pp-mo,项目名称:ncobj,代码行数:27,代码来源:simple_semantic_containers.py

示例4: test_shared_clash

 def test_shared_clash(self):
     # NOTE: "complete" won't allow this, but this method doesn't care.
     g = og('', vv=[ov('v1', dd=[od('x', 2)]),
                    ov('v2', dd=[od('x', 3)])])
     add_missing_dims(g)
     self.assertEqual(len(g.dimensions), 1)
     self.assertEqual(g.dimensions.names(), ['x'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:7,代码来源:test_grouping.py

示例5: test_grouped_okay

 def test_grouped_okay(self):
     g = og('', dd=[od('x'), od('y')],
            vv=[ov('v1', dd=[od('x')]), ov('v2', dd=[od('x'), od('y')])],
            gg=[og('subgroup', dd=[od('z')],
                   vv=[ov('sv1', dd=[od('x')]),
                       ov('sv2', dd=[od('y'), od('z')])])])
     self.assertTrue(has_no_missing_dims(g))
开发者ID:pp-mo,项目名称:ncobj,代码行数:7,代码来源:test_grouping.py

示例6: test_fail_nomatch

 def test_fail_nomatch(self):
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 2)]),
                ov('v2', dd=[od('x', 3)])])
     with self.assertRaises(DimensionConflictError) as err_context:
         check_dims(g)
     msg = err_context.exception.message
     self.check_all_in_str(msg, ['/v1', '"x" = 2', '/v2', '"x" = 3'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:8,代码来源:test_grouping.py

示例7: test_okay_override_subgroup

 def test_okay_override_subgroup(self):
     # NOTE: here *two* 'x' dimensions, which do not conflict.
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 2)])],
            gg=[og('subgroup',
                   dd=[od('x')],
                   vv=[ov('v2', dd=[od('x', 3)])])])
     check_dims(g)
开发者ID:pp-mo,项目名称:ncobj,代码行数:8,代码来源:test_grouping.py

示例8: test_subgroup_okay

 def test_subgroup_okay(self):
     g = og('root', vv=[ov('test_var')],
            gg=[og('tst1', vv=[ov('test_var')])])
     subgroup = g.groups['tst1']
     self.assertFalse(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
     check_names(g)
     self.assertFalse(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
开发者ID:pp-mo,项目名称:ncobj,代码行数:9,代码来源:test_grouping.py

示例9: test_fail_conflicting_data_shapes

 def test_fail_conflicting_data_shapes(self):
     d1 = _mockdata((2, 23))
     v1 = ov('v1', dd=[od('x'), od('y')], data=d1)
     v2 = ov('v2', dd=[od('x', 17), od('y', 23)])
     g = og('', dd=[od('x'), od('y')], vv=[v1, v2])
     with self.assertRaises(DimensionConflictError) as err_context:
         check_dims(g)
     msg = err_context.exception.message
     self.check_all_in_str(msg, ['/v1', '/v2', '"x" = 17', '"x" = 2'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:9,代码来源:test_grouping.py

示例10: test_multiple

 def test_multiple(self):
     g = og('', vv=[ov('v1', dd=[od('x'), od('y')]),
                    ov('v2', dd=[od('y'), od('z')])])
     self.assertEqual(all_dimensions(g), [])
     r = add_missing_dims(g)
     self.assertEqual(len(r), 3)
     self.assertEqual(len(g.dimensions), 3)
     self.assertIn(od('x'), g.dimensions)
     self.assertIn(od('y'), g.dimensions)
     self.assertIn(od('z'), g.dimensions)
开发者ID:pp-mo,项目名称:ncobj,代码行数:10,代码来源:test_grouping.py

示例11: test_unlimited

 def test_unlimited(self):
     g = og('', vv=[ov('v1', dd=[od('x', 2, u=True)]),
                    ov('v2', dd=[od('x', 2)])])
     self.assertEqual(all_dimensions(g), [])
     self.assertEqual(g.variables['v2'].dimensions[0], od('x', 2))
     self.do_complete(g)
     self.assertNotEqual(g.variables['v2'].dimensions[0], od('x', 2))
     self.assertEqual(list(g.dimensions), [od('x', 2, u=True)])
     test_dim = g.dimensions['x']
     self.assertIs(g.variables['v1'].dimensions[0], test_dim)
     self.assertIs(g.variables['v2'].dimensions[0], test_dim)
开发者ID:pp-mo,项目名称:ncobj,代码行数:11,代码来源:test_grouping.py

示例12: test_with_varsdata_okay

 def test_with_varsdata_okay(self):
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 2)])],
            gg=[og('subgroup', vv=[ov('v2', dd=[od('x', 2)])])])
     subgroup = g.groups['subgroup']
     tag_group(g)
     self.assertTrue(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
     check_dims(g)
     self.assertTrue(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
开发者ID:pp-mo,项目名称:ncobj,代码行数:11,代码来源:test_grouping.py

示例13: test_partial_grouped

 def test_partial_grouped(self):
     # Build a group with one dimension to be found in the subgroup.
     g = og('',
            gg=[og('subgroup',
                   dd=[od('x', 4)],
                   vv=[ov('subvar_1', dd=[od('x')]),
                       ov('subvar_2', dd=[od('z', 3), od('x')])])])
     dim_x_def = g.groups['subgroup'].dimensions['x']
     self.do_complete(g)
     self.assertEqual(list(g.dimensions), [od('z', 3)])
     self.assertEqual(list(g.groups['subgroup'].dimensions), [dim_x_def])
     self.assertIs(g.groups['subgroup'].dimensions['x'], dim_x_def)
开发者ID:pp-mo,项目名称:ncobj,代码行数:12,代码来源:test_grouping.py

示例14: test_grouped_fail

 def test_grouped_fail(self):
     g = og('', dd=[od('x'), od('y')],
            vv=[ov('v1', dd=[od('x')]), ov('v2', dd=[od('x'), od('y')])],
            gg=[og('subgroup', dd=[od('zz')],
                   vv=[ov('sv1', dd=[od('x')]),
                       ov('sv2', dd=[od('y'), od('z')])])])
     with self.assertRaises(IncompleteStructureError) as err_context:
         has_no_missing_dims(g, fail_if_not=True)
     msg = err_context.exception.message
     self.check_all_in_str(msg, [
         'Variable "/subgroup/sv2"', 'dimension "z"',
         'no definition exists'])
开发者ID:pp-mo,项目名称:ncobj,代码行数:12,代码来源:test_grouping.py

示例15: test_with_varsdata_fail

 def test_with_varsdata_fail(self):
     g = og('', dd=[od('x')],
            vv=[ov('v1', dd=[od('x', 2)])],
            gg=[og('subgroup', vv=[ov('v2', dd=[od('x', 3)])])])
     subgroup = g.groups['subgroup']
     tag_group(g)
     self.assertTrue(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
     with self.assertRaises(DimensionConflictError):
         check_dims(g)
     self.assertTrue(group_is_tagged(g))
     self.assertFalse(group_is_tagged(subgroup))
开发者ID:pp-mo,项目名称:ncobj,代码行数:12,代码来源:test_grouping.py


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