Maintenance scheduled for Thursday, September 24th at 15:00 MDT. Expected downtime <1 hour.

Merge branch '41-add-combine-method' into 'master'

Resolve "Add method to combine full results files"

Closes #41

See merge request mdomanski/fluegg!35
parents e03bcafc ee4bcec7
......@@ -274,6 +274,46 @@ class FullResults(Results):
return positions
def add(self, results):
"""Merges this results instance with another FullResults instance
Parameters
----------
results: Full Results
Must have an identical configuration and specifications except
for num_eggs
"""
# compare results instances
if not isinstance(results, FullResults):
raise TypeError(
"The added configuration instance is not type FullResults")
other_config = results.configuration()
for key in self._configuration:
if key in ['num_eggs', 'sim_name']:
continue
if self._configuration[key] != other_config[key]:
raise ValueError(
"The configuration values for {} are mismatched".format(key))
# merge
positions = results.positions()
widths = results._width
depths = results._depth
positions_merged = np.concatenate((self._positions, positions), axis=1)
self._positions = positions_merged
widths_merged = np.concatenate((self._width, widths), axis=1)
self._width = widths_merged
depths_merged = np.concatenate((self._depth, depths), axis=1)
self._depth = depths_merged
self._configuration['num_eggs'] = \
str(int(self._configuration['num_eggs']) +
int(other_config['num_eggs']))
def in_domain(self, time):
"""Returns a results instance containing particles that are
in the simulation domain at a given time
......
Markdown is supported
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