本文整理汇总了Python中cis.data_io.ungridded_data.UngriddedData.from_points_array方法的典型用法代码示例。如果您正苦于以下问题:Python UngriddedData.from_points_array方法的具体用法?Python UngriddedData.from_points_array怎么用?Python UngriddedData.from_points_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cis.data_io.ungridded_data.UngriddedData
的用法示例。
在下文中一共展示了UngriddedData.from_points_array方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_list_gridded_ungridded_box_moments
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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)
示例2: test_already_collocated_in_col_gridded_to_ungridded_in_2d
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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)
示例3: test_collocation_of_pres_alt_points_on_hybrid_pressure_coordinates_multi_var
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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])
示例4: test_already_collocated_in_col_ungridded_to_ungridded_in_2d
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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)
示例5: test_already_collocated_in_col_ungridded_to_ungridded_in_2d
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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)
示例6: test_basic_col_gridded_to_ungridded_using_li_in_2d
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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)
示例7: test_already_collocated_in_col_gridded_to_ungridded_in_2d
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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)
示例8: test_extrapolation_of_pres_points_on_hybrid_pressure_coordinates
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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)
示例9: test_alt_extrapolation
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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)
示例10: test_already_collocated_in_col_ungridded_to_ungridded_in_2d
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
def test_already_collocated_in_col_ungridded_to_ungridded_in_2d(self):
from cis.collocation.col_implementations import GeneralUngriddedCollocator, nn_pressure, SepConstraintKdtree
import datetime as dt
ug_data = mock.make_regular_4d_ungridded_data()
sample_points = UngriddedData.from_points_array(
[HyperPoint(lat=0.0, lon=0.0, pres=80.0, t=dt.datetime(1984, 9, 4, 15, 54))])
col = GeneralUngriddedCollocator()
new_data = col.collocate(sample_points, ug_data, SepConstraintKdtree(), nn_pressure())[0]
eq_(new_data.data[0], 41.0)
示例11: test_coordinates_outside_grid_in_col_gridded_to_ungridded_in_2d
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
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)
示例12: test_basic_col_with_incompatible_points_throws_a_TypeError
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
def test_basic_col_with_incompatible_points_throws_a_TypeError(self):
from cis.collocation.col_implementations import GeneralUngriddedCollocator, nn_pressure, SepConstraintKdtree
ug_data = mock.make_regular_4d_ungridded_data()
# Make sample points with no time dimension specified
sample_points = UngriddedData.from_points_array(
[HyperPoint(1.0, 1.0), HyperPoint(4.0, 4.0), HyperPoint(-4.0, -4.0)])
col = GeneralUngriddedCollocator()
with self.assertRaises(AttributeError):
new_data = col.collocate(sample_points, ug_data, SepConstraintKdtree(), nn_pressure())[0]
示例13: test_collocation_of_pres_points_on_hybrid_altitude_coordinates
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
def test_collocation_of_pres_points_on_hybrid_altitude_coordinates(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, pres=100.0, t=dt.datetime(1984, 8, 27))])
col = GriddedUngriddedCollocator(fill_value=np.NAN)
# Since there is no corresponding pressure field in the source data a ValueError should be raised
assert_raises(ValueError, col.collocate, sample_points, cube, None, 'lin')
示例14: test_basic_col_in_2d
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
def test_basic_col_in_2d(self):
# lat: -10 to 10 step 5; lon -5 to 5 step 5
ug_data = mock.make_regular_2d_ungridded_data()
sample_points = UngriddedData.from_points_array(
[HyperPoint(lat=1.0, lon=1.0), HyperPoint(lat=4.0, lon=4.0), HyperPoint(lat=-4.0, lon=-4.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)
eq_(new_data.data[1], 12.0)
eq_(new_data.data[2], 4.0)
示例15: test_coordinates_outside_grid_in_col_ungridded_to_ungridded_in_2d
# 需要导入模块: from cis.data_io.ungridded_data import UngriddedData [as 别名]
# 或者: from cis.data_io.ungridded_data.UngriddedData import from_points_array [as 别名]
def test_coordinates_outside_grid_in_col_ungridded_to_ungridded_in_2d(self):
ug_data = mock.make_regular_2d_ungridded_data()
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 = GeneralUngriddedCollocator(fill_value=-999)
new_data = col.collocate(sample_points, ug_data, SepConstraintKdtree(), nn_horizontal_only())[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)