Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyAJohnston committed Nov 26, 2024
1 parent 3e438b8 commit 87bdbe1
Showing 1 changed file with 9 additions and 32 deletions.
41 changes: 9 additions & 32 deletions molecularnodes/entities/trajectory/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,11 @@ def interpolate(self, value: bool) -> None:
self.object.mn.interpolate = value

def _frame_range(self, frame: int):
"Get the trajectory frame numbers over which we will average values"
return frames_to_average(frame, self.average)

def _cache_ordered(self) -> np.ndarray:
"Return the cached frames as a 3D array, in chronological order"
keys = list(self.cache.keys())
keys.sort()
return np.array([self.cache[k] for k in keys])
Expand Down Expand Up @@ -568,7 +570,14 @@ def position_cache_mean(self, frame: int) -> np.ndarray:

return np.mean(array, axis=0)

def _position_at_frame(self, frame: int) -> np.ndarray:
"Return the atom positions at the given universe frame number"
self.uframe = frame
return self.univ_positions

def update_position_cache(self, frame: int) -> None:
"Update the currently cached positions, based on the new frame"
# get the individual frame numbers that we will be caching
frames_to_cache = self._frame_range(frame)

# remove any frames that no longer need to be cached
Expand All @@ -589,38 +598,6 @@ def frame_mapper(self, frame: int):
mapping=self.frame_mapping,
)

def _position_at_frame(self, frame: int) -> np.ndarray:
if frame not in self.cache:
self.uframe = frame
self.cache[frame] = self.univ_positions
return self.cache[frame]

# def _averaged_position_at_frame(self, frame: int) -> np.ndarray:
# if self.average == 0:
# return self._position_at_frame(frame)

# frame_numbers = self._frame_range(frame)

# positions = np.zeros((len(frame_numbers), self.n_atoms, 3), dtype=float)

# first_pos = None

# for i, frame_number in enumerate(frame_numbers):
# new_pos = self._position_at_frame(frame_number)

# if self.correct_periodic and self.is_orthorhombic:
# if first_pos is None:
# first_pos = new_pos
# else:
# new_pos = correct_periodic_positions(
# positions_1=first_pos,
# positions_2=new_pos,
# dimensions=self.universe.dimensions[:3] * self.world_scale,
# )
# positions[i] = new_pos

# return np.mean(positions, axis=0)

def _update_positions(self, frame):
"""
The function that will be called when the frame changes.
Expand Down

0 comments on commit 87bdbe1

Please sign in to comment.