LSST Applications g00274db5b6+edbf708997,g00d0e8bbd7+edbf708997,g199a45376c+5137f08352,g1fd858c14a+1d4b6db739,g262e1987ae+f4d9505c4f,g29ae962dfc+7156fb1a53,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3e17d7035e+5b3adc59f5,g3fd5ace14f+852fa6fbcb,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+9f17e571f4,g67b6fd64d1+6dc8069a4c,g74acd417e5+ae494d68d9,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+536efcc10a,g7cc15d900a+d121454f8d,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d7436a09f+28c28d8d6d,g8ea07a8fe4+db21c37724,g92c671f44c+9f17e571f4,g98df359435+b2e6376b13,g99af87f6a8+b0f4ad7b8d,gac66b60396+966efe6077,gb88ae4c679+7dec8f19df,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gc24b5d6ed1+9f17e571f4,gca7fc764a6+6dc8069a4c,gcc769fe2a4+97d0256649,gd7ef33dd92+6dc8069a4c,gdab6d2f7ff+ae494d68d9,gdbb4c4dda9+9f17e571f4,ge410e46f29+6dc8069a4c,geaed405ab2+e194be0d2b,w.2025.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.ip.isr.electrostaticBrighterFatter Namespace Reference

Classes

class  CustomFFTConvolution
 
class  ElectrostaticBrighterFatterDistortionMatrix
 

Functions

 electrostaticBrighterFatterCorrection (exposure, electroBfDistortionMatrix, applyGain, gains=None)
 

Detailed Description

Brighter Fatter Kernel calibration definition.

Function Documentation

◆ electrostaticBrighterFatterCorrection()

lsst.ip.isr.electrostaticBrighterFatter.electrostaticBrighterFatterCorrection ( exposure,
electroBfDistortionMatrix,
applyGain,
gains = None )
Evaluates the correction of CCD images affected by the
brighter-fatter effect, as described in
https://arxiv.org/abs/2301.03274. Requires as input the result of
an electrostatic fit to flat covariance data (or any other
determination of pixel boundary shifts under the influence of a
single electron).

The filename refers to an input tuple that contains the
boundary shifts for one electron. This file is produced by an
electrostatic fit to data extracted from flat-field statistics,
implemented in https://gitlab.in2p3.fr/astier/bfptc/tools/fit_cov.py.

Definition at line 559 of file electrostaticBrighterFatter.py.

559def electrostaticBrighterFatterCorrection(exposure, electroBfDistortionMatrix, applyGain, gains=None):
560 """
561 Evaluates the correction of CCD images affected by the
562 brighter-fatter effect, as described in
563 https://arxiv.org/abs/2301.03274. Requires as input the result of
564 an electrostatic fit to flat covariance data (or any other
565 determination of pixel boundary shifts under the influence of a
566 single electron).
567
568 The filename refers to an input tuple that contains the
569 boundary shifts for one electron. This file is produced by an
570 electrostatic fit to data extracted from flat-field statistics,
571 implemented in https://gitlab.in2p3.fr/astier/bfptc/tools/fit_cov.py.
572 """
573
574 # Use the symmetrize function to fill the four quadrants for each kernel
575 r = electroBfDistortionMatrix.fitRange - 1
576 aN = electroBfDistortionMatrix.aN
577 aS = electroBfDistortionMatrix.aS
578 aE = electroBfDistortionMatrix.aE
579 aW = electroBfDistortionMatrix.aW
580
581 # Initialize kN and kE arrays
582 kN = np.zeros((2 * r + 1, 2 * r + 1))
583 kE = np.zeros_like(kN)
584
585 # Fill in the 4 quadrants for kN
586 kN[r:, r:] = aN # Quadrant 1 (bottom-right)
587 kN[:r+1, r:] = np.flipud(aN) # Quadrant 2 (top-right)
588 kN[r:, :r+1] = np.fliplr(aS) # Quadrant 3 (bottom-left)
589 kN[:r+1, :r+1] = np.flipud(np.fliplr(aS)) # Quadrant 4 (top-left)
590
591 # Fill in the 4 quadrants for kE
592 kE[r:, r:] = aE # Quadrant 1 (bottom-right)
593 kE[:r+1, r:] = np.flipud(aW) # Quadrant 2 (top-right)
594 kE[r:, :r+1] = np.fliplr(aE) # Quadrant 3 (bottom-left)
595 kE[:r+1, :r+1] = np.flipud(np.fliplr(aW)) # Quadrant 4 (top-left)
596
597 # Tweak the edges so that the sum rule applies.
598 kN[:, 0] = -kN[:, -1]
599 kE[0, :] = -kE[-1, :]
600
601 # We use the normalization of Guyonnet et al. (2015),
602 # which is compatible with the way the input file is produced.
603 # The factor 1/2 is due to the fact that the charge distribution at the end
604 # is twice the average, and the second 1/2 is due to
605 # charge interpolation.
606 kN *= 0.25
607 kE *= 0.25
608
609 # Indeed, i and j in the tuple refer to serial and parallel directions.
610 # In most Python code, the image reads im[j, i], so we transpose:
611 kN = kN.T
612 kE = kE.T
613
614 # Get the image to perform the correction
615 image = exposure.getMaskedImage().getImage()
616
617 # The image needs to be units of electrons/holes
618 with gainContext(exposure, image, applyGain, gains):
619 # Computes the correction and returns the "delta_image",
620 # which should be subtracted from "im" in order to undo the BF effect.
621 # The input image should be expressed in electrons
622 im = image.getArray().copy()
623 convolver = CustomFFTConvolution(im, kN)
624 convolutions = convolver(im, [kN, kE])
625
626 # The convolutions contain the boundary shifts (in pixel size units)
627 # for [horizontal, vertical] boundaries.
628 # We now compute the charge to move around.
629 delta = np.zeros_like(im)
630 boundaryCharge = np.zeros_like(im)
631
632 # Horizontal boundaries (parallel direction).
633 # We could use a more elaborate interpolator for estimating the
634 # charge on the boundary.
635 boundaryCharge[:-1, :] = im[1:, :] + im[:-1, :]
636 # boundaryCharge[1:-2,:] = (9./8.)*(I[2:-1,:]+I[1:-2,:] -
637 # (1./8.)*(I[0:-3,:]+I[3,:])
638
639 # The charge to move around is the
640 # product of the boundary shift (in pixel size units) times the
641 # charge on the boundary (in charge per pixel unit).
642 dq = boundaryCharge * convolutions[0]
643 delta += dq
644
645 # What is gained by a pixel is lost by its neighbor (the right one).
646 delta[1:, :] -= dq[:-1, :]
647
648 # Vertical boundaries.
649 boundaryCharge = np.zeros_like(im) # Reset to zero.
650 boundaryCharge[:, :-1] = im[:, 1:] + im[:, :-1]
651 dq = boundaryCharge * convolutions[1]
652 delta += dq
653
654 # What is gained by a pixel is lost by its neighbor.
655 delta[:, 1:] -= dq[:, :-1]
656
657 # TODO: One might check that delta.sum() ~ 0 (charge conservation).
658
659 # Apply the correction to the original image
660 exposure.image.array -= delta
661
662 return exposure