Skip to content

Commit

Permalink
Merge pull request #540 from dirac-institute/standardziers/fixes
Browse files Browse the repository at this point in the history
Few ImageCollection and Standardizer bugfixes.
  • Loading branch information
DinoBektesevic authored Apr 8, 2024
2 parents 7412363 + 9dc757a commit 36a2fc6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/kbmod/image_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,12 @@ def __getitem__(self, key):
if isinstance(key, (int, str, np.integer)):
return self.data[self._userColumns][key]
elif isinstance(key, (list, np.ndarray, slice)):
return self.__class__(self.data[key], standardizers=self._standardizers[key])
# current data table has standardizer idxs with respect to current
# list of standardizers. Sub-selecting them resets the count to 0
meta = self.data[key]
stds = [self._standardizers[idx] for idx in meta["std_idx"]]
meta["std_idx"] = np.arange(len(stds))
return self.__class__(meta, standardizers=stds)
else:
return self.data[key]

Expand Down Expand Up @@ -502,14 +507,14 @@ def toImageStack(self):
layeredImages = [img for std in self._standardizers for img in std.toLayeredImage()]
return ImageStack(layeredImages)

def toWorkUnit(self, config):
def toWorkUnit(self, config=None):
"""Return an `~kbmod.WorkUnit` object for processing with
KBMOD.
Parameters
----------
config : `~kbmod.SearchConfiguration`
Search configuration.
config : `~kbmod.SearchConfiguration` or None, optional
Search configuration. Default ``None``.
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion src/kbmod/standardizers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .standardizer import *
from .fits_standardizers import *
from .butler_standardizer import *
from .standardizer import *
18 changes: 17 additions & 1 deletion src/kbmod/standardizers/butler_standardizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ def resolveTarget(self, tgt):
return False

def __init__(self, id, butler, config=None, **kwargs):
# Somewhere around w_2024_ builds the datastore.root
# was removed as an attribute of the datastore, not sure
# it was ever replaced with anything back-compatible
try:
super().__init__(str(butler._datastore.root), config=config)
except:
super().__init__(butler.datastore.root, config=config)

super().__init__(butler.datastore.root, config=config)
self.butler = butler

Expand Down Expand Up @@ -310,8 +318,16 @@ def standardizePSF(self):
]

def standardizeWCS(self):
wcs = None
if self.exp.hasWcs():
meta = self.exp.wcs.getFitsMetadata()
# NAXIS values are required if we reproject
# so we must extract them if we can
meta["NAXIS1"] = self.exp.getWidth()
meta["NAXIS2"] = self.exp.getHeight()
wcs = WCS(meta)
return [
WCS(self.exp.wcs.getFitsMetadata()) if self.exp.hasWcs() else None,
wcs,
]

def standardizeBBox(self):
Expand Down

0 comments on commit 36a2fc6

Please sign in to comment.