本文整理汇总了Python中cis.collocation.col_implementations.GeneralUngriddedCollocator.collocate方法的典型用法代码示例。如果您正苦于以下问题:Python GeneralUngriddedCollocator.collocate方法的具体用法?Python GeneralUngriddedCollocator.collocate怎么用?Python GeneralUngriddedCollocator.collocate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cis.collocation.col_implementations.GeneralUngriddedCollocator
的用法示例。
在下文中一共展示了GeneralUngriddedCollocator.collocate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_already_collocated_in_col_ungridded_to_ungridded_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [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)
示例2: test_list_gridded_ungridded_box_moments
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [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)
示例3: test_list_ungridded_ungridded_box_mean
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [as 别名]
def test_list_ungridded_ungridded_box_mean(self):
ug_data_1 = mock.make_regular_2d_ungridded_data()
ug_data_2 = mock.make_regular_2d_ungridded_data(data_offset=3)
ug_data_2.long_name = 'TOTAL SNOWFALL RATE: LS+CONV KG/M2/S'
ug_data_2.standard_name = 'snowfall_rate'
ug_data_2.metadata._name = 'snow'
data_list = UngriddedDataList([ug_data_1, ug_data_2])
sample_points = mock.make_regular_2d_ungridded_data()
constraint = SepConstraintKdtree('500km')
kernel = moments()
col = GeneralUngriddedCollocator()
output = col.collocate(sample_points, data_list, constraint, kernel)
expected_result = np.array(list(range(1, 16)))
expected_stddev = np.array(15 * [float('inf')])
expected_n = np.array(15 * [1])
assert len(output) == 6
assert isinstance(output, UngriddedDataList)
assert output[3].var_name == 'snow'
assert output[4].var_name == 'snow_std_dev'
assert output[5].var_name == 'snow_num_points'
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)
示例4: test_already_collocated_in_col_ungridded_to_ungridded_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [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)
示例5: test_already_collocated_in_col_gridded_to_ungridded_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [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)
示例6: test_basic_col_with_incompatible_points_throws_a_TypeError
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [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]
示例7: test_already_collocated_in_col_ungridded_to_ungridded_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [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)
示例8: test_basic_col_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [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)
示例9: test_basic_col_gridded_to_ungridded_using_li_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [as 别名]
def test_basic_col_gridded_to_ungridded_using_li_in_2d(self):
from cis.collocation.col_implementations import GeneralUngriddedCollocator, li
cube = gridded_data.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 = GeneralUngriddedCollocator()
new_data = col.collocate(sample_points, cube, None, li())[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)
示例10: test_basic_col_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [as 别名]
def test_basic_col_in_2d(self):
from cis.collocation.col_implementations import GeneralUngriddedCollocator, nn_horizontal, SepConstraintKdtree
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()
new_data = col.collocate(sample_points, ug_data, SepConstraintKdtree(), nn_horizontal())[0]
eq_(new_data.data[0], 8.0)
eq_(new_data.data[1], 12.0)
eq_(new_data.data[2], 4.0)
示例11: test_coordinates_outside_grid_in_col_ungridded_to_ungridded_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [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)
示例12: test_alt_extrapolation
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [as 别名]
def test_alt_extrapolation(self):
from cis.collocation.col_implementations import GeneralUngriddedCollocator, li
import datetime as dt
cube = gridded_data.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 = GeneralUngriddedCollocator(fill_value=np.NAN)
new_data = col.collocate(sample_points, cube, None, li(extrapolate=True))[0]
assert_almost_equal(new_data.data[0], 126.0, decimal=7)
示例13: test_coordinates_outside_grid_in_col_ungridded_to_ungridded_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [as 别名]
def test_coordinates_outside_grid_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()
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()
new_data = col.collocate(sample_points, ug_data, DummyConstraint(), nn_horizontal())[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)
示例14: test_coordinates_outside_grid_in_col_gridded_to_ungridded_in_2d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [as 别名]
def test_coordinates_outside_grid_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())
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()
new_data = col.collocate(sample_points, cube, None, nn_gridded())[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)
示例15: test_basic_col_in_4d
# 需要导入模块: from cis.collocation.col_implementations import GeneralUngriddedCollocator [as 别名]
# 或者: from cis.collocation.col_implementations.GeneralUngriddedCollocator import collocate [as 别名]
def test_basic_col_in_4d(self):
from cis.collocation.col_implementations import GeneralUngriddedCollocator, mean, SepConstraintKdtree
import datetime as dt
ug_data = mock.make_regular_4d_ungridded_data()
# Note - This isn't actually used for averaging
sample_points = UngriddedData.from_points_array(
[HyperPoint(lat=1.0, lon=1.0, alt=12.0, t=dt.datetime(1984, 8, 29, 8, 34))])
col = GeneralUngriddedCollocator()
new_data = col.collocate(sample_points, ug_data, SepConstraintKdtree(), mean())[0]
eq_(new_data.data[0], 25.5)