Skip to content

Commit 88f1fff

Browse files
committed
Colour continents by composition on field plots
1 parent 11b4ea6 commit 88f1fff

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

stagpy/plates.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from contextlib import ExitStack, suppress
44

55
import matplotlib.pyplot as plt
6+
from matplotlib import colors
67
import numpy as np
78
from scipy.signal import argrelextrema
89

@@ -196,19 +197,26 @@ def _surf_diag(snap, name):
196197
raise error.UnknownVarError(name)
197198

198199

199-
def _continents_location(snap):
200-
"""Location of continents in phi direction."""
201-
if snap.sdat.par['boundaries']['air_layer']:
202-
icont = _isurf(snap) - 6
200+
def _continents_location(snap, at_surface=True):
201+
"""Location of continents as a boolean array.
202+
203+
If at_surface is True, it is evaluated only at the surface, otherwise it is
204+
evaluated in the entire domain.
205+
"""
206+
if at_surface:
207+
if snap.sdat.par['boundaries']['air_layer']:
208+
icont = _isurf(snap) - 6
209+
else:
210+
icont = -1
203211
else:
204-
icont = -1
212+
icont = slice(None)
205213
csurf = snap.fields['c'].values[0, :, icont, 0]
206214
if snap.sdat.par['boundaries']['air_layer'] and\
207215
not snap.sdat.par['continents']['proterozoic_belts']:
208-
return (csurf >= 3) & (csurf < 4)
216+
return (csurf >= 3) & (csurf <= 4)
209217
elif (snap.sdat.par['boundaries']['air_layer'] and
210218
snap.sdat.par['continents']['proterozoic_belts']):
211-
return (csurf >= 3) & (csurf < 5)
219+
return (csurf >= 3) & (csurf <= 5)
212220
elif snap.sdat.par['tracersin']['tracers_weakcrust']:
213221
return csurf >= 3
214222
return csurf >= 2
@@ -295,14 +303,14 @@ def plot_scalar_field(step, fieldname, ridges, trenches):
295303
fig, axis, _, _ = field.plot_scalar(step, fieldname)
296304

297305
if conf.plates.continents:
298-
concfld = step.fields['c'].values[0, :, :, 0]
299-
continentsfld = np.ma.masked_where(
300-
concfld < 3, concfld) # plotting continents, to-do
301-
continentsfld = continentsfld / continentsfld
306+
c_field = np.ma.masked_where(
307+
~_continents_location(step, at_surface=False),
308+
step.fields['c'].values[0, :, :, 0])
302309
cbar = conf.field.colorbar
303310
conf.field.colorbar = False
304-
field.plot_scalar(step, 'c', continentsfld, axis,
305-
cmap='cool_r', vmin=0, vmax=0)
311+
cmap = colors.ListedColormap(["k", "g", "m"])
312+
field.plot_scalar(step, 'c', c_field, axis, cmap=cmap,
313+
norm=colors.BoundaryNorm([2, 3, 4, 5], cmap.N))
306314
conf.field.colorbar = cbar
307315

308316
# plotting velocity vectors

0 commit comments

Comments
 (0)