Skip to content

Commit 3aaaf40

Browse files
Update GP recipe 19 to view interesting window of 1980+
1 parent 53b981b commit 3aaaf40

File tree

1 file changed

+70
-34
lines changed

1 file changed

+70
-34
lines changed

docs/source/recipes/plot_19_recipe.py

Lines changed: 70 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,77 +19,113 @@
1919
# Collapse data by area mean (average over spatial dimensions)
2020
am_max = sst.collapse("area: maximum") # equivalent to "X Y: mean"
2121
am_min = sst.collapse("area: minimum") # equivalent to "X Y: mean"
22-
#am.squeeze(inplace=True)cf.seasons()
2322
print("AM SEASONAL IS", am_min, am_max)
24-
# REDUCE TO TEST
25-
am_min = am_min[-100:] # final 100 points
26-
am_max = am_max[-100:] # final 100 points
2723

28-
# Check available coordinates (already found 'dimensioncoordinate0' as the
29-
# time coordinate)
30-
###print("Available coordinates:", am.coordinates())
24+
# Reduce all timeseries down to just 1980+ since there are some data
25+
# quality issues before 1970
26+
am_max = am_max.subspace(T=cf.ge(cf.dt("1980-01-01")))
27+
am_min = am_min.subspace(T=cf.ge(cf.dt("1980-01-01")))
28+
print("FINAL FIELDS ARE", am_max, am_min)
3129

32-
###am_dim_key, am_data = am.coordinate("dimensioncoordinate0", item=True)
3330
am_sub_1 = am_min.collapse("T: mean", group=cf.mam())
3431
am_sub_2 = am_min.collapse("T: mean", group=cf.jja())
3532
am_sub_3 = am_min.collapse("T: mean", group=cf.son())
3633
am_sub_4 = am_min.collapse("T: mean", group=cf.djf())
34+
3735
am_sub_5 = am_max.collapse("T: mean", group=cf.mam())
3836
am_sub_6 = am_max.collapse("T: mean", group=cf.jja())
3937
am_sub_7 = am_max.collapse("T: mean", group=cf.son())
4038
am_sub_8 = am_max.collapse("T: mean", group=cf.djf())
4139

4240

41+
cfp.gopen(rows=2, columns=1, bottom=0.2, file="global_avg_sst_plot.png")
4342

44-
"""
45-
am_sub_1 = am.subspace(**{am_dim_key: cf.mam()})
46-
am_sub_2 = am.subspace(**{am_dim_key: cf.month(3)})
47-
am_sub_3 = am.subspace(**{am_dim_key: cf.month(4)})
48-
am_sub_4 = am.subspace(**{am_dim_key: cf.month(5)})
49-
am_sub_2 = am_sub_2 - am_sub_1
50-
am_sub_3 = am_sub_3 - am_sub_1
51-
am_sub_4 = am_sub_4 - am_sub_1
52-
"""
43+
# Put maxima subplot at top since these values are higher, given
44+
# increasing x axis
45+
xticks = list(range(1980, 2024))
46+
xlabels = [None for i in xticks]
5347

54-
55-
cfp.gopen(file="global_avg_sst_plot.png")
56-
#cfp.lineplot(
57-
# am,
58-
# color="blue",
59-
# title="Global Average Sea Surface Temperature",
60-
# ylabel="Temperature (K)",
61-
# xlabel="Time"
62-
#)
48+
cfp.gpos(1)
6349
cfp.lineplot(
64-
am_sub_1,
50+
am_max,
51+
color="grey",
52+
xlabel="",
53+
#xticks=xticks,
54+
#xticklabels=xlabels,
55+
)
56+
cfp.lineplot(
57+
am_sub_5,
6558
color="red",
59+
markeredgecolor="red",
60+
marker="o",
61+
xlabel="",
62+
#xticks=xticks,
63+
#xticklabels=xlabels,
6664
)
6765
cfp.lineplot(
68-
am_sub_2,
66+
am_sub_6,
6967
color="green",
68+
markeredgecolor="green",
69+
marker="o",
70+
xlabel="",
71+
#xticks=xticks,
72+
#xticklabels=xlabels,
7073
)
7174
cfp.lineplot(
72-
am_sub_3,
75+
am_sub_7,
7376
color="blue",
77+
markeredgecolor="blue",
78+
marker="o",
79+
xlabel="",
80+
#xticks=xticks,
81+
#xticklabels=xlabels,
7482
)
7583
cfp.lineplot(
76-
am_sub_4,
84+
am_sub_8,
7785
color="purple",
86+
markeredgecolor="purple",
87+
marker="o",
88+
xlabel="",
89+
#xticks=xticks,
90+
#xticklabels=xlabels,
7891
)
92+
93+
# Minima subplot below the maxima one
94+
cfp.gpos(2)
7995
cfp.lineplot(
80-
am_sub_5,
96+
am_min,
97+
color="grey",
98+
)
99+
#cfp.lineplot(
100+
# am,
101+
# color="blue",
102+
# title="Global Average Sea Surface Temperature",
103+
# ylabel="Temperature (K)",
104+
# xlabel="Time"
105+
#)
106+
cfp.lineplot(
107+
am_sub_1,
81108
color="red",
109+
markeredgecolor="red",
110+
marker="o"
82111
)
83112
cfp.lineplot(
84-
am_sub_6,
113+
am_sub_2,
85114
color="green",
115+
markeredgecolor="green",
116+
marker="o"
86117
)
87118
cfp.lineplot(
88-
am_sub_7,
119+
am_sub_3,
89120
color="blue",
121+
markeredgecolor="blue",
122+
marker="o"
90123
)
91124
cfp.lineplot(
92-
am_sub_8,
125+
am_sub_4,
93126
color="purple",
127+
markeredgecolor="purple",
128+
marker="o"
94129
)
130+
95131
cfp.gclose()

0 commit comments

Comments
 (0)