Skip to content

Commit

Permalink
setters for grid properties, skeleton for chunk method
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed Aug 28, 2024
1 parent b346270 commit 8706356
Showing 1 changed file with 178 additions and 0 deletions.
178 changes: 178 additions & 0 deletions uxarray/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,12 @@ def n_nodes_per_face(self) -> xr.DataArray:

return self._ds["n_nodes_per_face"]

@n_nodes_per_face.setter
def n_nodes_per_face(self, value):
"""Setter for ``n_nodes_per_face``"""
assert isinstance(value, xr.DataArray)
self._ds["n_nodes_per_face"] = value

@property
def node_lon(self) -> xr.DataArray:
"""Longitude of each node in degrees.
Expand All @@ -583,6 +589,12 @@ def node_lon(self) -> xr.DataArray:
_populate_node_latlon(self)
return self._ds["node_lon"]

@node_lon.setter
def node_lon(self, value):
"""Setter for ``node_lon``"""
assert isinstance(value, xr.DataArray)
self._ds["node_lon"] = value

@property
def node_lat(self) -> xr.DataArray:
"""Latitude of each node in degrees.
Expand All @@ -594,6 +606,12 @@ def node_lat(self) -> xr.DataArray:
_populate_node_latlon(self)
return self._ds["node_lat"]

@node_lat.setter
def node_lat(self, value):
"""Setter for ``node_lat``"""
assert isinstance(value, xr.DataArray)
self._ds["node_lat"] = value

@property
def node_x(self) -> xr.DataArray:
"""Cartesian x location of each node in meters.
Expand All @@ -605,6 +623,12 @@ def node_x(self) -> xr.DataArray:

return self._ds["node_x"]

@node_x.setter
def node_x(self, value):
"""Setter for ``node_x``"""
assert isinstance(value, xr.DataArray)
self._ds["node_x"] = value

@property
def node_y(self) -> xr.DataArray:
"""Cartesian y location of each node in meters.
Expand All @@ -615,6 +639,12 @@ def node_y(self) -> xr.DataArray:
_populate_node_xyz(self)
return self._ds["node_y"]

@node_y.setter
def node_y(self, value):
"""Setter for ``node_y``"""
assert isinstance(value, xr.DataArray)
self._ds["node_y"] = value

@property
def node_z(self) -> xr.DataArray:
"""Cartesian z location of each node in meters.
Expand All @@ -625,6 +655,12 @@ def node_z(self) -> xr.DataArray:
_populate_node_xyz(self)
return self._ds["node_z"]

@node_z.setter
def node_z(self, value):
"""Setter for ``node_z``"""
assert isinstance(value, xr.DataArray)
self._ds["node_z"] = value

@property
def edge_lon(self) -> xr.DataArray:
"""Longitude of the center of each edge in degrees.
Expand All @@ -637,6 +673,12 @@ def edge_lon(self) -> xr.DataArray:
_set_desired_longitude_range(self._ds)
return self._ds["edge_lon"]

@edge_lon.setter
def edge_lon(self, value):
"""Setter for ``edge_lon``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_lon"] = value

@property
def edge_lat(self) -> xr.DataArray:
"""Latitude of the center of each edge in degrees.
Expand All @@ -648,6 +690,12 @@ def edge_lat(self) -> xr.DataArray:
_set_desired_longitude_range(self._ds)
return self._ds["edge_lat"]

@edge_lat.setter
def edge_lat(self, value):
"""Setter for ``edge_lat``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_lat"] = value

@property
def edge_x(self) -> xr.DataArray:
"""Cartesian x location of the center of each edge in meters.
Expand All @@ -659,6 +707,12 @@ def edge_x(self) -> xr.DataArray:

return self._ds["edge_x"]

@edge_x.setter
def edge_x(self, value):
"""Setter for ``edge_x``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_x"] = value

@property
def edge_y(self) -> xr.DataArray:
"""Cartesian y location of the center of each edge in meters.
Expand All @@ -669,6 +723,12 @@ def edge_y(self) -> xr.DataArray:
_populate_edge_centroids(self)
return self._ds["edge_y"]

@edge_y.setter
def edge_y(self, value):
"""Setter for ``edge_y``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_y"] = value

@property
def edge_z(self) -> xr.DataArray:
"""Cartesian z location of the center of each edge in meters.
Expand All @@ -679,6 +739,12 @@ def edge_z(self) -> xr.DataArray:
_populate_edge_centroids(self)
return self._ds["edge_z"]

@edge_z.setter
def edge_z(self, value):
"""Setter for ``edge_z``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_z"] = value

@property
def face_lon(self) -> xr.DataArray:
"""Longitude of the center of each face in degrees.
Expand All @@ -690,6 +756,12 @@ def face_lon(self) -> xr.DataArray:
_set_desired_longitude_range(self._ds)
return self._ds["face_lon"]

@face_lon.setter
def face_lon(self, value):
"""Setter for ``face_lon``"""
assert isinstance(value, xr.DataArray)
self._ds["face_lon"] = value

@property
def face_lat(self) -> xr.DataArray:
"""Latitude of the center of each face in degrees.
Expand All @@ -702,6 +774,12 @@ def face_lat(self) -> xr.DataArray:

return self._ds["face_lat"]

@face_lat.setter
def face_lat(self, value):
"""Setter for ``face_lat``"""
assert isinstance(value, xr.DataArray)
self._ds["face_lat"] = value

@property
def face_x(self) -> xr.DataArray:
"""Cartesian x location of the center of each face in meters.
Expand All @@ -713,6 +791,12 @@ def face_x(self) -> xr.DataArray:

return self._ds["face_x"]

@face_x.setter
def face_x(self, value):
"""Setter for ``face_x``"""
assert isinstance(value, xr.DataArray)
self._ds["face_x"] = value

@property
def face_y(self) -> xr.DataArray:
"""Cartesian y location of the center of each face in meters.
Expand All @@ -723,6 +807,12 @@ def face_y(self) -> xr.DataArray:
_populate_face_centroids(self)
return self._ds["face_y"]

@face_y.setter
def face_y(self, value):
"""Setter for ``face_x``"""
assert isinstance(value, xr.DataArray)
self._ds["face_y"] = value

@property
def face_z(self) -> xr.DataArray:
"""Cartesian z location of the center of each face in meters.
Expand All @@ -733,6 +823,12 @@ def face_z(self) -> xr.DataArray:
_populate_face_centroids(self)
return self._ds["face_z"]

@face_z.setter
def face_z(self, value):
"""Setter for ``face_z``"""
assert isinstance(value, xr.DataArray)
self._ds["face_z"] = value

@property
def face_node_connectivity(self) -> xr.DataArray:
"""Indices of the nodes that make up each face.
Expand All @@ -755,6 +851,12 @@ def face_node_connectivity(self) -> xr.DataArray:

return self._ds["face_node_connectivity"]

@face_node_connectivity.setter
def face_node_connectivity(self, value):
"""Setter for ``face_node_connectivity``"""
assert isinstance(value, xr.DataArray)
self._ds["face_node_connectivity"] = value

@property
def edge_node_connectivity(self) -> xr.DataArray:
"""Indices of the two nodes that make up each edge.
Expand All @@ -768,6 +870,12 @@ def edge_node_connectivity(self) -> xr.DataArray:

return self._ds["edge_node_connectivity"]

@edge_node_connectivity.setter
def edge_node_connectivity(self, value):
"""Setter for ``edge_node_connectivity``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_node_connectivity"] = value

@property
def node_node_connectivity(self) -> xr.DataArray:
"""Indices of the nodes that surround each node."""
Expand All @@ -777,6 +885,12 @@ def node_node_connectivity(self) -> xr.DataArray:
)
return self._ds["node_node_connectivity"]

@node_node_connectivity.setter
def node_node_connectivity(self, value):
"""Setter for ``node_node_connectivity``"""
assert isinstance(value, xr.DataArray)
self._ds["node_node_connectivity"] = value

@property
def face_edge_connectivity(self) -> xr.DataArray:
"""Indices of the edges that surround each face.
Expand All @@ -788,6 +902,12 @@ def face_edge_connectivity(self) -> xr.DataArray:

return self._ds["face_edge_connectivity"]

@face_edge_connectivity.setter
def face_edge_connectivity(self, value):
"""Setter for ``face_edge_connectivity``"""
assert isinstance(value, xr.DataArray)
self._ds["face_edge_connectivity"] = value

@property
def edge_edge_connectivity(self) -> xr.DataArray:
"""Indices of the edges that surround each edge.
Expand All @@ -801,6 +921,12 @@ def edge_edge_connectivity(self) -> xr.DataArray:

return self._ds["edge_edge_connectivity"]

@edge_edge_connectivity.setter
def edge_edge_connectivity(self, value):
"""Setter for ``edge_edge_connectivity``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_edge_connectivity"] = value

@property
def node_edge_connectivity(self) -> xr.DataArray:
"""Indices of the edges that surround each node."""
Expand All @@ -811,6 +937,12 @@ def node_edge_connectivity(self) -> xr.DataArray:

return self._ds["node_edge_connectivity"]

@node_edge_connectivity.setter
def node_edge_connectivity(self, value):
"""Setter for ``node_edge_connectivity``"""
assert isinstance(value, xr.DataArray)
self._ds["node_edge_connectivity"] = value

@property
def face_face_connectivity(self) -> xr.DataArray:
"""Indices of the faces that surround each face.
Expand All @@ -822,6 +954,12 @@ def face_face_connectivity(self) -> xr.DataArray:

return self._ds["face_face_connectivity"]

@face_face_connectivity.setter
def face_face_connectivity(self, value):
"""Setter for ``face_face_connectivity``"""
assert isinstance(value, xr.DataArray)
self._ds["face_face_connectivity"] = value

@property
def edge_face_connectivity(self) -> xr.DataArray:
"""Indices of the faces that saddle each edge.
Expand All @@ -833,6 +971,12 @@ def edge_face_connectivity(self) -> xr.DataArray:

return self._ds["edge_face_connectivity"]

@edge_face_connectivity.setter
def edge_face_connectivity(self, value):
"""Setter for ``edge_face_connectivity``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_face_connectivity"] = value

@property
def node_face_connectivity(self) -> xr.DataArray:
"""Indices of the faces that surround each node.
Expand All @@ -844,6 +988,12 @@ def node_face_connectivity(self) -> xr.DataArray:

return self._ds["node_face_connectivity"]

@node_face_connectivity.setter
def node_face_connectivity(self, value):
"""Setter for ``node_face_connectivity``"""
assert isinstance(value, xr.DataArray)
self._ds["node_face_connectivity"] = value

@property
def edge_node_distances(self):
"""Distances between the two nodes that surround each edge.
Expand All @@ -854,6 +1004,12 @@ def edge_node_distances(self):
_populate_edge_node_distances(self)
return self._ds["edge_node_distances"]

@edge_node_distances.setter
def edge_node_distances(self, value):
"""Setter for ``edge_node_distances``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_node_distances"] = value

@property
def edge_face_distances(self):
"""Distances between the centers of the faces that saddle each edge.
Expand All @@ -864,6 +1020,12 @@ def edge_face_distances(self):
_populate_edge_face_distances(self)
return self._ds["edge_face_distances"]

@edge_face_distances.setter
def edge_face_distances(self, value):
"""Setter for ``edge_face_distances``"""
assert isinstance(value, xr.DataArray)
self._ds["edge_face_distances"] = value

@property
def antimeridian_face_indices(self) -> np.ndarray:
"""Index of each face that crosses the antimeridian."""
Expand All @@ -883,6 +1045,12 @@ def face_areas(self) -> xr.DataArray:
)
return self._ds["face_areas"]

@face_areas.setter
def face_areas(self, value):
"""Setter for ``face_areas``"""
assert isinstance(value, xr.DataArray)
self._ds["face_areas"] = value

@property
def bounds(self):
"""Latitude Longitude Bounds for each Face in degrees.
Expand All @@ -897,13 +1065,23 @@ def bounds(self):

return self._ds["bounds"]

@bounds.setter
def bounds(self, value):
"""Setter for ``bounds``"""
assert isinstance(value, xr.DataArray)
self._ds["bounds"] = value

@property
def face_jacobian(self):
"""Declare face_jacobian as a property."""
if self._face_jacobian is None:
_ = self.face_areas
return self._face_jacobian

def chunk(self):
# TODO: add general chunking method
pass

def get_ball_tree(
self,
coordinates: Optional[str] = "nodes",
Expand Down

0 comments on commit 8706356

Please sign in to comment.