Skip to content

Commit 40389e4

Browse files
committed
Only compute icont where needed
1 parent e7ac14a commit 40389e4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

stagpy/plates.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def detect_plates(step, vrms_surface, fids, time):
7272
vphi = step.fields['v2'].values[0, :, :, 0]
7373
ph_coord = step.geom.p_centers
7474

75-
indsurf, _ = _isurf_icont(step)
75+
indsurf = _isurf(step)
7676

7777
# vphi at cell-center
7878
vph2 = 0.5 * (vphi[1:] + vphi[:-1])
@@ -162,21 +162,18 @@ def plot_plate_limits_field(axis, rcmb, ridges, trenches):
162162
arrowprops=dict(facecolor='green', shrink=0.05))
163163

164164

165-
def _isurf_icont(snap):
166-
"""Return index of surface and of continent detection."""
165+
def _isurf(snap):
166+
"""Return index of surface accounting for air layer."""
167167
if snap.sdat.par['boundaries']['air_layer']:
168168
dsa = snap.sdat.par['boundaries']['air_thickness']
169169
# we are a bit below the surface; delete "-some number" to be just
170170
# below the surface (that is considered plane here); should check if
171171
# in the thermal boundary layer
172172
isurf = np.argmin(
173173
np.abs(1 - dsa - snap.geom.r_centers + snap.geom.rcmb)) - 4
174-
# depth to detect the continents
175-
icont = isurf - 6
176174
else:
177175
isurf = -1
178-
icont = -1
179-
return isurf, icont
176+
return isurf
180177

181178

182179
def _surf_diag(snap, name):
@@ -185,7 +182,7 @@ def _surf_diag(snap, name):
185182
Can be a sfield, a regular scalar field evaluated at the surface,
186183
or dv2 (which is dvphi/dphi).
187184
"""
188-
isurf, _ = _isurf_icont(snap)
185+
isurf = _isurf(snap)
189186
with suppress(error.UnknownVarError):
190187
return snap.sfields[name]
191188
with suppress(error.UnknownVarError):
@@ -201,7 +198,10 @@ def _surf_diag(snap, name):
201198

202199
def _continents_location(snap):
203200
"""Location of continents in phi direction."""
204-
isurf, icont = _isurf_icont(snap)
201+
if snap.sdat.par['boundaries']['air_layer']:
202+
icont = _isurf(snap) - 6
203+
else:
204+
icont = -1
205205
csurf = snap.fields['c'].values[0, :, icont, 0]
206206
if snap.sdat.par['boundaries']['air_layer'] and\
207207
not snap.sdat.par['continents']['proterozoic_belts']:
@@ -340,7 +340,7 @@ def main_plates(sdat):
340340
# averaged horizontal surface velocity needed for redimensionalisation
341341
uprof_averaged, radius, _ = sdat.walk.filter(rprofs=True)\
342342
.rprofs_averaged['vhrms']
343-
isurf, _ = _isurf_icont(next(iter(sdat.walk)))
343+
isurf = _isurf(next(iter(sdat.walk)))
344344
vrms_surface = uprof_averaged[isurf]
345345

346346
# determine names of files

0 commit comments

Comments
 (0)