I have two colormaps which are both created using arrays of (n,n) size (n being an even integer).
The first represents the intensity of a light beam on a surface. Intensity across the surface
The other represents the polarization of the beam across the same surface, at the same time. Polarization of the beam across the surface in °
I would like to only show values of the second colormap where there is a certain amount of intensity.
It would be even better if the gradient of the first colormap could be applied over the second colormap.
You can create a mask array of 0 and 1, with the same dimensions and size as the image and set the values of this mask to 1 where the intensity is above your threshold, then multiply the polarisation by this mask.
Let's say you have the two arrays intensity
and polarisation
. The mask
array will be 0 except where intensity
is above the threshold
.
import numpy as np
intensity = np.ones((50,50)) * np.random.rand(50,50)
polarisation = np.ones((50,50))
threshold = 0.5
mask = np.zeros(np.shape(intensity))
mask[np.where(intensity>threshold)] = 1
filtered_polarisation = polarisation * mask