ZScaleInterval#

class astropy.visualization.ZScaleInterval(n_samples=1000, contrast=0.25, max_reject=0.5, min_npixels=5, krej=2.5, max_iterations=5)[source]#

Bases: BaseInterval

Interval based on IRAF’s zscale.

Original implementation: spacetelescope/stsci.numdisplay

Licensed under a 3-clause BSD style license (see AURA_LICENSE.rst).

Parameters:
n_samplespython:int, optional

The number of points in the array to sample for determining scaling factors. Defaults to 1000.

Changed in version 7.0: nsamples parameter is removed.

contrastpython:float, optional

The scaling factor (between 0 and 1) for determining the minimum and maximum value. Larger values decrease the difference between the minimum and maximum values used for display. Defaults to 0.25.

max_rejectpython:float, optional

If more than max_reject * npixels pixels are rejected, then the returned values are the minimum and maximum of the data. Defaults to 0.5.

min_npixelspython:int, optional

If there are less than min_npixels pixels remaining after the pixel rejection, then the returned values are the minimum and maximum of the data. Defaults to 5.

krejpython:float, optional

The number of sigma used for the rejection. Defaults to 2.5.

max_iterationspython:int, optional

The maximum number of iterations for the rejection. Defaults to 5.

Methods Summary

__call__(values[, clip, out])

Transform values using this interval.

get_limits(values)

Return the minimum and maximum value in the interval based on the values provided.

Methods Documentation

__call__(values, clip=True, out=None)#

Transform values using this interval.

The vmin and vmax values are determined by the get_limits method.

The following transformation is then applied to the values:

\[{\rm result} = \frac{{\rm values} - v_{\rm min}} {v_{\rm max} - v_{\rm min}}\]

If clip is True (default), the result is then clipped to the [0:1] range.

Parameters:
valuesnumpy:array_like

The input values.

clipbool, optional

If True (default), values outside the [0:1] range are clipped to the [0:1] range.

outndarray, optional

If specified, the output values will be placed in this array (typically used for in-place calculations).

Returns:
resultndarray

The transformed values.

get_limits(values)[source]#

Return the minimum and maximum value in the interval based on the values provided.

Parameters:
valuesndarray

The image values.

Returns:
vmin, vmaxpython:float

The mininium and maximum image value in the interval.