Commit 3c9ca876 authored by Domanski, Marian M.'s avatar Domanski, Marian M.
Browse files

Merge branch '37-add-split-method-to-full-results' into 'master'

Resolve "Add split method to full results"

Closes #37

See merge request mdomanski/fluegg!31
parents ce3523a2 72bde13f
......@@ -275,6 +275,49 @@ class FullResults(Results):
return positions
def in_domain(self, time):
"""Returns a results instance containing particles that are
in the simulation domain at a given time
time : float
Simulation time, in seconds. `time` must be finite.
Full Results or None
Returns None if no particles are in the domain at `time`
if not np.isfinite(time):
raise ValueError("time must be a finite value")
positions_at_time = np.apply_along_axis(
lambda p: np.interp(
particles_in_domain = positions_at_time[:, 0] <= self._domain_length
if np.any(particles_in_domain):
cls = self.__class__
res = cls.__new__(cls)
res._positions = self._positions[:, particles_in_domain, :]
res._depth = self._depth[:, particles_in_domain]
res._width = self._width[:, particles_in_domain]
res._domain_length = self._domain_length
res._configuration = self.configuration()
res._time = self._time.copy()
res = None
return res
def positions(self, normalize=()):
"""Returns particle position array
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment