T & S biases#

%load_ext autoreload
%autoreload 2
%%capture 
# comment above line to see details about the run(s) displayed
from misc import *
import nc_time_axis
%matplotlib inline

Drifts#

Potential temperature#

%matplotlib inline
nr=1
nc=1
fs=(9,5.5)
reg_mom = ['Global','SouthernOcean','PacificOcean','IndianOcean','AtlanticOcean','Arctic','LabSea']
matplotlib.rcParams.update({'font.size': 17})
vmax=1.5; vmin=-vmax
for m in reg_mom:
  fig, ax = plt.subplots(nrows=nr, ncols=nc, figsize=fs, sharex=False, sharey=True)

  plt.suptitle(str(m)+', Potential Temperature bias [C]', fontsize=14)
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    ds_mom = xr.open_dataset(path+case+'_thetao_drift.nc').sel(time=slice('0001-01-01', end_date))
    
    splitscale =  [0., -500., -4000]
    dummy_mom = np.ma.masked_invalid(ds_mom.sel(region=m).thetao_drift.values)
    ztplot(dummy_mom, ds_mom.time.values, ds_mom.z_l.values*-1, ignore=np.nan, splitscale=splitscale, 
           contour=True, axis=ax , title=label[i], extend='both', colormap='dunnePM', 
           autocenter=True, tunits='Year', show=False, clim=(vmin, vmax)) 
    plt.subplots_adjust(top = 0.8)
    plt.tight_layout()
_images/9a00cd568a0e98b1dcc38dcafb12b62a747ceb2af8b8103fa01c62c893593c43.png _images/8edffabc51fb75fc2041c3eef5a39d84baebba7d61363b4c6f5f778b0e22419e.png _images/25978e6334d2f69b32b7b321348d011f15b5c86dc208108261be1fabe400a41b.png _images/b8a3af2c99d24b1a57ab7487ba21f68f6d761f20e19b4c45cddbbefcb1909f97.png _images/00f545b05cb2c15235f2c4e0ab01e7878316cf57f74a81fb50d836395a3fc5e3.png _images/be27fb2e89c8070c5e63918bb856a07b38a2a02fa390c51cdc549d7069bc035c.png _images/22d96b9e1409b3fb10f11ea4729f05350fe83916f276820a76077f7324c182bd.png

Salinity#

reg_mom = ['Global','SouthernOcean','PacificOcean','IndianOcean','AtlanticOcean','Arctic','LabSea']
matplotlib.rcParams.update({'font.size': 17})
vmax=0.2; vmin=-vmax
for m in reg_mom:
  fig, ax = plt.subplots(nrows=nr, ncols=nc, figsize=fs, sharex=False, sharey=True)
  plt.suptitle(str(m)+', Salinity bias [psu]', fontsize=14)
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    ds_mom = xr.open_dataset(path+case+'_so_drift.nc').sel(time=slice('0001-01-01', end_date))
    
    splitscale =  [0., -500., -4000]
    dummy_mom = np.ma.masked_invalid(ds_mom.sel(region=m).so_drift.values)
    ztplot(dummy_mom, ds_mom.time.values, ds_mom.z_l.values*-1, ignore=np.nan, splitscale=splitscale, 
           contour=True, axis=ax , title=label[i], extend='both', colormap='dunnePM', 
           autocenter=True, tunits='Year', show=False, clim=(vmin, vmax)) 
    plt.subplots_adjust(top = 0.8)
    plt.tight_layout()
_images/288f1c3d2e5746f71bea94ca5a8338c2381cdbd2831339113677ac63e56962d0.png _images/04b07324139a124ccdf2190661ef11f0beff286ce2d5640b51a1178eff9520ee.png _images/6fc0107c3fbbf27f768f808185aa04b9ec7532c0b23782babd3b735b9292469c.png _images/c96af9385dd41603e7879caee94b9aa8697c92325faf1fc21e41cc4c244f3ac6.png _images/0ff6fb34362d596318884a40094a57b50634af3bd98dd165f76dc3a28c11c4fd.png _images/694f11ac4a70417a8a342f960d3b0024b471f7fa4143a120b46b4122e943214b.png _images/f744e3ab50a810b9fcf429f4934d655acb6c6a63e0cb802ffa6e6ba64ffaeaea.png

RMSE#

Potential Temperature#

reg_mom = ['Global','SouthernOcean','PacificOcean','IndianOcean','AtlanticOcean','Arctic','LabSea']
matplotlib.rcParams.update({'font.size': 17})
vmax=3; vmin=0
for m in reg_mom:
  fig, ax = plt.subplots(nrows=nr, ncols=nc, figsize=fs, sharex=False, sharey=True)

  plt.suptitle(str(m)+', Potential Temperature [C] RMS (model - obs)', fontsize=14)
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    ds_mom = xr.open_dataset(path+case+'_thetao_rmse.nc').sel(time=slice('0001-01-01', end_date))
    
    splitscale =  [0., -500., -4000]
    dummy_mom = np.ma.masked_invalid(ds_mom.sel(region=m).thetao_rms.values)
    ztplot(dummy_mom, ds_mom.time.values, ds_mom.z_l.values*-1, ignore=np.nan, splitscale=splitscale, 
           contour=True, axis=ax , title=label[i], extend='both', colormap='hot_r', 
           autocenter=True, tunits='Year', show=False, clim=(vmin, vmax)) 
    plt.subplots_adjust(top = 0.8)
    plt.tight_layout()
_images/13c690c1b8957e1e85032badaf02bb81e206d8a566548fc0baf5773bfe242a3a.png _images/05eb9a3bf2ce5b86f17f6c1869a6793bf91a772fbfcc76e7cf206cee55831d50.png _images/9c724f9fccccff21dce0a468a64de30890ce733dd684444ad4d714a1910b70a7.png _images/bfd1ef8567383c01520e0aa9008f883f4fca19bf3f40693b8b82c68c3ac18bf9.png _images/8d4b9f5b6447789bf6b6d2e891bcecbd233f5e8f86821960d59d20c9aa3242d2.png _images/994dc3deb06c0c405e7bf5920d7f39b301554263fe8df849414a2c456c6b26d1.png _images/9508920967408be652ff3f69ffeca6764cba62b0664bd922596bd7f223e63e3f.png

Salinity#

reg_mom = ['Global','SouthernOcean','PacificOcean','IndianOcean','AtlanticOcean','Arctic','LabSea']

vmax=0.5; vmin=0
for m in reg_mom:
  fig, ax = plt.subplots(nrows=nr, ncols=nc, figsize=fs, sharex=False, sharey=True)
  plt.suptitle(str(m)+', Salinity [psu] RMS (model - obs)', fontsize=14)
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    ds_mom = xr.open_dataset(path+case+'_so_rmse.nc').sel(time=slice('0001-01-01', end_date))
    
    splitscale =  [0., -500., -4000]
    dummy_mom = np.ma.masked_invalid(ds_mom.sel(region=m).so_rms.values)
    ztplot(dummy_mom, ds_mom.time.values, ds_mom.z_l.values*-1, ignore=np.nan, splitscale=splitscale, 
           contour=True, axis=ax , title=label[i], extend='both', colormap='hot_r', 
           autocenter=True, tunits='Year', show=False, clim=(vmin, vmax)) 
    plt.subplots_adjust(top = 0.8)
    plt.tight_layout()
_images/e8ca923d01ae1a3d3790326573ee971a385e6e6de74544f112cbbbbd81c25109.png _images/e161b885680eb4b2c693aba8471b322f05f0717224e41e58a745efed4faa6f38.png _images/5ba5589130328749a990c5cb1c34fe0da5eaa0755041cc5e1a5911cbcf6fd9a3.png _images/0375ec951ea57636d8ac75230249da864c3da716fedb7f2ccdbc44a66178e0e6.png _images/44ed4b20ffe5499a28c299111ea0d13c1c69733f449bf50dec839b817b719a1f.png _images/61f7754b280bb2e715be49bf205e69eed8c2d78920db7209bc24fa6c986581a0.png _images/e871a0bd26453a308064eef43f76694d758a324f121ef7ad8c0ce80899dca21e.png

Biases at selected vertical levels#

Potential Temperature#

# change k indice to see bias at other depths
levels=[0,1,2,5,10,15,18,20,25,30,32]
tlim=[5,7.5,7.5,5,5,5,3,2,1,1,1]

for k,t in zip(levels,tlim):
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    ds_mom_t = xr.open_dataset(path+case+'_thetao_time_mean.nc')
    if 'area_t' in dir(grd[i]):
      area = grd[i].area_t
    else:
      area = grd[i].areacello
    
    fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(12,6.5))
    temp_mom = np.ma.masked_invalid(ds_mom_t.thetao_bias[k,:].values)
  
    plt.suptitle('Temperature bias [C] at depth = {} m (level = {})'.format(ds_mom_t.z_l[k].values, k))
    xyplot(temp_mom, grd[i].geolon, grd[i].geolat, area, title=str(label[i]+' - obs'), axis=ax, 
         clim=(-t,t), nbins=100, colormap=plt.cm.bwr, centerlabels=True)
    plt.subplots_adjust(top = 0.8)
_images/fd78fc109d6cdde980395c279bdfd4a29d2f0912816ef7a44c85a8fd86818305.png _images/0f55d6f2e17132cd84c0736d2b23e498cfae5f064cd72f1b7eb6a215212577fc.png _images/5499c304bdc0c2f32f0b2b4480bae27747fd984ce32e53007866a8748f9a8f47.png _images/0d4d74037eb0dacf8de2322da7fbfa370c5c312c61a517c128d0603f826d4a9d.png _images/3a9a5d02fc0acf2bc3a0c96b211edcb12fca49afd50142082d2a7cd4d0791e74.png _images/4c7ab41d6d5815b42f102cf442ed17d86de618253b79b363eb01a0e1e800618e.png _images/4ff1096533b36d553bcbe00ed3a040193835fcc7b05182331d7c0ccc47c3a2f9.png _images/5d58bcc6807dd476bb3f6c702951d3583e68138058c4b5591602a1c0fcd19555.png _images/b64eee2b5b8907861c293bf81b245adfe0c2903df06dab0bb08060837e6428c9.png _images/cafd3eb6a79c33b1e46507f5348875fd192e8a1be16eb1737aa88d0255afff61.png _images/1b05f93d3138524ea4fc8e8bf18b01811b360294015fb09f951057bb0d71c41a.png

Salinity#

# change k indice to see bias at other depths
#levels=[0,5,10,15,20,25]
slim=[5,3,2,2,1.5,1,1,0.5,0.1,0.1,0.1]

for k,s in zip(levels,slim):
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    if 'area_t' in dir(grd[i]):
      area = grd[i].area_t
    else:
      area = grd[i].areacello
    
    ds_mom_s = xr.open_dataset(path+case+'_so_time_mean.nc')
    fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(12,6.5))
    salt_mom = np.ma.masked_invalid(ds_mom_s.so_bias[k,:].values)
    
    plt.suptitle('Salinity bias [psu] at depth = {} m (level = {})'.format(ds_mom_s.z_l[k].values, k))
    xyplot(salt_mom, grd[i].geolon, grd[i].geolat, area, title=str(label[i]+' - obs'), axis=ax, 
         clim=(-s,s), nbins=50, colormap=plt.cm.bwr, centerlabels=True)
    plt.subplots_adjust(top = 0.8)
_images/ffd133f75a520ee08242d6de54082d44dd120605e77bda15e74cb1c39e85ac05.png _images/65ab1222ec410d3b7cf6ad6786f00b69346b93d6675b45a70938c4515e937b30.png _images/c8a9c6d3acd08dc43f4983fb445b9eeaf8cafdfb2d126320a430685e61fd6033.png _images/0842fb3d20d2957146f58250c69cb1ce9b670e7a3762f5a8e2d52dcc247d820e.png _images/d70e8d36803856bf4dcb39a0f6db2c80cd32ec3b03066d3197820d5a5e564ba1.png _images/f014076a3beed2c5752b4253574dc619c7e04abb95b09dfd3b66032d4bf710f8.png _images/9bb4bef645c9b0923b42433915d784f7cfa6aa5516a0f043d13ea44f97123656.png _images/5eba76724bf6d80d145453ad174f214d8c690c9bbe23552ec0749abcedfb7558.png _images/4ec0eb88033599f8e953ca8daafadd4cee585c4c4b5bbd978ea46ccd42db80f1.png _images/03e47e046f10c0d106b727d433775baedae509658103fc5849fb99afef9d566b.png _images/679bd6202526f166b9b306b8ba7dfbc40becacb0910c41c693b544c785e7dd51.png

Zonal biases#

Potential temperature#

reg = "AtlanticOcean"
var = 'thetao_bias'
units = r'$^o$C'
regions = ['Global','MedSea','Arctic','PacificOcean',
           'AtlanticOcean','IndianOcean','SouthernOcean',
          'LabSea']
ylim_min = [-90, 30, 62, -50, -50, -50, -90, 50]
ylim_max = [ 90, 47, 90,  65,  72,  30, -35, 68 ]

cmap = plt.get_cmap('bwr')  
cmap.set_bad(color='black')  
matplotlib.rcParams.update({'font.size': 16})

for reg, j in zip(regions, range(len(regions))):
  da  = []
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    ds_mom_t = xr.open_dataset(path+case+'_thetao_time_mean.nc')
    atl = basin_code[i].sel(region=reg)
    # Set zero values to NaN
    atl = atl.where(atl != 0, np.nan)
    da.append((ds_mom_t[var] * atl).weighted(grd_xr[i].areacello.fillna(0)).mean('xh').expand_dims(case=[label[i]]).sel(yh=slice(ylim_min[j], 
                                                                                                                                 ylim_max[j])))

  combined_da = xr.concat(da, dim="case")
  col = None
  if len(combined_da) > 1:
      col = "case"
  g = combined_da.plot(x="yh", y="z_l", col=col, 
                 yincrease=False, col_wrap=2,
                figsize=(12,4), cmap=cmap, robust=True,
                cbar_kwargs={"label": reg + ', ' + var + ' ({})'.format(units)})
_images/34efeac15f1447aa29e591b062b931b486c55124d32e141c4edbcf6fb3917eba.png _images/8c76cf031b1bcc50464c98a9af36b1d5eefc3bc0051e9e98a885711c3dfe9039.png _images/ea1d57aa2f5c32e0054dcb562df8f2eb66cf51824baa4a3572866eec25f0414d.png _images/a84b2775e4c5efd6fd6ff31a4b58ffbaa474709a971044e59d9a1a435e13d775.png _images/a4338e1676500a085820ce92342e7bcbe25ffb831a44be83bf5772d2e58a247b.png _images/e8d39ec8d2d3430bb23b405ee77556a27705e4de24f276dda9f876e84a69a2cb.png _images/8ee043d8c6b0cccbb4854309c893690a473e5fc070c668944fdae149557c4cad.png _images/fc141876a0323eb51a69f82ff405243bd50e16b6c59936377a7c0d6b12bd9895.png

Salinity#

reg = "AtlanticOcean"
var = 'so_bias'
units = 'psu'
regions = ['Global','MedSea','Arctic','PacificOcean',
           'AtlanticOcean','IndianOcean','SouthernOcean',
          'LabSea']
cmap = plt.get_cmap('bwr')  
cmap.set_bad(color='black')  
matplotlib.rcParams.update({'font.size': 16})

for reg, j in zip(regions, range(len(regions))):
  #print(reg)
  da  = []
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    ds_mom_t = xr.open_dataset(path+case+'_so_time_mean.nc')
    atl = basin_code[i].sel(region=reg)
    # Set zero values to NaN
    atl = atl.where(atl != 0, np.nan)
    da.append((ds_mom_t[var] * atl).weighted(grd_xr[i].areacello.fillna(0)).mean('xh').expand_dims(case=[label[i]]).sel(yh=slice(ylim_min[j], ylim_max[j])))

  combined_da = xr.concat(da, dim="case")
  col = None
  if len(combined_da) > 1:
      col = "case"
  g = combined_da.plot(x="yh", y="z_l", col=col, 
                 yincrease=False, col_wrap=2,
                figsize=(12,4), cmap=cmap, robust=True,
                cbar_kwargs={"label": reg + ', ' + var + ' ({})'.format(units)})
_images/5eb02db3bb148827f03a250a6cf45baf1a34dda48ca77bebc1cadb049ed670cb.png _images/744721223b2c0d96b6ca0bddcbb1439177d6ffe9a12abf68a74444f581ed43fb.png _images/a19ea555c05ccf35a58b3560d90bb0f41e307cc0403566f7ba3adffafb5b641b.png _images/aeb4ff07919e242ceca2fd5e402cb076d4cabf45121075b5d447a53cbc09ffc2.png _images/df809789df1178fcaafe8fc8d95c6c6500f705b76463fd15433a457658560830.png _images/44c13b907c4ebe582ef0c44e29a89cf200cb63a305867472fd8866ec83ea7953.png _images/46bdc1ab6c4d6679eb96c97e4d662ef9570103b7419fe9ef66d5be5f44a94a38.png _images/a6dfe45d7a8d11c59eceedc889d209fac35c5983215befd0e7652cb5596ecd36.png

Meridional biases#

Potential temperature#

reg = "AtlanticOcean"
var = 'thetao_bias'
units = r'$^o$C'
regions = ['Global','MedSea','Arctic','PacificOcean',
           'AtlanticOcean','IndianOcean','SouthernOcean',
          'LabSea']
xlim_min = [-287, -10, -240, -255, -110, -287, -287, -62]
xlim_max = [ 73,   40,   40,  -68,  25,  73, 73, -42 ]
cmap = plt.get_cmap('bwr')  
cmap.set_bad(color='black')  
matplotlib.rcParams.update({'font.size': 16})

for reg, j in zip(regions, range(len(regions))):
  #print(reg)
  da  = []
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    ds_mom_t = xr.open_dataset(path+case+'_thetao_time_mean.nc')
    atl = basin_code[i].sel(region=reg)
    # Set zero values to NaN
    atl = atl.where(atl != 0, np.nan)
    da.append((ds_mom_t[var] * \
      atl).weighted(grd_xr[i].areacello.fillna(0)).mean('yh').expand_dims(case=[label[i]]).sel(xh=slice(xlim_min[j], 
                                                                                                xlim_max[j])))

  combined_da = xr.concat(da, dim="case")
  col = None
  if len(combined_da) > 1:
      col = "case"
  g = combined_da.plot(x="xh", y="z_l", col=col, 
                 yincrease=False, col_wrap=2,
                figsize=(12,4), cmap=cmap, robust=True,
                cbar_kwargs={"label": reg + ', ' + var + ' ({})'.format(units)})
_images/f3fba8fea5f80c9d4af4c3a3fa3812371fc9af81b868bcd8fe9ab41b1188f780.png _images/67ff46b370f125bcfc5ad19db5ec8f42f16c6979dccf6417b224bfd0adb66d91.png _images/7ad84969dd1d02b116c1ad836f9ba73d29458eccdffb701bbab0e573114dee05.png _images/82c1e16f6fa687c3267d8dba601dcf397b1a0cc9aa43f647404da9920ccb2d71.png _images/f7b7c3091fb6ee4426e2fdde63e59c8e576743b08f0e36fbf475352e40f6ed67.png _images/c76774efdf1aeba7513f68fa1fc657ffe99ef50ef8ca95b9b2087d57ad51f852.png _images/29ff0153485802eee2a303aee7ddfb99fc200dfbc60e3250ab9fb4f49b484623.png _images/0def11f7c8f5a74dba070ba7bb7a6d42eacd107fe4c6c0730201530203197a09.png

Salinity#

reg = "AtlanticOcean"
var = 'so_bias'
units = 'psu'
regions = ['Global','MedSea','Arctic','PacificOcean',
           'AtlanticOcean','IndianOcean','SouthernOcean',
          'LabSea']
cmap = plt.get_cmap('bwr')  
cmap.set_bad(color='black')  
matplotlib.rcParams.update({'font.size': 16})

for reg, j in zip(regions, range(len(regions))):
  #print(reg)
  da  = []
  for path, case, i in zip(ocn_path, casename, range(len(casename))):
    ds_mom_t = xr.open_dataset(path+case+'_so_time_mean.nc')
    atl = basin_code[i].sel(region=reg)
    # Set zero values to NaN
    atl = atl.where(atl != 0, np.nan)
    da.append((ds_mom_t[var] * \
      atl).weighted(grd_xr[i].areacello.fillna(0)).mean('yh').expand_dims(case=[label[i]]).sel(xh=slice(xlim_min[j], 
                                                                                               xlim_max[j])))

  combined_da = xr.concat(da, dim="case")
  col = None
  if len(combined_da) > 1:
      col = "case"
  g = combined_da.plot(x="xh", y="z_l", col=col, 
                 yincrease=False, col_wrap=2,
                figsize=(12,4), cmap=cmap, robust=True,
                cbar_kwargs={"label": reg + ', ' + var + ' ({})'.format(units)})
_images/37ba26a177113dd26e2fc4ca21e34c1cd1a8e2f10f370df4aa367c10da4170f6.png _images/abfe1f55b2c398d8163614310e757e2116c18ba0c8495fbe658f0bafd4113372.png _images/d13e0ed15c70da2dc2be13797a230d153cdf2462701557e664cf760c3cc15aa9.png _images/fa770c1f1da63f8500e0abac15603866a30e0bc612d9e96d13c17ebb66be58e4.png _images/d3fe7849544b06bc07665acafe05139b321be73ca97b561695c62cb16b38b7e7.png _images/e1f126f9955d2c702ab6f55650ebb09419dd70b3ae22d47e8b63c70f0bd17ad6.png _images/8c4798775deb1a8e83fc0015eb3a21795f8ae6f1619471ad317ab11748773c30.png _images/64779d38810eddb2809c9923bafb05d245d35487fb0320029938ba2bbdc8bbd2.png