# 3.3.6 Image parameter determination

Author(s): Claus Fabricius, Lennart Lindegren, Michael Davidson

The ultimate purpose of the pre-processing is to measure the key properties of the source within each window, specifically its location and flux. The along-scan location corresponds to a transit time, and for 2D windows the across-scan location is also determined. These quantities are the primary inputs to the astrometric and G-band photometric solutions produced by AGIS and PhotPipe respectively.

In Gaia EDR3 the parameters for only a single source are fitted for each window. As an interim treatment to handle the presence of multiple sources a watershed segmentation is performed on the AF2 to AF9 samples. The samples associated with secondary sources are then masked. Further samples are masked if they are in the non-linear regime, suspected to be cosmic rays, or are on known hot columns. Charge injections and gate release lines are also masked. IPD is attempted only if sufficient samples are available with the same gating and geometry. The SM processing uses only a ‘sub-window’ of the central eight lines to avoid expensive and unnecessary sampling of the PSF wings. No attempt to handle non-linear effects such as CTI or blooming is made and so the window model is linear.

As noted in Section 3.3.4 in Gaia EDR3 a local additive background (assumed to be constant) is fitted as an image parameter for the majority of sources in order to better track the straylight features. This is constrained to be positive. The background contributions from the dark signal and charge release are kept fixed in the forward model. Using the 1D case with an LSF $L$ as an example, the expected de-biased photo-electron flux $N(k)$ of a single stellar source can be modelled as

 $\lambda_{k}\equiv\mbox{E}\left(N_{k}\right)=\beta+\alpha L(k-\kappa)\,,$ (3.5)

where $\beta$, $\alpha$ and $\kappa$ are the background level, the flux of the source, and the along-scan image location. The index $k$ is the along-scan location of the CCD sample under consideration.

Several calibrations are necessary, from the bias through to the PSF or LSF as described in the earlier sections. Furthermore, to sample the PSF/LSF the across-scan rate of the source must be derived from the attitude and an estimate of the source colour is required. In Gaia EDR3 about 40.7% of sources have wave number values from the Gaia DR2 photometric processing; a default value is used for the remainder. The full maximum-likelihood model described below also depends on good initial values for the image parameters. A centre-of-flux algorithm is used to estimate the initial source location apart for bright stars where the core is saturated, in which case a maximum correlation method is used with the PSF over a grid of possible locations. The integrated source counts within the window is used to initialise the flux parameter.

The final image parameters, viz. transit time, flux, and for 2D windows also the AC position, were determined with a maximum-likelihood method described in Section 3.3.6. For converting the fluxes from digital units to ${\rm e}^{-}/{\rm s}$, gain factors determined before launch were used. The resulting parameters are stored as intermediate data for later use in the astrometric and photometric core processes.

## A general Maximum-Likelihood algorithm for CCD modelling

The general principle for Maximum-Likelihood (ML) fitting of arbitrary models in the presence of Poissonian noise is simple and can be formulated in a general framework which is independent of the precise model. In this way, it is possible to use the same fitting procedure for 1D and 2D profile fitting to CCD sample data, as well as for more complex fitting (e.g., for estimating the parameters of the LSF model). Here, we outline the basic model for this framework.

### Model of sample data

The basic input for the estimation procedure consists of data and a parametrised model. The estimation procedure adjusts the model parameters until the predicted data agrees as well as possible with observed data. At the same time, it provides an estimate of the covariance matrix of the estimated parameters and a measure of the goodness-of-fit. The ML criterion is used for the fit, which in principle requires that the probability distribution of the data is known as a function of the model parameters. In practice, a simplified noise model is used, which is believed to be accurate enough, which leads to simple and efficient algorithms.

Let $\{N_{k}\}$ be the sample data, $\boldsymbol{\theta}=\{\theta_{i}\}$ the model parameters, and $\{\lambda_{k}(\boldsymbol{\theta})\}$ the sample values predicted by the model for given parameters. Thus, if the model is correct and $\boldsymbol{\theta}$ are the true model parameters, we have for each $k$:

 $\mbox{E}(N_{k})=\lambda_{k}(\boldsymbol{\theta}).$ (3.6)

Using a noise model, we have in addition:

 $\mbox{Var}(N_{k})=\lambda_{k}(\boldsymbol{\theta})+r^{2},$ (3.7)

where $r$ is the standard deviation of the readout noise. More precisely, the adopted continuous probability density function (pdf) for the random variable $N_{k}$ is given by:

 $p(N|\lambda,r)=\mbox{const}\times\frac{(\lambda+r^{2})^{N+r^{2}}}{\Gamma(N+r^{% 2}+1)}\,e^{-\lambda-r^{2}},$ (3.8)

valid for any real value $N\geq-r^{2}$.

It is assumed that $N_{k}$, $\lambda_{k}$, and $r$ are all expressed in electrons per sample (not in arbitrary ADU units, voltages, or similar). In particular, $N_{k}$ is the sample value after correction for bias and gain, but including dark signal and background. The readout noise $r$ is assumed to be known; it is never one of the parameters to be estimated by the methods described in this document.

The functions $\lambda_{k}(\boldsymbol{\theta})$ are in principle defined by the various source, attitude, and calibration models, including the LSF, PSF, and CTI models. The set of parameters included in the vector $\boldsymbol{\theta}$ varies depending on the application. For example, in the 1D image centroiding algorithm, $\boldsymbol{\theta}$ may consist of just two parameters representing the intensity and location of the image; in the LSF calibration process, $\boldsymbol{\theta}$ will contain the parameters (e.g., spline coefficients) defining the LSF for a particular class of stars; and so on. The intensity model $\lambda_{k}(\boldsymbol{\theta})$ is left completely open here; the only thing we need to know about it is the number of free parameters, $n=\dim(\boldsymbol{\theta})$.

### Maximum-Likelihood estimation

Given a set of sample data $\{N_{k}\}$, the ML estimation of the parameter vector $\boldsymbol{\theta}$ is done by maximizing the likelihood function:

 $L(\boldsymbol{\theta}|\{N_{k}\})=\prod_{k}p(N_{k}|\lambda_{k}(\boldsymbol{% \theta}),r),$ (3.9)

where $p(N|\lambda,r)$ is the pdf of the sample value from the adopted noise model (Equation 3.8). Mathematically equivalent, but more convenient in practice, is to maximize the log-likelihood function:

 $\ell(\boldsymbol{\theta}|\{N_{k}\})=\sum_{k}\ln p(N_{k}|\lambda_{k}(% \boldsymbol{\theta}),r).$ (3.10)

Using the modified Poissonian model, Equation 3.8, we have:

 $\ell(\boldsymbol{\theta}|\{N_{k}\})=\mbox{const}+\sum_{k}\left[(N_{k}+r^{2})% \ln\left(\lambda_{k}(\boldsymbol{\theta})+r^{2}\right)-\lambda_{k}(\boldsymbol% {\theta})\right],$ (3.11)

where the additive constant absorbs all terms that do not depend on $\boldsymbol{\theta}$. (Remember that $r$ is never one of the free model parameters.) The maximum of Equation 3.11 is obtained by solving the $n$ simultaneous likelihood equations

 $\frac{\partial\ell(\boldsymbol{\theta}|\{N_{k}\})}{\partial\boldsymbol{\theta}% }=\boldsymbol{0}.$ (3.12)

Using Equation 3.11, these equations become:

 $\sum_{k}\frac{N_{k}-\lambda_{k}(\boldsymbol{\theta})}{\lambda_{k}(\boldsymbol{% \theta})+r^{2}}\,\frac{\partial\lambda_{k}}{\partial\boldsymbol{\theta}}=% \boldsymbol{0}.$ (3.13)