diff --git a/src/kbmod/dataclasses.py b/src/kbmod/dataclasses.py deleted file mode 100644 index a92b43a27..000000000 --- a/src/kbmod/dataclasses.py +++ /dev/null @@ -1,145 +0,0 @@ -import os -from dataclasses import dataclass, field -from typing import Sequence - -import numpy as np - - -__all__ = ["StandardizedHeader",] - - - - -@dataclass -class StandardizedHeader: - """A dataclass that associates standardized metadata with one or more - standardized WCS. - """ - metadata: Metadata = None - wcs: Sequence[Wcs] = field(default_factory=list) - - @classmethod - def fromDict(cls, data): - """Construct an StandardizedHeader from a dictionary. - - The dictionary can contain either a flattened set of values like: - - {obs_lon: ... , wcs_radius: ... } - - or have separated metadata and wcs values like: - - {metadata: {...}, wcs: {...}} - - in which case the wcs can be an iterable, i.e. - - {metadata: {...}, wcs: [{...}, {...}, ... ]} - - Parameters - ---------- - data : `dict` - Dictionary containing at least the required standardized keys for - `Metadata` and `Wcs`. - """ - meta, wcs = None, [] - if "metadata" in data and "wcs" in data: - meta = Metadata(**data["metadata"]) - - # sometimes multiExt Fits have only 1 valid image extension - # otherwise we expect a list. - if isinstance(data["wcs"], dict): - wcs.append(Wcs(metadata=meta, **data["wcs"])) - else: - for ext in data["wcs"]: - wcs.append(Wcs(metadata=meta, **ext)) - else: - meta = Metadata.fromDictSubset(data) - wcs = Wcs.fromDictSubset(data) - wcs.metadata = meta - - if type(wcs) != list: - wcs = [wcs, ] - - return cls(metadata=meta, wcs=wcs) - - def __eq__(self, other): - return self.isClose(other) - - @property - def isMultiExt(self): - """True when the header is a multi extension header.""" - return len(self.wcs) > 1 - - def updateMetadata(self, standardizedMetadata): - """Update metadata values from a dictionary or another Metadata object. - - Parameters - ---------- - standardizedMetadata : `dict` or `Metadata` - All, or subset of all, metadata keys which values will be updated. - """ - metadata = dataToComponent(standardizedMetadata, Metadata) - if metadata is not None: - self.metadata = metadata - else: - raise ValueError(f"Could not create metadata from the given data: {standardizedMetadata}") - - def appendWcs(self, standardizedWcs): - """Append a WCS component. - - Parameters - ---------- - standardizedWcs : `dict` or `Wcs` - Data which to append to the current collection of associated wcs's. - """ - wcs = dataToComponent(standardizedWcs, Wcs) - if wcs is not None: - self.wcs.append(wcs) - else: - raise ValueError(f"Could not create a WCS from the given data: {standardizedWcs}") - - def extendWcs(self, standardizedWcs): - """Extend current collection of associated wcs by appending elements - from an iterable. - - Parameters - ---------- - standardizedWcs : `iterable`` - Data which to append to the current collection of associated wcs's. - """ - for wcs in standardizedWcs: - self.appendWcs(wcs) - - def isClose(self, other, **kwargs): - """Tests approximate equality between two standardized headers by - testing appoximate equality of respective metadatas and wcs's. - - Parameters - ---------- - other : `StandardizeHeader` - Another `Metadata` instance to test approximate equality with. - **kwargs : `dict` - Keyword arguments passed onto `numpy.allclose` - - Returns - ------- - approxEqual : `bool` - True when approximately equal, False otherwise. - """ - if len(self.wcs) != len(other.wcs): - return False - - areClose = self.metadata.isClose(other.metadata, **kwargs) - for thisWcs, otherWcs in zip(self.wcs, other.wcs): - areClose = areClose and thisWcs.isClose(otherWcs, **kwargs) - - return areClose - - def toDict(self): - """Returns a dictionary of standardized metadata and wcs values.""" - if self.isMultiExt: - wcsDicts = {"wcs": [wcs.toDict() for wcs in self.wcs]} - else: - wcsDicts = {"wcs": self.wcs[0].toDict()} - metadataDict = {"metadata": self.metadata.toDict()} - metadataDict.update(wcsDicts) - return metadataDict diff --git a/src/kbmod/image_info2.py b/src/kbmod/image_info.py similarity index 100% rename from src/kbmod/image_info2.py rename to src/kbmod/image_info.py diff --git a/src/kbmod/standardizers/example_thing b/src/kbmod/standardizers/example_thing deleted file mode 100644 index cedfbf51d..000000000 --- a/src/kbmod/standardizers/example_thing +++ /dev/null @@ -1 +0,0 @@ -python -c "from kbmod import image_info2;test = image_info2.ImageInfoSet.fromLocation('/epyc/users/smotherh/DEEP/PointingGroups/butler-repo/B1a_20210909/calibrate_r/20211202T181518Z/calexp/20210910/VR/VR_DECam_c0007_6300.0_2600.0/1031745/calexp_DECam_VR_VR_DECam_c0007_6300_0_2600_0_1031745_S29_B1a_20210909_calibrate_r_20211202T181518Z.fits');print(test)" \ No newline at end of file