From 603d442098d5b28fa99317b6335e14390ed8be1f Mon Sep 17 00:00:00 2001 From: Jeremy Kubica <104161096+jeremykubica@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:52:20 -0500 Subject: [PATCH] Address Dinos comment in the PR --- src/kbmod/image_collection.py | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/kbmod/image_collection.py b/src/kbmod/image_collection.py index e764aa0e..ff2b9ded 100644 --- a/src/kbmod/image_collection.py +++ b/src/kbmod/image_collection.py @@ -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