Skip to content

Commit

Permalink
Merge pull request #222 from lsst/tickets/DM-35772
Browse files Browse the repository at this point in the history
DM-35772: Remove gen2 code from ip_isr.
  • Loading branch information
erykoff committed Aug 1, 2022
2 parents 3503c2a + a697c69 commit 38cc328
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 550 deletions.
27 changes: 0 additions & 27 deletions bin.src/runIsr.py

This file was deleted.

68 changes: 0 additions & 68 deletions python/lsst/ip/isr/fringe.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,42 +80,6 @@ class FringeTask(Task):
ConfigClass = FringeConfig
_DefaultName = 'isrFringe'

def readFringes(self, dataRef, expId=None, assembler=None):
"""Read the fringe frame(s), and pack data into a Struct
The current implementation assumes only a single fringe frame and
will have to be updated to support multi-mode fringe subtraction.
This implementation could be optimised by persisting the fringe
positions and fluxes.
Parameters
----------
dataRef : `daf.butler.butlerSubset.ButlerDataRef`
Butler reference for the exposure that will have fringing
removed.
expId : `int`, optional
Exposure id to be fringe corrected, used to set RNG seed.
assembler : `lsst.ip.isr.AssembleCcdTask`, optional
An instance of AssembleCcdTask (for assembling fringe
frames).
Returns
-------
fringeData : `pipeBase.Struct`
Struct containing fringe data:
- ``fringes`` : `lsst.afw.image.Exposure` or `list` thereof
Calibration fringe files containing master fringe frames.
- ``seed`` : `int`, optional
Seed for random number generation.
"""
try:
fringe = dataRef.get("fringe", immediate=True)
except Exception as e:
raise RuntimeError("Unable to retrieve fringe for %s: %s" % (dataRef.dataId, e))

return self.loadFringes(fringe, expId=expId, assembler=assembler)

def loadFringes(self, fringeExp, expId=None, assembler=None):
"""Pack the fringe data into a Struct.
Expand Down Expand Up @@ -212,38 +176,6 @@ def run(self, exposure, fringes, seed=None):
afwDisplay.Display(frame=getFrame()).mtv(exposure, title="Fringe subtracted")
return solution, rms

@timeMethod
def runDataRef(self, exposure, dataRef, assembler=None):
"""Remove fringes from the provided science exposure.
Retrieve fringes from butler dataRef provided and remove from
provided science exposure. Fringes are only subtracted if the
science exposure has a filter listed in the configuration.
Parameters
----------
exposure : `lsst.afw.image.Exposure`
Science exposure from which to remove fringes.
dataRef : `daf.persistence.butlerSubset.ButlerDataRef`
Butler reference to the exposure. Used to find
appropriate fringe data.
assembler : `lsst.ip.isr.AssembleCcdTask`, optional
An instance of AssembleCcdTask (for assembling fringe
frames).
Returns
-------
solution : `np.array`
Fringe solution amplitudes for each input fringe frame.
rms : `float`
RMS error for the fit solution for this exposure.
"""
if not self.checkFilter(exposure):
self.log.info("Filter not found in FringeTaskConfig.filters. Skipping fringe correction.")
return
fringeStruct = self.readFringes(dataRef, assembler=assembler)
return self.run(exposure, **fringeStruct.getDict())

def checkFilter(self, exposure):
"""Check whether we should fringe-subtract the science exposure.
Expand Down
42 changes: 5 additions & 37 deletions python/lsst/ip/isr/isrMock.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"CalibratedRawMock", "MasterMock",
"BiasMock", "DarkMock", "FlatMock", "FringeMock", "UntrimmedFringeMock",
"BfKernelMock", "DefectMock", "CrosstalkCoeffMock", "TransmissionMock",
"DataRefMock"]
"MockDataContainer", "MockFringeContainer"]


class IsrMockConfig(pexConfig.Config):
Expand Down Expand Up @@ -932,12 +932,8 @@ def __init__(self, **kwargs):
self.config.doTransmissionCurve = True


class DataRefMock(object):
"""Simulated gen2 butler data ref.
Currently only supports get and put operations, which are most
likely to be called for data in ISR processing.
class MockDataContainer(object):
"""Container for holding ISR mock objects.
"""
dataId = "isrMock Fake Data"
darkval = 2. # e-/sec
Expand Down Expand Up @@ -1017,25 +1013,9 @@ def get(self, dataType, **kwargs):
else:
raise RuntimeError("ISR DataRefMock cannot return %s.", dataType)

def put(self, exposure, filename):
"""Write an exposure to a FITS file.
Parameters
----------
exposure : `lsst.afw.image.Exposure`
Image data to write out.
filename : `str`
Base name of the output file.
"""
exposure.writeFits(filename+".fits")


class FringeDataRefMock(object):
"""Simulated gen2 butler data ref.
Currently only supports get and put operations, which are most
likely to be called for data in ISR processing.

class MockFringeContainer(object):
"""Container for mock fringe data.
"""
dataId = "isrMock Fake Data"
darkval = 2. # e-/sec
Expand Down Expand Up @@ -1101,15 +1081,3 @@ def get(self, dataType, **kwargs):
return None
else:
return None

def put(self, exposure, filename):
"""Write an exposure to a FITS file.
Parameters
----------
exposure : `lsst.afw.image.Exposure`
Image data to write out.
filename : `str`
Base name of the output file.
"""
exposure.writeFits(filename+".fits")

0 comments on commit 38cc328

Please sign in to comment.