def __init__(self, w): """ For spectra close to original (think perfect diffuse reflector) this is expected to yield the characteristic of the illuminant. XYZ values must be normalized as clearly simulating more photons will give larger values... The Yint is hoped to provide a less adhoc way of doing the normalization. """ assert w is not None X = np.sum(_cie.X(w)) Y = np.sum(_cie.Y(w)) Z = np.sum(_cie.Z(w)) Yint = Y X /= Yint # normalize such that Y=1 Y /= Yint Z /= Yint x = X/(X+Y+Z) # Chromaticity coordinates y = Y/(X+Y+Z) self.wp = np.array([X,Y,Z,Yint,x,y])
def hist1d_XYZ(self,w,x,xb): hX, hXx = np.histogram(x,bins=xb, weights=_cie.X(w)) hY, hYx = np.histogram(x,bins=xb, weights=_cie.Y(w)) hZ, hZx = np.histogram(x,bins=xb, weights=_cie.Z(w)) assert np.all(hXx == xb) & np.all(hYx == xb ) & np.all(hZx == xb) raw = np.dstack([hX,hY,hZ]) self.raw = np.copy(raw) return raw
def hist2d_XYZ(self,w,x,y,xb,yb): bins = [xb,yb] hX, hXx, hXy = np.histogram2d(x,y,bins=bins, weights=_cie.X(w)) hY, hYx, hYy = np.histogram2d(x,y,bins=bins, weights=_cie.Y(w)) hZ, hZx, hZy = np.histogram2d(x,y,bins=bins, weights=_cie.Z(w)) assert np.all(hXx == xb) & np.all(hYx == xb ) & np.all(hZx == xb) assert np.all(hXy == yb) & np.all(hYy == yb ) & np.all(hZy == yb) return np.dstack([hX,hY,hZ])
def hist0d_XYZ(self,w, nb=100): X = np.sum(_cie.X(w)) Y = np.sum(_cie.Y(w)) Z = np.sum(_cie.Z(w)) hX = np.repeat(X, nb) hY = np.repeat(Y, nb) hZ = np.repeat(Z, nb) raw = np.dstack([hX,hY,hZ]) self.raw = np.copy(raw) return raw
def whitepoint(wd): bb = _cie.BB6K(wd) bb /= bb.max() X = np.sum( _cie.X(wd)*bb ) Y = np.sum( _cie.Y(wd)*bb ) Z = np.sum( _cie.Z(wd)*bb ) norm = Y # Normalize Y to 1 X /= norm Y /= norm Z /= norm return [X,Y,Z], norm