Skip to content

Commit

Permalink
feat(transform): no-op elevation vis weights if the dataset exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgray committed Dec 17, 2024
1 parent 5d0746c commit 595a1ca
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions draco/analysis/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,17 +506,21 @@ def process(self, data: containers.HybridVisStream):
data
Input container with different weights dataset
"""
weights = data.weight[:].local_array

# Remove the reference to the vis_weight dataset
del data["vis_weight"]

# Add the new elevation-dependent weight dataset
data.add_dataset("elevation_vis_weight")
data.redistribute("freq")

# Write the weights into the new dataset, broadcasting over
# the elevation axis
data.weight[:].local_array[:] = weights[..., np.newaxis, :]
# if elevation-dependent weights alread exist, this
# should be a no-op and just pass the dataset along
if "elevation_vis_weight" in data:
self.log.debug("Container already has the required dataset.")
else:
weights = data["vis_weight"][:].local_array
# Remove the reference to the vis_weight dataset
del data["vis_weight"]
# Add the new elevation-dependent weight dataset
data.add_dataset("elevation_vis_weight")
# Write the weights into the new dataset, broadcasting over
# the elevation axis
data.weight[:].local_array[:] = weights[..., np.newaxis, :]

return data

Expand Down

0 comments on commit 595a1ca

Please sign in to comment.