Commit 71c66a5d authored by Clément Haëck's avatar Clément Haëck
Browse files

Up median cli plot

parent 707a1f5c
......@@ -8,6 +8,7 @@ import lib
import as lh
import Plots.util as plot_util
args = dict(region='GS', days=1)
fixes = dict(
......@@ -31,15 +32,10 @@ ds = ds.load()
N = lh.get_N(ds).sel(var='CHL').reset_coords(drop=True)
frac = N / N.sum('mask') * 100.
ds['frac'] = frac.reset_coords(drop=True)
ds['frac'] = frac
pdf = lh.get_pdf(ds)
ds['med'] = lh.get_median(pdf).load()
# T = lh.get_total(ds.hist_CHL)
# T_img = (T.sel(mask='bkg') +'bkg', var='CHL')
# * N.sel(mask='frt', var='CHL'))
# ds['surplus'] = (T.sum('mask') - T_img) / T.sum('mask') * 100.
ds = ds.drop_vars(['hist_CHL', 'hist_sst'])
clis = lh.get_climatology(ds)
......@@ -57,14 +53,17 @@ def plot(cli, cli_d1, cli_d9, ax, var, sel, color='k', ls='-'):
ax.plot(cli.time, get(cli), color=color, ls=ls)
ax.fill_between(cli.time.values, get(cli_d1), get(cli_d9),
color=color, alpha=.4)
color=color, alpha=.3)
cset = tc.tol_cset('vibrant')
colors = dict(low='red', mid='blue', hi='teal')
colors = {m: getattr(cset, c) for m, c in colors.items()}
fig, axes = plt.subplots(3, 3, figsize=(10.8, 6), sharex=True)
fig, axes = plt.subplots(3, 3, figsize=(10, 6), sharex=True)
fig.subplots_adjust(left=0.06, bottom=0.05, right=0.98, top=0.95,
hspace=0.1, wspace=0.2)
hspace=0.1, wspace=0.15)
for ax in axes.flat:
......@@ -74,36 +73,33 @@ for ax in axes.flat:
for i, var in enumerate(['sst', 'CHL']):
for j, zone in enumerate(loop_zones()):
sel = dict(zone=zone, var=var)
sel['mask'] = 'low'
plot(*clis, axes[i, j], 'med', sel, color=cset.cyan)
sel['mask'] = 'mid'
plot(*clis, axes[i, j], 'med', sel,
sel['mask'] = 'hi'
plot(*clis, axes[i, j], 'med', sel,
for m, c in colors.items():
sel['mask'] = m
plot(*clis, axes[i, j], 'med', sel, color=c)
for j, zone in enumerate(loop_zones()):
sel = dict(zone=zone)
sel['mask'] = 'mid'
plot(*clis, axes[2, j], 'frac', sel,
sel['mask'] = 'hi'
plot(*clis, axes[2, j], 'frac', sel,
for m in ['mid', 'hi']:
sel['mask'] = m
plot(*clis, axes[2, j], 'frac', sel, color=colors[m])
axes[2, j].set_ylim(0, 60)
plt.setp(axes[2, j].xaxis.get_majorticklabels(), ha='left')
axes[0, 0].set_xlim(*(clis[0].time[[0, -1]].values))
axes[0, 0].set_ylabel('SST [°C]')
axes[1, 0].set_ylabel('CHL [mg/m³]')
axes[2, 0].set_ylabel('Fronts surface [%]')
axes[0, 0].set_ylabel(plot_util.SST_LABEL)
axes[1, 0].set_ylabel(plot_util.CHL_LABEL)
axes[2, 0].set_ylabel('Fronts surface [\%]')
axes[0, 0].set_title('SOUTH')
axes[0, 1].set_title('JET')
axes[0, 2].set_title('NORTH')
axes[0, 0].set_title('South')
axes[0, 1].set_title('Jet')
axes[0, 2].set_title('North')
labels = ['Front', 'Background']
handles = [plt.Line2D((), (), ls='-',,
plt.Line2D((), (), ls='-', color=cset.teal)]
fig.legend(handles, labels, bbox_to_anchor=[0.50, 0.78], loc='upper left',
labels = ['Low', 'Med', 'Hi']
handles = [plt.Line2D((), (), ls='-', color=c) for c in colors.values()]
fig.legend(handles, labels, bbox_to_anchor=[0.52, 0.78], loc='upper left',
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