Skip to content

Commit

Permalink
Merge pull request #158 from chrishavlin/comment_on_ratio
Browse files Browse the repository at this point in the history
add a note on why ratio is needed in BlockCollection.add_data
  • Loading branch information
matthewturk authored Dec 5, 2024
2 parents d554a33 + 0abac19 commit dea0f45
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions yt_idv/scene_data/block_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,18 @@ def add_data(self, field, no_ghost=False):
LE = np.array([b.LeftEdge for i, b in self.blocks.values()]).min(axis=0)
RE = np.array([b.RightEdge for i, b in self.blocks.values()]).max(axis=0)
self.diagonal = np.sqrt(((RE - LE) ** 2).sum())
# Now we set up our buffer
vert = np.array(vert, dtype="f4")

# Note: the block LeftEdge and RightEdge arrays are plain np arrays in
# units of code_length, so need to convert to unitary units (in range 0,1)
# after the fact:
units = self.data_source.ds.units
ratio = (units.code_length / units.unitary).base_value
dx = np.array(dx, dtype="f4") * ratio
le = np.array(le, dtype="f4") * ratio
re = np.array(re, dtype="f4") * ratio

# Now we set up our buffer
vert = np.array(vert, dtype="f4")
self.vertex_array.attributes.append(
VertexAttribute(name="model_vertex", data=vert)
)
Expand Down

0 comments on commit dea0f45

Please sign in to comment.