Skip to content

Commit

Permalink
Fix a bug in vrfy section for plotting meridional slice (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
apchoiCMD authored Oct 30, 2023
1 parent 08e0c4a commit f7bb53b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion scripts/exgdas_global_marine_analysis_vrfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,15 @@
config = plotConfig(grid_file=grid_file,
data_file=data_file,
lats=np.arange(-60, 60, 10),
lons=np.arange(-280, 80, 30),
variables_zonal={'Temp': [0, 2],
'Salt': [0, 0.2],
'u': [0, 0.2],
'v': [0, 0.2]},
variables_meridional={'Temp': [0, 2],
'Salt': [0, 0.2],
'u': [0, 0.2],
'v': [0, 0.2]},
variables_horiz={'Temp': [0, 2],
'Salt': [0, 0.2],
'u': [0, 0.2],
Expand All @@ -103,7 +108,7 @@
config = plotConfig(grid_file=grid_file,
data_file=data_file,
lats=np.arange(-60, 60, 10),
lons=np.arange(-280, 80, 10),
lons=np.arange(-280, 80, 30),
variables_zonal={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1]},
variables_horiz={'Temp': [-0.5, 0.5],
Expand Down
14 changes: 7 additions & 7 deletions ush/soca/soca_vrfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def plotConfig(grid_file=[],
lat=np.nan,
lats=np.arange(-60, 60, 10),
lon=np.nan,
lons=np.arange(-280, 80, 10),
lons=np.arange(-280, 80, 30),
proj='set me',
projs=['Global']):

Expand All @@ -52,8 +52,8 @@ def plotConfig(grid_file=[],
config['bounds'] = bounds
config['lats'] = lats # all the lats to plot
config['lat'] = lat # the lat being currently plotted
config['lons'] = lons
config['lon'] = lon
config['lons'] = lons # all the lons to plot
config['lon'] = lon # the lon being currently plotted
config['max depths'] = max_depths # all the max depths to plot
config['max depth'] = max_depth # the max depth currently plotted
config['horiz variables'] = variables_horiz # all the vars for horiz plots
Expand Down Expand Up @@ -159,13 +159,13 @@ def plotMeridionalSlice(config):
lon = float(config['lon'])
grid = xr.open_dataset(config['grid file'])
data = xr.open_dataset(config['fields file'])
lon_index = np.argmin(np.array(np.abs(np.squeeze(grid.lon)[:, 0]-lon)))
slice_data = np.squeeze(np.array(data[config['variable']]))[:, lon_index, :]
depth = np.squeeze(np.array(grid['h']))[:, lon_index, :]
lon_index = np.argmin(np.array(np.abs(np.squeeze(grid.lon)[0, :]-lon)))
slice_data = np.squeeze(np.array(data[config['variable']]))[:, :, lon_index]
depth = np.squeeze(np.array(grid['h']))[:, :, lon_index]
depth[np.where(np.abs(depth) > 10000.0)] = 0.0
depth = np.cumsum(depth, axis=0)
bounds = config['bounds']
y = np.tile(np.squeeze(grid.lon[:, lon_index]), (np.shape(depth)[0], 1))
y = np.tile(np.squeeze(grid.lat)[:, lon_index], (np.shape(depth)[0], 1))
fig, ax = plt.subplots(figsize=(8, 5))
plt.pcolormesh(y, -depth, slice_data,
vmin=bounds[0], vmax=bounds[1],
Expand Down

0 comments on commit f7bb53b

Please sign in to comment.