Data

data.adjust_wl(fw_in, wl_in, wl_out)[source]

Adjust the wavelength list of the input function(s).

data.adobe_abs_to_norm_xyz(abs_xyz)[source]

Converting the absolute XYZ to Adobe normalized XYZ.

The conversion formula is:

Xn = (Xa - Xk) / (Xw - Xk) * Xw / Yw
Yn = (Ya - Yk) / (Yw - Yk)
Zn = (Za - Zk) / (Zw - Zk) * Zw / Yw

where (Xa, Ya, Za) is absolute XYZ value, (Xk, Yk, Zk) = (0.5282, 0.5557, 0.6052) is the reference display black point, (Xw, Yw, Zw) = (152.07, 160.00, 174.25) is the reference display white point, and (Xn, Yn, Zn) is the normalized XYZ value.

Parameters:

abs_xyz: ndarray

Absolute XYZ values, of the following format:
  • 1D ndarray of length 3.
  • 2D ndarray of size (3,N).
Returns:

An ndarray of the same format as input.

References

Accessed on: Nov 30, 2014.
data.adobe_gamma(linear_data)[source]

The per-channel, nonlinear transfer function used in Adobe RGB (1998) color space.

C= ( C_{linear} ) ^ {1 / 2.19921875}

The value 2.19921875 is obtained from (2 + 51/256).

Accessed from: http://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf. Accessed on: Nov 30, 2014.

data.get_blackbody_spd(temperature, wl)[source]

Get blackbody radiation spectral power distribution.

data.load_fw(name, wl=None)[source]

Load function of wavelength.

Parameters:

name: str

A string for the name of function, currently support:
  • “xyz-cmfs”: CIE-XYZ color matching functions.
  • “d65-spd”: CIE-D65 spectral power distribution.

wl: ndarray

Wavelength list, optional.

Returns:

fw : ndarray

The loaded function(s) of wavelength.

wl : ndarray

It will be the same as input wl if it is not None, or will be loaded together with fw as input data.

data.read_cvrl_csv(csv_filename, empty_val=0.0)[source]

Read a csv file downloaded from cvrl.org.

Some of the entries in the csv are empty, and will be filled with ‘empty_val’. If reading linear data, ‘empty_val’ should be set as 0.0, and if reading log data, it should be set as -np.inf.

Returns:

A ndarray of size Nx2 or Nx4.

The first column is wavelength in unit of nm, and following columns the corresponding functions with respect to wavelength.

data.srgb_gamma(linear_data)[source]

The per-channel, nonlinear transfer function used in sRGB.

The conversion formula is:

C = 12.92 * C_linear,                     if C_linear <= 0.0031308
    1.055 * C_linear ** (1/2.4) - 0.055,  otherwise
Accessed on: Oct 28, 2014.
data.srgb_inverse_gamma(nonlinear_data)[source]

The per-channel transform from nonlinear sRGB data to linear sRGB data.

The conversion formula is:

C_linear = C / 12.92,                     if C <= 0.04045
           ((C + 0.055) / 1.055) ^ 2.4,   otherwise
Accessed on: Apr 24, 2015.