LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
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 206 of file crosstalk.py.

206def 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