diff --git a/docs/releases/development.rst b/docs/releases/development.rst index 61cb61b..97e8aff 100644 --- a/docs/releases/development.rst +++ b/docs/releases/development.rst @@ -33,3 +33,4 @@ Next release (in development) * Add :func:`emsarray.utils.name_to_data_array()` and :func:`~emsarray.utils.data_array_to_name()` functions. Allow more functions to interchangeably take either a data array or the name of a data array (:pr:`142`). +* Add :attr:`.Convention.depth_coordinates` and :meth:`.Convention.get_depth_coordinate_for_data_array()`. Deprecate functions :meth:`.Convention.get_depth_name()`, :meth:`.Convention.get_all_depth_names()`, and :meth:`Convention.get_time_name()`. Remove deprecated functions ``Convention.get_depths()`` and ``Convention.get_times()`` (:pr:`143`). diff --git a/src/emsarray/cli/commands/extract_points.py b/src/emsarray/cli/commands/extract_points.py index 2250bbb..58fbc78 100644 --- a/src/emsarray/cli/commands/extract_points.py +++ b/src/emsarray/cli/commands/extract_points.py @@ -6,6 +6,7 @@ import emsarray from emsarray.cli import BaseCommand, CommandException +from emsarray.exceptions import NoSuchCoordinateError from emsarray.operations import point_extraction from emsarray.utils import to_netcdf_with_fixes @@ -79,8 +80,8 @@ def handle(self, options: argparse.Namespace) -> None: f"{rows.head()}\n" f"(total rows: {len(rows)})") try: - time_name = dataset.ems.get_time_name() - except KeyError: + time_name = dataset.ems.time_coordinate.name + except NoSuchCoordinateError: time_name = None to_netcdf_with_fixes( diff --git a/src/emsarray/conventions/_base.py b/src/emsarray/conventions/_base.py index 9ac82c5..a0ba6f8 100644 --- a/src/emsarray/conventions/_base.py +++ b/src/emsarray/conventions/_base.py @@ -276,51 +276,8 @@ def _get_data_array(self, data_array: DataArrayOrName) -> xarray.DataArray: @cached_property def time_coordinate(self) -> xarray.DataArray: - """The time coordinate for this dataset. - - Returns - ------- - xarray.DataArray - The variable for the time coordinate for this dataset. - - Raises - ------ - exceptions.NoSuchCoordinateError - If no time coordinate was found - - See Also - -------- - get_time_name - """ - return self.dataset[self.get_time_name()] - - @cached_property - def depth_coordinate(self) -> xarray.DataArray: - """The depth coordinate for this dataset. - - Returns - ------- - xarray.DataArray - The variable for the depth coordinate for this dataset. - - Raises - ------ - exceptions.NoSuchCoordinateError - If no depth coordinate was found - - See Also - -------- - get_depth_name """ - return self.dataset[self.get_depth_name()] - - def get_time_name(self) -> Hashable: - """Get the name of the time variable in this dataset. - - Returns - ------- - Hashable - The name of the time coordinate. + xarray.DataArray: The time coordinate for this dataset. Raises ------ @@ -339,7 +296,8 @@ def get_time_name(self) -> Hashable: ---------- .. [1] `CF Conventions v1.10, 4.4 Time Coordinate `_ """ - for name, variable in self.dataset.variables.items(): + for name in self.dataset.variables.keys(): + variable = self.dataset[name] # xarray will automatically decode all time variables # and move the 'units' attribute over to encoding to store this change. if 'units' in variable.encoding: @@ -348,27 +306,20 @@ def get_time_name(self) -> Hashable: if 'since' in units: # The variable must now be a numpy datetime if variable.dtype.type == numpy.datetime64: - return name + return variable raise NoSuchCoordinateError("Could not find time coordinate in dataset") - def get_depth_name(self) -> Hashable: - """Get the name of the layer depth coordinate variable. - - For datasets with multiple depth variables, this should be the one that - represents the centre of the layer, not the bounds. - - Note that this is the name of the coordinate variable, - not the name of the dimension, for datasets where these differ. - - Returns - ------- - Hashable - The name of the depth coordinate. + @cached_property + def depth_coordinate(self) -> xarray.DataArray: + """ + xarray.DataArray: The depth coordinate for this dataset. + For datasets with multiple depth coordinates + this will be the depth coordinate with the smallest :attr:`~xarray.DataArray.size`. Raises ------ exceptions.NoSuchCoordinateError - If no time coordinate was found + If no depth coordinate was found Notes ----- @@ -382,24 +333,31 @@ def get_depth_name(self) -> Hashable: all coordinates are checked for a ``standard_name: "depth"``, ``coordinate_type: "Z"``, or ``axiz: "Z"``. + See Also + -------- + :attr:`depth_coordinates` + :attr:`get_depth_coordinate_for_data_array` + References ---------- .. [2] `CF Conventions v1.10, 4.3 Vertical (Height or Depth) Coordinate `_ """ - try: - return self.get_all_depth_names()[0] - except IndexError: - raise NoSuchCoordinateError("Could not find depth coordinate in dataset") + depth_coordinates = self.depth_coordinates + if len(depth_coordinates) == 0: + raise NoSuchCoordinateError("Dataset has no depth coordinate") + return min(depth_coordinates, key=lambda c: c.size) - def get_all_depth_names(self) -> list[Hashable]: - """Get the names of all depth layers. - Some datasets include both a depth layer centre, - and the depth layer 'edges'. + @cached_property + def depth_coordinates(self) -> tuple[xarray.DataArray, ...]: + """ + tuple of xarray.DataArray: All the depth coordinate for this dataset. - Note that this is the names of the coordinate variables, - not the names of the dimensions, for datasets where these differ. + See Also + -------- + :attr:`depth_coordinate` + :attr:`get_depth_coordinate_for_data_array` """ - depth_names = [] + depth_coordinates = [] for name in self.dataset.variables.keys(): data_array = self.dataset[name] @@ -422,53 +380,154 @@ def get_all_depth_names(self) -> list[Hashable]: # The variable isn't on a grid - this is good! pass - depth_names.append(name) + depth_coordinates.append(data_array) - return depth_names + return tuple(depth_coordinates) @utils.deprecated( ( - "Convention.get_depths() is deprecated. " - "Use Convention.depth_coordinate.values instead." + "Convention.get_time_name() is deprecated. " + "Use Convention.time_coordinate.name instead." ), DeprecationWarning, ) - def get_depths(self) -> numpy.ndarray: - """Get the depth of each vertical layer in this dataset. + def get_time_name(self) -> Hashable: + """Get the name of the time variable in this dataset. - .. deprecated:: 0.5.0 - This method is replaced by - :attr:`Convention.depth_coordinate.values `. + .. deprecated:: 0.7.0 + :meth:`Convention.get_time_name()` is deprecated and will be removed. + Use `Convention.time_coordinate.name` instead. Returns ------- - :class:`numpy.ndarray` - An array of depths, one per vertical layer in the dataset. + Hashable + The name of the time coordinate. + + See Also + -------- + :attr:`Convention.time_coordinate` + + Raises + ------ + exceptions.NoSuchCoordinateError + If no time coordinate was found """ - return cast(numpy.ndarray, self.depth_coordinate.values) + return self.time_coordinate.name @utils.deprecated( ( - "Convention.get_times() is deprecated. " - "Use Convention.time_coordinate.values instead." + "Convention.get_depth_name() is deprecated. " + "Use Convention.depth_coordinate.name instead." ), DeprecationWarning, ) - def get_times(self) -> numpy.ndarray: - """Get all timesteps in this dataset. + def get_depth_name(self) -> Hashable: + """Get the name of the layer depth coordinate variable. - .. deprecated:: 0.5.0 - This method is replaced by - :attr:`Convention.time_coordinate.values `. + .. deprecated:: 0.7.0 + :meth:`Convention.get_depth_name()` is deprecated and will be removed. + Use `Convention.depth_coordinate.name` instead. + + For datasets with multiple depth variables, this should be the one that + represents the centre of the layer, not the bounds. + + Note that this is the name of the coordinate variable, + not the name of the dimension, for datasets where these differ. Returns ------- - :class:`numpy.ndarray` - An array of datetimes. - The datetimes will be whatever native format the dataset uses, - likely :class:`numpy.datetime64`. + Hashable + The name of the depth coordinate. + + Raises + ------ + exceptions.NoSuchCoordinateError + If no time coordinate was found + + See Also + -------- + :attr:`Convention.depth_coordinate` + :meth:`Convention.get_depth_coordinate_for_data_array` """ - return cast(numpy.ndarray, self.time_coordinate.values) + return self.depth_coordinate.name + + @utils.deprecated( + ( + "Convention.get_all_depth_names() is deprecated. " + "Use [c.name for c in Convention.depth_coordinates] instead." + ), + DeprecationWarning, + ) + def get_all_depth_names(self) -> list[Hashable]: + """Get the names of all depth layers. + Some datasets include both a depth layer centre, + and the depth layer 'edges'. + + .. deprecated:: 0.7.0 + :meth:`Convention.get_all_depth_names()` is deprecated and will be removed. + Use `[c.name for c in Convention.depth_coordinates]` instead. + + Note that this is the names of the coordinate variables, + not the names of the dimensions, for datasets where these differ. + + See also + -------- + :attr:`depth_coordinate` + :attr:`depth_coordinates` + :meth:`get_depth_coordinate_for_data_array` + """ + return [c.name for c in self.depth_coordinates] + + def get_depth_coordinate_for_data_array( + self, + data_array: DataArrayOrName, + ) -> xarray.DataArray: + """ + Find the depth coordinate for a particular data array. + Some conventions will contain multiple depth coordinates, + meaning that a default :attr:`depth_coordinate` value can be misleading. + + Parameters + ---------- + data_array : xarray.DataArray or Hashable + A data array or the name of a data array in the dataset. + + Returns + ------- + xarray.DataArray + The depth coordinate variable for the data array. + + Raises + ------ + NoSuchCoordinateError + If data array does not have an associated depth coordinate + ValueError + If multiple depth coordinates matched the data array. + + See also + -------- + :attr:`depth_coordinate` + The default or main depth coordinate for this dataset, + but not necessarily the correct depth coordinate for all variables. + :attr:`depth_coordinates` + All the depth coordinates in this dataset. + """ + data_array = utils.name_to_data_array(self.dataset, data_array) + name = repr(data_array.name) if data_array.name is not None else 'data array' + + candidates = [ + coordinate + for coordinate in self.depth_coordinates + if coordinate.dims[0] in data_array.dims + ] + if len(candidates) == 0: + raise NoSuchCoordinateError(f"No depth coordinate found for {name}") + if len(candidates) > 1: + raise ValueError( + f"Multiple possible depth coordinates found for {name}: " + ", ".join(repr(c.name) for c in candidates) + ) + return candidates[0] @abc.abstractmethod def ravel_index(self, index: Index) -> int: @@ -980,7 +1039,7 @@ def animate_on_figure( Pass in either the name of a coordinate variable or coordinate variable itself. Optional, if not supplied the time coordinate - from :meth:`get_time_name` is used. + from :attr:`Convention.time_coordinate` is used. Other appropriate coordinates to animate over include depth. **kwargs Any extra arguments are passed to :func:`.plot.animate_on_figure`. @@ -1556,17 +1615,17 @@ def select_variables(self, variables: Iterable[DataArrayOrName]) -> xarray.Datas drop_geometry """ all_vars = set(self.dataset.variables.keys()) - keep_vars = { + keep_vars = [ *variables, *self.get_all_geometry_names(), - *self.get_all_depth_names(), - } + *self.depth_coordinates, + ] try: - keep_vars.add(self.get_time_name()) + keep_vars.append(self.time_coordinate) except NoSuchCoordinateError: pass - keep_vars = {utils.data_array_to_name(self.dataset, v) for v in keep_vars} - return self.dataset.drop_vars(all_vars - keep_vars) + keep_var_names = {utils.data_array_to_name(self.dataset, v) for v in keep_vars} + return self.dataset.drop_vars(all_vars - keep_var_names) @abc.abstractmethod def make_clip_mask( @@ -1685,7 +1744,7 @@ def to_netcdf(self, path: Pathish, **kwargs: Any) -> None: make the EMS compatible. """ try: - time_variable = self.get_time_name() + time_variable = self.time_coordinate except KeyError: time_variable = None utils.to_netcdf_with_fixes( @@ -1696,7 +1755,7 @@ def to_netcdf(self, path: Pathish, **kwargs: Any) -> None: def ocean_floor(self) -> xarray.Dataset: """An alias for :func:`emsarray.operations.depth.ocean_floor`""" return depth.ocean_floor( - self.dataset, self.get_all_depth_names(), + self.dataset, self.depth_coordinates, non_spatial_variables=[self.time_coordinate]) def normalize_depth_variables( @@ -1707,7 +1766,7 @@ def normalize_depth_variables( ) -> xarray.Dataset: """An alias for :func:`emsarray.operations.depth.normalize_depth_variables`""" return depth.normalize_depth_variables( - self.dataset, self.get_all_depth_names(), + self.dataset, self.depth_coordinates, positive_down=positive_down, deep_to_shallow=deep_to_shallow) diff --git a/src/emsarray/conventions/shoc.py b/src/emsarray/conventions/shoc.py index 5cf574e..1483499 100644 --- a/src/emsarray/conventions/shoc.py +++ b/src/emsarray/conventions/shoc.py @@ -48,24 +48,30 @@ class ShocStandard(ArakawaC): ArakawaCGridKind.node: ('y_grid', 'x_grid'), } - def get_depth_name(self) -> Hashable: + @cached_property + def depth_coordinate(self) -> xarray.DataArray: name = 'z_centre' - if name not in self.dataset.variables: + try: + return self.dataset[name] + except KeyError: raise NoSuchCoordinateError( f"SHOC dataset did not have expected depth coordinate {name!r}") - return name - def get_all_depth_names(self) -> list[Hashable]: - return [ - name for name in ['z_centre', 'z_grid'] - if name in self.dataset.variables] + @cached_property + def depth_coordinates(self) -> tuple[xarray.DataArray, ...]: + names = ['z_centre', 'z_grid'] + return tuple( + self.dataset[name] for name in names + if name in self.dataset.variables) - def get_time_name(self) -> Hashable: + @cached_property + def time_coordinate(self) -> xarray.DataArray: name = 't' - if name not in self.dataset.variables: + try: + return self.dataset[name] + except KeyError: raise NoSuchCoordinateError( f"SHOC dataset did not have expected time coordinate {name!r}") - return name def drop_geometry(self) -> xarray.Dataset: dataset = super().drop_geometry() @@ -109,23 +115,27 @@ def check_dataset(cls, dataset: xarray.Dataset) -> Optional[int]: return None return Specificity.HIGH - def get_time_name(self) -> Hashable: - name = 'time' - if name not in self.dataset.variables: - raise NoSuchCoordinateError( - f"SHOC dataset did not have expected time coordinate {name!r}") - return name - - def get_depth_name(self) -> Hashable: + @cached_property + def depth_coordinate(self) -> xarray.DataArray: name = 'zc' - if name not in self.dataset.variables: + try: + return self.dataset[name] + except KeyError: raise NoSuchCoordinateError( f"SHOC dataset did not have expected depth coordinate {name!r}") - return name - def get_all_depth_names(self) -> list[Hashable]: - name = 'zc' - if name in self.dataset.variables: - return [name] - else: - return [] + @cached_property + def depth_coordinates(self) -> tuple[xarray.DataArray, ...]: + names = ['zc'] + return tuple( + self.dataset[name] for name in names + if name in self.dataset.variables) + + @cached_property + def time_coordinate(self) -> xarray.DataArray: + name = 'time' + try: + return self.dataset[name] + except KeyError: + raise NoSuchCoordinateError( + f"SHOC dataset did not have expected time coordinate {name!r}") diff --git a/src/emsarray/operations/depth.py b/src/emsarray/operations/depth.py index 5d8bf5e..3ab9765 100644 --- a/src/emsarray/operations/depth.py +++ b/src/emsarray/operations/depth.py @@ -25,16 +25,15 @@ def ocean_floor( Parameters ---------- - dataset + dataset : xarray.Dataset The dataset to reduce. depth_coordinates : iterable of DataArrayOrName The depth coordinate variables. - For supported conventions, use :meth:`.Convention.get_all_depth_names()`. + For supported conventions, use :meth:`.Convention.depth_coordinates()`. non_spatial_variables : iterable of DataArrayOrName - Optional. A list of any non-spatial coordinate variables, such as time. The ocean floor is assumed to be static across non-spatial dimensions. - For supported conventions, use :meth:`.Convention.get_time_name()`. + For supported conventions, use :meth:`.Convention.time_coordinate`. Returns ------- @@ -75,7 +74,7 @@ def ocean_floor( >>> operations.ocean_floor( ... big_dataset['temp'].isel(record=0).to_dataset(), - ... depth_coordinates=big_dataset.ems.get_all_depth_names()) + ... depth_coordinates=big_dataset.ems.depth_coordinates)) Dimensions: (y: 5, x: 5) Coordinates: @@ -88,7 +87,7 @@ def ocean_floor( See Also -------- :meth:`.Convention.ocean_floor` - :meth:`.Convention.get_all_depth_names` + :meth:`.Convention.depth_coordinates` :func:`.normalize_depth_variables` :func:`.utils.extract_vars` """ @@ -199,7 +198,7 @@ def _find_ocean_floor_indices( def normalize_depth_variables( dataset: xarray.Dataset, - depth_variables: Iterable[DataArrayOrName], + depth_coordinates: Iterable[DataArrayOrName], *, positive_down: Optional[bool] = None, deep_to_shallow: Optional[bool] = None, @@ -219,7 +218,7 @@ def normalize_depth_variables( ---------- dataset : xarray.Dataset The dataset to normalize - depth_variables : iterable of DataArrayOrName + depth_coordinates : iterable of DataArrayOrName The depth coordinate variables. positive_down : bool, optional If True, positive values will indicate depth below the surface. @@ -238,10 +237,10 @@ def normalize_depth_variables( See Also -------- :meth:`.Convention.normalize_depth_variables` - :meth:`.Convention.get_all_depth_names` + :meth:`.Convention.depth_coordinates` """ new_dataset = dataset.copy() - for variable in depth_variables: + for variable in depth_coordinates: variable = utils.name_to_data_array(dataset, variable) name = variable.name if len(variable.dims) != 1: diff --git a/src/emsarray/transect.py b/src/emsarray/transect.py index c569953..e3d92fe 100644 --- a/src/emsarray/transect.py +++ b/src/emsarray/transect.py @@ -57,7 +57,8 @@ def plot( Passed to :meth:`Transect.plot_on_figure()`. """ figure = pyplot.figure(layout="constrained", figsize=figsize) - transect = Transect(dataset, line) + depth_coordinate = dataset.ems.get_depth_coordinate_for_data_array(data_array) + transect = Transect(dataset, line, depth=depth_coordinate) transect.plot_on_figure(figure, data_array, **kwargs) pyplot.show() return figure diff --git a/tests/conventions/test_base.py b/tests/conventions/test_base.py index bb6916c..43b908e 100644 --- a/tests/conventions/test_base.py +++ b/tests/conventions/test_base.py @@ -136,18 +136,19 @@ def apply_clip_mask(self, clip_mask: xarray.Dataset, work_dir: Pathish) -> xarra return masking.mask_grid_dataset(self.dataset, clip_mask, work_dir) -def test_get_time_name(datasets: pathlib.Path) -> None: +def test_time_coordinate(datasets: pathlib.Path) -> None: dataset = xarray.open_dataset(datasets / 'times.nc') SimpleConvention(dataset).bind() - assert dataset.ems.get_time_name() == 'time' - xarray.testing.assert_equal(dataset.ems.time_coordinate, dataset['time']) + time_coordinate = dataset.ems.time_coordinate + assert time_coordinate.name == 'time' + xarray.testing.assert_equal(time_coordinate, dataset['time']) -def test_get_time_name_missing() -> None: +def test_time_coordinate_missing() -> None: dataset = xarray.Dataset() SimpleConvention(dataset).bind() with pytest.raises(NoSuchCoordinateError): - dataset.ems.get_time_name() + dataset.ems.time_coordinate @pytest.mark.parametrize('attrs', [ @@ -156,20 +157,20 @@ def test_get_time_name_missing() -> None: {'standard_name': 'depth'}, {'axis': 'Z'}, ], ids=lambda a: '{}:{}'.format(*next(iter(a.items())))) -def test_get_depth_name(attrs: dict) -> None: +def test_depth_coordinate(attrs: dict) -> None: dataset = xarray.Dataset({ 'name': (['dim'], [0, 1, 2], attrs), }) SimpleConvention(dataset).bind() - assert dataset.ems.get_depth_name() == 'name' + assert dataset.ems.depth_coordinate.name == 'name' xarray.testing.assert_equal(dataset.ems.depth_coordinate, dataset['name']) -def test_get_depth_name_missing() -> None: +def test_depth_coordinate_missing() -> None: dataset = xarray.Dataset() SimpleConvention(dataset).bind() with pytest.raises(NoSuchCoordinateError): - dataset.ems.get_depth_name() + dataset.ems.depth_coordinate @pytest.mark.parametrize('include_time', [True, False]) diff --git a/tests/conventions/test_cfgrid1d.py b/tests/conventions/test_cfgrid1d.py index 24cc979..fd53083 100644 --- a/tests/conventions/test_cfgrid1d.py +++ b/tests/conventions/test_cfgrid1d.py @@ -238,8 +238,8 @@ def test_manual_coordinate_names(): def test_varnames(): dataset = make_dataset(width=11, height=7, depth=5) - assert dataset.ems.get_depth_name() == 'depth' - assert dataset.ems.get_time_name() == 'time' + assert dataset.ems.depth_coordinate.name == 'depth' + assert dataset.ems.time_coordinate.name == 'time' def test_polygons_no_bounds(): diff --git a/tests/conventions/test_cfgrid2d.py b/tests/conventions/test_cfgrid2d.py index 8e55f24..550c342 100644 --- a/tests/conventions/test_cfgrid2d.py +++ b/tests/conventions/test_cfgrid2d.py @@ -168,19 +168,18 @@ def test_make_dataset(): def test_varnames(): dataset = make_dataset(j_size=10, i_size=10) - assert dataset.ems.get_depth_name() == 'zc' - assert dataset.ems.get_all_depth_names() == ['zc'] - assert dataset.ems.get_time_name() == 'time' + assert dataset.ems.depth_coordinate.name == 'zc' + assert {c.name for c in dataset.ems.depth_coordinates} == {'zc'} + assert dataset.ems.time_coordinate.name == 'time' def test_no_depth_coordinate(): dataset = make_dataset(j_size=10, i_size=10) dataset = dataset.isel({'k': -1}, drop=True) - print(dataset) - assert dataset.ems.get_all_depth_names() == [] + assert dataset.ems.depth_coordinates == () with pytest.raises(NoSuchCoordinateError): - dataset.ems.get_depth_name() + dataset.ems.depth_coordinate @pytest.mark.parametrize( diff --git a/tests/conventions/test_shoc_standard.py b/tests/conventions/test_shoc_standard.py index 2948458..3bdaeed 100644 --- a/tests/conventions/test_shoc_standard.py +++ b/tests/conventions/test_shoc_standard.py @@ -218,9 +218,9 @@ def test_make_dataset(): def test_varnames(): dataset = make_dataset(j_size=10, i_size=10) - assert dataset.ems.get_depth_name() == 'z_centre' - assert dataset.ems.get_all_depth_names() == ['z_centre', 'z_grid'] - assert dataset.ems.get_time_name() == 't' + assert dataset.ems.depth_coordinate.name == 'z_centre' + assert {c.name for c in dataset.ems.depth_coordinates} == {'z_centre', 'z_grid'} + assert dataset.ems.time_coordinate.name == 't' def test_polygons(): diff --git a/tests/conventions/test_ugrid.py b/tests/conventions/test_ugrid.py index cf8c8c3..7313841 100644 --- a/tests/conventions/test_ugrid.py +++ b/tests/conventions/test_ugrid.py @@ -347,9 +347,9 @@ def test_make_dataset(): def test_varnames(): dataset = make_dataset(width=3) - assert dataset.ems.get_depth_name() == 'Mesh2_layers' - assert dataset.ems.get_all_depth_names() == ['Mesh2_layers'] - assert dataset.ems.get_time_name() == 't' + assert dataset.ems.depth_coordinate.name == 'Mesh2_layers' + assert {c.name for c in dataset.ems.depth_coordinates} == {'Mesh2_layers'} + assert dataset.ems.time_coordinate.name == 't' def test_polygons(): diff --git a/tests/operations/depth/test_ocean_floor.py b/tests/operations/depth/test_ocean_floor.py index b9cc718..33b7116 100644 --- a/tests/operations/depth/test_ocean_floor.py +++ b/tests/operations/depth/test_ocean_floor.py @@ -68,8 +68,8 @@ def test_ocean_floor_from_files(name): floored = dataset.ems.ocean_floor() depth_dimensions = { - dataset.variables[name].dims[0] - for name in dataset.ems.get_all_depth_names() + coordinate.dims[0] + for coordinate in dataset.ems.depth_coordinates } original_dimensions = set(dataset.dims) floored_dimensions = set(floored.dims)