327 prim_grid = get_grid(string[5:])
332 if hasattr(prim_grid,
"clon")
and hasattr(prim_grid,
"clat"):
333 elem_centers_lon, elem_centers_lat = prim_grid.clon, prim_grid.clat
336 prim_grid.vlon[prim_grid.vertex_of_cell], prim_grid.vlat[prim_grid.vertex_of_cell])
338 boundary_edges = (prim_grid.adjacent_cell_of_edge < 0)
339 is_boundary = sum(boundary_edges) != 0
340 boundary_nodes, bnodes_inverse = np.unique(
341 prim_grid.edge_vertices[:, boundary_edges[0, :] + boundary_edges[1, :]], return_inverse=
True)
342 bnodes_inverse = bnodes_inverse.reshape(2, -1)
345 if hasattr(prim_grid,
"elon")
and hasattr(prim_grid,
"elat"):
346 edge_centers_lon, edge_centers_lat = prim_grid.elon[is_boundary], prim_grid.elat[is_boundary]
349 prim_grid.vlon[prim_grid.edge_vertices[:, is_boundary].T], prim_grid.vlat[prim_grid.edge_vertices[:, is_boundary].T])
351 if hasattr(prim_grid,
"elon")
and hasattr(prim_grid,
"elat"):
352 edge_centers_lon, edge_centers_lat = prim_grid.elon, prim_grid.elat
355 prim_grid.vlon[prim_grid.edge_vertices.T], prim_grid.vlat[prim_grid.edge_vertices.T])
357 nelem = len(elem_centers_lon)
358 nedges = len(edge_centers_lon)
359 self.
vlonvlon = np.concatenate([edge_centers_lon, elem_centers_lon, prim_grid.vlon[boundary_nodes]])
360 self.
vlatvlat = np.concatenate([edge_centers_lat, elem_centers_lat, prim_grid.vlat[boundary_nodes]])
364 nedges + prim_grid.adjacent_cell_of_edge[:, ~is_boundary],
365 nedges + nelem + bnodes_inverse,
366 np.stack([range(sum(is_boundary)), nedges + prim_grid.adjacent_cell_of_edge[boundary_edges[0, is_boundary].astype(int), is_boundary]])
369 prim_grid.edge_vertices[:, ~is_boundary],
370 np.stack([boundary_nodes[bnodes_inverse[0, :]], -1*np.ones(bnodes_inverse[0, :].shape, dtype=int)]),
371 prim_grid.edge_vertices[:, is_boundary],
375 [np.stack([np.flatnonzero(~boundary_edges[0, :]), nedges+prim_grid.adjacent_cell_of_edge[0, ~boundary_edges[0, :]]]),
376 np.stack([np.flatnonzero(~boundary_edges[1, :]), nedges+prim_grid.adjacent_cell_of_edge[1, ~boundary_edges[1, :]]]),
377 np.stack([np.flatnonzero(is_boundary), nedges + nelem + bnodes_inverse[0, :]]),
378 np.stack([np.flatnonzero(is_boundary), nedges + nelem + bnodes_inverse[1, :]])
381 prim_grid.edge_vertices[:, ~boundary_edges[0, :]],
382 prim_grid.edge_vertices[:, ~boundary_edges[1, :]],
383 np.stack([boundary_nodes[bnodes_inverse[0, :]], -1*np.ones(bnodes_inverse[0, :].shape, dtype=int)]),
384 np.stack([boundary_nodes[bnodes_inverse[1, :]], -1*np.ones(bnodes_inverse[1, :].shape, dtype=int)]),