FairShip
Loading...
Searching...
No Matches
fieldMapTools.MapRange Class Reference

Public Member Functions

 Nx (self)
 Ny (self)
 Nz (self)
 N (self)
 shape (self)
 axis_values (self)
 node_indices (self, entries, order="xslow")
 extent_mismatch (self)

Public Attributes

 xMin
 xMax
 dx
 yMin
 yMax
 dy
 zMin
 zMax
 dz
 Nx
 Ny
 Nz

Static Protected Member Functions

 _bins (lo, hi, step)

Detailed Description

Coordinate limits and binning of a field map, in cm.

Definition at line 38 of file fieldMapTools.py.

Member Function Documentation

◆ _bins()

fieldMapTools.MapRange._bins ( lo,
hi,
step )
staticprotected

Definition at line 52 of file fieldMapTools.py.

52 def _bins(lo, hi, step):
53 # Same arithmetic as ShipBFieldMap::setLimits(): the 1.5 rounds up to
54 # the nearest integer while counting both endpoints.
55 if step <= 0.0:
56 raise ValueError(f"Non-positive bin width {step}")
57 return int((hi - lo) / step + 1.5)
58

◆ axis_values()

fieldMapTools.MapRange.axis_values ( self)
Nominal node coordinates along each axis.

Definition at line 79 of file fieldMapTools.py.

79 def axis_values(self):
80 """Nominal node coordinates along each axis."""
81 return (
82 self.xMin + self.dx * np.arange(self.Nx),
83 self.yMin + self.dy * np.arange(self.Ny),
84 self.zMin + self.dz * np.arange(self.Nz),
85 )
86

◆ extent_mismatch()

fieldMapTools.MapRange.extent_mismatch ( self)
Deviation of each axis extent from a whole number of bins, in bins.

A non-zero value means the limits and the bin width disagree, so the
node coordinates drift away from the nominal grid.

Definition at line 97 of file fieldMapTools.py.

97 def extent_mismatch(self):
98 """Deviation of each axis extent from a whole number of bins, in bins.
99
100 A non-zero value means the limits and the bin width disagree, so the
101 node coordinates drift away from the nominal grid.
102 """
103 return tuple(
104 abs((n - 1) * d - (hi - lo)) / d
105 for n, d, lo, hi in (
106 (self.Nx, self.dx, self.xMin, self.xMax),
107 (self.Ny, self.dy, self.yMin, self.yMax),
108 (self.Nz, self.dz, self.zMin, self.zMax),
109 )
110 )
111
112

◆ N()

fieldMapTools.MapRange.N ( self)

Definition at line 72 of file fieldMapTools.py.

72 def N(self):
73 return self.Nx * self.Ny * self.Nz
74

◆ node_indices()

fieldMapTools.MapRange.node_indices ( self,
entries,
order = "xslow" )
Grid indices (iX, iY, iZ) of the given entry numbers.

Definition at line 87 of file fieldMapTools.py.

87 def node_indices(self, entries, order="xslow"):
88 """Grid indices (iX, iY, iZ) of the given entry numbers."""
89 entries = np.asarray(entries)
90 iZ = entries % self.Nz
91 if order == "xslow":
92 return entries // (self.Ny * self.Nz), (entries // self.Nz) % self.Ny, iZ
93 if order == "yslow":
94 return (entries // self.Nz) % self.Nx, entries // (self.Nx * self.Nz), iZ
95 raise ValueError(f"Unknown data order {order!r}, expected one of {ORDERS}")
96

◆ Nx()

fieldMapTools.MapRange.Nx ( self)

Definition at line 60 of file fieldMapTools.py.

60 def Nx(self):
61 return self._bins(self.xMin, self.xMax, self.dx)
62

◆ Ny()

fieldMapTools.MapRange.Ny ( self)

Definition at line 64 of file fieldMapTools.py.

64 def Ny(self):
65 return self._bins(self.yMin, self.yMax, self.dy)
66

◆ Nz()

fieldMapTools.MapRange.Nz ( self)

Definition at line 68 of file fieldMapTools.py.

68 def Nz(self):
69 return self._bins(self.zMin, self.zMax, self.dz)
70

◆ shape()

fieldMapTools.MapRange.shape ( self)

Definition at line 76 of file fieldMapTools.py.

76 def shape(self):
77 return (self.Nx, self.Ny, self.Nz)
78

Member Data Documentation

◆ dx

fieldMapTools.MapRange.dx

Definition at line 61 of file fieldMapTools.py.

◆ dy

fieldMapTools.MapRange.dy

Definition at line 65 of file fieldMapTools.py.

◆ dz

fieldMapTools.MapRange.dz

Definition at line 69 of file fieldMapTools.py.

◆ Nx

fieldMapTools.MapRange.Nx

Definition at line 77 of file fieldMapTools.py.

◆ Ny

fieldMapTools.MapRange.Ny

Definition at line 77 of file fieldMapTools.py.

◆ Nz

fieldMapTools.MapRange.Nz

Definition at line 77 of file fieldMapTools.py.

◆ xMax

fieldMapTools.MapRange.xMax

Definition at line 61 of file fieldMapTools.py.

◆ xMin

fieldMapTools.MapRange.xMin

Definition at line 61 of file fieldMapTools.py.

◆ yMax

fieldMapTools.MapRange.yMax

Definition at line 65 of file fieldMapTools.py.

◆ yMin

fieldMapTools.MapRange.yMin

Definition at line 65 of file fieldMapTools.py.

◆ zMax

fieldMapTools.MapRange.zMax

Definition at line 69 of file fieldMapTools.py.

◆ zMin

fieldMapTools.MapRange.zMin

Definition at line 69 of file fieldMapTools.py.


The documentation for this class was generated from the following file: