Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Reads data of oil spill arrival time from shipping routes to different sites and computes its monthly mean and standard deviation
Author: Thomas Dobbelaere, Earth and Life Institute, UCLouvain, Belgium
Last modified: 19 July 2022
"""
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import pyplot
import calendar
import matplotlib as mpl
months = [calendar.month_abbr[i] for i in range(1,13)]
fd = np.load("arrival_by_route.npy", allow_pickle=True).item()
routes = fd["routes"]
meanv = np.nanmean(fd["data"], axis=2)
stdv = np.nanstd(fd["data"], axis=2)
route_names = {
"Barhain" : "Barhain",
"Iran" : "Qatar-Iran",
"Ras_laffan_field": 'Ras Laffan to North Field',
"Ras_laffan": "Ras Laffan LNG export",
"Doha" : 'Doha-Mesaieed'
}
x = np.arange(len(months))
width = 0.18
offset = np.arange(-2,3)*width
clrs = mpl.cm.Reds_r(0.1 + 0.8*np.linspace(0,1,5))
fig, ax = plt.subplots(figsize=(14,7))
ibar = 0
for key,label in route_names.items():
row = routes.index(key)
ax.bar( x+offset[ibar], meanv[row], width=width, yerr=stdv[row], \
color=clrs[ibar], ecolor="k", capsize=3, label=label)
ibar += 1
ax.set_ylabel('Mean arrival time (days)', fontsize=14)
ax.set_yticklabels((0,1,2,3,4),fontsize=14)
ax.set_xticks(x)
ax.set_xticklabels(months, fontsize=14)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
for i in range(1,5):
ax.axhline(y=i, color='grey', linestyle=(0, (2, 10)))
ax.legend(loc=1, fontsize=12)
plt.savefig('mean_arrival_by_route.png', bbox_inches='tight', dpi=200)