diff --git a/test/test_subset.py b/test/test_subset.py index 184d0fcb0..db2108971 100644 --- a/test/test_subset.py +++ b/test/test_subset.py @@ -144,7 +144,7 @@ def test_inverse_indices(): # Ensure code raises exceptions when the element is edges or nodes assert pytest.raises(Exception, grid.subset.bounding_circle, center_coord, r=10, element="edge centers", inverse_indices=True) - assert pytest.raises(Exception, grid.subset.bounding_circle, center_coord, r=10, element="node centers", inverse_indices=True) + assert pytest.raises(Exception, grid.subset.bounding_circle, center_coord, r=10, element="nodes", inverse_indices=True) # Test isel directly subset = grid.isel(n_face=[1], inverse_indices=True) diff --git a/uxarray/cross_sections/dataarray_accessor.py b/uxarray/cross_sections/dataarray_accessor.py index fd0e81e84..52599c7a4 100644 --- a/uxarray/cross_sections/dataarray_accessor.py +++ b/uxarray/cross_sections/dataarray_accessor.py @@ -35,7 +35,7 @@ def constant_latitude( Must be between -90.0 and 90.0 inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) Returns ------- @@ -80,7 +80,7 @@ def constant_longitude( Must be between -180.0 and 180.0 inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) Returns ------- diff --git a/uxarray/cross_sections/grid_accessor.py b/uxarray/cross_sections/grid_accessor.py index 17fee3f8e..76485fbda 100644 --- a/uxarray/cross_sections/grid_accessor.py +++ b/uxarray/cross_sections/grid_accessor.py @@ -39,7 +39,7 @@ def constant_latitude( If True, also returns the indices of the faces that intersect with the line of constant latitude. inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) Returns ------- @@ -97,7 +97,7 @@ def constant_longitude( If True, also returns the indices of the faces that intersect with the line of constant longitude. inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) Returns ------- diff --git a/uxarray/grid/grid.py b/uxarray/grid/grid.py index 9f62da303..bf7f8864f 100644 --- a/uxarray/grid/grid.py +++ b/uxarray/grid/grid.py @@ -142,7 +142,7 @@ class Grid: is_subset : bool, default=False Flag to mark if the grid is a subset or not - inverse_indices: xr.Dataset, defaul=None + inverse_indices: xr.Dataset, default=None A dataset of indices that correspond to the original grid, if the grid being constructed is a subset Examples @@ -168,7 +168,7 @@ def __init__( grid_ds: xr.Dataset, source_grid_spec: Optional[str] = None, source_dims_dict: Optional[dict] = {}, - is_subset=False, + is_subset: bool = False, inverse_indices: Optional[xr.Dataset] = None, ): # check if inputted dataset is a minimum representable 2D UGRID unstructured grid @@ -1529,7 +1529,7 @@ def global_sphere_coverage(self): return not self.partial_sphere_coverage @property - def inverse_indices(self): + def inverse_indices(self) -> xr.Dataset: """Indices for a subset that map each face in the subset back to the original grid""" if self.is_subset: return self._inverse_indices @@ -2246,8 +2246,8 @@ def isel( Parameters inverse_indices : Union[List[str], Set[str], bool], default=False - Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + Indicates whether to store the original grids indices. Passing `True` stores the original face indices, + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) **dims_kwargs: kwargs Dimension to index, one of ['n_node', 'n_edge', 'n_face'] diff --git a/uxarray/grid/slice.py b/uxarray/grid/slice.py index 1bfc8a017..a85c9f78f 100644 --- a/uxarray/grid/slice.py +++ b/uxarray/grid/slice.py @@ -91,7 +91,7 @@ def _slice_face_indices( to exclusive (i.e elements be made up all desired features from a slice) inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) """ if inclusive is False: raise ValueError("Exclusive slicing is not yet supported.") @@ -151,12 +151,12 @@ def _slice_face_indices( inverse_indices_ds = xr.Dataset() index_types = { - "face centers": face_indices, - "edge centers": edge_indices, - "nodes": node_indices, + "face": face_indices, + "edge": edge_indices, + "node": node_indices, } if isinstance(inverse_indices, bool): - inverse_indices_ds["face centers"] = face_indices + inverse_indices_ds["face"] = face_indices else: for index_type in inverse_indices[0]: if index_type in index_types: diff --git a/uxarray/subset/dataarray_accessor.py b/uxarray/subset/dataarray_accessor.py index 23609ba65..2d966c587 100644 --- a/uxarray/subset/dataarray_accessor.py +++ b/uxarray/subset/dataarray_accessor.py @@ -56,7 +56,7 @@ def bounding_box( Element for use with `coords` comparison, one of `nodes`, `face centers`, or `edge centers` inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) """ grid = self.uxda.uxgrid.subset.bounding_box( lon_bounds, lat_bounds, element, method, inverse_indices=inverse_indices @@ -85,7 +85,7 @@ def bounding_circle( Element for use with `coords` comparison, one of `nodes`, `face centers`, or `edge centers` inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) """ grid = self.uxda.uxgrid.subset.bounding_circle( center_coord, r, element, inverse_indices=inverse_indices, **kwargs @@ -113,7 +113,7 @@ def nearest_neighbor( Element for use with `coords` comparison, one of `nodes`, `face centers`, or `edge centers` inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) """ grid = self.uxda.uxgrid.subset.nearest_neighbor( diff --git a/uxarray/subset/grid_accessor.py b/uxarray/subset/grid_accessor.py index d0d8a9d08..a504179f1 100644 --- a/uxarray/subset/grid_accessor.py +++ b/uxarray/subset/grid_accessor.py @@ -56,7 +56,7 @@ def bounding_box( Element for use with `coords` comparison, one of `nodes`, `face centers`, or `edge centers` inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) """ if method == "coords": @@ -135,7 +135,7 @@ def bounding_circle( Element for use with `coords` comparison, one of `nodes`, `face centers`, or `edge centers` inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) """ coords = np.asarray(center_coord) @@ -172,7 +172,7 @@ def nearest_neighbor( Element for use with `coords` comparison, one of `nodes`, `face centers`, or `edge centers` inverse_indices : Union[List[str], Set[str], bool], optional Indicates whether to store the original grids indices. Passing `True` stores the original face centers, - other reverse indices can be stored by passing any or all of the following: (["face centers", "edge centers", "nodes"], True) + other reverse indices can be stored by passing any or all of the following: (["face", "edge", "node"], True) """ coords = np.asarray(center_coord)