Skip to content

Commit

Permalink
Try to make splines more periodic
Browse files Browse the repository at this point in the history
The RectBivariateSpline does not support periodic data, but by including
copies on the left and on the right, the spline will be closer to periodic.
  • Loading branch information
dschwoerer committed Nov 25, 2024
1 parent 086f89c commit 8a89e1d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions zoidberg/poloidal_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ def __init__(self, R, Z):
self.nz = nz

xinds = np.arange(nx)
zinds = np.arange(nz + 1)
zinds = np.arange(nz * 3)
# Repeat the final point in y since periodic in y
R_ext = np.concatenate((R, np.reshape(R[:, 0], (nx, 1))), axis=1)
Z_ext = np.concatenate((Z, np.reshape(Z[:, 0], (nx, 1))), axis=1)
R_ext = np.concatenate((R, R, R), axis=1)
Z_ext = np.concatenate((Z, Z, Z), axis=1)

self._spl_r = RectBivariateSpline(xinds, zinds, R_ext)
self._spl_z = RectBivariateSpline(xinds, zinds, Z_ext)
Expand Down Expand Up @@ -330,8 +330,8 @@ def getCoordinate(self, xind, zind, dx=0, dz=0):
# Periodic in y
zind = np.remainder(zind, nz)

R = self._spl_r(xind, zind, dx=dx, dy=dz, grid=False)
Z = self._spl_z(xind, zind, dx=dx, dy=dz, grid=False)
R = self._spl_r(xind, zind + self.nz, dx=dx, dy=dz, grid=False)
Z = self._spl_z(xind, zind + self.nz, dx=dx, dy=dz, grid=False)

return R, Z

Expand Down

0 comments on commit 8a89e1d

Please sign in to comment.