Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f7294dc

Browse files
committedAug 2, 2023
Merge branch 'doku_rework' of https://github.com/magpylib/magpylib into doku_rework
2 parents 180a34f + 1ca1d02 commit f7294dc

18 files changed

+792
-3
lines changed
 

‎docs/_pages/gallery/gallery_tutorial_custom.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ import magpylib as magpy
3434

3535
While each of these features can be used individually, the combination of the two (own source class with own 3D representation) enables a high level of customization in Magpylib. Such user-defined objects will feel like native Magpylib objects and can be used in combination with all other features, which is demonstrated in the following example:
3636

37+
<<<<<<< HEAD:docs/examples/examples_04_custom_source.md
38+
The class `CustomSource` allows users to integrate their own custom-object field computation into the Magpylib interface. For this, the argument `field_func` must be provided with a function that is then automatically called with `getB` and `getH`. This custom field function is treated like a core function. It must have the positional arguments `field` (with values `'B'` or `'H'`), and `observers` (must accept array_like, shape (n,3)) and return the B-field in units of mT and the H-field in units of kA/m with a similar shape. A fundamental example how to create a custom source object is shown below:
39+
=======
40+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c:docs/_pages/gallery/gallery_tutorial_custom.md
3741
3842
```{code-cell} ipython3
3943
import numpy as np
@@ -136,7 +140,7 @@ ax2.set(
136140
ylabel='z-position (mm)',
137141
aspect=1,
138142
)
139-
fig.colorbar(cp, label='[$charge/mm^2$]', ax=ax2)
143+
fig.colorbar(cp, label='($charge/mm^2$)', ax=ax2)
140144
141145
plt.tight_layout()
142146
plt.show()

‎docs/_pages/page_01_introduction.md

+679
Large diffs are not rendered by default.

‎magpylib/_src/display/backend_matplotlib.py

+8
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ def draw_frame(frame_ind):
286286
constructor = tr["constructor"]
287287
args = tr.get("args", ())
288288
kwargs = tr.get("kwargs", {})
289+
<<<<<<< HEAD
290+
getattr(ax, constructor)(*args, **kwargs)
291+
ax.set(
292+
**{f"{k}label": f"{k} (mm)" for k in "xyz"},
293+
**{f"{k}lim": r for k, r in zip("xyz", ranges)},
294+
)
295+
=======
289296
if frame_ind == 0:
290297
if row_col_num not in count_with_labels:
291298
count_with_labels[row_col_num] = 0
@@ -318,6 +325,7 @@ def draw_frame(frame_ind):
318325
)
319326
else:
320327
ax.legend(loc="best")
328+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
321329

322330
def animate(ind): # pragma: no cover
323331
for ax in axes.values():

‎magpylib/_src/fields/field_BH_cylinder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def fieldH_cylinder_diametral(
8787
dim: ndarray, shape (n,2)
8888
dimension of cylinder (d, h), diameter and height, in units of mm
8989
tetta: ndarray, shape (n,)
90-
angle between magnetization vector and x-axis in [rad]. M = (cos(tetta), sin(tetta), 0)
90+
angle between magnetization vector and x-axis in rad. M = (cos(tetta), sin(tetta), 0)
9191
obs_pos: ndarray, shape (n,3)
9292
position of observer (r,phi,z) in cylindrical coordinates in units of mm and rad
9393
@@ -410,7 +410,7 @@ def magnet_cylinder_field(
410410
# dim: ndarray, shape (n,2)
411411
# dimension of cylinder (d, h), diameter and height, in units of mm
412412
# tetta: ndarray, shape (n,)
413-
# angle between magnetization vector and x-axis in [rad]. M = (cos(tetta), sin(tetta), 0)
413+
# angle between magnetization vector and x-axis in rad. M = (cos(tetta), sin(tetta), 0)
414414
# obs_pos: ndarray, shape (n,3)
415415
# position of observer (r,phi,z) in cylindrical coordinates in units of mm and rad
416416
# niter: int

‎magpylib/_src/fields/field_BH_cylinder_segment.py

+8
Original file line numberDiff line numberDiff line change
@@ -2140,11 +2140,19 @@ def magnet_cylinder_segment_core(
21402140
Parameters
21412141
----------
21422142
mag: ndarray, shape (n,3)
2143+
<<<<<<< HEAD
2144+
magnetization vector (M, phi, th) in spherical CS, units: mT rad
2145+
obs_pos : ndarray, shape (n,3)
2146+
observer positions (r,phi,z) in cy CS, units: mm rad
2147+
dim: ndarray, shape (n,6)
2148+
segment dimensions (r1,r2,phi1,phi2,z1,z2) in cy CS , units: mm rad
2149+
=======
21432150
magnetization vector (M, phi, th) in spherical CS, units: mT, rad
21442151
obs_pos : ndarray, shape (n,3)
21452152
observer positions (r,phi,z) in cy CS, units: mm rad
21462153
dim: ndarray, shape (n,6)
21472154
segment dimensions (r1,r2,phi1,phi2,z1,z2) in cy CS , units: mm, rad
2155+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
21482156
21492157
Returns
21502158
-------

‎magpylib/_src/fields/field_wrap_BH.py

+8
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ def getB(
543543
output="ndarray",
544544
**kwargs,
545545
):
546+
<<<<<<< HEAD
547+
"""Compute B-field in mT for given sources and observers.
548+
=======
546549
"""Compute B-field in units of mT for given sources and observers.
550+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
547551

548552
Field implementations can be directly accessed (avoiding the object oriented
549553
Magpylib interface) by providing a string input `sources=source_type`, array_like
@@ -647,7 +651,11 @@ def getB(
647651

648652
Examples
649653
--------
654+
<<<<<<< HEAD
655+
In this example we compute the B-field (mT) of a spherical magnet and a current loop
656+
=======
650657
In this example we compute the B-field in units of mT of a spherical magnet and a current loop
658+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
651659
at the observer position (1,1,1) given in units of mm:
652660

653661
>>> import magpylib as magpy

‎magpylib/_src/obj_classes/class_BaseExcitations.py

+8
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ def magnetization(self):
202202

203203
@magnetization.setter
204204
def magnetization(self, mag):
205+
<<<<<<< HEAD
206+
"""Set magnetization vector, array_like, shape (3,), unit (mT)."""
207+
=======
205208
"""Set magnetization vector, array_like, shape (3,), unit mT."""
209+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
206210
self._magnetization = check_format_input_vector(
207211
mag,
208212
dims=(1,),
@@ -229,7 +233,11 @@ def current(self):
229233

230234
@current.setter
231235
def current(self, current):
236+
<<<<<<< HEAD
237+
"""Set current value, scalar, unit (A)."""
238+
=======
232239
"""Set current value, scalar, unit A."""
240+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
233241
# input type and init check
234242
self._current = check_format_input_scalar(
235243
current,

‎magpylib/_src/obj_classes/class_Sensor.py

+8
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ def getB(
152152
Examples
153153
--------
154154
Sensors are observers for magnetic field computation. In this example we compute the
155+
<<<<<<< HEAD
156+
B-field (mT) as seen by the sensor in the center of a circular current loop:
157+
=======
155158
B-field in units of mT as seen by the sensor in the center of a circular current loop:
159+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
156160
157161
>>> import magpylib as magpy
158162
>>> sens = magpy.Sensor()
@@ -227,7 +231,11 @@ def getH(
227231
Examples
228232
--------
229233
Sensors are observers for magnetic field computation. In this example we compute the
234+
<<<<<<< HEAD
235+
H-field (kA/m) as seen by the sensor in the center of a circular current loop:
236+
=======
230237
H-field in kA/m as seen by the sensor in the center of a circular current loop:
238+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
231239
232240
>>> import magpylib as magpy
233241
>>> sens = magpy.Sensor()

‎magpylib/_src/obj_classes/class_current_Line.py

+8
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ class Line(BaseCurrent):
4545
4646
Examples
4747
--------
48+
<<<<<<< HEAD
49+
`Line` objects are magnetic field sources. In this example we compute the H-field (kA/m)
50+
=======
4851
`Line` objects are magnetic field sources. In this example we compute the H-field kA/m
52+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
4953
of a square-shaped line-current with 1 A current at the observer position (1,1,1) given in
5054
units of mm:
5155
@@ -118,5 +122,9 @@ def vertices(self):
118122

119123
@vertices.setter
120124
def vertices(self, vert):
125+
<<<<<<< HEAD
126+
"""Set Line vertices, array_like, (mm)."""
127+
=======
121128
"""Set Line vertices, array_like, mm."""
129+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
122130
self._vertices = check_format_input_vertices(vert)

‎magpylib/_src/obj_classes/class_current_Loop.py

+8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ class Loop(BaseCurrent):
4444
4545
Examples
4646
--------
47+
<<<<<<< HEAD
48+
`Loop` objects are magnetic field sources. In this example we compute the H-field (kA/m)
49+
=======
4750
`Loop` objects are magnetic field sources. In this example we compute the H-field kA/m
51+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
4852
of such a current loop with 100 A current and a diameter of 2 mm at the observer position
4953
(1,1,1) given in units of mm:
5054
@@ -104,7 +108,11 @@ def diameter(self):
104108

105109
@diameter.setter
106110
def diameter(self, dia):
111+
<<<<<<< HEAD
112+
"""Set Loop loop diameter, float, (mm)."""
113+
=======
107114
"""Set Loop loop diameter, float, mm."""
115+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
108116
self._diameter = check_format_input_scalar(
109117
dia,
110118
sig_name="diameter",

‎magpylib/_src/obj_classes/class_magnet_Cuboid.py

+4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ class Cuboid(BaseMagnet):
4545
4646
Examples
4747
--------
48+
<<<<<<< HEAD
49+
`Cuboid` magnets are magnetic field sources. Below we compute the H-field (kA/m) of a
50+
=======
4851
`Cuboid` magnets are magnetic field sources. Below we compute the H-field in kA/m of a
52+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
4953
cubical magnet with magnetization (100,200,300) in units of mT and 1 mm sides
5054
at the observer position (1,1,1) given in units of mm:
5155

‎magpylib/_src/obj_classes/class_magnet_Cylinder.py

+4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ class Cylinder(BaseMagnet):
4545
4646
Examples
4747
--------
48+
<<<<<<< HEAD
49+
`Cylinder` magnets are magnetic field sources. Below we compute the H-field (kA/m) of a
50+
=======
4851
`Cylinder` magnets are magnetic field sources. Below we compute the H-field in kA/m of a
52+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
4953
cylinder magnet with magnetization (100,200,300) in units of mT and 1 mm diameter and height
5054
at the observer position (1,1,1) given in units of mm:
5155

‎magpylib/_src/obj_classes/class_magnet_CylinderSegment.py

+4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ class CylinderSegment(BaseMagnet):
5858
Examples
5959
--------
6060
`CylinderSegment` magnets are magnetic field sources. In this example we compute the
61+
<<<<<<< HEAD
62+
H-field (kA/m) of such a cylinder segment magnet with magnetization (100,200,300)
63+
=======
6164
H-field kA/m of such a cylinder segment magnet with magnetization (100,200,300)
65+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
6266
in units of mT, inner radius 1 mm, outer radius 2 mm, height 1 mm, and
6367
section angles 0 and 45 deg at the observer position (2,2,2) in units of mm:
6468

‎magpylib/_src/obj_classes/class_magnet_Sphere.py

+8
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ class Sphere(BaseMagnet):
4545
4646
Examples
4747
--------
48+
<<<<<<< HEAD
49+
`Sphere` objects are magnetic field sources. In this example we compute the H-field (kA/m)
50+
=======
4851
`Sphere` objects are magnetic field sources. In this example we compute the H-field kA/m
52+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
4953
of a spherical magnet with magnetization (100,200,300) in units of mT and diameter
5054
of 1 mm at the observer position (1,1,1) given in units of mm:
5155
@@ -105,7 +109,11 @@ def diameter(self):
105109

106110
@diameter.setter
107111
def diameter(self, dia):
112+
<<<<<<< HEAD
113+
"""Set Sphere diameter, float, (mm)."""
114+
=======
108115
"""Set Sphere diameter, float, mm."""
116+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
109117
self._diameter = check_format_input_scalar(
110118
dia,
111119
sig_name="diameter",

‎magpylib/_src/obj_classes/class_magnet_Tetrahedron.py

+11
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,17 @@ class Tetrahedron(BaseMagnet):
5454
5555
Examples
5656
--------
57+
<<<<<<< HEAD
58+
`Tetrahedron` magnets are magnetic field sources. Below we compute the H-field (kA/m) of a
59+
tetrahedron magnet with magnetization (100,200,300) in units of mT dimensions defined
60+
through the vertices (0,0,0), (1,0,0), (0,1,0) and (0,0,1) in units of mm at the
61+
observer position (1,1,1) given in units of m:
62+
=======
5763
`Tetrahedron` magnets are magnetic field sources. Below we compute the H-field in kA/m of a
5864
tetrahedron magnet with magnetization (100,200,300) in units of mT dimensions defined
5965
through the vertices (0,0,0), (1,0,0), (0,1,0) and (0,0,1) in units of mm at the
6066
observer position (1,1,1) given in units of mm:
67+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
6168
6269
>>> import magpylib as magpy
6370
>>> verts = [(0,0,0), (1,0,0), (0,1,0), (0,0,1)]
@@ -117,7 +124,11 @@ def vertices(self):
117124

118125
@vertices.setter
119126
def vertices(self, dim):
127+
<<<<<<< HEAD
128+
"""Set Tetrahedron vertices (a,b,c), shape (3,), mm."""
129+
=======
120130
"""Set Tetrahedron vertices (a,b,c), shape (3,), (mm)."""
131+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
121132
self._vertices = check_format_input_vector(
122133
dim,
123134
dims=(2,),

‎magpylib/_src/obj_classes/class_magnet_TriangularMesh.py

+4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ class TriangularMesh(BaseMagnet):
3838
the local object coordinates (rotates with object).
3939
4040
vertices: ndarray, shape (n,3)
41+
<<<<<<< HEAD
42+
A set of points in units of m in the local object coordinates from which the
43+
=======
4144
A set of points in units of mm in the local object coordinates from which the
45+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
4246
triangular faces of the mesh are constructed by the additional `faces`input.
4347
4448
faces: ndarray, shape (n,3)

‎magpylib/_src/obj_classes/class_misc_Dipole.py

+6
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ class Dipole(BaseSource):
4343
4444
Examples
4545
--------
46+
<<<<<<< HEAD
47+
`Dipole` objects are magnetic field sources. In this example we compute the H-field (kA/m)
48+
of such a magnetic dipole with a moment of (100,100,100) mT*mm^2 at an observer position
49+
(1,1,1) given in units of mm:
50+
=======
4651
`Dipole` objects are magnetic field sources. In this example we compute the H-field kA/m
4752
of such a magnetic dipole with a moment of (100,100,100) in units of mT*mm^2 at an
4853
observer position (1,1,1) given in units of mm:
54+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
4955
5056
>>> import magpylib as magpy
5157
>>> src = magpy.misc.Dipole(moment=(100,100,100))

‎magpylib/_src/obj_classes/class_misc_Triangle.py

+9
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ class Triangle(BaseMagnet):
5555
5656
Examples
5757
--------
58+
<<<<<<< HEAD
59+
`Triangle` objects are magnetic field sources. Below we compute the H-field (kA/m) of a
60+
Triangle object with magnetization (100,200,300) in units of mT dimensions defined
61+
=======
5862
`Triangle` objects are magnetic field sources. Below we compute the H-field in kA/m of a
5963
Triangle object with magnetization (100,200,300) in units of mT, dimensions defined
64+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
6065
through the vertices (0,0,0), (1,0,0) and (0,1,0) in units of mm at the
6166
observer position (1,1,1) given in units of mm:
6267
@@ -118,7 +123,11 @@ def vertices(self):
118123

119124
@vertices.setter
120125
def vertices(self, val):
126+
<<<<<<< HEAD
127+
"""Set face vertices (a,b,c), shape (3,3), (mm)."""
128+
=======
121129
"""Set face vertices (a,b,c), shape (3,3), mm."""
130+
>>>>>>> 0ad604af38a3349f58f35e8e8e911c4eb2961e3c
122131
self._vertices = check_format_input_vector(
123132
val,
124133
dims=(2,),

0 commit comments

Comments
 (0)
Please sign in to comment.