Skip to content

Commit

Permalink
Fix spline signs
Browse files Browse the repository at this point in the history
  • Loading branch information
bendudson committed Aug 3, 2024
1 parent fe21db9 commit 521ec7e
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions hypnotoad/geqdsk/_geqdsk.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,10 @@ def write(data, fh, label=None, shot=None, time=None):
sign = -1.0 if psi1D[1] < psi1D[0] else 1.0
# spline fitting requires increasing X axis, so reverse if needed

fprime_spl = (
sign
* interpolate.InterpolatedUnivariateSpline(
sign * psi1D, data["fpol"]
).derivative()
)
ffprime = data["fpol"] * fprime_spl(psi1D)
fprime_spl = interpolate.InterpolatedUnivariateSpline(
sign * psi1D, sign * data["fpol"]
).derivative()
ffprime = data["fpol"] * fprime_spl(sign * psi1D)
write_1d(ffprime, co)

if "pprime" in data:
Expand All @@ -158,13 +155,10 @@ def write(data, fh, label=None, shot=None, time=None):
from scipy import interpolate

sign = -1.0 if psi1D[1] < psi1D[0] else 1.0
pprime_spl = (
sign
* interpolate.InterpolatedUnivariateSpline(
sign * psi1D, data["pres"]
).derivative()
)
write_1d(pprime_spl(psi1D), co)
pprime_spl = interpolate.InterpolatedUnivariateSpline(
sign * psi1D, sign * data["pres"]
).derivative()
write_1d(pprime_spl(sign * psi1D), co)

write_2d(data["psi"], co)
write_1d(data["qpsi"], co)
Expand Down

0 comments on commit 521ec7e

Please sign in to comment.