Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sec23
korte
pymagglobal
Commits
641ad641
Commit
641ad641
authored
Oct 26, 2021
by
Maximilian Schanner
Browse files
Fix scalar input for grads.
parent
86df9cd5
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
641ad641
Changelog
=========
2021-10-26 v1.1.2
-----------------
* Adapt grad functions to scalar input
2021-10-20 v1.1.1
-----------------
* Correct documentation of equi_sph
...
...
pymagglobal/__init__.py
View file @
641ad641
...
...
@@ -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
'
pymagglobal/utils.py
View file @
641ad641
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment