Skip to content

Commit

Permalink
Merge pull request #782 from lsst/tickets/DM-38694
Browse files Browse the repository at this point in the history
DM-38694: Use InMemoryDatasetHandle in assemble coadd test
  • Loading branch information
timj committed May 4, 2023
2 parents a57fb48 + ad3aa6a commit cb98b56
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 41 deletions.
6 changes: 3 additions & 3 deletions python/lsst/pipe/tasks/functors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ def computeDeltaRaDec(self, x, y, cd11, cd12, cd21, cd22):
"""
return (x * cd11 + y * cd12, x * cd21 + y * cd22)

def computeSkySeperation(self, ra1, dec1, ra2, dec2):
def computeSkySeparation(self, ra1, dec1, ra2, dec2):
"""Compute the local pixel scale conversion.
Parameters
Expand All @@ -1226,7 +1226,7 @@ def computeSkySeperation(self, ra1, dec1, ra2, dec2):
np.sin(deltaDec / 2) ** 2
+ np.cos(dec2) * np.cos(dec1) * np.sin(deltaRa / 2) ** 2))

def getSkySeperationFromPixel(self, x1, y1, x2, y2, cd11, cd12, cd21, cd22):
def getSkySeparationFromPixel(self, x1, y1, x2, y2, cd11, cd12, cd21, cd22):
"""Compute the distance on the sphere from x2, y1 to x1, y1.
Parameters
Expand Down Expand Up @@ -1258,7 +1258,7 @@ def getSkySeperationFromPixel(self, x1, y1, x2, y2, cd11, cd12, cd21, cd22):
ra1, dec1 = self.computeDeltaRaDec(x1, y1, cd11, cd12, cd21, cd22)
ra2, dec2 = self.computeDeltaRaDec(x2, y2, cd11, cd12, cd21, cd22)
# Great circle distance for small separations.
return self.computeSkySeperation(ra1, dec1, ra2, dec2)
return self.computeSkySeparation(ra1, dec1, ra2, dec2)


class ComputePixelScale(LocalWcs):
Expand Down
48 changes: 11 additions & 37 deletions tests/assembleCoaddTestUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,7 @@

from astro_metadata_translator import makeObservationInfo

__all__ = ["MockWarpReference", "makeMockSkyInfo", "MockCoaddTestData"]


class MockWarpReference(pipeBase.InMemoryDatasetHandle):
"""Very simple object that looks like a Gen 3 data reference to a warped
exposure.
Parameters
----------
exposure : `lsst.afw.image.Exposure`
The exposure to be retrieved by the data reference.
"""
def get(self, *, component=None, parameters=None):
"""Retrieve the specified dataset using the API of the Gen 3 Butler.
Parameters
----------
component : `str`, optional
If supplied, return the named metadata of the exposure.
parameters : `dict`, optional
If supplied, use the parameters to modify the exposure,
typically by taking a subset.
Returns
-------
`lsst.afw.image.Exposure` or `lsst.afw.image.VisitInfo`
or `lsst.meas.algorithms.SingleGaussianPsf`
Either the exposure or its metadata, depending on the component
requested.
"""
exp = super().get(component=component, parameters=parameters)
if isinstance(exp, afwImage.ExposureF):
exp = exp.clone()
return exp
__all__ = ["makeMockSkyInfo", "MockCoaddTestData"]


def makeMockSkyInfo(bbox, wcs, patch):
Expand Down Expand Up @@ -419,7 +386,7 @@ def makeDataRefList(exposures, matchedExposures, warpType, tract=0, patch=42, co
Returns
-------
dataRefList : `list` of `MockWarpReference`
dataRefList : `list` of `~lsst.pipe.base.InMemoryDatasetHandle`
The data references.
Raises
Expand All @@ -435,7 +402,14 @@ def makeDataRefList(exposures, matchedExposures, warpType, tract=0, patch=42, co
exposure = matchedExposures[expId]
else:
raise ValueError("warpType must be one of 'direct' or 'psfMatched'")
dataRef = MockWarpReference(exposure, storageClass="ExposureF",
tract=tract, patch=patch, visit=expId, coaddName=coaddName)
dataRef = pipeBase.InMemoryDatasetHandle(
exposure,
storageClass="ExposureF",
copy=True,
tract=tract,
patch=patch,
visit=expId,
coaddName=coaddName
)
dataRefList.append(dataRef)
return dataRefList
2 changes: 1 addition & 1 deletion tests/test_functors.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def testConvertPixelToArcseconds(self):
"base_LocalWcs_CDMatrix_2_2")

# Exercise the full set of functions in LocalWcs.
sepRadians = func.getSkySeperationFromPixel(
sepRadians = func.getSkySeparationFromPixel(
df[("meas", "g", "someCentroid_x")] - df[("meas", "g", "slot_Centroid_x")],
df[("meas", "g", "someCentroid_y")] - df[("meas", "g", "slot_Centroid_y")],
0.0,
Expand Down
1 change: 1 addition & 0 deletions tests/test_psfCandidateSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import lsst.afw.image as afwImage
import lsst.utils.tests
import lsst.meas.extensions.piff.piffPsfDeterminer
from lsst.utils import getPackageDir
from lsst.pipe.tasks.characterizeImage import CharacterizeImageTask, CharacterizeImageConfig

Expand Down
1 change: 1 addition & 0 deletions tests/test_skySources.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import logging

import lsst.afw.image as afwImage
import lsst.meas.extensions.piff.piffPsfDeterminer
import lsst.utils.tests
from lsst.utils import getPackageDir
from lsst.pipe.tasks.characterizeImage import CharacterizeImageTask, CharacterizeImageConfig
Expand Down

0 comments on commit cb98b56

Please sign in to comment.