Skip to content

Commit a012e57

Browse files
Choose better colourmap and time snapshot for recipe 20
1 parent f75a3cb commit a012e57

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

docs/source/recipes/plot_20_recipe.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
# Now we need to use some means to condense the u and v fields in the same way into
1818
# having 1 time point, not 720 - for example we can just pick a time value out:
19-
chosen_time = "2006-01-16 00:00:00"
19+
print("Times are", v.construct("T").data.datetime_as_string)
20+
chosen_time = "2006-01-15 23:30:00" # 720 choices to choose from!
2021
v_1 = v.subspace(T=cf.dt(chosen_time))
2122
u_1 = u.subspace(T=cf.dt(chosen_time))
2223
v_1 = v_1.squeeze()
@@ -32,8 +33,6 @@
3233
# Note that there appear to be some really large vectors all pointing in the
3334
# same direction which are spamming the plot. We need to remove these. By
3435
# looking at the data we can see what these are and work out how to remove them:
35-
print(u.data)
36-
print(u[:10].data.array)
3736

3837
# ... shows more of the array
3938

@@ -52,21 +51,16 @@
5251
# This field also needs masking for those data points.
5352
w_2 = w_1.where(cf.lt(-9e+03), cf.masked)
5453
print(w_2)
55-
print(w_2, w_2[:10].data.array)
54+
55+
56+
# Plot divergence in the background
57+
div = cf.div_xy(u_2, v_2, radius="earth")
58+
5659

5760
# Our final basic plot:
5861
cfp.mapset(resolution="10m") # makes UK coastline more high-res
59-
cfp.gopen(file="irish-sea-currents.png")
60-
# BTW ignore the warnings below - they aren't relevant.
61-
cfp.vect(u=u_2, v=v_2, stride=5, scale=2, key_length=1)
62-
cfp.levs(min=-5, max=5, step=0.5)
63-
cfp.con(w_1, blockfill=True, lines=False)
62+
cfp.gopen(file=f"irish-sea-currents-with-divergence-{chosen_time}.png")
63+
cfp.cscale("ncl_default")
64+
cfp.vect(u=u_2, v=v_2, stride=6, scale=3, key_length=1)
65+
cfp.con(div, lines=False)
6466
cfp.gclose()
65-
66-
# Ideas for TODOs:
67-
# investigate difference days (do this by changing the 'T=cf.dt("2006-01-16 00:00:00")') datetime
68-
# values to different ones in the time coordinate data so you look at different days, or repace it
69-
# with a collapse over some stat e.g. mean to show the mean over all the times,
70-
# calculate divergence, calculate curl / relative voriticity, calculate absolute voriticity,
71-
# explore the other dataset as well (that covers other dates/times) - you could compare the
72-
# two to effectively compare the currents across different dates.

0 commit comments

Comments
 (0)