![]() |
FairShip
|
Classes | |
| class | MapRange |
Functions | |
| read_range (path) | |
| is_field_map (path) | |
| branches (path) | |
| entry_count (path) | |
| has_coords (path) | |
| _columns (path, names) | |
| read_field (path, order="xslow", rng=None) | |
| transpose_xy (field) | |
| read_coords (path) | |
| _residuals (coords, rng, order) | |
| coord_residuals (path, rng=None, order="xslow") | |
| infer_data_order (path, rng=None) | |
| core_slices (rng, xy_fraction=0.3, z_fraction=0.25) | |
| div_b_rms (field, rng, region=None) | |
| on_axis (field, rng) | |
| canonicalise (in_path, out_path, order="xslow", rng=None) | |
Variables | |
| tuple | FIELD_BRANCHES = ("Bx", "By", "Bz") |
| tuple | COORD_BRANCHES = ("x", "y", "z") |
| tuple | ORDERS = ("xslow", "yslow") |
Helpers for reading, validating and repacking FairShip magnetic field maps. A FairShip ROOT field map holds two trees. ``Range`` has a single entry with the coordinate limits and bin widths (cm), and ``Data`` has ``Nx*Ny*Nz`` entries with the field components (Tesla), optionally accompanied by the node coordinates. ``ShipBFieldMap`` reads ``Data`` sequentially and only imposes the grid structure at lookup time, through ``index = (iX*Ny + iY)*Nz + iZ``: z is increased first, then y, then x. Nothing in the file states the ordering, so a map written in a different order is read transposed. When ``Nx == Ny`` and the x and y ranges agree, even the entry count still matches and the mistake is silent. The functions here make the ordering checkable, from both the stored coordinates and from the field itself.
|
protected |
Definition at line 155 of file fieldMapTools.py.
|
protected |
Per-axis deviation of the stored coordinates from ``order``, in bins.
Definition at line 189 of file fieldMapTools.py.
| fieldMapTools.branches | ( | path | ) |
Names of the branches of the ``Data`` tree.
Definition at line 140 of file fieldMapTools.py.
| fieldMapTools.canonicalise | ( | in_path, | |
| out_path, | |||
| order = "xslow", | |||
| rng = None ) |
Write a field map in canonical order, with matching node coordinates. ``order`` is the order the *input* is in. The output is always ``(iX*Ny + iY)*Nz + iZ`` with freshly generated ``x``, ``y`` and ``z`` branches, so ``ShipBFieldMap`` can verify it.
Definition at line 278 of file fieldMapTools.py.
| fieldMapTools.coord_residuals | ( | path, | |
| rng = None, | |||
| order = "xslow" ) |
Largest deviation of a stored coordinate from the node ``order`` puts it at. Returned per axis, in bin widths, over every entry. A map in the given order sits within a fraction of a bin; a permuted one is off by tens of bins. ``None`` if the map stores no coordinates.
Definition at line 198 of file fieldMapTools.py.
| fieldMapTools.core_slices | ( | rng, | |
| xy_fraction = 0.3, | |||
| z_fraction = 0.25 ) |
Slices selecting the middle of the map, away from coils and yoke.
Definition at line 233 of file fieldMapTools.py.
| fieldMapTools.div_b_rms | ( | field, | |
| rng, | |||
| region = None ) |
RMS of div B over the core of the map, and the local gradient scale. A physical field has div B = 0, so an ordering that scrambles neighbouring nodes shows up as a large residual. The gradient scale is the RMS of the three diagonal derivatives, which is what the residual should be compared against: it is the size div B would have if the derivatives did not cancel.
Definition at line 256 of file fieldMapTools.py.
| fieldMapTools.entry_count | ( | path | ) |
Number of entries in the ``Data`` tree.
Definition at line 145 of file fieldMapTools.py.
| fieldMapTools.has_coords | ( | path | ) |
Whether the map stores the node coordinates alongside the field.
Definition at line 150 of file fieldMapTools.py.
| fieldMapTools.infer_data_order | ( | path, | |
| rng = None ) |
Guess the data order from the stored coordinates. Returns ``"xslow"``, ``"yslow"``, or ``None`` when the map stores no coordinates or matches neither ordering.
Definition at line 214 of file fieldMapTools.py.
| fieldMapTools.is_field_map | ( | path | ) |
Whether the file holds both trees a FairShip field map needs. False for anything ROOT cannot open, an unfetched git-lfs pointer included. PyROOT raises OSError there rather than handing back a null file, so checking the returned handle would never catch it.
Definition at line 122 of file fieldMapTools.py.
| fieldMapTools.on_axis | ( | field, | |
| rng ) |
Field along z at the grid node closest to x = y = 0.
Definition at line 272 of file fieldMapTools.py.
| fieldMapTools.read_coords | ( | path | ) |
Read the stored node coordinates, or ``None`` if the map has none.
Definition at line 182 of file fieldMapTools.py.
| fieldMapTools.read_field | ( | path, | |
| order = "xslow", | |||
| rng = None ) |
Read the field as an ``(Nx, Ny, Nz, 3)`` array of Tesla. ``order`` says how the flat entries map onto the grid: ``xslow`` is the canonical ``(iX*Ny + iY)*Nz + iZ``, ``yslow`` its x/y transpose.
Definition at line 160 of file fieldMapTools.py.
| fieldMapTools.read_range | ( | path | ) |
Read the ``Range`` tree of a field map.
Definition at line 113 of file fieldMapTools.py.
| fieldMapTools.transpose_xy | ( | field | ) |
The same field read with x and y swapped.
Definition at line 177 of file fieldMapTools.py.
| tuple fieldMapTools.COORD_BRANCHES = ("x", "y", "z") |
Definition at line 31 of file fieldMapTools.py.
| tuple fieldMapTools.FIELD_BRANCHES = ("Bx", "By", "Bz") |
Definition at line 27 of file fieldMapTools.py.
| tuple fieldMapTools.ORDERS = ("xslow", "yslow") |
Definition at line 34 of file fieldMapTools.py.