Skip to content

Commit

Permalink
pass oversample call from PolarizedNeutronProbe to individual xs (now…
Browse files Browse the repository at this point in the history
… using calc_T from xs instead of T)
  • Loading branch information
bmaranville committed Apr 3, 2024
1 parent f5b2c43 commit 3c4046d
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions refl1d/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ def __init__(self, xs: Optional[Tuple]=None,
self.oversample(oversampling, oversampling_seed)

@property
def xs(self):
def xs(self) -> List[Union[NeutronProbe, None]]:
return [getattr(self, xs_name) for xs_name in self._xs_names]

def parameters(self):
Expand Down Expand Up @@ -1893,20 +1893,11 @@ def shared_beam(self, intensity=1, background=0,
x.theta_offset = theta_offset
x.sample_broadening = sample_broadening

def oversample(self, n=6, seed=1):
self._oversample(n, seed)
self.oversampling = n
self.oversampling_seed = seed

def _oversample(self, n=6, seed=1):
# doc string is inherited from parent (see below)
rng = numpy.random.RandomState(seed=seed)
T = rng.normal(self.T[:, None], self.dT[:, None], size=(len(self.dT), n))
L = rng.normal(self.L[:, None], self.dL[:, None], size=(len(self.dL), n))
T = T.flatten()
L = L.flatten()
self._set_calc(T, L)
_oversample.__doc__ = Probe.oversample.__doc__
def oversample(self, **kw):
for xs in self.xs:
if xs is not None:
xs.oversample(**kw)
oversample.__doc__ = Probe.oversample.__doc__

def _calculate_union(self):
theta_offsets = [x.theta_offset.value for x in self.xs if x is not None]
Expand Down

0 comments on commit 3c4046d

Please sign in to comment.