In [1]:
import warnings
warnings.filterwarnings('ignore')
import iris
import iris.plot as iplt
import numpy
import matplotlib.pyplot as plt
import glob
In [2]:
model = 'EC-Earth3-Veg'
In [3]:
wm_file_pattern = '/g/data/r87/dbi599/zika/water-mass_Omon_%s_historical_*.nc' %(model)
wm_file = glob.glob(wm_file_pattern)[0]
In [4]:
vcube_tbin = iris.load_cube(wm_file, 'Ocean Grid-Cell Volume binned by temperature')
print(vcube_tbin.summary(shorten=True))
In [5]:
vscube_tbin = iris.load_cube(wm_file, "Sea Water Salinity times Ocean Grid-Cell Volume binned by temperature")
print(vscube_tbin.summary(shorten=True))
In [6]:
so_profiles = vscube_tbin / vcube_tbin
print(so_profiles.summary(shorten=True))
In [7]:
plt.plot(so_profiles.data[0, :, 0], so_profiles.coord('sea_water_potential_temperature').points,
color='red', label='North Atlantic')
plt.plot(so_profiles.data[0, :, 1], so_profiles.coord('sea_water_potential_temperature').points,
color='gold', label='South Atlantic')
plt.plot(so_profiles.data[0, :, 2], so_profiles.coord('sea_water_potential_temperature').points,
color='blue', label='North Pacific')
plt.plot(so_profiles.data[0, :, 3], so_profiles.coord('sea_water_potential_temperature').points,
color='cyan', label='South Atlantic')
plt.plot(so_profiles.data[0, :, 4], so_profiles.coord('sea_water_potential_temperature').points,
color='green', label='Indian')
plt.xlabel('salinity (g/kg)')
plt.ylabel('temperature (C)')
plt.legend()
plt.show()
In [8]:
vcube_sbin = iris.load_cube(wm_file, 'Ocean Grid-Cell Volume binned by salinity')
print(vcube_sbin.summary(shorten=True))
In [9]:
vtcube_sbin = iris.load_cube(wm_file, "Sea Water Potential Temperature times Ocean Grid-Cell Volume binned by salinity")
print(vtcube_sbin.summary(shorten=True))
In [10]:
thetao_profiles = vtcube_sbin / vcube_sbin
print(thetao_profiles.summary(shorten=True))
In [11]:
thetao_profiles[0, :, 0]
Out[11]:
In [12]:
thetao_profiles.coord('sea_water_salinity').points[3: -3]
Out[12]:
In [13]:
iplt.plot(thetao_profiles[0, 3:-3, 0], color='red', label='North Atlantic')
iplt.plot(thetao_profiles[0, 3:-3, 1], color='gold', label='South Atlantic')
iplt.plot(thetao_profiles[0, 3:-3, 2], color='blue', label='North Pacific')
iplt.plot(thetao_profiles[0, 3:-3, 3], color='cyan', label='South Atlantic')
iplt.plot(thetao_profiles[0, 3:-3, 4], color='green', label='Indian')
plt.xlabel('salinity (g/kg)')
plt.ylabel('temperature (C)')
plt.legend()
plt.show()
In [14]:
iplt.plot(vcube_sbin[0, 3:-3, 0], color='red', label='North Atlantic')
iplt.plot(vcube_sbin[0, 3:-3, 1], color='gold', label='South Atlantic')
iplt.plot(vcube_sbin[0, 3:-3, 2], color='blue', label='North Pacific')
iplt.plot(vcube_sbin[0, 3:-3, 3], color='cyan', label='South Atlantic')
iplt.plot(vcube_sbin[0, 3:-3, 4], color='green', label='Indian')
plt.xlabel('salinity (g/kg)')
plt.ylabel('volume (m3)')
plt.legend()
plt.show()
In [14]:
wfo_hist_pattern = '/g/data/r87/dbi599/zika/wfo-tos-binned_Omon_%s_historical_*.nc' %(model)
wfo_hist_file = glob.glob(wfo_hist_pattern)[0]
In [15]:
wfo_hist_cube = iris.load_cube(wfo_hist_file, 'water_flux_into_sea_water')
print(wfo_hist_cube.summary(shorten=True))
In [16]:
fig = plt.figure(figsize=[10, 7])
plt.axhline(y=0, color='0.5')
iplt.plot(wfo_hist_cube[0, :, 0], label='North Atlantic')
iplt.plot(wfo_hist_cube[0, :, 1], label='South Atlantic')
iplt.plot(wfo_hist_cube[0, :, 2], label='North Pacific')
iplt.plot(wfo_hist_cube[0, :, 3], label='South Pacific')
iplt.plot(wfo_hist_cube[0, :, 4], label='Indian')
plt.legend()
plt.xlabel('sea surface temperature')
plt.ylabel('water flux into sea water (kg s-1)')
plt.title('%s (year 1850)' %(model))
plt.show()
In [60]:
vol_pattern = '/g/data/r87/dbi599/zika/volo-tsdist_Omon_%s_historical_*.nc' %(model)
vol_file = glob.glob(vol_pattern)[0]
vol_cube = iris.load_cube(vol_file)
print(vol_cube.summary(shorten=True))
In [61]:
vol_cube.data.sum()
Out[61]:
In [62]:
def plot_basin(vol_cube, salinity_cube, basin_name):
"""Plot at volume distribution."""
x_values = vol_cube.coord('sea_water_salinity').points
y_values = vol_cube.coord('sea_water_potential_temperature').points
extents = [x_values[0], x_values[-1], y_values[0], y_values[-1]]
basin_dict = {'north_atlantic': 0, 'south_atlantic': 1,
'north_pacific': 2, 'south_pacific': 3,
'indian': 4, 'arctic': 5, 'marginal_seas_and_land': 6}
log_hist = numpy.log(vol_cube.data[:, :, basin_dict[basin_name]]).T
plt.figure(figsize=(9, 8))
plt.imshow(log_hist, origin='lower', extent=extents, aspect='auto', cmap='hot_r')
cb = plt.colorbar()
cb.set_label('log(volume), $m^3 (^\circ C \; g/kg)^{-1}$')
sprofile = salinity_cube.data[-1, :, basin_dict[basin_name]]
plt.plot(sprofile, salinity_cube.coord('sea_water_potential_temperature').points)
plt.xlim(x_values[0], x_values[-1])
plt.title(basin_name)
plt.xlabel('salinity (g/kg)')
plt.ylabel('temperature (C)')
plt.show()
In [63]:
plot_basin(vol_cube, so_profiles, 'north_atlantic')
In [10]:
plot_basin(vol_cube, so_profiles, 'south_atlantic')
In [11]:
plot_basin(vol_cube, so_profiles, 'north_pacific')
In [12]:
plot_basin(vol_cube, so_profiles, 'south_pacific')
In [13]:
plot_basin(vol_cube, so_profiles, 'indian')
In [17]:
area_file = '/g/data/r87/dbi599/CMIP6/CMIP/CCCma/CanESM5/historical/r1i1p1f1/Omon/areao/gn/v20190429/areao-tsdist_Omon_CanESM5_historical_r1i1p1f1_gn_2005-2014-monthly-clim.nc'
area_cube = iris.load_cube(area_file)
print(area_cube.summary(shorten=True))
In [20]:
awm_files = glob.glob('/g/data/r87/dbi599/CMIP6/CMIP/CCCma/CanESM5/historical/r1i1p1f1/Omon/water-mass/gn/v20190429/surface-water-mass_Omon_CanESM5_historical_r1i1p1f1_gn_*.nc')
awm_files.sort()
In [21]:
acube = iris.load_cube(awm_files[-1], 'cell_area')
print(acube.summary(shorten=True))
In [24]:
#ascube = iris.load_cube(awm_files[-1], "Sea Water Salinity times Grid-Cell Area")
ascube = iris.load_cube(awm_files[-1], "Sea Water Salinity times Grid-Cell Area for Ocean Variables")
print(ascube.summary(shorten=True))
In [25]:
sos_profiles = ascube / acube
print(sos_profiles.summary(shorten=True))
In [26]:
def plot_surface_basin(area_cube, salinity_cube, basin_name):
"""Plot the surface layer area distribution."""
x_values = area_cube.coord('sea_water_salinity').points
y_values = area_cube.coord('sea_water_potential_temperature').points
extents = [x_values[0], x_values[-1], y_values[0], y_values[-1]]
basin_dict = {'north_atlantic': 0, 'south_atlantic': 1,
'north_pacific': 2, 'south_pacific': 3,
'indian': 4, 'arctic': 5, 'marginal_seas_and_land': 6}
log_hist = numpy.log(area_cube.data[:, :, basin_dict[basin_name]]).T
#hist = area_cube.data[:, :, basin_dict[basin_name]].T
plt.figure(figsize=(9, 8))
plt.imshow(log_hist, origin='lower', extent=extents, aspect='auto', cmap='hot_r')
cb = plt.colorbar()
cb.set_label('log(area), $m^2 (^\circ C \; g/kg)^{-1}$')
sprofile = salinity_cube.data[-1, :, basin_dict[basin_name]]
plt.plot(sprofile, salinity_cube.coord('sea_water_potential_temperature').points)
plt.xlim(x_values[0], x_values[-1])
plt.title(basin_name)
plt.xlabel('salinity (g/kg)')
plt.ylabel('temperature (C)')
plt.show()
In [27]:
plot_surface_basin(area_cube, sos_profiles, 'north_atlantic')
In [28]:
plot_surface_basin(area_cube, sos_profiles, 'south_atlantic')
In [29]:
plot_surface_basin(area_cube, sos_profiles, 'north_pacific')
In [30]:
plot_surface_basin(area_cube, sos_profiles, 'south_pacific')
In [31]:
plot_surface_basin(area_cube, sos_profiles, 'indian')