|
3 | 3 | from contextlib import ExitStack, suppress |
4 | 4 |
|
5 | 5 | import matplotlib.pyplot as plt |
| 6 | +from matplotlib import colors |
6 | 7 | import numpy as np |
7 | 8 | from scipy.signal import argrelextrema |
8 | 9 |
|
@@ -196,19 +197,26 @@ def _surf_diag(snap, name): |
196 | 197 | raise error.UnknownVarError(name) |
197 | 198 |
|
198 | 199 |
|
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 |
203 | 211 | else: |
204 | | - icont = -1 |
| 212 | + icont = slice(None) |
205 | 213 | csurf = snap.fields['c'].values[0, :, icont, 0] |
206 | 214 | if snap.sdat.par['boundaries']['air_layer'] and\ |
207 | 215 | not snap.sdat.par['continents']['proterozoic_belts']: |
208 | | - return (csurf >= 3) & (csurf < 4) |
| 216 | + return (csurf >= 3) & (csurf <= 4) |
209 | 217 | elif (snap.sdat.par['boundaries']['air_layer'] and |
210 | 218 | snap.sdat.par['continents']['proterozoic_belts']): |
211 | | - return (csurf >= 3) & (csurf < 5) |
| 219 | + return (csurf >= 3) & (csurf <= 5) |
212 | 220 | elif snap.sdat.par['tracersin']['tracers_weakcrust']: |
213 | 221 | return csurf >= 3 |
214 | 222 | return csurf >= 2 |
@@ -295,14 +303,14 @@ def plot_scalar_field(step, fieldname, ridges, trenches): |
295 | 303 | fig, axis, _, _ = field.plot_scalar(step, fieldname) |
296 | 304 |
|
297 | 305 | 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]) |
302 | 309 | cbar = conf.field.colorbar |
303 | 310 | 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)) |
306 | 314 | conf.field.colorbar = cbar |
307 | 315 |
|
308 | 316 | # plotting velocity vectors |
|
0 commit comments