Skip to content

Commit 5584098

Browse files
committed
Documentation of plates API
1 parent 0b42556 commit 5584098

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

docs/sources/apiref/plates.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ plates
22
======
33

44
.. automodule:: stagpy.plates
5-
:members: cmd
5+
:members:

stagpy/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ def _index_collection(arg):
180180
CONF_DEF['plates'] = OrderedDict((
181181
('plot',
182182
Conf('c.T.v2-v2.dv2-v2.topo_top', True, 'o',
183-
{'nargs': '?', 'const': '', 'type': str},
184-
True, 'variables to plot (see stagpy var)')),
183+
{'nargs': '?', 'const': '', 'type': str}, True,
184+
'variables to plot, can be a surface field, field, or dv2')),
185185
('field',
186186
Conf('eta', True, None, {},
187187
True, 'field variable to plot with plates info')),

stagpy/plates.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
def _vzcheck(iphis, snap, vz_thres):
18-
"""Detect plates and check with vz and plate size."""
18+
"""Remove positions where vz is below threshold."""
1919
# verifying vertical velocity
2020
vzabs = np.abs(snap.fields['v3'].values[0, ..., 0])
2121
argdel = []
@@ -28,7 +28,20 @@ def _vzcheck(iphis, snap, vz_thres):
2828

2929
@lru_cache()
3030
def detect_plates(snap, vz_thres_ratio=0):
31-
"""Detect plates using derivative of horizontal velocity."""
31+
"""Detect plate limits using derivative of horizontal velocity.
32+
33+
This function is cached for convenience.
34+
35+
Args:
36+
snap (:class:`~stagpy._step.Step`): a step of a StagyyData instance.
37+
vz_thres_ratio (float): if above zero, an addition check based on the
38+
vertical velocities is performed. Limits detected above a region
39+
where the vertical velocity is below vz_thres_ratio * mean(vzabs)
40+
are ignored.
41+
Returns:
42+
tuple of :class:`numpy.array`: itrenches, iridges
43+
1D arrays containing phi-index of detected trenches and ridges.
44+
"""
3245
dvphi = _surf_diag(snap, 'dv2').values
3346

3447
# finding trenches
@@ -157,7 +170,15 @@ def _continents_location(snap, at_surface=True):
157170

158171

159172
def plot_at_surface(snap, names):
160-
"""Plot surface diagnostics."""
173+
"""Plot surface diagnostics.
174+
175+
Args:
176+
snap (:class:`~stagpy._step.Step`): a step of a StagyyData instance.
177+
names (str): names of requested surface diagnotics. They are separated
178+
by ``-`` (figures), ``.`` (subplots) and ``,`` (same subplot).
179+
Surface diagnotics can be valid surface field names, field names,
180+
or `"dv2"` which is d(vphi)/dphi.
181+
"""
161182
for vfig in list_of_vars(names):
162183
fig, axes = plt.subplots(nrows=len(vfig), sharex=True,
163184
figsize=(12, 2 * len(vfig)))
@@ -246,7 +267,13 @@ def _write_trench_diagnostics(step, vrms_surf, fid):
246267

247268

248269
def plot_scalar_field(snap, fieldname):
249-
"""Plot scalar field with plate information."""
270+
"""Plot scalar field with plate information.
271+
272+
Args:
273+
snap (:class:`~stagpy._step.Step`): a step of a StagyyData instance.
274+
fieldname (str): name of the field that should be decorated with plate
275+
informations.
276+
"""
250277
fig, axis, _, _ = field.plot_scalar(snap, fieldname)
251278

252279
if conf.plates.continents:

0 commit comments

Comments
 (0)