Skip to content

Commit

Permalink
Merge branch 'feature/line_locus' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Nov 3, 2023
2 parents 66c26b6 + 42bcdca commit e390d46
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 135 deletions.
8 changes: 3 additions & 5 deletions colour/colorimetry/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,10 @@ def __init__(
)

@staticmethod
def _on_domain_changed(
cls, name: str, value: NDArrayFloat
) -> NDArrayFloat:
"""Invalidate *cls._shape* when *cls._domain* is changed."""
def _on_domain_changed(sd, name: str, value: NDArrayFloat) -> NDArrayFloat:
"""Invalidate *sd._shape* when *sd._domain* is changed."""
if name == "_domain":
cls._shape = None
sd._shape = None

return value

Expand Down
2 changes: 1 addition & 1 deletion colour/io/luts/cinespace_csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _parse_table_section(lines):
)
):
LUT = LUT3x1D(
domain=pre_LUT.reshape(3, 4).transpose()[0:2],
domain=pre_LUT.reshape([3, 4]).transpose()[0:2],
name=title,
comments=comments,
table=table,
Expand Down
6 changes: 6 additions & 0 deletions colour/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
plot_RGB_colourspace_section,
)
from .temperature import (
lines_daylight_locus,
LABELS_PLANCKIAN_LOCUS_DEFAULT,
lines_planckian_locus,
plot_planckian_locus_in_chromaticity_diagram_CIE1931,
plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS,
plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS,
Expand Down Expand Up @@ -239,6 +242,9 @@
"plot_RGB_colourspace_section",
]
__all__ += [
"lines_daylight_locus",
"LABELS_PLANCKIAN_LOCUS_DEFAULT",
"lines_planckian_locus",
"plot_planckian_locus_in_chromaticity_diagram_CIE1931",
"plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS",
"plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS",
Expand Down
29 changes: 14 additions & 15 deletions colour/plotting/diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
),
}
)
"""Chromaticity diagram default labels."""
"""*Chromaticity Diagram* default labels."""


def lines_spectral_locus(
Expand Down Expand Up @@ -271,7 +271,6 @@ def lines_spectral_locus(
XYZ_to_ij = METHODS_CHROMATICITY_DIAGRAM[method]["XYZ_to_ij"]
ij_to_XYZ = METHODS_CHROMATICITY_DIAGRAM[method]["ij_to_XYZ"]

# [ Spectral Locus ]
# CMFS
ij_cmfs = XYZ_to_ij(cmfs.values, illuminant)

Expand Down Expand Up @@ -305,7 +304,7 @@ def lines_spectral_locus(
lines_sl["colour"] = colour_sl

# Labels Normals
ij_n, colours_l, normal_l = [], [], []
ij_n, colour_l, normal_l = [], [], []
wl_ij_cmfs = dict(zip(wavelengths, ij_cmfs))
for label in cast(Tuple, labels):
ij_l = wl_ij_cmfs.get(label)
Expand Down Expand Up @@ -335,15 +334,15 @@ def lines_spectral_locus(
> 0
else np.array([dy, -dx])
)
normal = normalise_vector(normal) / 40
normal = normalise_vector(normal)

ij_n.append([[i, j], [i + normal[0], j + normal[1]]])
ij_n.append([[i, j], [i + normal[0] / 50, j + normal[1] / 50]])
normal_l.append([normal, normal])
colours_l.append([ij_l, ij_l])
colour_l.append([ij_l, ij_l])

ij_w = as_float_array(ij_n).reshape(-1, 2)
normal_w = as_float_array(normal_l).reshape(-1, 2)
colours_w = as_float_array(colours_l).reshape(-1, 2)
ij_w = as_float_array(ij_n).reshape([-1, 2])
normal_w = as_float_array(normal_l).reshape([-1, 2])
colours_w = as_float_array(colour_l).reshape([-1, 2])

colour_w = normalise_maximum(
XYZ_to_plotting_colourspace(
Expand Down Expand Up @@ -427,14 +426,14 @@ def plot_spectral_locus(

method = validate_method(method, tuple(METHODS_CHROMATICITY_DIAGRAM))

labels = optional(
spectral_locus_labels, LABELS_CHROMATICITY_DIAGRAM_DEFAULT[method]
)

spectral_locus_colours = optional(
spectral_locus_colours, CONSTANTS_COLOUR_STYLE.colour.dark
)

labels = optional(
spectral_locus_labels, LABELS_CHROMATICITY_DIAGRAM_DEFAULT[method]
)

use_RGB_colours = str(spectral_locus_colours).upper() == "RGB"

settings: Dict[str, Any] = {"uniform": True}
Expand Down Expand Up @@ -491,8 +490,8 @@ def plot_spectral_locus(
)

axes.text(
positions[i, 0] + normals[i, 0] * 1.25,
positions[i, 1] + normals[i, 1] * 1.25,
positions[i, 0] + normals[i, 0] / 50 * 1.25,
positions[i, 1] + normals[i, 1] / 50 * 1.25,
label,
clip_on=True,
ha="left" if lines_w["normal"][::2][i, 0] >= 0 else "right",
Expand Down
Loading

0 comments on commit e390d46

Please sign in to comment.