@@ -113,73 +113,73 @@ def plot_sgrid(axes, ds, nodes=False, rho_points=False, edge_points=False):
113
113
114
114
raise NotImplementedError ("have to port ugrid code to Sgrid" )
115
115
116
- mesh_defs = ds [ds .cf .cf_roles ["grid_topology" ][0 ]].attrs
117
- lon_var , lat_var = mesh_defs ["node_coordinates" ].split ()
118
- nodes_lon , nodes_lat = (ds [n ] for n in mesh_defs ["node_coordinates" ].split ())
119
-
120
-
121
- faces = ds [mesh_defs ["face_node_connectivity" ]]
122
-
123
- if faces .shape [0 ] == 3 :
124
- # swap order for mpl triangulation
125
- faces = faces .T
126
- start_index = faces .attrs .get ("start_index" )
127
- start_index = 0 if start_index is None else start_index
128
- faces = faces - start_index
129
-
130
- mpl_tri = Triangulation (nodes_lon , nodes_lat , faces )
131
-
132
- axes .triplot (mpl_tri )
133
- if face_numbers :
134
- try :
135
- face_lon , face_lat = (ds [n ] for n in mesh_defs ["face_coordinates" ].split ())
136
- except KeyError :
137
- raise ValueError ('"face_coordinates" must be defined to plot the face numbers' )
138
- for i , point in enumerate (zip (face_lon , face_lat )):
139
- axes .annotate (
140
- f"{ i } " ,
141
- point ,
142
- xytext = (0 , 0 ),
143
- textcoords = "offset points" ,
144
- horizontalalignment = "center" ,
145
- verticalalignment = "center" ,
146
- bbox = {
147
- "facecolor" : "white" ,
148
- "alpha" : 1.0 ,
149
- "boxstyle" : "round,pad=0.0" ,
150
- "ec" : "white" ,
151
- },
152
- )
116
+ grid_defs = ds [ds .cf .cf_roles ["grid_topology" ][0 ]].attrs
117
+ lon_var , lat_var = grid_defs ["node_coordinates" ].split ()
118
+ nodes_lon , nodes_lat = (ds [n ] for n in grid_defs ["node_coordinates" ].split ())
119
+
120
+
121
+ # faces = ds[mesh_defs["face_node_connectivity"]]
122
+
123
+ # if faces.shape[0] == 3:
124
+ # # swap order for mpl triangulation
125
+ # faces = faces.T
126
+ # start_index = faces.attrs.get("start_index")
127
+ # start_index = 0 if start_index is None else start_index
128
+ # faces = faces - start_index
129
+
130
+ # mpl_tri = Triangulation(nodes_lon, nodes_lat, faces)
131
+
132
+ # axes.triplot(mpl_tri)
133
+ # if face_numbers:
134
+ # try:
135
+ # face_lon, face_lat = (ds[n] for n in mesh_defs["face_coordinates"].split())
136
+ # except KeyError:
137
+ # raise ValueError('"face_coordinates" must be defined to plot the face numbers')
138
+ # for i, point in enumerate(zip(face_lon, face_lat)):
139
+ # axes.annotate(
140
+ # f"{i}",
141
+ # point,
142
+ # xytext=(0, 0),
143
+ # textcoords="offset points",
144
+ # horizontalalignment="center",
145
+ # verticalalignment="center",
146
+ # bbox={
147
+ # "facecolor": "white",
148
+ # "alpha": 1.0,
149
+ # "boxstyle": "round,pad=0.0",
150
+ # "ec": "white",
151
+ # },
152
+ # )
153
153
154
154
# plot nodes
155
155
if nodes :
156
156
axes .plot (nodes_lon , nodes_lat , "o" )
157
- # plot node numbers
158
- if node_numbers :
159
- for i , point in enumerate (zip (nodes_lon , nodes_lat )):
160
- axes .annotate (
161
- f"{ i } " ,
162
- point ,
163
- xytext = (2 , 2 ),
164
- textcoords = "offset points" ,
165
- bbox = {
166
- "facecolor" : "white" ,
167
- "alpha" : 1.0 ,
168
- "boxstyle" : "round,pad=0.0" ,
169
- "ec" : "white" ,
170
- },
171
- )
172
-
173
- # boundaries -- if they are there.
174
- if "boundary_node_connectivity" in mesh_defs :
175
- bounds = ds [mesh_defs ["boundary_node_connectivity" ]]
176
-
177
- lines = []
178
- for bound in bounds .data :
179
- line = (
180
- (nodes_lon [bound [0 ]], nodes_lat [bound [0 ]]),
181
- (nodes_lon [bound [1 ]], nodes_lat [bound [1 ]]),
182
- )
183
- lines .append (line )
184
- lc = LineCollection (lines , linewidths = 2 , colors = (1 , 0 , 0 , 1 ))
185
- axes .add_collection (lc )
157
+ # # plot node numbers
158
+ # if node_numbers:
159
+ # for i, point in enumerate(zip(nodes_lon, nodes_lat)):
160
+ # axes.annotate(
161
+ # f"{i}",
162
+ # point,
163
+ # xytext=(2, 2),
164
+ # textcoords="offset points",
165
+ # bbox={
166
+ # "facecolor": "white",
167
+ # "alpha": 1.0,
168
+ # "boxstyle": "round,pad=0.0",
169
+ # "ec": "white",
170
+ # },
171
+ # )
172
+
173
+ # # boundaries -- if they are there.
174
+ # if "boundary_node_connectivity" in mesh_defs:
175
+ # bounds = ds[mesh_defs["boundary_node_connectivity"]]
176
+
177
+ # lines = []
178
+ # for bound in bounds.data:
179
+ # line = (
180
+ # (nodes_lon[bound[0]], nodes_lat[bound[0]]),
181
+ # (nodes_lon[bound[1]], nodes_lat[bound[1]]),
182
+ # )
183
+ # lines.append(line)
184
+ # lc = LineCollection(lines, linewidths=2, colors=(1, 0, 0, 1))
185
+ # axes.add_collection(lc)
0 commit comments