Skip to content

Commit

Permalink
Docstring update. Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Jul 22, 2020
1 parent 650ea41 commit 5734bc3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
7 changes: 5 additions & 2 deletions python/lsst/ip/isr/calibType.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ class IsrCalib(abc.ABC):
_SCHEMA = 'NO SCHEMA'
_VERSION = 0

def __init__(self, camera=None, detector=None,
detectorName=None, detectorId=None, log=None, **kwargs):
def __init__(self, camera=None, detector=None, detectorName=None, detectorId=None, log=None, **kwargs):
self._instrument = None
self._raftName = None
self._slotName = None
Expand Down Expand Up @@ -595,6 +594,10 @@ def fromDict(cls, dictionary):
"""
calib = cls()
calib.updateMetadata(setDate=False, **dictionary['metadata'])

# These properties should be in the metadata, but occasionally
# are found in the dictionary itself. Check both places,
# ending with `None` if neither contains the information.
calib._detectorName = dictionary.get('detectorName',
dictionary['metadata'].get('DET_NAME', None))
calib._detectorSerial = dictionary.get('detectorSerial',
Expand Down
44 changes: 38 additions & 6 deletions python/lsst/ip/isr/crosstalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,37 @@ class CrosstalkCalib(IsrCalib):
Log to write messages to.
**kwargs :
Parameters to pass to parent constructor.
Notes
-----
The crosstalk attributes stored are:
hasCrosstalk : `bool`
Whether there is crosstalk defined for this detector.
nAmp : `int`
Number of amplifiers in this detector.
crosstalkShape : `tuple` [`int`, `int`]
A tuple containing the shape of the ``coeffs`` matrix. This
should be equivalent to (``nAmp``, ``nAmp``).
coeffs : `np.ndarray`
A matrix containing the crosstalk coefficients. coeff[i][j]
contains the coefficients to calculate the contribution
amplifier_j has on amplifier_i (each row[i] contains the
corrections for detector_i).
coeffErr : `np.ndarray`, optional
A matrix (as defined by ``coeffs``) containing the standard
distribution of the crosstalk measurements.
coeffNum : `np.ndarray`, optional
A matrix containing the number of pixel pairs used to measure
the ``coeffs`` and ``coeffErr``.
coeffValid : `np.ndarray`, optional
A matrix of Boolean values indicating if the coefficient is
valid, defined as abs(coeff) > coeffErr / sqrt(coeffNum).
interChip : `dict` [`np.ndarray`]
A dictionary keyed by detectorName containing ``coeffs``
matrices used to correct for inter-chip crosstalk with a
source on the detector indicated.
"""
_OBSTYPE = 'CROSSTALK'
_SCHEMA = 'Gen3 Crosstalk'
Expand Down Expand Up @@ -170,7 +201,8 @@ def fromDict(cls, dictionary):

calib.setMetadata(dictionary['metadata'])
calib._detectorName = dictionary.get('detectorName',
dictionary['metadata'].get('DETECTOR', None))
dictionary['metadata'].get('DET_NAME', None))
calib._detectorId = dictionary['metadata'].get('DETECTOR', None)
calib._detectorSerial = dictionary.get('detectorSerial',
dictionary['metadata'].get('DET_SER', None))
calib._instrument = dictionary.get('instrument',
Expand All @@ -193,7 +225,7 @@ def fromDict(cls, dictionary):
if 'coeffValid' in dictionary:
calib.coeffValid = np.array(dictionary['coeffValid']).reshape(calib.crosstalkShape)
else:
calib.coeffValid = np.zeros_like(calib.coeffs, dtype=bool)
calib.coeffValid = np.ones_like(calib.coeffs, dtype=bool)

calib.interChip = dictionary.get('interChip', None)
if calib.interChip:
Expand Down Expand Up @@ -318,7 +350,8 @@ def toTable(self):
return tableList

# Implementation methods.
def extractAmp(self, image, amp, ampTarget, isTrimmed=False):
@staticmethod
def extractAmp(image, amp, ampTarget, isTrimmed=False):
"""Extract the image data from an amp, flipped to match ampTarget.
Parameters
Expand Down Expand Up @@ -355,11 +388,10 @@ def extractAmp(self, image, amp, ampTarget, isTrimmed=False):
# Flipping is necessary only if the desired configuration doesn't match what we currently have
xFlip = X_FLIP[targetAmpCorner] ^ X_FLIP[thisAmpCorner]
yFlip = Y_FLIP[targetAmpCorner] ^ Y_FLIP[thisAmpCorner]
self.log.debug("Extract amp: %s %s %s %s",
amp.getName(), ampTarget.getName(), thisAmpCorner, targetAmpCorner)
return lsst.afw.math.flipImage(output, xFlip, yFlip)

def calculateBackground(self, mi, badPixels=["BAD"]):
@staticmethod
def calculateBackground(mi, badPixels=["BAD"]):
"""Estimate median background in image.
Getting a great background model isn't important for crosstalk correction,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_crosstalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
import lsst.afw.cameraGeom as cameraGeom

from lsst.pipe.base import Struct
from lsst.ip.isr import (IsrTask, CrosstalkCalib,
CrosstalkTask, NullCrosstalkTask)
from lsst.ip.isr import IsrTask, CrosstalkCalib, CrosstalkTask, NullCrosstalkTask

try:
display
Expand Down

0 comments on commit 5734bc3

Please sign in to comment.