Skip to content
Snippets Groups Projects
Commit 0e87f9ec authored by Martin Lange's avatar Martin Lange
Browse files

cache data_size / calculate more efficiently

parent 29221381
No related branches found
No related tags found
1 merge request!237Optimize units etc.
......@@ -84,6 +84,7 @@ class RectilinearGrid(StructuredGrid):
self._crs = crs
self._data_shape = None
self._data_size = None
def to_unstructured(self):
"""
......@@ -116,6 +117,13 @@ class RectilinearGrid(StructuredGrid):
self._data_shape = super().data_shape
return self._data_shape
@property
def data_size(self):
"""int: Size of the associated data."""
if self._data_size is None:
self._data_size = super().data_size
return self._data_size
@property
def axes(self):
"""list of np.ndarray: Grid points."""
......@@ -438,6 +446,15 @@ class UnstructuredGrid(Grid):
else (len(self.cells),)
)
@property
def data_size(self):
"""int: Size of the associated data."""
return (
len(self.points)
if self.data_location == Location.POINTS
else len(self.cells)
)
@property
def cells(self):
"""np.ndarray: Cell nodes in ESMF format."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment