Skip to content

Instantly share code, notes, and snippets.

View jbusecke's full-sized avatar

Julius Busecke jbusecke

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
ds_sigma_map = ds_sigma.sel(
time='2000-01',
sigma_0=26.6,
method='nearest'
).sel(y=slice(-90,0)).squeeze()
import cartopy.crs as ccrs
import matplotlib.path as mpath
import cartopy.feature as cfeature
ds_sigma_section = ds_sigma.sel(
time='2010-01',
y=slice(-90,10)
).interp(x=230).squeeze()
fig, axarr = plt.subplots(nrows=2, figsize=[10,8], sharex=True)
for ax, var, cmap in zip(
axarr.flat,
['so', 'cfc11'],
[cmo.haline, cmo.matter]
# Lets do the same thing with cfcs and package them into a dataset
cfc_sigma = grid.transform(
ds.cfc11,
'Z',
target_values,
target_data=ds.sigma_0)
ds_sigma = xr.Dataset({'cfc11':cfc_sigma, 'so':so_sigma})
ds_sigma
so_sigma = grid.transform(
ds.so,
'Z',
target_values,
target_data=ds.sigma_0
)
so_sigma
target_values = levels=np.arange(24.2,28, 0.2)
# create the grid object
from xgcm import Grid
grid = Grid(
ds,
periodic=False,
coords={'Z':{'center':'lev', 'outer':'lev_outer'}})
grid
@jbusecke
jbusecke / pb5.py
Last active October 29, 2020 15:20
fig, axarr = plt.subplots(nrows=3, figsize=[10,12], sharex=True)
for ax, var, cmap in zip(
axarr.flat,
['thetao', 'so', 'cfc11'],
[cmo.thermal, cmo.haline, cmo.matter]
):
kwargs = dict(yincrease=False, x='lat', y='lev', ax=ax)
# Plot a section along the dateline in 1980 in the southern ocean
@jbusecke
jbusecke / pb4.py
Last active October 29, 2020 15:22
ds_section = ds.sel(
time='2010-01',
y=slice(-90,10),
lev=slice(0,1500)
).interp(x=230).squeeze()
from fastjmd95 import rho
ds['sigma_0'] = rho(ds.so, ds.thetao, 0) - 1000