LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Classes | Functions
lsst.obs.decam.crosstalk Namespace Reference

Classes

class  DecamCrosstalkConfig
 
class  DecamCrosstalkTask
 
class  DecamCrosstalkIO
 

Functions

def subtractCrosstalkIO (mef, sources, coeffs)
 

Function Documentation

◆ subtractCrosstalkIO()

def lsst.obs.decam.crosstalk.subtractCrosstalkIO (   mef,
  sources,
  coeffs 
)
Remove crosstalk from a DECam Multi-Extension FITS raw image.

This version uses astropy I/O rather than the Butler due to the cross-amp
crosstalk and ease of accessing Multi-Extension FITS data. It does not
integrate with isr and does not use the Butler.

WARNING: this will run fine on a non-overscan-corrected raw image, but the
crosstalk coefficients were computed post-overscan-correction. Therefore,
**the input raw image should be overscan corrected before this is run.**

Parameters
----------
mef : `astropy.io.fits.hdu.hdulist.HDUList`
    One DECam Multi-Extension FITS image.
sources : `defaultdict`
    Crosstalk source areas affecting flux in a certain victim area.
coeffs : `list`
    Linear crosstalk coefficients.

Returns
-------
mef : `astropy.io.fits.hdu.hdulist.HDUList`
    New MEF image with crosstalk corrected data and updated header.

Definition at line 206 of file crosstalk.py.

206 def subtractCrosstalkIO(mef, sources, coeffs):
207  """Remove crosstalk from a DECam Multi-Extension FITS raw image.
208 
209  This version uses astropy I/O rather than the Butler due to the cross-amp
210  crosstalk and ease of accessing Multi-Extension FITS data. It does not
211  integrate with isr and does not use the Butler.
212 
213  WARNING: this will run fine on a non-overscan-corrected raw image, but the
214  crosstalk coefficients were computed post-overscan-correction. Therefore,
215  **the input raw image should be overscan corrected before this is run.**
216 
217  Parameters
218  ----------
219  mef : `astropy.io.fits.hdu.hdulist.HDUList`
220  One DECam Multi-Extension FITS image.
221  sources : `defaultdict`
222  Crosstalk source areas affecting flux in a certain victim area.
223  coeffs : `list`
224  Linear crosstalk coefficients.
225 
226  Returns
227  -------
228  mef : `astropy.io.fits.hdu.hdulist.HDUList`
229  New MEF image with crosstalk corrected data and updated header.
230  """
231  log = logging.getLogger('lsst.obs.decam.subtractCrosstalkIO')
232  lowx = {} # Lower x pixel index of given chip region
233  highx = {} # Upper x pixel index of given chip region
234  extension = {} # FITS extension of given chip position from CCDNUM header
235  corrected = [0] * 63 # placeholder for corrected data
236 
237  for i in range(1, 63):
238  ccd = '%02d' % mef[i].header['CCDNUM']
239  extension[ccd] = i
240  for section in 'AB':
241  ccdsec_str = mef[i].header['DATASEC' + section]
242  ccdsec_list = re.findall(r"[\w']+", ccdsec_str)
243  lowx[ccd + section] = int(ccdsec_list[0]) - 1
244  highx[ccd + section] = int(ccdsec_list[1])
245  corrected[i] = mef[i].data.astype(np.float32)
246  for ccd in ['%02d' % i for i in range(1, 63)]:
247  for section in 'AB':
248  victim = ccd + section
249  victim_data = corrected[extension[ccd]][:, lowx[victim]:highx[victim]]
250  for source in sources[victim]:
251  source_data = mef[extension[source[:2]]].data[:, lowx[source]:highx[source]]
252  if lowx[victim] != lowx[source]:
253  # If regions were read out on different sides of the CCD
254  # (i.e., an A and B mismatch) flip data in the x-direction
255  source_data = np.fliplr(source_data)
256  # Perform linear crosstalk correction
257  victim_data[:, :] = victim_data - coeffs[(victim, source)] * source_data
258  log.info('Correcting victim %s from crosstalk source %s for HDU %s', victim, source, ccd)
259 
260  for i in range(1, 63):
261  mef[i].header['HISTORY'] = 'Crosstalk corrected on {0}'.format(
262  dt.datetime.now().strftime("%Y-%m-%dT%H:%M:%S"))
263  mef[i] = fits.ImageHDU(header=mef[i].header, data=corrected[i])
264 
265  return mef
def subtractCrosstalkIO(mef, sources, coeffs)
Definition: crosstalk.py:206
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174