complex_field_to_rgb

hcipy.plotting.complex_field_to_rgb(field, theme='dark', rmin=None, rmax=None, norm=None, cmap=None)

Convert a complex field to an RGB field.

This function takes a scalar Field with complex numbers and converts it to a vector Field containing the red, green and blue values corresponding to the phase and amplitude of the complex input Field. The phase is decoded as hue, and amplitude as saturation/value. This function is especially useful for plotting complex fields.

Parameters:
fieldscalar Field or ndarray

The field that we want to convert.

theme{‘dark’, ‘light’}

Sets whether the amplitude is visualized on a dark or light background. “dark” uses black for zero amplitude and lightens with increasing amplitude. “light” uses white for zero amplitude and darkens with increasing amplitude.

rminscalar

The minimum value on the colorbar. If this is not given, then the minimum of the absolute value of the Field will be used.

rmaxscalar

The maximum value on the colorbar. If this is not given, then the maximum of the absolute value of the Field will be used.

normNormalize

A Normalize instance is used to scale the absolute value to the (0, 1) range used for the value or saturation for the returned color. If it is not given, a linear scale will be used.

cmapColormap or None

The colormap to use for the phase. If this is None, the default hsv colormap will be used.

Returns:
Field

A vector field containing the red, green and blue components.

Raises:
ValueError

If the supplied field is not a scalar field.