Skip to content

Commit

Permalink
Add a height scaling factor when using default height (#56)
Browse files Browse the repository at this point in the history
* set a heigh multiplier

* only use hidden height factor attr in default height method
  • Loading branch information
chrisjonesBSU authored Sep 18, 2023
1 parent 45fcd2d commit ac038b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions cmeutils/tests/test_visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ def test_box_radius(self, p3ht_fresnel):
assert p3ht_fresnel.box_radius == 0.1

def test_default_height(self, p3ht_fresnel):
assert p3ht_fresnel.height == np.linalg.norm(
p3ht_fresnel.box_length[:3] * p3ht_fresnel.view_axis
assert (
p3ht_fresnel.height
== np.linalg.norm(
p3ht_fresnel.box_length[:3] * p3ht_fresnel.view_axis
)
* p3ht_fresnel._height_factor
)

def test_reset_height(self, p3ht_fresnel):
Expand Down
5 changes: 3 additions & 2 deletions cmeutils/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(
self.gsd_file = gsd_file
with gsd.hoomd.open(gsd_file) as traj:
self._n_frames = len(traj)
self._height_factor = 1.25
self._unwrap_positions = unwrap_positions
self._snapshot = None
self._view_axis = np.asarray(view_axis)
Expand All @@ -89,7 +90,6 @@ def __init__(
self._specular = specular
self._specular_trans = specular_trans
self._metal = metal
# self._view_axis = np.asarray(view_axis)
self._up = np.asarray(up)
self._show_box = show_box
self._box_radius = box_radius
Expand Down Expand Up @@ -321,7 +321,8 @@ def box_length(self):

def _default_height(self):
"""Set the height based on box dimensions and view axis"""
return np.linalg.norm(self.view_axis * self.box_length[:3])
height = np.linalg.norm(self.view_axis * self.box_length[:3])
return height * self._height_factor

def reset_height(self):
"""Reset the height of the camera to the default."""
Expand Down

0 comments on commit ac038b5

Please sign in to comment.