Skip to content

Commit 9c1fd95

Browse files
committed
New _Geometry.at_r method
1 parent 9506170 commit 9c1fd95

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

stagpy/_step.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,21 @@ def at_z(self, zval):
167167
"""Return iz closest to given zval position.
168168
169169
In spherical geometry, the bottom boundary is considered to be at z=0.
170+
Use :func:`~_step._Geometry.at_r` to find a cell at a given radial
171+
position.
170172
"""
171173
if self.curvilinear:
172174
zval += self.rcmb
173175
return np.argmin(np.abs(self.z_coord - zval))
174176

177+
def at_r(self, rval):
178+
"""Return ir closest to given rval position.
179+
180+
If called in cartesian geometry, this is equivalent to
181+
:func:`~_step._Geometry.at_z`.
182+
"""
183+
return np.argmin(np.abs(self.r_coord - rval))
184+
175185
def __getattr__(self, attr):
176186
# provide nDtot, D_coord, D_mesh and nbtot
177187
# with D = x, y, z or t, p, r

0 commit comments

Comments
 (0)