Commit 812b23e4 authored by Clément Haëck's avatar Clément Haëck
Browse files

Up separation plot

parent 2e750c53
from os import path
from cmocean import cm
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
import tol_colors as tc
import lib
import lib.data.ostia
import lib.data.globcolour
import lib.data.SN_separation
import lib.data.hi
import lib.data.p_frt_mask
plt.switch_backend('agg')
fixes = dict(
Y=2007
Y=2007,
# m=1,
# d=1,
number=2,
scale=30.,
coef=0,
)
threshold_S = 6.0
threshold_N = 15.0
SS_lat = 32.
odir = path.join(lib.root_plot, 'SN_separation')
st = lib.data.ostia.get_data(fixes=fixes)
thr = lib.data.SN_separation.get_data(fixes=fixes)
st['thr'] = lib.data.SN_separation.smooth(thr, 8)
st = st.isel(time=slice(None, None, 10))
st = st.sel(lat=slice(30, None))
st['GS_N'] = st.analysed_sst > st.thr
im_kw = dict(
add_labels=False,
vmin=0,
cmap='inferno'
)
hatch_kw = dict(
add_labels=False,
add_colorbar=False,
alpha=0.,
levels=[0, 0.5],
hatches=['', '. .']
)
oc = lib.data.globcolour.get_data(fixes=fixes, days=8)
hi = lib.data.hi.get_data(fixes=fixes)
st, hi = lib.fix_time_daily(st, hi)
st, oc, hi = xr.align(st, oc, hi, exclude=['lon', 'lat'])
mask = lib.data.p_frt_mask.get_data(fixes=dict(threshold=1e-2)).mask
cset = tc.tol_cset('bright')
for i, d in enumerate(st.time.dt.strftime('%F').values):
fig, ax = plt.subplots(figsize=(5, 5))
fig.subplots_adjust(left=0.05, bottom=0.05, right=0.98, top=0.98)
im = st.analysed_sst.isel(time=i).plot.imshow(ax=ax, **im_kw)
st.GS_N.isel(time=i).plot.contourf(ax=ax, **hatch_kw)
ax.set_aspect('equal')
fig, axes = plt.subplots(1, 3, figsize=(10.7, 3.1), sharex=True, sharey=True)
fig.subplots_adjust(left=0.03, bottom=0.07, right=0.99, top=0.90,
wspace=0.05)
ax1, ax2, ax3 = axes
sst = st.isel(time=i)
chl = oc.isel(time=i)
hit = hi.isel(time=i)
ax2.set_title(sst.time.dt.strftime('%F').values)
HI = lib.data.hi.apply_coef(hit, lib.data.hi.get_coef(fixes))
frt = HI > threshold_N
frt = frt.where(sst.analysed_sst < sst.thr, HI > threshold_S)
frt = frt.where(np.isfinite(sst.analysed_sst))
frt = frt.where(mask)
sst.analysed_sst.plot.imshow(ax=ax1, cmap=cm.thermal, center=False,
add_labels=False)
chl.CHL.plot.imshow(ax=ax2, cmap=cm.algae,
norm=plt.cm.colors.LogNorm(1e-2, 10),
add_labels=False)
frt.plot.imshow(ax=ax3, cmap='Greens',
add_labels=False, add_colorbar=False)
np.isfinite(sst.analysed_sst).plot.contour(
ax=ax3, add_colorbar=False, add_labels=False,
colors='k', linewidths=0.5)
for ax in axes:
sst.analysed_sst.plot.contour(ax=ax, levels=[sst.thr.values],
add_colorbar=False, add_labels=False,
linewidths=0.5, colors=cset.purple)
ax.axhline(SS_lat, color=cset.purple, lw=0.5)
ax.set_aspect('equal')
fig.canvas.draw()
fig.savefig(path.join(odir, '{}.png'.format(d)), dpi=250)
plt.close(fig)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment