Commit 641ad641 authored by Maximilian Schanner's avatar Maximilian Schanner
Browse files

Fix scalar input for grads.

parent 86df9cd5
Changelog
=========
2021-10-26 v1.1.2
-----------------
* Adapt grad functions to scalar input
2021-10-20 v1.1.1
-----------------
* Correct documentation of equi_sph
......
......@@ -46,4 +46,4 @@ from pymagglobal.core import local_curve, dipole_series, file2splines, \
Model
from pymagglobal import utils
__version__ = '1.1.1'
__version__ = '1.1.2'
......@@ -42,26 +42,47 @@ def _nicelabel(label):
def grad_d(n, e, z):
'''Calculate the gradient of D.
'''
n = np.atleast_1d(n)
e = np.atleast_1d(e)
z = np.atleast_1d(z)
res = np.column_stack((-e, n, np.zeros_like(n)))
res /= (n**2 + e**2)[:, np.newaxis]
if res.shape[0] == 1:
res = res.flatten()
return np.rad2deg(res)
def grad_i(n, e, z):
'''Calculate the gradient of I.
'''
n = np.atleast_1d(n)
e = np.atleast_1d(e)
z = np.atleast_1d(z)
res = -np.column_stack((n, e, z)) \
* z[:, np.newaxis]
res /= (n**2 + e**2 + z**2)[:, np.newaxis]
res[:, 2] += 1.
res /= np.sqrt(n**2 + e**2)[:, np.newaxis]
if res.shape[0] == 1:
res = res.flatten()
return np.rad2deg(res)
def grad_f(n, e, z):
n = np.atleast_1d(n)
e = np.atleast_1d(e)
z = np.atleast_1d(z)
'''Calculate the gradient of F '''
res = np.column_stack((n, e, z))
res /= np.sqrt(n**2 + e**2 + z**2)[:, np.newaxis]
if res.shape[0] == 1:
res = res.flatten()
return res
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment