Skip to content

Commit aea2ec7

Browse files
committed
Apply suggestions from code review
1 parent d46b18d commit aea2ec7

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

compass/ocean/tests/isomip_plus/initial_state.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -248,40 +248,42 @@ def _plot(self, ds):
248248
sectionY=section_y, dsMesh=ds, ds=ds,
249249
showProgress=show_progress)
250250

251-
ds['oceanFracObserved'] = \
251+
ssh = ds['ssh'].expand_dims(dim='Time', axis=0)
252+
oceanFracObserved = \
252253
ds['oceanFracObserved'].expand_dims(dim='Time', axis=0)
253-
ds['landIceThickness'] = \
254+
oceanFracObserved = \
255+
ds['oceanFracObserved'].expand_dims(dim='Time', axis=0)
256+
landIcePressure = \
257+
ds['landIcePressure'].expand_dims(dim='Time', axis=0)
258+
landIceThickness = \
254259
ds['landIceThickness'].expand_dims(dim='Time', axis=0)
255-
ds['landIceGroundedFraction'] = \
260+
landIceGroundedFraction = \
256261
ds['landIceGroundedFraction'].expand_dims(dim='Time', axis=0)
257-
ds['bottomDepth'] = ds['bottomDepth'].expand_dims(dim='Time', axis=0)
258-
ds['totalColThickness'] = ds['ssh']
259-
ds['totalColThickness'].values = \
260-
ds['layerThickness'].sum(dim='nVertLevels')
262+
bottomDepth = ds['bottomDepth'].expand_dims(dim='Time', axis=0)
263+
totalColThickness = ds.layerThickness.sum(dim='nVertLevels')
261264
tol = 1e-10
262265
plotter.plot_horiz_series(ds.landIceMask,
263266
'landIceMask', 'landIceMask',
264267
True)
265268
plotter.plot_horiz_series(ds.landIceFloatingMask,
266269
'landIceFloatingMask', 'landIceFloatingMask',
267270
True)
268-
plotter.plot_horiz_series(ds.landIcePressure,
271+
plotter.plot_horiz_series(landIcePressure,
269272
'landIcePressure', 'landIcePressure',
270273
True, vmin=1e5, vmax=1e7, cmap_scale='log')
271-
plotter.plot_horiz_series(ds.landIceThickness,
274+
plotter.plot_horiz_series(landIceThickness,
272275
'landIceThickness', 'landIceThickness',
273276
True, vmin=0, vmax=1e3)
274-
plotter.plot_horiz_series(ds.ssh,
275-
'ssh', 'ssh',
277+
plotter.plot_horiz_series(ssh, 'ssh', 'ssh',
276278
True, vmin=-700, vmax=0)
277-
plotter.plot_horiz_series(ds.bottomDepth,
279+
plotter.plot_horiz_series(bottomDepth,
278280
'bottomDepth', 'bottomDepth',
279281
True, vmin=0, vmax=700)
280-
plotter.plot_horiz_series(ds.ssh + ds.bottomDepth,
282+
plotter.plot_horiz_series(ds.ssh + bottomDepth,
281283
'H', 'H', True,
282284
vmin=min_column_thickness + tol, vmax=700,
283285
cmap_set_under='r', cmap_scale='log')
284-
plotter.plot_horiz_series(ds.totalColThickness,
286+
plotter.plot_horiz_series(totalColThickness,
285287
'totalColThickness', 'totalColThickness',
286288
True, vmin=min_column_thickness + 1e-10,
287289
vmax=700, cmap_set_under='r')
@@ -296,13 +298,13 @@ def _plot(self, ds):
296298
True, vmin=0 + tol, vmax=1 - tol,
297299
cmap='cmo.balance',
298300
cmap_set_under='k', cmap_set_over='r')
299-
plotter.plot_horiz_series(ds.landIceGroundedFraction,
301+
plotter.plot_horiz_series(landIceGroundedFraction,
300302
'landIceGroundedFraction',
301303
'landIceGroundedFraction',
302304
True, vmin=0 + tol, vmax=1 - tol,
303305
cmap='cmo.balance',
304306
cmap_set_under='k', cmap_set_over='r')
305-
plotter.plot_horiz_series(ds.oceanFracObserved,
307+
plotter.plot_horiz_series(oceanFracObserved,
306308
'oceanFracObserved', 'oceanFracObserved',
307309
True, vmin=0 + tol, vmax=1 - tol,
308310
cmap='cmo.balance',
@@ -417,7 +419,7 @@ def _write_time_varying_forcing(self, ds_init, ice_density):
417419
land_ice_pressure=land_ice_pressure,
418420
modify_mask=ds_init.bottomDepth > 0.)
419421
land_ice_draft = np.maximum(land_ice_draft, -ds_init.bottomDepth)
420-
land_ice_draft = land_ice_draft.transpose()
422+
land_ice_draft = land_ice_draft.transpose('nCells', 'nVertLevels')
421423
else:
422424
land_ice_draft = ds_init.landIceDraft
423425
land_ice_pressure = ds_init.landIcePressure

0 commit comments

Comments
 (0)