本文整理汇总了Python中iris.coords.AuxCoord类的典型用法代码示例。如果您正苦于以下问题:Python AuxCoord类的具体用法?Python AuxCoord怎么用?Python AuxCoord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AuxCoord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_lazy_bounds
def test_set_lazy_bounds(self):
# Setting new lazy bounds.
coord = AuxCoord(self.pts_real, bounds=self.bds_real)
new_bounds = self.bds_lazy + 102.3
coord.bounds = new_bounds
result = coord.core_bounds()
self.assertEqualLazyArraysAndDtypes(result, new_bounds)
示例2: test_set_points_with_lazy_bounds
def test_set_points_with_lazy_bounds(self):
# Setting points does not touch lazy bounds.
coord = AuxCoord(self.pts_real, bounds=self.bds_lazy)
new_pts = self.pts_real + 102.3
coord.points = new_pts
result = coord.core_bounds()
self.assertEqualLazyArraysAndDtypes(result, self.bds_lazy)
示例3: test_serialize
def test_serialize(self):
# Collapse a string AuxCoord, causing it to be serialised.
string = Pair(np.array(['two', 'four', 'six', 'eight']),
np.array([['one', 'three'],
['three', 'five'],
['five', 'seven'],
['seven', 'nine']]))
string_nobounds = Pair(np.array(['ecks', 'why', 'zed']),
None)
string_multi = Pair(np.array(['three', 'six', 'nine']),
np.array([['one', 'two', 'four', 'five'],
['four', 'five', 'seven', 'eight'],
['seven', 'eight', 'ten', 'eleven']]))
def _serialize(data):
return '|'.join(str(item) for item in data.flatten())
for units in ['unknown', 'no_unit']:
for points, bounds in [string, string_nobounds, string_multi]:
coord = AuxCoord(points=points, bounds=bounds, units=units)
collapsed_coord = coord.collapsed()
self.assertArrayEqual(collapsed_coord.points,
_serialize(points))
if bounds is not None:
for index in np.ndindex(bounds.shape[1:]):
index_slice = (slice(None),) + tuple(index)
self.assertArrayEqual(
collapsed_coord.bounds[index_slice],
_serialize(bounds[index_slice]))
示例4: test_lazy_points
def test_lazy_points(self):
# Getting lazy points realises them.
coord = AuxCoord(self.pts_lazy)
self.assertTrue(coord.has_lazy_points())
result = coord.points
self.assertFalse(coord.has_lazy_points())
self.assertEqualRealArraysAndDtypes(result, self.pts_real)
示例5: _add_available_aux_coords
def _add_available_aux_coords(self, cube, filenames):
from iris.aux_factory import HybridPressureFactory
from iris.coords import AuxCoord
from iris.exceptions import CoordinateNotFoundError
import iris
if cube.coords('hybrid A coefficient at layer midpoints'):
# First convert the hybrid coefficients to hPa, so that air pressure will be in hPa
cube.coord('hybrid A coefficient at layer midpoints').convert_units('hPa')
try:
surface_pressure = cube.coord('surface pressure')
except iris.exceptions.CoordinateNotFoundError as e:
# If there isn't a surface pressure coordinate we can try and pull out the lowest pressure level
with demote_warnings():
surface_pressure_cubes = iris.load(filenames, 'atmospheric pressure at interfaces',
callback=self.load_multiple_files_callback)
surface_pressure_cube = surface_pressure_cubes.concatenate_cube()[:, -1, :, :]
surface_pressure = AuxCoord(points=surface_pressure_cube.data, long_name='surface pressure', units='Pa')
cube.add_aux_coord(surface_pressure, (0, 2, 3))
surface_pressure.convert_units('hPa')
if len(cube.coords(long_name='hybrid level at layer midpoints')) > 0:
cube.add_aux_factory(HybridPressureFactory(delta=cube.coord('hybrid A coefficient at layer midpoints'),
sigma=cube.coord('hybrid B coefficient at layer midpoints'),
surface_air_pressure=surface_pressure))
示例6: test_2d_contiguous_both_dirs
def test_2d_contiguous_both_dirs(self):
coord = AuxCoord(self.points_3by3, bounds=self.lon_bounds_3by3)
contiguous, diffs = coord._discontiguity_in_bounds()
diffs_along_x, diffs_along_y = diffs
self.assertTrue(contiguous)
self.assertTrue(not diffs_along_x.any())
self.assertTrue(not diffs_along_y.any())
示例7: test_2d_lat_bounds
def test_2d_lat_bounds(self):
coord = AuxCoord(np.array([[1, 1], [3, 3]]),
bounds=np.array([[[0, 0, 2, 2], [0, 0, 2, 2]],
[[2, 2, 4, 4], [2, 2, 4, 4]]]))
expected = np.array([[0, 0, 0], [2, 2, 2], [4, 4, 4]])
result = coord.contiguous_bounds()
self.assertArrayEqual(result, expected)
示例8: test_lazy_bounds
def test_lazy_bounds(self):
# Getting lazy bounds realises them.
coord = AuxCoord(self.pts_real, bounds=self.bds_lazy)
self.assertTrue(coord.has_lazy_bounds())
result = coord.bounds
self.assertFalse(coord.has_lazy_bounds())
self.assertEqualRealArraysAndDtypes(result, self.bds_real)
示例9: test_real_set_lazy
def test_real_set_lazy(self):
# Setting new lazy points does not make a copy.
coord = AuxCoord(self.pts_real)
new_pts = self.pts_lazy + 102.3
coord.points = new_pts
result = coord.core_points()
self.assertEqualLazyArraysAndDtypes(result, new_pts)
示例10: test_real_points_with_real_bounds
def test_real_points_with_real_bounds(self):
# Getting real points does not change real bounds.
coord = AuxCoord(self.pts_real, bounds=self.bds_real)
coord.points
result = coord.core_bounds()
self.assertArraysShareData(
result, self.bds_real,
'Bounds do not share data with the provided array.')
示例11: test_2d_discontiguous_along_y
def test_2d_discontiguous_along_y(self):
coord = AuxCoord(self.points_3by3[::2, :],
bounds=self.lat_bounds_3by3[::2, :, :])
contiguous, diffs = coord._discontiguity_in_bounds()
diffs_along_x, diffs_along_y = diffs
self.assertFalse(contiguous)
self.assertTrue(not diffs_along_x.any())
self.assertArrayEqual(diffs_along_y, np.array([[True, True, True]]))
示例12: test_numeric_nd
def test_numeric_nd(self):
# Contiguous only defined for 2d bounds.
coord = AuxCoord(points=np.array([3, 6, 9]),
bounds=np.array([[1, 2, 4, 5],
[4, 5, 7, 8],
[7, 8, 10, 11]]))
with self.assertRaises(ValueError):
coord.collapsed()
示例13: test_2d_discontiguous_along_x
def test_2d_discontiguous_along_x(self):
coord = AuxCoord(self.points_3by3[:, ::2],
bounds=self.lon_bounds_3by3[:, ::2, :])
contiguous, diffs = coord._discontiguity_in_bounds()
diffs_along_x, diffs_along_y = diffs
self.assertFalse(contiguous)
self.assertArrayEqual(diffs_along_x,
np.array([True, True, True]).reshape(3, 1))
self.assertTrue(not diffs_along_y.any())
示例14: test_set_real_bounds
def test_set_real_bounds(self):
# Setting new real bounds does not make a copy.
coord = AuxCoord(self.pts_real, bounds=self.bds_real)
new_bounds = self.bds_real + 102.3
coord.bounds = new_bounds
result = coord.core_bounds()
self.assertArraysShareData(
result, new_bounds,
'Bounds do not share data with the assigned array.')
示例15: test_real_set_real
def test_real_set_real(self):
# Setting new real points does not make a copy.
coord = AuxCoord(self.pts_real)
new_pts = self.pts_real + 102.3
coord.points = new_pts
result = coord.core_points()
self.assertArraysShareData(
result, new_pts,
'Points do not share data with the assigned array.')