-
Notifications
You must be signed in to change notification settings - Fork 300
Add summary of ugrid to cube print out #3688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
8cefdf4
bbecf2f
495f8e4
d8274ae
3f4e76e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,16 @@ | |
|
|
||
|
|
||
| class CubeUgrid( | ||
| namedtuple("CubeUgrid", ["cube_dim", "grid", "mesh_location"]) | ||
| namedtuple( | ||
| "CubeUgrid", | ||
| [ | ||
| "cube_dim", | ||
| "grid", | ||
| "mesh_location", | ||
| "topology_dimension", | ||
| "node_coordinates", | ||
| ], | ||
| ) | ||
| ): | ||
| """ | ||
| Object recording the unstructured grid dimension of a cube. | ||
|
|
@@ -64,13 +73,25 @@ class CubeUgrid( | |
| Which element of the mesh the cube is mapped to. | ||
| Can be 'face', 'edge' or 'node'. A 'volume' is not supported. | ||
|
|
||
| * topology_dimension (int): | ||
| The highest dimensionality of the geometric elements in the mesh. | ||
|
|
||
| * node_coordinates (set): | ||
| A set of the names of the spatial coordinates, used to geolocate the nodes. | ||
|
|
||
| """ | ||
|
|
||
| def __str__(self): | ||
| result = "Cube unstructured-grid dimension:" | ||
| result += "\n cube dimension = {}".format(self.cube_dim) | ||
| result += '\n mesh_location = "{}"'.format(self.mesh_location) | ||
| result += '\n mesh "{}" :\n'.format(self.grid.mesh_name) | ||
| result += '\n mesh "{}" :'.format(self.grid.mesh_name) | ||
| result += '\n topology_dimension "{}" :'.format( | ||
| self.topology_dimension | ||
| ) | ||
| result += '\n node_coordinates "{}" :\n'.format( | ||
| " ".join(self.node_coordinates) | ||
| ) | ||
| try: | ||
| mesh_str = str(self.grid.info) | ||
| except TypeError: | ||
|
|
@@ -79,6 +100,9 @@ def __str__(self): | |
| result += "\n" | ||
| return result | ||
|
|
||
| def name(self): | ||
| return ".".join([self.grid.mesh_name, self.mesh_location]) | ||
|
|
||
|
|
||
| class UGridCFReader: | ||
| """ | ||
|
|
@@ -188,8 +212,23 @@ def complete_ugrid_cube(self, cube): | |
| raise ValueError(msg.format(meshes_info)) | ||
| if meshes_info: | ||
| i_dim, (mesh, mesh_location) = meshes_info[0] | ||
| mesh_var = self.dataset.variables[mesh.mesh_name] | ||
|
|
||
| topology_dimension = mesh_var.getncattr("topology_dimension") | ||
| node_coordinates = [] | ||
| for node_var_name in mesh_var.getncattr("node_coordinates").split( | ||
| " " | ||
| ): | ||
| node_var = self.dataset.variables[node_var_name] | ||
| node_coordinates.append(node_var.getncattr("standard_name")) | ||
|
||
| node_coordinates = set(node_coordinates) | ||
|
|
||
| cube.ugrid = CubeUgrid( | ||
| cube_dim=i_dim, grid=mesh, mesh_location=mesh_location | ||
| cube_dim=i_dim, | ||
| grid=mesh, | ||
| mesh_location=mesh_location, | ||
| topology_dimension=topology_dimension, | ||
| node_coordinates=node_coordinates, | ||
| ) | ||
| else: | ||
| # Add an empty 'cube.ugrid' to all cubes otherwise. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.