feat: Adds numpy make more dipoles at once and converters
This commit is contained in:
@@ -54,6 +54,16 @@ class OscillatingDipole():
|
||||
return (1 / numpy.pi) * (self.w / (f**2 + self.w**2))
|
||||
|
||||
|
||||
def dot_inputs_to_array(dot_inputs: Sequence[DotInput]) -> numpy.ndarray:
|
||||
return numpy.array([numpy.append(numpy.array(input[0]), input[1]) for input in dot_inputs])
|
||||
|
||||
|
||||
def dot_range_measurements_low_high_arrays(dot_range_measurements: Sequence[DotRangeMeasurement]) -> Tuple[numpy.ndarray, numpy.ndarray]:
|
||||
lows = [measurement.v_low for measurement in dot_range_measurements]
|
||||
highs = [measurement.v_high for measurement in dot_range_measurements]
|
||||
return (numpy.array(lows), numpy.array(highs))
|
||||
|
||||
|
||||
class OscillatingDipoleArrangement():
|
||||
'''
|
||||
A collection of oscillating dipoles, which we are interested in being able to characterise.
|
||||
|
||||
@@ -62,6 +62,23 @@ class FixedMagnitudeModel(Model):
|
||||
s_pts = numpy.array((self.rng.uniform(self.xmin, self.xmax), self.rng.uniform(self.ymin, self.ymax), self.rng.uniform(self.zmin, self.zmax)))
|
||||
return OscillatingDipoleArrangement([OscillatingDipole(numpy.array([px, py, pz]), s_pts, frequency)])
|
||||
|
||||
def get_n_single_dipoles(self, n: int, max_frequency: float) -> numpy.ndarray:
|
||||
# psw
|
||||
|
||||
theta = 2 * numpy.pi * self.rng.random(n)
|
||||
phi = numpy.arccos(2 * self.rng.random(n) - 1)
|
||||
px = self.pfixed * numpy.cos(theta) * numpy.sin(phi)
|
||||
py = self.pfixed * numpy.sin(theta) * numpy.sin(phi)
|
||||
pz = self.pfixed * numpy.cos(phi)
|
||||
|
||||
sx = self.rng.uniform(self.xmin, self.xmax, n)
|
||||
sy = self.rng.uniform(self.ymin, self.ymax, n)
|
||||
sz = self.rng.uniform(self.zmin, self.zmax, n)
|
||||
|
||||
w = self.rng.uniform(1, max_frequency, n)
|
||||
|
||||
return numpy.array([px, py, pz, sx, sy, sz, w]).T
|
||||
|
||||
def n(self) -> int:
|
||||
return self._n
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ class Model():
|
||||
def get_dipoles(self, frequency: float) -> OscillatingDipoleArrangement:
|
||||
raise NotImplementedError
|
||||
|
||||
def get_n_single_dipoles(self, n: int, max_frequency: float) -> numpy.ndarray:
|
||||
raise NotImplementedError
|
||||
|
||||
def solution_single_dipole(self, pt: numpy.ndarray) -> OscillatingDipole:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
Reference in New Issue
Block a user