Skip to content

Commit 5a434d6

Browse files
committed
Drop grid areas for planar MPAS meshes
We don't have a sphere radius to work from so we should just let the regridder handle it.
1 parent 654fbbb commit 5a434d6

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

pyremap/descriptor/mpas_cell_mesh_descriptor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ def to_scrip(self, scrip_filename, expand_dist=None, expand_factor=None):
127127

128128
ds_out = xr.Dataset()
129129

130-
ds_out['grid_area'] = (('grid_size',), area_cell / (sphere_radius**2))
130+
if sphere_radius > 0:
131+
ds_out['grid_area'] = (
132+
('grid_size',),
133+
area_cell / (sphere_radius**2),
134+
)
135+
ds_out.grid_area.attrs['units'] = 'radians^2'
131136

132137
ds_out['grid_center_lat'] = (('grid_size',), lat_cell)
133138
ds_out['grid_center_lon'] = (('grid_size',), lon_cell)
@@ -165,7 +170,6 @@ def to_scrip(self, scrip_filename, expand_dist=None, expand_factor=None):
165170
ds_out.grid_corner_lat.attrs['units'] = 'radians'
166171
ds_out.grid_corner_lon.attrs['units'] = 'radians'
167172
ds_out.grid_imask.attrs['units'] = 'unitless'
168-
ds_out.grid_area.attrs['units'] = 'radians^2'
169173

170174
if expand_dist is not None or expand_factor is not None:
171175
expand_scrip(ds_out, expand_dist, expand_factor)

pyremap/descriptor/mpas_edge_mesh_descriptor.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,16 @@ def to_scrip(self, scrip_filename, expand_dist=None, expand_factor=None):
142142
mask = cells_on_edge[:, i_cell] >= 0
143143
valid_cells_on_edge[mask] = valid_cells_on_edge[mask] + 1
144144

145-
ds_out['grid_area'] = (
146-
('grid_size',),
147-
0.5 * valid_cells_on_edge * dc_edge * dv_edge / (sphere_radius**2),
148-
)
145+
if sphere_radius > 0:
146+
ds_out['grid_area'] = (
147+
('grid_size',),
148+
0.5
149+
* valid_cells_on_edge
150+
* dc_edge
151+
* dv_edge
152+
/ (sphere_radius**2),
153+
)
154+
ds_out.grid_area.attrs['units'] = 'radians^2'
149155

150156
ds_out['grid_center_lat'] = (('grid_size',), lat_edge)
151157
ds_out['grid_center_lon'] = (('grid_size',), lon_edge)
@@ -198,7 +204,6 @@ def to_scrip(self, scrip_filename, expand_dist=None, expand_factor=None):
198204
ds_out.grid_corner_lat.attrs['units'] = 'radians'
199205
ds_out.grid_corner_lon.attrs['units'] = 'radians'
200206
ds_out.grid_imask.attrs['units'] = 'unitless'
201-
ds_out.grid_area.attrs['units'] = 'radians^2'
202207

203208
if expand_dist is not None or expand_factor is not None:
204209
expand_scrip(ds_out, expand_dist, expand_factor)

pyremap/descriptor/mpas_vertex_mesh_descriptor.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ def to_scrip(self, scrip_filename, expand_dist=None, expand_factor=None):
136136
vertex_area[mask] + kite_areas_on_vertex[mask, icell]
137137
)
138138

139-
ds_out['grid_area'] = (
140-
('grid_size',),
141-
vertex_area / (sphere_radius**2),
142-
)
139+
if sphere_radius > 0:
140+
ds_out['grid_area'] = (
141+
('grid_size',),
142+
vertex_area / (sphere_radius**2),
143+
)
144+
ds_out.grid_area.attrs['units'] = 'radians^2'
143145

144146
ds_out['grid_center_lat'] = (('grid_size',), lat_vertex)
145147
ds_out['grid_center_lon'] = (('grid_size',), lon_vertex)
@@ -191,7 +193,6 @@ def to_scrip(self, scrip_filename, expand_dist=None, expand_factor=None):
191193
ds_out.grid_corner_lat.attrs['units'] = 'radians'
192194
ds_out.grid_corner_lon.attrs['units'] = 'radians'
193195
ds_out.grid_imask.attrs['units'] = 'unitless'
194-
ds_out.grid_area.attrs['units'] = 'radians^2'
195196

196197
if expand_dist is not None or expand_factor is not None:
197198
expand_scrip(ds_out, expand_dist, expand_factor)

0 commit comments

Comments
 (0)