Skip to content

Commit 5321402

Browse files
committed
Add support for staggered variables on B-grid
1 parent 3abedd8 commit 5321402

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

src/access_moppy/ocean.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,12 @@ def __init__(
190190
self.arakawa = "B" # ACCESS-OM2 MOM5 uses B-grid
191191

192192
def infer_grid_type(self):
193-
"""Infer the grid type (T, U, V, Q) and memory mode based on present coordinates."""
193+
"""Infer the grid type (T, U, V, C) and memory mode based on present coordinates."""
194194
grid_types = {
195195
"T": {"xt_ocean", "yt_ocean"},
196-
"U": {"xu_ocean", "yu_ocean"},
196+
"U": {"xu_ocean", "yt_ocean"},
197+
"V": {"xt_ocean", "yu_ocean"},
198+
"C": {"xu_ocean", "yu_ocean"},
197199
}
198200
present_coords = set(self.ds.coords)
199201

@@ -246,7 +248,7 @@ def __init__(
246248
self.arakawa = "C" # ACCESS-OM3 MOM6 uses C-grid
247249

248250
def infer_grid_type(self):
249-
"""Infer the grid type (T, U, V, Q) and memory mode based on present coordinates."""
251+
"""Infer the grid type (T, U, V, C) and memory mode based on present coordinates."""
250252
grid_types = {
251253
"T": {"xh", "yh"},
252254
"U": {"xq", "yh"},

src/access_moppy/ocean_supergrid.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,24 @@ def extract_grid(self, grid_type: str, arakawa: str, symmetric=None):
238238
case "B":
239239
match grid_type:
240240
case "T":
241-
x_centers = self.hcell_centres_x
241+
x_centers = self.hcell_centres_x # geolon_t
242242
x_bounds = self.hcell_corners_x
243-
y_centers = self.hcell_centres_y
243+
y_centers = self.hcell_centres_y # geolat_t
244244
y_bounds = self.hcell_corners_y
245245
case "U":
246-
x_centers = self.qcell_centres_x[1:, 1:]
246+
x_centers = self.qcell_centres_x[1:,1:] # geolon_c
247+
x_bounds = self.qcell_corners_x[1:,1:,:]
248+
y_centers = self.hcell_centres_y # geolat_t
249+
y_bounds = self.hcell_corners_y
250+
case "V":
251+
x_centers = self.hcell_centres_x # geolon_t
252+
x_bounds = self.hcell_corners_x
253+
y_centers = self.qcell_centres_y[1:,1:] # geolat_c
254+
y_bounds = self.qcell_corners_y[1:,1:,:]
255+
case "C":
256+
x_centers = self.qcell_centres_x[1:, 1:] # geolon_c
247257
x_bounds = self.qcell_corners_x[1:, 1:, :]
248-
y_centers = self.qcell_centres_y[1:, 1:]
258+
y_centers = self.qcell_centres_y[1:, 1:] # geolat_c
249259
y_bounds = self.qcell_corners_y[1:, 1:, :]
250260
case _:
251261
raise ValueError(
@@ -255,24 +265,24 @@ def extract_grid(self, grid_type: str, arakawa: str, symmetric=None):
255265
i_start = 0 if symmetric else 1
256266
match grid_type:
257267
case "T":
258-
x_centers = self.hcell_centres_x
268+
x_centers = self.hcell_centres_x # geolon
259269
x_bounds = self.hcell_corners_x
260-
y_centers = self.hcell_centres_y
270+
y_centers = self.hcell_centres_y # geolat
261271
y_bounds = self.hcell_corners_y
262272
case "U":
263-
x_centers = self.ucell_centres_x[:, i_start:]
273+
x_centers = self.ucell_centres_x[:, i_start:] # geolon_u
264274
x_bounds = self.ucell_corners_x[:, i_start:, :]
265-
y_centers = self.ucell_centres_y[:, i_start:]
275+
y_centers = self.ucell_centres_y[:, i_start:] # geolat_u
266276
y_bounds = self.ucell_corners_y[:, i_start:, :]
267277
case "V":
268-
x_centers = self.vcell_centres_x[i_start:, :]
278+
x_centers = self.vcell_centres_x[i_start:, :] # geolon_v
269279
x_bounds = self.vcell_corners_x[i_start:, :, :]
270-
y_centers = self.vcell_centres_y[i_start:, :]
280+
y_centers = self.vcell_centres_y[i_start:, :] # geolat_v
271281
y_bounds = self.vcell_corners_y[i_start:, :, :]
272282
case "C":
273-
x_centers = self.qcell_centres_x[i_start:, i_start:]
283+
x_centers = self.qcell_centres_x[i_start:, i_start:] # geolon_c
274284
x_bounds = self.qcell_corners_x[i_start:, i_start:, :]
275-
y_centers = self.qcell_centres_y[i_start:, i_start:]
285+
y_centers = self.qcell_centres_y[i_start:, i_start:] # geolat_c
276286
y_bounds = self.qcell_corners_y[i_start:, i_start:, :]
277287
case _:
278288
raise ValueError(

0 commit comments

Comments
 (0)