Skip to content

Commit

Permalink
Merge branch 'tickets/DM-24466'
Browse files Browse the repository at this point in the history
  • Loading branch information
plazas committed Apr 17, 2020
2 parents 5c61226 + 5423a6f commit 6a9ca1a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
38 changes: 30 additions & 8 deletions python/lsst/obs/hsc/hscMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ def __init__(self, **kwargs):

super(HscMapper, self).__init__(policy, os.path.dirname(policyFile), **kwargs)

self._linearize = Linearizer()

# Ensure each dataset type of interest knows about the full range of keys available from the registry
keys = {'field': str,
'visit': int,
Expand Down Expand Up @@ -217,8 +215,6 @@ def bypass_ccdExposureId_bits(self, datasetType, pythonType, location, dataId):

def map_linearizer(self, dataId, write=False):
"""Map a linearizer."""
if self._linearize is None:
raise RuntimeError("No linearizer available.")
actualId = self._transformId(dataId)
return ButlerLocation(
pythonType="lsst.ip.isr.LinearizeSquared",
Expand All @@ -230,11 +226,37 @@ def map_linearizer(self, dataId, write=False):
storage=self.rootStorage)

def bypass_linearizer(self, datasetType, pythonType, butlerLocation, dataId):
"""Return the linearizer.
"""Return a linearizer for the given detector.
On each call, a fresh instance of `Linearizer` is returned; the caller is responsible for
initializing it appropriately for the detector.
Parameters
----------
datasetType : `str``
The dataset type.
pythonType : `str` or `type`
Type of python object.
butlerLocation : `lsst.daf.persistence.ButlerLocation`
Struct-like class that holds information needed to persist and retrieve an object using
the LSST Persistence Framework.
dataId : `dict`
dataId passed to map location.
Returns
-------
Linearizer : `lsst.ip.isr.Linearizer`
Linearizer object for the given detector.
Notes
-----
Linearizers are not saved to persistent storage; rather, they are managed entirely in memory.
On each call, this function will return a new instance of `Linearizer`, which must be managed
(including setting it up for use with a particular detector) by the caller. Calling
`bypass_linearizer` twice for the same detector will return _different_ instances of `Linearizer`,
which share no state.
"""
if self._linearize is None:
raise RuntimeError("No linearizer available.")
return self._linearize
return Linearizer()

def _computeCoaddExposureId(self, dataId, singleFilter):
"""Compute the 64-bit (long) identifier for a coadd.
Expand Down
6 changes: 5 additions & 1 deletion tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ def testFlat(self):
self.assertEqual(flat.getDetector().getId(), self.ccdNum)

def testLinearizer(self):
self.assertTrue(self.butler.get('linearizer', ccdnum=1))
lin1 = self.butler.get('linearizer', ccdnum=1)
lin2 = self.butler.get('linearizer', ccdnum=2)
self.assertIsNotNone(lin1)
self.assertIsNotNone(lin2)
self.assertNotEqual(lin1, lin2)


class TestMemory(lsst.utils.tests.MemoryTestCase):
Expand Down

0 comments on commit 6a9ca1a

Please sign in to comment.