LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
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 205 of file crosstalk.py.

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