APLpy Normalizations

APLpy uses a different set of normalization techniques than other image display tools. The default options available for the stretch argument are linear, sqrt, power, log, and arcsinh.

In all cases, the transformations below map the values from the image onto a scale from 0 to 1 which then corresponds to the endpoints of the colormap being used.

Log Scale

APLpy defines the log scale with a vmid parameter such that

y = \frac{\log_{10}(x \cdot (m-1) + 1)}{\log_{10}(m)}


m = \frac{v_{\rm max} - v_{\rm mid}}{v_{\rm min}-v_{\rm mid}}


x=\frac{v-v_{\rm min}}{v_{\rm max}-v_{\rm min}}

and v is the image pixel values. Note that v_{\rm mid} should be smaller than v_{\rm min}, which means that m will always be larger than one. By default, v_{\rm mid}=0 and v_{\rm min} is therefore required to be positive (but negative values of v_{\rm min} are allowed if v_{\rm mid} is specified).

For reference, in the FITS display program ds9, the log scale is defined by

y = \frac{\log_{10}(ax+1)}{\log_{10}(a)}

where a defaults to 1000 and recommended values are from 100-10000 (see here).

The two stretches are nearly (but not completely) identical for m
\approx a+1. If you want to convert from the ds9 a parameter to APLpy’s v_{\rm mid}, you can use this formula:

v_{\rm mid} = \frac{m \cdot v_{\rm min}-v_{\rm max}}{m-1} \approx \frac{(a+1) \cdot v_{\rm min} - v_{\rm max}}{a}

Arcsinh Scale

The arcsinh scale is defined by

y = \frac{\textrm{asinh}(x/m)}{\textrm{asinh}(1/m)}


m = \frac{v_{\rm mid} - v_{\rm min}}{v_{\rm max}-v_{\rm min}}

By default, v_{\rm mid} is chosen such that 1/m=-30.

For reference, the ds9 definition is simply

y = \frac{\textrm{asinh}(10x)}{3}

Linear Scale

The linear scale is only concerned with the vmin and vmax keywords:

y=\frac{x-v_{\rm min}}{v_{\rm max}-v_{\rm min}}

Square Root Scale

The square root scale is given by

y=\sqrt{\frac{x-v_{\rm min}}{v_{\rm max}-v_{\rm min}}}

Power Scale

The power root scale is

y=\left[\frac{x-v_{\rm min}}{v_{\rm max}-v_{\rm min}}\right]^a

where a is passed in as the exponent keyword.