Skip to content

Commit

Permalink
Address Dinos comment in the PR
Browse files Browse the repository at this point in the history
jeremykubica committed Nov 15, 2024
1 parent 7f045b5 commit 603d442
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions src/kbmod/image_collection.py
Original file line number Diff line number Diff line change
@@ -885,39 +885,20 @@ def toWorkUnit(self, search_config=None, **kwargs):

logger.info("Building WorkUnit from ImageCollection")

# Create a storage location for additional image metadata to save.
# Not all of this may be present in from the ImageCollection,
# in which case we will append None.
metadata_vals = {
"visit": [],
}

# Extract data from each standardizer and each LayeredImage within
# that standardizer.
layeredImages = []
for std in self.get_standardizers(**kwargs):
num_added = 0
for img in std["std"].toLayeredImage():
layeredImages.append(img)
num_added += 1

# Get each meta data value from the standardizer so it can be
# passed to the WorkUnit. Use the same value for all images from
# this standardizer.
metadata = std["std"].standardizeMetadata()
for col in metadata_vals.keys():
value = metadata.get(col, None)
metadata_vals[col].extend([value] * num_added)

# Append the WCS information if we have it.
# Extract all of the relevant metadata from the ImageCollection.
metadata = Table(self.toBinTableHDU().data)
if None not in self.wcs:
metadata_vals["per_image_wcs"] = list(self.wcs)

# Save the metadata as a table, but prune it if empty.
image_metadata = Table(metadata_vals) if len(metadata_vals.keys()) > 0 else None
metadata["per_image_wcs"] = list(self.wcs)

# Create the basic WorkUnit from the ImageStack.
imgstack = ImageStack(layeredImages)
work = WorkUnit(imgstack, search_config, org_image_meta=image_metadata)
work = WorkUnit(imgstack, search_config, org_image_meta=metadata)

return work

0 comments on commit 603d442

Please sign in to comment.