Python API
oersted
Python bindings for oersted
BHCurve
dataclass
B-H curve for a nonlinear magnetic material
Source code in src/oersted/materials.py
11 12 13 14 15 16 17 18 19 20 21 | |
lookup
lookup(h: float) -> float
Linearly interpolate from the B-H curve
Source code in src/oersted/materials.py
18 19 20 21 | |
CentroidMesh
A finite element mesh represented solely by the centroidal values of the elements
This is used in the point source calculations. It is an approximation, but
extremely fast and accurate for far field or force calculations.
Source code in src/oersted/mesh.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
centroids
property
centroids: NDArray[float64]
Return an (N,3) array of the centroid position of each element in the mesh
num_elems
property
num_elems: int
Return the number of elements in the mesh
volumes
property
volumes: NDArray[float64]
Return an (N,) array of the volume of each element
DirectSolver
Bases: Solver
Controls solver options for using the direct (full integration) solution routines
Source code in src/oersted/solver.py
46 47 48 49 50 51 52 53 54 55 56 57 | |
FreeSpace
dataclass
Bases: Material
Source code in src/oersted/materials.py
38 39 40 41 42 | |
mu_r
mu_r(h: float) -> float
Free space (vacuum) has a relative permeability of exactly 1.0
Source code in src/oersted/materials.py
40 41 42 | |
LinearMaterial
dataclass
Bases: Material
A linear magnetic material that has a constant mu_r for all values of applied H-field.
Source code in src/oersted/materials.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
mu_r
mu_r(h: float)
Return the relative magnetic permeability
Source code in src/oersted/materials.py
56 57 58 | |
to_mh_curve
to_mh_curve() -> tuple[NDArray[float64], NDArray[float64]]
Convert the B-H curve to an M-H curve, which is more convenient for magnetization calculations
Source code in src/oersted/materials.py
60 61 62 63 64 65 | |
Mesh
A continuous finite element mesh made of tet4 elements
Source code in src/oersted/mesh.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
centroids
property
centroids: NDArray[float64]
Returns an (N,3) array of all element centroids in the mesh
connectivity
property
connectivity: NDArray[uint32]
Returns an (N,4) array of the node numbers associated with each element
Node numbers are indices into the self._nodes array
edges
property
edges
Returns an (N,2) array of edges in the model
Each value in the array is a node number associated with that edge. The first node is the start node, the second is the end node. This provides directionality for the edge.
faces
property
faces
Returns an (N,3) array of nodes associated with each element face in the model
Nodes are ordered such that the right hand rule forms the face normal.
nodes
property
nodes: NDArray[float64]
Returns an (N,3) array of nodal coordinates in the mesh
num_elems
property
num_elems: int
Returns the number of elements in the model
num_nodes
property
num_nodes: int
Returns the number of nodes in the model
surface
property
surface: SurfaceMesh
Return the surface mesh associated with the volumetric mesh
volumes
property
volumes: NDArray[float64]
Return an (N,) array of the volume of each element in the mesh
append
append(mesh: Mesh) -> Mesh
Convenience function for appending two meshes together.
Source code in src/oersted/mesh.py
274 275 276 277 278 279 280 281 | |
from_step
classmethod
from_step(
filename: str,
mesh_size: float,
mesh_size_scale: float = 1000.0,
part_size_scale: float = 0.001,
) -> Mesh
Create a Mesh from a step file
Note
oersted needs mesh dimensions in meters, but gmsh typically works in mm.
This function scales the input mesh size up to be in mm, and scales the
gmsh resultant down to be in m. Adjust these parameters if the mesh isn't
working properly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
STEP file to mesh |
required |
mesh_size
|
float
|
(m) nominal element size to use for the mesh |
required |
mesh_size_scale
|
float
|
(mm/m) adjust if the model units are in mm and not m |
1000.0
|
part_size_scale
|
float
|
(m/mm) adjust if the mesh units are in mm and not m |
0.001
|
Returns:
| Type | Description |
|---|---|
Mesh
|
volumetric tet4 mesh of the STEP file |
Source code in src/oersted/mesh.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
plot
plot(filename: str | None = None)
Convenience function for plotting just the mesh itself
Source code in src/oersted/mesh.py
238 239 240 | |
to_centroid_mesh
to_centroid_mesh() -> CentroidMesh
Create a centroid mesh from a tet4 mesh
Source code in src/oersted/mesh.py
178 179 180 | |
NonlinearMaterial
dataclass
Bases: Material
A nonlinear magnetic material that has a B-H curve
Source code in src/oersted/materials.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
mu_r
mu_r(h: float) -> float
Return the relative magnetic permeability at a given H-field strength
Source code in src/oersted/materials.py
77 78 79 80 81 82 83 84 | |
to_mh_curve
to_mh_curve() -> tuple[NDArray[float64], NDArray[float64]]
Convert the B-H curve to an M-H curve, which is more convenient for magnetization calculations
Source code in src/oersted/materials.py
86 87 88 89 | |
OctreeSolver
Bases: Solver
Controls solver options for using the octree (Barnes-Hut) solution routines
This uses the "new" 3-zone octree solver.
Warning
There is currently a bug with leaf_threshold > 1, so the solver will
always use a leaf threshold of 1.
Source code in src/oersted/solver.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
alpha
property
alpha
Returns the near/mid-field element radius ratio (accuracy control)
leaf_threshold
property
leaf_threshold
Returns the number of sources that will be evaluated individually at the octree leaf level
theta
property
theta
Returns the Barnes-Hut angle-opening criteria (accuracy control)
OctreeSolver2Zone
Bases: Solver
Controls solver options for using the octree (Barnes-Hut) solution routines
This uses the "old" 2-zone octree solver.
Source code in src/oersted/solver.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
leaf_threshold
property
leaf_threshold
Returns the number of sources that will be evaluated individually at the octree leaf level
theta
property
theta
Returns the Barnes-Hut angle-opening criteria (accuracy control)
Solver
Defines a generic solver with options for iterative and multi-threaded solutions
Source code in src/oersted/solver.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
alpha
property
alpha
Under-relaxation factor for iterative solves.
edge
property
edge
Whether or not the edge-based element calculation should be used
max_iterations
property
max_iterations
Maximum number of iterations for iterative solves.
n_threads
property
n_threads
Number of threads for solving.
tol
property
tol
Convergence tolerance for iterative solves.
Note
This is typically a value of the H-field for magnetization calculations; the default value is roughly 1.3e-6 T, which may be more than necessary for most applications.
b_field
b_field(
source: Mesh | CentroidMesh,
j_density: NDArray[float64],
targets: NDArray[float64],
solver: DirectSolver
| OctreeSolver
| OctreeSolver2Zone
| None = None,
) -> NDArray[float64]
Compute the magnetic flux density at a collection of target points using the specific source mesh and solver options, assuming the target points are in free space
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Mesh | CentroidMesh
|
mesh to use as the field source |
required |
j_density
|
NDArray[float64]
|
(A/m^2) (N,3) array of current density vectors at each of the element centroids |
required |
targets
|
NDArray[float64]
|
(m) (N,3) array of target point positions in 3D space |
required |
solver
|
DirectSolver | OctreeSolver | OctreeSolver2Zone | None
|
selects the solution settings |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(T) (N,3) array of magnetic flux density (B) vectors at each target position |
Source code in src/oersted/biotsavart.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
bz_finite_length_solenoid
bz_finite_length_solenoid(
jmag: float,
length: float,
r: float,
dr: float,
z: float,
) -> float
Compute the magnetic field on the axis of a finite-length solenoid
This function assumes that the solenoid dr dimension is small relative to the
radius and thickness, and does not correct for finite radial thickness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jmag
|
float
|
(A/m2) magnitude of current density in the solenoid |
required |
length
|
float
|
(m) length of the solenoid |
required |
r
|
float
|
(m) representative radius of the solenoid |
required |
dr
|
float
|
(m) thickness of the solenoid cross section |
required |
z
|
float
|
(m) position along the axis of the solenoid at which the field should be calculated |
required |
Returns:
| Type | Description |
|---|---|
float
|
(T) axial magnetic field |
Reference
https://en.wikipedia.org/wiki/Solenoid#Finite_continuous_solenoid (with modifications for current density and finite thickness)
Source code in src/oersted/testing.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
bz_loop_axis
bz_loop_axis(
current: float, radius: float, z: float
) -> float
Compute the vertical field Bz at the center of a current-carrying loop
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
float
|
(A) total electrical current in the loop |
required |
radius
|
float
|
(m) centerline radius of the loop |
required |
z
|
float
|
(m) height of the target point along the loop axis |
required |
Returns:
| Type | Description |
|---|---|
float
|
(T) magnetic flux density, oriented along the loop axis |
Source code in src/oersted/testing.py
170 171 172 173 174 175 176 177 178 179 180 181 | |
dbzdz_loop_axis
dbzdz_loop_axis(
current: float, radius: float, z: float
) -> float
Compute the vertical field gradient dBz/dz at the center of a current-carrying loop
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
float
|
(A) total electrical current in the loop |
required |
radius
|
float
|
(m) centerline radius of the loop |
required |
z
|
float
|
(m) height of the target point along the loop axis |
required |
Returns:
| Type | Description |
|---|---|
float
|
(T/m) magnetic flux density gradient, oriented along the loop axis |
Source code in src/oersted/testing.py
184 185 186 187 188 189 190 191 192 193 194 195 196 | |
demag_solve
demag_solve(
mesh: Mesh,
material: Material,
h_external: NDArray[float64],
solver: DirectSolver | OctreeSolver | OctreeSolver2Zone,
) -> tuple[NDArray[float64], NDArray[float64]]
Compute magnetization field M and the total H field at element centroids, given a background field
Uses simple fixed-point iteration and therefore only converges for low-permeable materials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
finite element mesh on which to evaluate the demagnetizing field |
required |
material
|
Material
|
linear or nonlinear magnetic maaterial properties |
required |
h_external
|
NDArray[float64]
|
(A/m) an (Ne,3) array of external field at each element centroid |
required |
solver
|
DirectSolver | OctreeSolver | OctreeSolver2Zone
|
solution parameters for the problem, including iteration method |
required |
Returns:
| Type | Description |
|---|---|
(M, Htotal)
|
each (Ne, 3), magnetization field M(Htotal) and total H field |
NDArray[float64]
|
at element centroids. These can be summed to give B = mu0 * (Htotal + M). |
Source code in src/oersted/magnetization.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
h_field
h_field(
source: Mesh | CentroidMesh,
j_density: NDArray[float64],
targets: NDArray[float64],
solver: DirectSolver
| OctreeSolver
| OctreeSolver2Zone
| None = None,
edge: bool = False,
) -> NDArray[float64]
Compute the magnetic field strength at a collection of target points using a current-carrying source mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Mesh | CentroidMesh
|
mesh to use as the field source |
required |
j_density
|
NDArray[float64]
|
(A/m^2) (N,3) array of current density vectors at each of the element centroids |
required |
targets
|
NDArray[float64]
|
(m) (N,3) array of target point positions in 3D space |
required |
solver
|
DirectSolver | OctreeSolver | OctreeSolver2Zone | None
|
selects the solution settings |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(T) (N,3) array of magnetic field strength (H) vectors at each target position |
Source code in src/oersted/biotsavart.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
h_mag
h_mag(
source: Mesh | CentroidMesh,
m_field: NDArray[float64],
targets: NDArray[float64],
solver: DirectSolver
| OctreeSolver
| OctreeSolver2Zone
| None = None,
) -> NDArray[float64]
Compute the magnetic field strength using a magnetized mesh as the source
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Mesh | CentroidMesh
|
mesh to use as the field source |
required |
m_field
|
NDArray[float64]
|
(A/m) (N,3) array of magnetization field vectors at each of the element centroids |
required |
targets
|
NDArray[float64]
|
(m) (N,3) array of target point positions in 3D space |
required |
solver
|
DirectSolver | OctreeSolver | OctreeSolver2Zone | None
|
selects the solution settings |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(T) (N,3) array of magnetic field strength (H) vectors at each target position |
Source code in src/oersted/biotsavart.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
kelvin_force_density
kelvin_force_density(
mesh: Mesh,
m_field_centroids: NDArray[float64],
b_field_nodes: NDArray[float64],
) -> NDArray[float64]
Compute the Kelvin force density acting on a magnetized mesh.
Note
The h_field must be calculated at the element nodes, while the magnetization field must be known at the centroids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
the mesh on which to evaluate the forces |
required |
m_field_centroids
|
NDArray[float64]
|
(A/m) the magnetization field (M field), evaluated at the centroids of the elements in the mesh |
required |
b_field_nodes
|
NDArray[float64]
|
(T) the magnetic flux density, evaluated at the nodes within the mesh |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N/m^3) an (N,3) array of the force density vector acting on each element centroid |
Source code in src/oersted/results.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
kelvin_forces
kelvin_forces(
mesh: Mesh,
m_field_centroids: NDArray[float64],
b_field_nodes: NDArray[float64],
) -> NDArray[float64]
Compute the Kelvin forces acting on a magnetized mesh.
Note
The h_field must be calculated at the element nodes, while the magnetization field must be known at the centroids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
the mesh on which to evaluate the forces |
required |
m_field_centroids
|
NDArray[float64]
|
(A/m) the magnetization field (M field), evaluated at the centroids of the elements in the mesh |
required |
b_field_nodes
|
NDArray[float64]
|
(T) the magnetic flux density, evaluated at the nodes within the mesh |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N) an (N,3) array of the force vector acting on each element centroid |
Source code in src/oersted/results.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
lorentz_force_density
lorentz_force_density(
j_density: NDArray[float64], b_field: NDArray[float64]
) -> NDArray[float64]
Compute the Lorentz forces acting on a mesh
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
j_density
|
NDArray[float64]
|
(A/m^2) an (N,3) array containing the current density vector at every element |
required |
b_field
|
NDArray[float64]
|
(T) an (N,3) array containing the magnetic flux density vector at every element |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N/m^3) an (N,3) array of the force density vectors acting on the mesh at every element |
Source code in src/oersted/results.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
lorentz_forces
lorentz_forces(
mesh: Mesh | CentroidMesh,
j_density: NDArray[float64],
b_field: NDArray[float64],
total: bool = False,
) -> NDArray[float64]
Compute the Lorentz forces acting on a mesh
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh | CentroidMesh
|
the finite element mesh on which the fields and forces are calculated |
required |
j_density
|
NDArray[float64]
|
(A/m^2) an (N,3) array containing the current density vector at every element |
required |
b_field
|
NDArray[float64]
|
(T) an (N,3) array containing the magnetic flux density vector at every element |
required |
total
|
bool
|
if true, return only the total force (default: false) |
False
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N) an (N,3) array of the force vectors acting on the mesh at every element |
Source code in src/oersted/results.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
make_helmholtz
make_helmholtz(
filename: str,
size: float,
jmag: None | float = None,
scale: float = 0.001,
) -> tuple[Mesh, NDArray[float64]]
Make the helmholtz coil test problem
The geometry of the problem is defined as:
- Two circular coils of radius R=0.2m
- Distance between the coils is d=0.2m
- Coils are aligned with the z-axis and symmetric about the xy plane
- Currents in the currents are flowing in the same direction
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
STEP file containing the geometry of a single loop in the Helmholtz pair |
required |
size
|
float
|
(m) mesh size |
required |
jmag
|
None | float
|
(A/m^2) magnitude of current density in each loop |
None
|
scale
|
float
|
(mm/m) scale factor for meshing |
0.001
|
Returns:
| Type | Description |
|---|---|
tuple[Mesh, NDArray[float64]]
|
(mesh, current density) the volumetric mesh and current density vectors of the Helmholtz coil pair |
Source code in src/oersted/testing.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
maxwell_forces
maxwell_forces(
mesh: SurfaceMesh, b_field: NDArray[float64]
) -> NDArray[float64]
Compute the maxwell stress tensor and determine the force vector acting on each surface face centroid. Returns an (N,3) array of the force vector
Warning
This form of the Maxwell stress tensor is numerically unstable, especially in the presence of large background fields. Perform a mesh convergence study to identify an appropriate mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
SurfaceMesh
|
a surface mesh on which to integrate the Maxwell stress tensor |
required |
b_field
|
NDArray[float64]
|
(T) magnetic flux density evaluated at each of the centroids of the surface mesh elements |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
(N) an (N,3) array of the force acting on each of the surface mesh centroids |
Source code in src/oersted/results.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
mesh_step
mesh_step(
infile: str,
max_size: float,
min_size: float = 0.0,
scale: float = 0.001,
) -> Mesh
Mesh a step file using gmsh
Note
This requires gmsh to be installed: pip install gmsh
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
infile
|
str
|
path to the STEP file to mesh |
required |
max_size
|
float
|
(m) maximum allowable element size |
required |
min_size
|
float
|
(m) minimum allowable element size |
0.0
|
scale
|
float
|
(mm/m) adjust if the part or mesh is scaled incorrectly |
0.001
|
Returns:
| Type | Description |
|---|---|
Mesh
|
a tet4 (volumetric) mesh of the component |
Source code in src/oersted/mesh.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
plot_mesh
plot_mesh(
mesh: Mesh,
filename: str | None = None,
scalars: NDArray[float64] | None = None,
centroids: NDArray[float64] | None = None,
vectors: NDArray[float64] | None = None,
vector_scale: float | None = None,
transparency: bool = False,
)
Make a 3D plot of the mesh
Note
This function requires pyvista: pip install pyvista.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
the tet4 mesh to plot |
required |
filename
|
str | None
|
if this argument is passed, save to file only |
None
|
scalars
|
NDArray[float64] | None
|
(Ne,) array of scalar values to color the mesh, defined at element centroids |
None
|
centroids
|
NDArray[float64] | None
|
(N,3) array of vector positions for plotting vector values on the mesh |
None
|
vectors
|
NDArray[float64] | None
|
(N,3) array of vector magnitudes for plotting vector values on the
mesh; must be same length as |
None
|
vector_scale
|
float | None
|
adjust for setting vector length |
None
|
transparency
|
bool
|
set to |
False
|
Source code in src/oersted/mesh.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
smape
smape(
baseline: NDArray[float64],
measurement: NDArray[float64],
) -> float
Compute the symmetric mean absolute percentage error of measurement
against baseline
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
baseline
|
NDArray[float64]
|
an (N,) array of data values to compute error against |
required |
measurement
|
NDArray[float64]
|
an (N,) array of data values of which to compute error |
required |
Returns:
| Type | Description |
|---|---|
float
|
error associated with this comparison |
Source code in src/oersted/testing.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |