# public documents.sextractor_doc

## [/] [measure_astrom.tex] - Rev 25

\section{Positional parameters derived from the isophotal profile}
\label{chap:isoparam}
The following parameters are derived from the spatial distribution $\cal S$ of pixels detected
above the extraction \index{threshold} threshold. {\em The pixel values $I_i$ are taken from the (filtered)
detection \index{image} image}.

{\bf Note that, unless otherwise noted, all parameter names given
below are only prefixes. They must be followed by "{\tt\_IMAGE}" if
the results shall be expressed in pixel units (see \S..), or
"{\tt\_WORLD}" for World Coordinate System (WCS) units (see
\S\ref{astrom})}. For example: {\tt THETA} $\rightarrow$ {\tt
THETA\_IMAGE}. In all cases, parameters are first computed in the \index{image} image
coordinate system, and then converted to \index{WCS} WCS if requested.

\subsection{Limits: {\tt XMIN}, {\tt YMIN}, {\tt XMAX}, {\tt YMAX}}
These coordinates define two corners of a rectangle which encloses the detected object:
\begin{eqnarray}
{\tt XMIN} & = & \min_{i \in {\cal S}} x_i,\\
{\tt YMIN} & = & \min_{i \in {\cal S}} y_i,\\
{\tt XMAX} & = & \max_{i \in {\cal S}} x_i,\\
{\tt YMAX} & = & \max_{i \in {\cal S}} y_i,
\end{eqnarray}
where $x_i$ and $y_i$ are respectively the x-coordinate and y-coordinate of pixel $i$.

\subsection{Barycenter: {\tt X}, {\tt Y}}
Barycenter coordinates generally define the position of the center'' of a source,
although this definition can be inadequate or inaccurate if its spatial profile shows
a strong skewness or very large wings. {\tt X} and {\tt Y} are simply computed
as the first order \index{moments} moments of the profile:
\begin{eqnarray}
{\tt X} & = & \overline{x} = \frac{\displaystyle \sum_{i \in {\cal S}}
I_i x_i}{\displaystyle \sum_{i \in {\cal S}} I_i},\\ {\tt Y} & = &
\overline{y} = \frac{\displaystyle \sum_{i \in {\cal S}} I_i
y_i}{\displaystyle \sum_{i \in {\cal S}} I_i}.
\end{eqnarray}
In practice, $x_i$ and $y_i$ are summed relative to
{\tt XMIN} and {\tt YMIN} in order to reduce roundoff errors in the summing.
\gam{Could be summed relative to {\tt XPEAK} and {\tt YPEAK} (which would be
computed first) for smaller
roundoff errors.}

\subsection{Position of the peak: {\tt XPEAK}, {\tt YPEAK}}
It is sometimes useful to have the position {\tt XPEAK},{\tt YPEAK} of
the pixel with maximum intensity in a detected object, for instance
when working with likelihood maps, or when searching for artifacts.
For better robustness, {\tt PEAK} coordinates are computed on {\em
filtered} profiles if available. On symmetrical profiles, {\tt PEAK}
positions and \index{barycenter} barycenters coincide within a fraction of pixel ({\tt
XPEAK} and {\tt YPEAK} coordinates are quantized by steps of 1 pixel,
thus {\tt XPEAK\_IMAGE} and {\tt YPEAK\_IMAGE} are integers). This is
no longer true for skewed profiles, therefore a simple comparison
between {\tt PEAK} and \index{barycenter} barycenter coordinates can be used to identify
asymmetrical objects on well-sampled \index{image} images.

\subsection{2nd order \index{moments} moments: {\tt X2}, {\tt Y2}, {\tt XY}}
(Centered) second-order \index{moments} moments are convenient for measuring the spatial spread of a source
profile. In {\sc SExtractor} they are computed with:
\begin{eqnarray}
{\tt X2} & = \overline{x^2} = & \frac{\displaystyle \sum_{i \in {\cal
S}} I_i x_i^2}{\displaystyle \sum_{i \in {\cal S}} I_i} -
\overline{x}^2,\\ {\tt Y2} & = \overline{y^2} = & \frac{\displaystyle
\sum_{i \in {\cal S}} I_i y_i^2}{\displaystyle \sum_{i \in {\cal S}}
I_i} - \overline{y}^2,\\ {\tt XY} & = \overline{xy} = &
\frac{\displaystyle \sum_{i \in {\cal S}} I_i x_i y_i}{\displaystyle
\sum_{i \in {\cal S}} I_i} - \overline{x}\,\overline{y},
\end{eqnarray}
These expressions are more subject to roundoff errors than if the 1st-order \index{moments} moments were
subtracted before summing, but allow both 1st and 2nd order \index{moments} moments to be computed in one
pass. Roundoff errors are however kept to a negligible value by measuring all positions
relative here again to {\tt XMIN} and {\tt YMIN}.
\gam{Could be summed relative to
{\tt XPEAK} and {\tt YPEAK} or
{\tt X} and {\tt Y}
for smaller roundoff errors.}

\subsection{Basic shape parameters: {\tt A}, {\tt B}, {\tt THETA}}
\label{chap:abtheta}
These parameters are intended to describe the detected object as an elliptical
shape. {\tt A} and {\tt B} are its \index{semi-major} semi-major and \index{semi-minor axis} semi-minor axis lengths,
respectively. More precisely, they represent the maximum and minimum spatial
\rms dispersion of the object profile along any direction. {\tt THETA} is the
position-angle between of the {\tt A} axis relative to the {\tt NAXIS1} \index{image} image axis. It is
counted counter-clockwise. Here is how they are computed:

2nd-order \index{moments} moments can easily be expressed in a referential rotated from the
$x,y$ \index{image} image coordinate system
by an angle +$\theta$:
$$\label{eq:varproj} \begin{array}{lcrrr} \overline{x_{\theta}^2} & = & \cos^2\theta\:\overline{x^2} & +\,\sin^2\theta\:\overline{y^2} & -\,2 \cos\theta \sin\theta\:\overline{xy},\\ \overline{y_{\theta}^2} & = & \sin^2\theta\:\overline{x^2} & +\,\cos^2\theta\:\overline{y^2} & +\,2 \cos\theta \sin\theta\:\overline{xy},\\ \overline{xy_{\theta}} & = & \cos\theta \sin\theta\:\overline{x^2} & -\,\cos\theta \sin\theta\:\overline{y^2} & +\,(\cos^2\theta - \sin^2\theta)\:\overline{xy}. \end{array}$$
One can find interesting angles $\theta_0$ for which the variance is
minimized (or maximized) along $x_{\theta}$:
$${\left.\frac{\partial \overline{x_{\theta}^2}}{\partial \theta} \right|}_{\theta_0} = 0,$$
$$2 \cos\theta \sin\theta_0\:(\overline{y^2} - \overline{x^2}) + 2 (\cos^2\theta_0 - \sin^2\theta_0)\:\overline{xy} = 0.$$
If $\overline{y^2} \neq \overline{x^2}$, this implies:
$$\label{eq:theta0} \tan 2\theta_0 = 2 \frac{\overline{xy}}{\overline{x^2} - \overline{y^2}},$$
a result which can also be obtained by requiring the \index{covariance} covariance
$\overline{xy_{\theta_0}}$ to be null.
Over the domain $[-\pi/2, +\pi/2[$, two different angles --- with opposite signs --- satisfy
(\ref{eq:theta0}).
By definition, {\tt THETA} is the position angle for which
$\overline{x_{\theta}^2}$ is {\em max}\,imized.
{\tt THETA} is therefore the solution to (\ref{eq:theta0}) that has the same sign as
the \index{covariance} covariance $\overline{xy}$.
{\tt A} and {\tt B} can now simply be expressed as:
\begin{eqnarray}
{\tt A}^2 & = & \overline{x^2}_{\tt THETA},\ \ \ {\rm and}\\
{\tt B}^2 & = & \overline{y^2}_{\tt THETA}.
\end{eqnarray}
{\tt A} and {\tt B} can be computed directly from the 2nd-order \index{moments} moments, using the following
equations derived from (\ref{eq:varproj}) after some algebra:
\begin{eqnarray}
\label{eq:aimage}
{\tt A}^2 & = & \frac{\overline{x^2}+\overline{y^2}}{2}
+ \sqrt{\left(\frac{\overline{x^2}-\overline{y^2}}{2}\right)^2 + \overline{xy}^2},\\
{\tt B}^2 & = & \frac{\overline{x^2}+\overline{y^2}}{2}
- \sqrt{\left(\frac{\overline{x^2}-\overline{y^2}}{2}\right)^2 + \overline{xy}^2}.
\end{eqnarray}
Note that {\tt A} and {\tt B} are exactly halves the $a$ and $b$
parameters computed by the \index{COSMOS} COSMOS \index{image} image analyser (Stobie 1980,1986).
Actually, $a$ and $b$ are defined by Stobie as the \index{semi-major} semi-major and
semi-minor axes of an elliptical shape with constant surface
brightness, which would have the same 2nd-order \index{moments} moments as the
analysed object.

\subsection{Ellipse parameters: {\tt CXX}, {\tt CYY}, {\tt CXY}}
\label{chap:cxx}
{\tt A}, {\tt B} and {\tt THETA} are not very convenient to use when,
for instance, one wants to know if a particular {\sc SExtractor}
detection extends over some position. For this kind of application,
three other ellipse parameters are provided; {\tt CXX}, {\tt CYY} and
{\tt CXY}. They do nothing more than describing the same ellipse, but
in a different way: the elliptical shape associated to a detection is
now parameterized as
$${\tt CXX} (x-\overline{x})^2 + {\tt CYY} (y-\overline{y})^2 + {\tt CXY} (x-\overline{x})(y-\overline{y}) = R^2,$$
where $R$ is a parameter which scales the ellipse, in units of {\tt A}
(or {\tt B}). Generally, the isophotal limit of a detected object is
well represented by $R\approx 3$ (Fig. \ref{fig:ellipse}). Ellipse
parameters can be derived from the 2nd order \index{moments} moments:
\begin{eqnarray}
{\tt CXX} & = & \frac{\cos^2 {\tt THETA}}{{\tt A}^2} + \frac{\sin^2
{\tt THETA}}{{\tt B}^2} =
\frac{\overline{y^2}}{\sqrt{\left(\frac{\overline{x^2}-\overline{y^2}}{2}\right)^2
+ \overline{xy}^2}}\\ {\tt CYY} & = & \frac{\sin^2 {\tt THETA}}{{\tt
A}^2} + \frac{\cos^2 {\tt THETA}}{{\tt B}^2} =
\frac{\overline{x^2}}{\sqrt{\left(\frac{\overline{x^2}-\overline{y^2}}{2}\right)^2
+ \overline{xy}^2}}\\ {\tt CXY} & = & 2 \,\cos {\tt THETA}\,\sin {\tt
THETA} \left( \frac{1}{{\tt A}^2} - \frac{1}{{\tt B}^2}\right) = -2\,
\frac{\overline{xy}}{\sqrt{\left(\frac{\overline{x^2}-\overline{y^2}}{2}\right)^2
+ \overline{xy}^2}}
\end{eqnarray}

%------------------------------ Fig. phot -----------------------------
\begin{figure}[htbp]
\centerline{\includegraphics[width=16cm]{ps/ellipse.ps}}
\caption{
The \index{mean} meaning of basic shape parameters.
}
\label{fig:ellipse}
\end{figure}

\subsection{By-products of shape parameters: {\tt ELONGATION} and
{\tt ELLIPTICITY}}

\footnote{Such parameters are dimensionless
and therefore do not accept any {\tt \_IMAGE} or {\tt \_WORLD} suffix}

These parameters are directly derived from {\tt A} and {\tt B}:
\begin{eqnarray}
{\tt ELONGATION} & = & \frac{\tt A}{\tt B}\ \ \ \ \ \mbox{and}\\
{\tt ELLIPTICITY} & = & 1 - \frac{\tt B}{\tt A}.
\end{eqnarray}

\subsection{Position errors: {\tt ERRX2}, {\tt ERRY2}, {\tt ERRXY},
{\tt ERRA}, {\tt ERRB}, {\tt ERRTHETA}, {\tt ERRCXX}, {\tt ERRCYY},
{\tt ERRCXY}}
\label{chap:poserr}
Uncertainties on the position of the \index{barycenter} barycenter can be estimated using
photon statistics. Of course, this kind of estimate has to be
considered as a lower-value of the real error since it does not
include, for instance, the contribution of detection biases or the
contamination by \index{neighbour} \index{neighbours} neighbours. As {\sc SExtractor} does not currently
take into account possible correlations between pixels, the variances
simply write:
\begin{eqnarray}
{\tt ERRX2} & = {\rm var}(\overline{x}) = & \frac{\displaystyle
\sum_{i \in {\cal S}} \sigma^2_i (x_i-\overline{x})^2} {\displaystyle
\left(\sum_{i \in {\cal S}} I_i\right)^2},\\ {\tt ERRY2} & = {\rm
var}(\overline{y}) = & \frac{\displaystyle \sum_{i \in {\cal S}}
\sigma^2_i (y_i-\overline{y})^2} {\displaystyle \left(\sum_{i \in
{\cal S}} I_i\right)^2},\\ {\tt ERRXY} & = {\rm
cov}(\overline{x},\overline{y}) = & \frac{\displaystyle \sum_{i \in
{\cal S}} \sigma^2_i (x_i-\overline{x})(y_i-\overline{y})}
{\displaystyle \left(\sum_{i \in {\cal S}} I_i\right)^2}.
\end{eqnarray}
$\sigma_i$ is the flux uncertainty estimated for pixel $i$:
$$\sigma^2_i = {\sigma_B}^2_i + \frac{I_i}{g_i},$$
where ${\sigma_B}_i$ is the \index{local background} local background noise and $g_i$ the local
\index{gain} gain --- conversion factor --- for pixel $i$ (see
\S\ref{chap:weight} for more details). Semi-major axis {\tt ERRA}, semi-minor
axis {\tt ERRB}, and position angle {\tt ERRTHETA} of the
$1\sigma$ position \index{error ellipse} error ellipse are computed from the \index{covariance} covariance
matrix exactly like in \ref{chap:abtheta} for shape parameters:
\begin{eqnarray}
\label{eq:erra}
{\tt ERRA}^2 & = & \frac{{\rm var}(\overline{x})+{\rm var}(\overline{y})}{2}
+ \sqrt{\left(\frac{{\rm var}(\overline{x})-{\rm var}(\overline{y})}{2}\right)^2
+ {\rm cov}^2(\overline{x},\overline{y})},\\
\label{eq:errb}
{\tt ERRB}^2 & = & \frac{{\rm var}(\overline{x})+{\rm var}(\overline{y})}{2}
- \sqrt{\left(\frac{{\rm var}(\overline{x})-{\rm var}(\overline{y})}{2}\right)^2
+ {\rm cov}^2(\overline{x},\overline{y})},\\
\label{eq:errtheta}
\tan (2{\tt ERRTHETA}) & = & 2 \,\frac{{\rm cov}(\overline{x},\overline{y})}
{{\rm var}(\overline{x}) - {\rm var}(\overline{y})}.
\end{eqnarray}
And the ellipse parameters are:
\begin{eqnarray}
\label{eq:errcxx}
{\tt ERRCXX} & = & \frac{\cos^2 {\tt ERRTHETA}}{{\tt ERRA}^2} +
\frac{\sin^2 {\tt ERRTHETA}}{{\tt ERRB}^2} = \frac{{\rm
var}(\overline{y})}{\sqrt{\left(\frac{{\rm var}(\overline{x}) -{\rm
var}(\overline{y})}{2}\right)^2 + {\rm
cov}^2(\overline{x},\overline{y})}},\\
\label{eq:errcyy}
{\tt ERRCYY} & = & \frac{\sin^2
{\tt ERRTHETA}}{{\tt ERRA}^2} + \frac{\cos^2 {\tt ERRTHETA}}{{\tt
ERRB}^2} = \frac{{\rm var}(\overline{x})}{\sqrt{\left(\frac{{\rm
var}(\overline{x}) -{\rm var}(\overline{y})}{2}\right)^2 + {\rm
cov}^2(\overline{x},\overline{y})}},\\
\label{eq:errcxy}
{\tt ERRCXY} & = & 2 \cos {\tt
ERRTHETA}\,\sin {\tt ERRTHETA} \left( \frac{1}{{\tt ERRA}^2} -
\frac{1}{{\tt ERRB}^2}\right)\\ & = & -2 \,\frac{{\rm
cov}(\overline{x},\overline{y})}{\sqrt{\left(\frac{{\rm
var}(\overline{x}) -{\rm var}(\overline{y})}{2}\right)^2 + {\rm
cov}^2(\overline{x},\overline{y})}}.
\end{eqnarray}

\subsection{Handling of infinitely thin'' detections}
Apart from the mathematical singularities that can be found in some of
the above equations describing shape parameters (and which {\sc
SExtractor} handles, of course), some detections with very specific
shapes may yield quite unphysical parameters, namely null values for
{\tt B}, {\tt ERRB}, or even {\tt A} and {\tt ERRA}. Such detections
include single-pixel objects and horizontal, vertical or diagonal
lines which are 1-pixel wide. They will generally originate from
\index{glitch} \index{glitches} glitches; but very undersampled and/or low S/N genuine sources may
also produce such shapes. \hide{How to handle them?}

For basic shape parameters, the following convention was adopted: if
the light distribution of the object falls on one single pixel, or
lies on a sufficiently thin line of pixels, which we translate
mathematically by
$$\label{eq:singutest} \overline{x^2}\,\overline{y^2} - \overline{xy}^2 < \rho^2,$$
then $\overline{x^2}$ and $\overline{y^2}$ are incremented by $\rho$.
{\sc SExtractor} sets $\rho=1/12$, which is the variance of a
1-dimensional top-hat distribution with unit width. Therefore
$1/\sqrt{12}$ represents the typical minor-axis values assigned (in
pixels units) to undersampled sources in {\sc SExtractor}.

Positional errors are more difficult to handle, as objects with very
high signal-to-noise can yield extremely small position uncertainties,
just like singular profiles do. Therefore {\sc SExtractor} first
checks that (\ref{eq:singutest}) is true. If this is the case, a new
test is conducted:
$$\label{eq:singutest2} {\rm var}(\overline{x})\,{\rm var}(\overline{y}) - {\rm covar}^2(\overline{x}, \overline{y}) < \rho^2_e,$$
where $\rho_e$ is arbitrarily set to $\left( \sum_{i \in {\cal S}} \sigma^2_i \right) / \left(\sum_{i \in {\cal S}} I_i\right)^2$. If
(\ref{eq:singutest2}) is true, then $\overline{x^2}$ and
$\overline{y^2}$ are incremented by $\rho_e$.