Last active
June 15, 2021 20:54
-
-
Save AntSimi/57163b5bd1958ec3768c2c0b59339df7 to your computer and use it in GitHub Desktop.
Ocean scale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot as plt | |
from matplotlib.patches import Ellipse | |
import numpy as np | |
period = dict( | |
second=1, | |
minute=10, | |
hour=1e2, | |
day=1e3, | |
week=1e4, | |
month=1e5, | |
year=1e6 | |
) | |
events = { | |
"mesoscale and\nshorther scale\nand\nphysical-biological\ninteraction" : ( | |
(1, 1e5), | |
(.5 * period['day'], 1 * period['year']), | |
(100, None) | |
), | |
"internal waves\nand\ninertial motions" : ( | |
(1, 1e4), | |
(1 * period['minute'], 2 * period['day']), | |
(50, None) | |
), | |
"submesoscale" : ( | |
(1e2, 1e4), | |
(period['hour'], period['day']), | |
(None, None) | |
), | |
"rossby\nwaves" : ( | |
(6e4, 1e7), | |
(1 * period['week'], 50 * period['year']), | |
(1e5, 10 * period['year']) | |
), | |
"climate\nchange" : ( | |
(1e5, 1e7), | |
(10 * period['year'], 1e4 * period['year']), | |
(None, None) | |
), | |
"basin scale\nvariability" : ( | |
(1e6, 1e7), | |
(2 * period['year'], 1e2 * period['year']), | |
(None, None) | |
), | |
"el nino" : ( | |
(1e5, 1e7), | |
(2 * period['year'], 10 * period['year']), | |
(None, None) | |
), | |
"seasonal\ncycle" : ( | |
(1e5, 1e7), | |
(.5 * period['year'], 3 * period['year']), | |
(None, None) | |
), | |
"barotropic\nvariability" : ( | |
(1e5, 1e7), | |
(5 * period['day'], 1 * period['year']), | |
(None, None) | |
), | |
# "eddies\nand\nfronts" : ( | |
# (5e3, 5e5), | |
# (1 * period['week'], 2 * period['year']), | |
# (None, None) | |
# ), | |
"mesoscale" : ( | |
(1e4, 1e6), | |
(period['week'], period['year']), | |
(None, None) | |
), | |
# "coastal\nupwelling" : ( | |
# (1e3, 1e5), | |
# (1 * period['day'], 1 * period['year']), | |
# (None, None) | |
# ), | |
"internal tides" : ( | |
(5e2, 1e5), | |
(.5 * period['day'], 1.5 * period['day']), | |
(None, None) | |
), | |
"surface tides" : ( | |
(5e4, 5e6), | |
(.5 * period['day'], 1.5 * period['day']), | |
(None, None) | |
), | |
"med\nsea":( | |
(8e3,15e3), | |
(period['week'], period['year']), | |
(None, None) | |
) | |
# "vertical\nturbulent\nmixing" : ( | |
# (5e-3, 10), | |
# (.5 * period['second'], 1 * period['hour']), | |
# (None, None) | |
# ), | |
# "surface\ngravity waves" : ( | |
# (1e-1, 1e2), | |
# (1 * period['second'], 1 * period['minute']), | |
# (None, None) | |
# ), | |
# "capilary\nwaves" : ( | |
# (1e-3, 2e-2), | |
# (.5 * period['second'], 2 * period['second']), | |
# (None, None) | |
# ), | |
# "molecular\nprocesses" : ( | |
# (1e-5, 1e-1), | |
# (1e-2 * period['second'], .5 * period['minute']), | |
# (None, None) | |
# ), | |
} | |
fig = plt.figure(figsize=(8,8), dpi=300) | |
ax = fig.add_subplot(111) | |
ax.set_xscale('log'), ax.set_yscale('log') | |
yticks = [ | |
(.1 * period['second'], '0.1sec'), | |
(period['second'], '1sec'), | |
(period['minute'], '1min'), | |
(period['hour'], '1hr'), | |
(period['day'], '1d'), | |
(period['week'], '1wk'), | |
(period['month'], '1mon'), | |
(period['year'], '1yr'), | |
(10 * period['year'], '10yr'), | |
(1e2 * period['year'], '100yr'), | |
(1e3 * period['year'], '1000yr'), | |
(1e4 * period['year'], '10000yr'), | |
] | |
yticks, ylabel = [i[0] for i in yticks], [i[1] for i in yticks] | |
ax.set_yticks(yticks), ax.set_yticklabels(ylabel) | |
xticks = [ | |
(1e-3, '1mm'), | |
(1e-2, '1cm'), | |
(1e-1, '10cm'), | |
(1, '1m'), | |
(10, '10m'), | |
(1e2, '100m'), | |
(1e3, '1km'), | |
(1e4, '10km'), | |
(1e5, '100km'), | |
(1e6, '1000km'), | |
(1e7, '10000km'), | |
(1e8, '100000km'), | |
] | |
xticks, xlabel = [i[0] for i in xticks], [i[1] for i in xticks] | |
ax.set_xticks(xticks), ax.set_xticklabels(xlabel) | |
ax.set_xlim(10, 1e7), ax.set_ylim(period['hour'] * .5, period['year'] * 1000) | |
cmap = plt.get_cmap('Spectral') | |
nb_event = len(events) | |
for i, (event, (x_range, y_range, (x_text, y_text))) in enumerate(events.items()): | |
((x0, y0), (x1, y1)) = ax.transData.transform([(x,y) for x, y in zip(x_range, y_range)]) | |
x, y = (x0 + x1) / 2, (y0 + y1) / 2 | |
if i % 2 == 0: | |
color = cmap(i / 2 /nb_event) | |
else: | |
color = cmap(1-i/2/nb_event) | |
e = Ellipse(xy=(x,y), width=x1-x0, height=y1-y0, transform=None, alpha=.7, color=color, clip_on=False) | |
ax.add_artist(e) | |
if x_text is None: | |
x_text = x | |
else: | |
x_text = ax.transData.transform([(x_text, 1e-12)])[0][0] | |
if y_text is None: | |
y_text = y | |
else: | |
y_text = ax.transData.transform([(1e-12, y_text)])[0][1] | |
ax.text(x_text,y_text, event.capitalize(), transform=None, horizontalalignment='center', verticalalignment='center') | |
ax.spines['top'].set_visible(False) | |
ax.spines['right'].set_visible(False) | |
ax.spines['left'].set_visible(False) | |
ax.spines['bottom'].set_visible(False) | |
ax.minorticks_off() | |
fig.savefig('ocean_scale.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment