Skip to content

Commit

Permalink
adding titles to vrfy plots (#578)
Browse files Browse the repository at this point in the history
* first pass at adding titles to vrfy plots

* python style

* some streamlining

* mv gsw before vader

---------

Co-authored-by: Guillaume Vernieres <[email protected]>
  • Loading branch information
AndrewEichmann-NOAA and guillaumevernieres authored Aug 24, 2023
1 parent 074f26a commit 57e2a50
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ if(BUILD_GDASBUNDLE)
ecbuild_bundle( PROJECT gsibec GIT "https://github.com/GEOS-ESM/GSIbec.git" TAG 1.1.2 )
endif()

# Gibbs seawater
ecbuild_bundle( PROJECT gsw GIT "https://github.com/jcsda-internal/GSW-Fortran.git" BRANCH develop )

# Core JEDI repositories
ecbuild_bundle( PROJECT oops GIT "https://github.com/jcsda/oops.git" BRANCH develop )
ecbuild_bundle( PROJECT vader GIT "https://github.com/jcsda/vader.git" BRANCH develop )
Expand All @@ -92,7 +95,6 @@ if(BUILD_GDASBUNDLE)
if ( BUILD_ICEPACK )
ecbuild_bundle( PROJECT icepack GIT "https://github.com/JCSDA-internal/Icepack.git" BRANCH feature/ecbuild-new )
endif()
ecbuild_bundle( PROJECT gsw GIT "https://github.com/jcsda-internal/GSW-Fortran.git" BRANCH develop )
ecbuild_bundle( PROJECT mom6 GIT "https://github.com/jcsda-internal/MOM6.git" BRANCH main-ecbuild RECURSIVE )
ecbuild_bundle( PROJECT soca GIT "https://github.com/jcsda-internal/soca.git" BRANCH develop )

Expand Down
1 change: 1 addition & 0 deletions scripts/exgdas_global_marine_analysis_vrfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
diagdir = os.path.join(comout, 'diags')
HOMEgfs = os.getenv('HOMEgfs')


#######################################
# ocean increment
#######################################
Expand Down
42 changes: 31 additions & 11 deletions ush/soca/soca_vrfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
def plotConfig(grid_file=[],
data_file=[],
variable=[],
PDY=os.getenv('PDY'),
cyc=os.getenv('cyc'),
exp=os.getenv('PSLOT'),
levels=[],
bounds=[],
colormap=[],
Expand All @@ -38,6 +41,9 @@ def plotConfig(grid_file=[],
config['comout'] = comout # output directory
config['grid file'] = grid_file
config['fields file'] = data_file
config['PDY'] = PDY
config['cyc'] = cyc
config['exp'] = exp
config['levels'] = [1]
config['colormap'] = colormap
config['bounds'] = bounds
Expand All @@ -63,15 +69,22 @@ def plotHorizontalSlice(config):
dirname = os.path.join(config['comout'], config['variable'])
os.makedirs(dirname, exist_ok=True)

if config['variable'] in ['Temp', 'Salt', 'u', 'v']:
variable = config['variable']
exp = config['exp']
PDY = config['PDY']
cyc = config['cyc']

if variable in ['Temp', 'Salt', 'u', 'v']:
level = config['levels'][0]
slice_data = np.squeeze(data[config['variable']])[level, :, :]
label_colorbar = config['variable']+' Level '+str(level)
figname = os.path.join(dirname, config['variable']+'_Level_'+str(level))
slice_data = np.squeeze(data[variable])[level, :, :]
label_colorbar = variable+' Level '+str(level)
figname = os.path.join(dirname, variable+'_Level_'+str(level))
title = f"{exp} {PDY} {cyc} {variable} Level {level}"
else:
slice_data = np.squeeze(data[config['variable']])
label_colorbar = config['variable']
figname = os.path.join(dirname, config['variable']+'_'+config['proj'])
slice_data = np.squeeze(data[variable])
label_colorbar = variable
figname = os.path.join(dirname, variable+'_'+config['proj'])
title = f"{exp} {PDY} {cyc} {variable}"

bounds = config['bounds']

Expand All @@ -86,6 +99,7 @@ def plotHorizontalSlice(config):
plt.colorbar(label=label_colorbar, shrink=0.5, orientation='horizontal')
ax.coastlines() # TODO: make this work on hpc
ax.gridlines(draw_labels=True)
ax.set_title(title)
if config['proj'] == 'South':
ax.set_extent([-180, 180, -90, -50], ccrs.PlateCarree())
if config['proj'] == 'North':
Expand All @@ -98,11 +112,15 @@ def plotZonalSlice(config):
"""
pcolormesh of a zonal slice of an ocean field
"""
variable = config['variable']
exp = config['exp']
PDY = config['PDY']
cyc = config['cyc']
lat = float(config['lat'])
grid = xr.open_dataset(config['grid file'])
data = xr.open_dataset(config['fields file'])
lat_index = np.argmin(np.array(np.abs(np.squeeze(grid.lat)[:, 0]-lat)))
slice_data = np.squeeze(np.array(data[config['variable']]))[:, lat_index, :]
slice_data = np.squeeze(np.array(data[variable]))[:, lat_index, :]
depth = np.squeeze(np.array(grid['h']))[:, lat_index, :]
depth[np.where(np.abs(depth) > 10000.0)] = 0.0
depth = np.cumsum(depth, axis=0)
Expand All @@ -112,11 +130,13 @@ def plotZonalSlice(config):
plt.pcolormesh(x, -depth, slice_data,
vmin=bounds[0], vmax=bounds[1],
cmap=config['colormap'])
plt.colorbar(label=config['variable']+' Lat '+str(lat), shrink=0.5, orientation='horizontal')
plt.colorbar(label=variable+' Lat '+str(lat), shrink=0.5, orientation='horizontal')
ax.set_ylim(-config['max depth'], 0)
dirname = os.path.join(config['comout'], config['variable'])
title = f"{exp} {PDY} {cyc} {variable} lat {int(lat)}"
ax.set_title(title)
dirname = os.path.join(config['comout'], variable)
os.makedirs(dirname, exist_ok=True)
figname = os.path.join(dirname, config['variable'] +
figname = os.path.join(dirname, variable +
'zonal_lat_'+str(int(lat)) + '_' + str(int(config['max depth'])) + 'm')
plt.savefig(figname, bbox_inches='tight', dpi=600)

Expand Down

0 comments on commit 57e2a50

Please sign in to comment.