LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
Classes | Functions
lsst.obs.decam.crosstalk Namespace Reference

Classes

class  DecamCrosstalkConfig
 
class  DecamCrosstalkIO
 
class  DecamCrosstalkTask
 

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 288 of file crosstalk.py.

288 def subtractCrosstalkIO(mef, sources, coeffs):
289  """Remove crosstalk from a DECam Multi-Extension FITS raw image.
290 
291  This version uses astropy I/O rather than the Butler due to the cross-amp
292  crosstalk and ease of accessing Multi-Extension FITS data. It does not
293  integrate with isr and does not use the Butler.
294 
295  WARNING: this will run fine on a non-overscan-corrected raw image, but the
296  crosstalk coefficients were computed post-overscan-correction. Therefore,
297  **the input raw image should be overscan corrected before this is run.**
298 
299  Parameters
300  ----------
301  mef : `astropy.io.fits.hdu.hdulist.HDUList`
302  One DECam Multi-Extension FITS image.
303  sources : `defaultdict`
304  Crosstalk source areas affecting flux in a certain victim area.
305  coeffs : `list`
306  Linear crosstalk coefficients.
307 
308  Returns
309  -------
310  mef : `astropy.io.fits.hdu.hdulist.HDUList`
311  New MEF image with crosstalk corrected data and updated header.
312  """
313  log = lsst.log.Log.getLogger('obs.decam.subtractCrosstalkIO')
314  lowx = {} # Lower x pixel index of given chip region
315  highx = {} # Upper x pixel index of given chip region
316  extension = {} # FITS extension of given chip position from CCDNUM header
317  corrected = [0] * 63 # placeholder for corrected data
318 
319  for i in range(1, 63):
320  ccd = '%02d' % mef[i].header['CCDNUM']
321  extension[ccd] = i
322  for section in 'AB':
323  ccdsec_str = mef[i].header['DATASEC' + section]
324  ccdsec_list = re.findall(r"[\w']+", ccdsec_str)
325  lowx[ccd + section] = int(ccdsec_list[0]) - 1
326  highx[ccd + section] = int(ccdsec_list[1])
327  corrected[i] = mef[i].data.astype(np.float32)
328  for ccd in ['%02d' % i for i in range(1, 63)]:
329  for section in 'AB':
330  victim = ccd + section
331  victim_data = corrected[extension[ccd]][:, lowx[victim]:highx[victim]]
332  for source in sources[victim]:
333  source_data = mef[extension[source[:2]]].data[:, lowx[source]:highx[source]]
334  if lowx[victim] != lowx[source]:
335  # If regions were read out on different sides of the CCD
336  # (i.e., an A and B mismatch) flip data in the x-direction
337  source_data = np.fliplr(source_data)
338  # Perform linear crosstalk correction
339  victim_data[:, :] = victim_data - coeffs[(victim, source)] * source_data
340  log.info('Correcting victim %s from crosstalk source %s for HDU %s' % (victim, source, ccd))
341 
342  for i in range(1, 63):
343  mef[i].header['HISTORY'] = 'Crosstalk corrected on {0}'.format(
344  dt.datetime.now().strftime("%Y-%m-%dT%H:%M:%S"))
345  mef[i] = fits.ImageHDU(header=mef[i].header, data=corrected[i])
346 
347  return mef
348 
def subtractCrosstalkIO(mef, sources, coeffs)
Definition: crosstalk.py:288
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:168
static Log getLogger(Log const &logger)
Definition: Log.h:745