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


Python ungridded_data.UngriddedData类代码示例

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


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

示例1: test_horizontal_constraint_in_2d

    def test_horizontal_constraint_in_2d(self):
        from cis.data_io.Coord import Coord, CoordList
        from cis.data_io.ungridded_data import Metadata
        ug_data = mock.make_regular_2d_ungridded_data()
        ug_data_points = ug_data.as_data_frame(time_index=False, name='vals').dropna(axis=1)
        sample_points = UngriddedData(np.array([0.0]), Metadata(),
                                      CoordList([Coord(np.array([7.5]), Metadata(standard_name='latitude')),
                                                 Coord(np.array([-2.5]), Metadata(standard_name='longitude'))]))
        sample_points_view = sample_points.as_data_frame(time_index=False, name='vals').dropna(axis=1)
        # sample_point = HyperPoint(lat=7.5, lon=-2.5)
        # sample_points = HyperPointList([sample_point])
        coord_map = None

        # One degree near 0, 0 is about 110km in latitude and longitude, so 300km should keep us to within 3 degrees
        #  in each direction
        constraint = SepConstraintKdtree(h_sep=400)

        index = HaversineDistanceKDTreeIndex()
        index.index_data(sample_points, ug_data_points, coord_map, leafsize=2)
        constraint.haversine_distance_kd_tree_index = index

        # This should leave us with 4 points
        ref_vals = np.array([10, 11, 13, 14])

        indices = constraint.haversine_distance_kd_tree_index.find_points_within_distance_sample(sample_points_view, 400)

        new_vals = ug_data.data.flat[indices]

        eq_(ref_vals.size, len(new_vals[0]))
        assert (np.equal(ref_vals, new_vals).all())
开发者ID:cedadev,项目名称:cis,代码行数:30,代码来源:test_kdtree_col.py

示例2: test_get_all_points_returns_points

    def test_get_all_points_returns_points(self):
        x_points = np.arange(-10, 11, 5)
        y_points = np.arange(-5, 6, 5)
        y, x = np.meshgrid(y_points, x_points)

        x = Coord(x, Metadata(standard_name='latitude', units='degrees'))
        y = Coord(y, Metadata(standard_name='longitude', units='degrees'))
        data = np.reshape(np.arange(15) + 1.0, (5, 3))

        coords = CoordList([x, y])
        ug = UngriddedData(data, Metadata(standard_name='rain', long_name="TOTAL RAINFALL RATE: LS+CONV KG/M2/S",
                                          units="kg m-2 s-1", missing_value=-999), coords)
        points = ug.get_all_points()
        num_points = len([p for p in points])
        assert(num_points == 15)
开发者ID:cpaulik,项目名称:cis,代码行数:15,代码来源:test_ungridded_data.py

示例3: test_can_create_ungridded_data

    def test_can_create_ungridded_data(self):
        x_points = np.arange(-10, 11, 5)
        y_points = np.arange(-5, 6, 5)
        y, x = np.meshgrid(y_points, x_points)

        x = Coord(x, Metadata(standard_name='latitude', units='degrees'))
        y = Coord(y, Metadata(standard_name='longitude', units='degrees'))
        data = np.reshape(np.arange(15) + 1.0, (5, 3))

        coords = CoordList([x, y])
        ug = UngriddedData(data, Metadata(standard_name='rain', long_name="TOTAL RAINFALL RATE: LS+CONV KG/M2/S",
                                          units="kg m-2 s-1", missing_value=-999), coords)
        standard_coords = ug.coords().find_standard_coords()
        assert(standard_coords == [x, y, None, None, None])
        assert(ug.data.size == 15)
开发者ID:cpaulik,项目名称:cis,代码行数:15,代码来源:test_ungridded_data.py

示例4: test_collocation_of_pres_alt_points_on_hybrid_pressure_coordinates_multi_var

    def test_collocation_of_pres_alt_points_on_hybrid_pressure_coordinates_multi_var(self):
        cube_list = [make_from_cube(mock.make_mock_cube(time_dim_length=3, hybrid_pr_len=10))]
        cube_list.append(make_from_cube(mock.make_mock_cube(time_dim_length=3,
                                                            hybrid_pr_len=10,
                                                            data_offset=100)))

        sample_points = UngriddedData.from_points_array(
            [HyperPoint(lat=0.0, lon=0.0, pres=111100040.5, alt=5000, t=dt.datetime(1984, 8, 28, 0, 0, 0)),
             HyperPoint(lat=0.0, lon=0.0, pres=113625040.5, alt=4000, t=dt.datetime(1984, 8, 28, 12, 0, 0)),
             HyperPoint(lat=5.0, lon=2.5, pres=177125044.5, alt=3000, t=dt.datetime(1984, 8, 28, 0, 0, 0)),
             HyperPoint(lat=-4.0, lon=-4.0, pres=166600039.0, alt=3500, t=dt.datetime(1984, 8, 27))])
        col = GriddedUngriddedCollocator()
        outlist = col.collocate(sample_points, cube_list, None, 'lin')
        # First data set:
        new_data = outlist[0]
        # Exactly on the lat, lon, time points, interpolated over pressure
        assert_almost_equal(new_data.data[0], 221.5, decimal=5)
        # Exactly on the lat, lon, points, interpolated over time and pressure
        assert_almost_equal(new_data.data[1], 226.5, decimal=7)
        # Exactly on the lat, time points, interpolated over longitude and pressure
        assert_almost_equal(new_data.data[2], 330.5, decimal=7)
        # Outside of the pressure bounds - extrapolation off
        assert np.ma.is_masked(new_data.data[3])

        # Second dataset:
        new_data = outlist[1]
        # Exactly on the lat, lon, time points, interpolated over pressure
        assert_almost_equal(new_data.data[0], 321.5, decimal=5)
        # Exactly on the lat, lon, points, interpolated over time and pressure
        assert_almost_equal(new_data.data[1], 326.5, decimal=7)
        # Exactly on the lat, time points, interpolated over longitude and pressure
        assert_almost_equal(new_data.data[2], 430.5, decimal=7)
        # Outside of the pressure bounds - extrapolation off
        assert np.ma.is_masked(new_data.data[3])
开发者ID:cedadev,项目名称:cis,代码行数:34,代码来源:test_gridded_ungridded_col.py

示例5: test_already_collocated_in_col_ungridded_to_ungridded_in_2d

 def test_already_collocated_in_col_ungridded_to_ungridded_in_2d(self):
     ug_data = mock.make_regular_2d_ungridded_data()
     # This point already exists on the cube with value 5 - which shouldn't be a problem
     sample_points = UngriddedData.from_points_array([HyperPoint(0.0, 0.0)])
     col = GeneralUngriddedCollocator(fill_value=-999)
     new_data = col.collocate(sample_points, ug_data, SepConstraintKdtree(), nn_horizontal_only())[0]
     eq_(new_data.data[0], 8.0)
开发者ID:cedadev,项目名称:cis,代码行数:7,代码来源:test_kdtree_col.py

示例6: test_already_collocated_in_col_gridded_to_ungridded_in_2d

 def test_already_collocated_in_col_gridded_to_ungridded_in_2d(self):
     cube = make_from_cube(mock.make_square_5x3_2d_cube())
     # This point already exists on the cube with value 5 - which shouldn't be a problem
     sample_points = UngriddedData.from_points_array([HyperPoint(0.0, 0.0)])
     col = GriddedUngriddedCollocator()
     new_data = col.collocate(sample_points, cube, None, 'nn')[0]
     eq_(new_data.data[0], 8.0)
开发者ID:cedadev,项目名称:cis,代码行数:7,代码来源:test_gridded_ungridded_col.py

示例7: test_list_gridded_ungridded_box_moments

    def test_list_gridded_ungridded_box_moments(self):
        data1 = make_from_cube(mock.make_mock_cube())
        data1.name = lambda: 'Name1'
        data1.var_name = 'var_name1'
        data1._standard_name = 'y_wind'
        data2 = make_from_cube(mock.make_mock_cube(data_offset=3))
        data2.name = lambda: 'Name1'
        data2.var_name = 'var_name2'
        data2._standard_name = 'x_wind'
        data_list = GriddedDataList([data1, data2])
        sample = UngriddedData.from_points_array(
            [HyperPoint(lat=1.0, lon=1.0, alt=12.0, t=dt.datetime(1984, 8, 29, 8, 34)),
             HyperPoint(lat=3.0, lon=3.0, alt=7.0, t=dt.datetime(1984, 8, 29, 8, 34)),
             HyperPoint(lat=-1.0, lon=-1.0, alt=5.0, t=dt.datetime(1984, 8, 29, 8, 34))])
        constraint = SepConstraintKdtree('500km')
        kernel = moments()

        col = GeneralUngriddedCollocator()
        output = col.collocate(sample, data_list, constraint, kernel)

        expected_result = np.array([28.0/3, 10.0, 20.0/3])
        expected_stddev = np.array([1.52752523, 1.82574186, 1.52752523])
        expected_n = np.array([3, 4, 3])
        assert len(output) == 6
        assert isinstance(output, UngriddedDataList)
        assert np.allclose(output[0].data, expected_result)
        assert np.allclose(output[1].data, expected_stddev)
        assert np.allclose(output[2].data, expected_n)
        assert np.allclose(output[3].data, expected_result + 3)
        assert np.allclose(output[4].data, expected_stddev)
        assert np.allclose(output[5].data, expected_n)
开发者ID:gitter-badger,项目名称:cis-1,代码行数:31,代码来源:test_general_ungridded_col.py

示例8: test_can_add_history

    def test_can_add_history(self):
        x_points = np.arange(-10, 11, 5)
        y_points = np.arange(-5, 6, 5)
        y, x = np.meshgrid(y_points, x_points)

        x = Coord(x, Metadata(standard_name='latitude', units='degrees'))
        y = Coord(y, Metadata(standard_name='longitude', units='degrees'))
        data = np.reshape(np.arange(15) + 1.0, (5, 3))

        coords = CoordList([x, y])
        ug = UngriddedData(data, Metadata(standard_name='rain', long_name="TOTAL RAINFALL RATE: LS+CONV KG/M2/S",
                                          units="kg m-2 s-1", missing_value=-999), coords)

        new_history = 'This is a new history entry.'
        ug.add_history(new_history)
        assert(ug.metadata.history.find(new_history) >= 0)
开发者ID:cpaulik,项目名称:cis,代码行数:16,代码来源:test_ungridded_data.py

示例9: test_GIVEN_missing_coord_values_WHEN_coords_data_THEN_missing_values_removed

    def test_GIVEN_missing_coord_values_WHEN_coords_data_THEN_missing_values_removed(self):
        x_points = np.arange(-10, 11, 5)
        y_points = np.arange(-5, 6, 5)
        y, x = np.meshgrid(y_points, x_points)
        y = np.ma.masked_array(y, np.zeros(y.shape, dtype=bool))
        y.mask[1, 2] = True

        x = Coord(x, Metadata(standard_name='latitude', units='degrees'))
        y = Coord(y, Metadata(standard_name='longitude', units='degrees'))
        coords = CoordList([x, y])

        data = np.reshape(np.arange(15) + 1.0, (5, 3))

        ug = UngriddedData(None, Metadata(), coords, lambda x: data)
        coords = ug.coords()
        for coord in coords:
            assert_that(len(coord.data), is_(14))
开发者ID:cedadev,项目名称:cis,代码行数:17,代码来源:test_ungridded_data.py

示例10: test_already_collocated_in_col_ungridded_to_ungridded_in_2d

    def test_already_collocated_in_col_ungridded_to_ungridded_in_2d(self):
        from cis.collocation.col_implementations import GeneralUngriddedCollocator, nn_horizontal, DummyConstraint

        ug_data = mock.make_regular_2d_ungridded_data()
        # This point already exists on the cube with value 5 - which shouldn't be a problem
        sample_points = UngriddedData.from_points_array([HyperPoint(0.0, 0.0)])
        col = GeneralUngriddedCollocator()
        new_data = col.collocate(sample_points, ug_data, DummyConstraint(), nn_horizontal())[0]
        eq_(new_data.data[0], 8.0)
开发者ID:cpaulik,项目名称:cis,代码行数:9,代码来源:test_kernel.py

示例11: test_already_collocated_in_col_gridded_to_ungridded_in_2d

    def test_already_collocated_in_col_gridded_to_ungridded_in_2d(self):
        from cis.collocation.col_implementations import GeneralUngriddedCollocator, nn_gridded

        cube = gridded_data.make_from_cube(mock.make_square_5x3_2d_cube())
        # This point already exists on the cube with value 5 - which shouldn't be a problem
        sample_points = UngriddedData.from_points_array([HyperPoint(0.0, 0.0)])
        col = GeneralUngriddedCollocator()
        new_data = col.collocate(sample_points, cube, None, nn_gridded())[0]
        eq_(new_data.data[0], 8.0)
开发者ID:cpaulik,项目名称:cis,代码行数:9,代码来源:test_kernel.py

示例12: test_alt_extrapolation

    def test_alt_extrapolation(self):
        cube = make_from_cube(mock.make_mock_cube(time_dim_length=3, hybrid_ht_len=10))

        sample_points = UngriddedData.from_points_array(
            [HyperPoint(lat=-4.0, lon=-4.0, alt=6382.8, t=dt.datetime(1984, 8, 27))])

        col = GriddedUngriddedCollocator(fill_value=np.NAN, extrapolate=True)
        new_data = col.collocate(sample_points, cube, None, 'lin')[0]
        assert_almost_equal(new_data.data[0], 126.0, decimal=7)
开发者ID:cedadev,项目名称:cis,代码行数:9,代码来源:test_gridded_ungridded_col.py

示例13: test_extrapolation_of_pres_points_on_hybrid_pressure_coordinates

    def test_extrapolation_of_pres_points_on_hybrid_pressure_coordinates(self):
        cube = make_from_cube(mock.make_mock_cube(time_dim_length=3, hybrid_pr_len=10))

        sample_points = UngriddedData.from_points_array(
            # Point interpolated in the horizontal and then extrapolated past the top vertical layer (by one layer)
            [HyperPoint(lat=-4.0, lon=-4.0, pres=68400050.0, t=dt.datetime(1984, 8, 27))])
        col = GriddedUngriddedCollocator(extrapolate=True)
        new_data = col.collocate(sample_points, cube, None, 'lin')[0]
        assert_almost_equal(new_data.data[0], 125.0, decimal=7)
开发者ID:cedadev,项目名称:cis,代码行数:9,代码来源:test_gridded_ungridded_col.py

示例14: test_basic_col_gridded_to_ungridded_using_li_in_2d

 def test_basic_col_gridded_to_ungridded_using_li_in_2d(self):
     cube = make_from_cube(mock.make_square_5x3_2d_cube())
     sample_points = UngriddedData.from_points_array(
         [HyperPoint(1.0, 1.0), HyperPoint(4.0, 4.0), HyperPoint(-4.0, -4.0)])
     col = GriddedUngriddedCollocator()
     new_data = col.collocate(sample_points, cube, None, 'lin')[0]
     assert_almost_equal(new_data.data[0], 8.8)
     assert_almost_equal(new_data.data[1], 11.2)
     assert_almost_equal(new_data.data[2], 4.8)
开发者ID:cedadev,项目名称:cis,代码行数:9,代码来源:test_gridded_ungridded_col.py

示例15: test_coordinates_outside_grid_in_col_gridded_to_ungridded_in_2d

 def test_coordinates_outside_grid_in_col_gridded_to_ungridded_in_2d(self):
     cube = make_from_cube(mock.make_square_5x3_2d_cube())
     sample_points = UngriddedData.from_points_array(
         [HyperPoint(5.5, 5.5), HyperPoint(-5.5, 5.5), HyperPoint(5.5, -5.5), HyperPoint(-5.5, -5.5)])
     col = GriddedUngriddedCollocator(extrapolate=True)
     new_data = col.collocate(sample_points, cube, None, 'nn')[0]
     eq_(new_data.data[0], 12.0)
     eq_(new_data.data[1], 6.0)
     eq_(new_data.data[2], 10.0)
     eq_(new_data.data[3], 4.0)
开发者ID:cedadev,项目名称:cis,代码行数:10,代码来源:test_gridded_ungridded_col.py


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