colour-science / colour

Colour Science for Python
https://www.colour-science.org
BSD 3-Clause "New" or "Revised" License
2.08k stars 259 forks source link

Implement shortcuts for the most used dataset elements. #97

Closed KelSolaar closed 10 years ago

KelSolaar commented 10 years ago

For instance when accessing the CIE 1931 2° Standard Observer illuminants we have right now to use the following form:

colour.ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]

we can for instance have a shortcut like this:

colour.ILLUMINANTS["2"]
KelSolaar commented 10 years ago

Here is the current relevant list of mappings and a proposal for some aliases: https://docs.google.com/spreadsheets/d/1Xfto7D6VAmEnT9EaZsjO5l_dnziRhd0AEVsBWZnp5_w/edit?usp=sharing

MichaelMauderer commented 10 years ago

I'm not sure I am a fan of the numeric aliases. While they are nice and short to write, they are impossible to interpret while reading the code that is using them.

I'd propose to use terse, but meaningful strings that contain enough information to at least give the reader an idea what he is seeing.

A few example (just of the top of my head, not supposed to be definitive)

Verbose name alias
Small Areas, Uniform Background & Surrounds small_uniform
Normal Scenes normal
Television & CRT, Dim Surrounds crt_dim
CIE 1931 2 Degree Standard Observer cie_2_1931
CIE 2012 2 Degree Standard Observer cie_2_2012
KelSolaar commented 10 years ago

Yeah that's the exact feeling I got when feeding the spreadsheet, I'll work toward a better proposal following your model.

KelSolaar commented 10 years ago

Here is a proposal Michael, if it looks good, I'll roll it:

Mapping Alias
CHROMATIC_ADAPTATION_METHODS
XYZ Scaling
Bradford
Von Kries
Fairchild
CAT02
CIECAM02_VIEWING_CONDITIONS
Average
Dim
Dark
HUNT_VIEWING_CONDITIONS
Small Areas, Uniform Background & Surrounds small_uniform
Normal Scenes normal
Television & CRT, Dim Surrounds tv_dim
Large Transparencies On Light Boxes light_boxes
Projected Transparencies, Dark Surrounds dark
LLAB_VIEWING_CONDITIONS
Reference Samples & Images, Average Surround, Subtending > 4 ref_average_4_plus
Reference Samples & Images, Average Surround, Subtending < 4 ref_average_4_minus
Television & VDU Displays, Dim Surround tv_dim
Cut Sheet Transparency, Dim Surround sheet_dim
35mm Projection Transparency, Dark Surround dark
RLAB_VIEWING_CONDITIONS
Average
Dim
Dark
COLOURCHECKERS
BabelColor Average average
ColorChecker 2005 crc_2005
ColorChecker 1976
COLOURCHECKERS_SPDS
BabelColor Average
ColorChecker N Ohta
BANDPASS_CORRECTION_METHODS
Stearns 1988
LIGHTNESS_FUNCTIONS
Lightness Glasser 1958
Lightness Wyszecki 1964
Lightness 1976 l_star
LUMINANCE_FUNCTIONS
Luminance Newhall 1943
Luminance 1976 l_star
Luminance ASTM D1535-08 astm
LMS_CMFS
Stockman & Sharpe 2 Degree Cone Fundamentals
RGB_CMFS
Wright & Guild 1931 2 Degree RGB CMFs
Stiles & Burch 1955 2 Degree RGB CMFs
Stiles & Burch 1959 10 Degree RGB CMFs
STANDARD_OBSERVERS_CMFS
CIE 1931 2 Degree Standard Observer cie_2_1931
CIE 1964 10 Degree Standard Observer cie_10_1964
CIE 2012 2 Degree Standard Observer
CIE 2012 10 Degree Standard Observer
CMFS
PHOTOPIC_LEFS
CIE 1924 Photopic Standard Observer cie_2_1924
Judd Modified CIE 1951 Photopic Standard Observer
Judd-Vos Modified CIE 1978 Photopic Standard Observer
CIE 1964 Photopic 10 Degree Standard Observer cie_10_1964
CIE 2008 2 Degree Physiologically Relevant LEF
CIE 2008 10 Degree Physiologically Relevant LEF
SCOTOPIC_LEFS
CIE 1951 Scotopic Standard Observer cie_1951
LEFS
ILLUMINANTS
CIE 1931 2 Degree Standard Observer cie_2_1931
CIE 1964 10 Degree Standard Observer cie_10_1964
RGB_COLOURSPACES
ACES_RGB_COLOURSPACE aces
ACES_RGB_LOG_COLOURSPACE
ACES_RGB_PROXY_10_COLOURSPACE
ACES_RGB_PROXY_12_COLOURSPACE
ADOBE_RGB_1998_COLOURSPACE adobe_1998
ADOBE_WIDE_GAMUT_RGB_COLOURSPACE
ALEXA_WIDE_GAMUT_RGB_COLOURSPACE
APPLE_RGB_COLOURSPACE
BEST_RGB_COLOURSPACE
BETA_RGB_COLOURSPACE
CIE_RGB_COLOURSPACE
C_LOG_COLOURSPACE
COLOR_MATCH_RGB_COLOURSPACE
DCI_P3_COLOURSPACE
DON_RGB_4_COLOURSPACE
ECI_RGB_V2_COLOURSPACE
EKTA_SPACE_PS_5_COLOURSPACE
MAX_RGB_COLOURSPACE
NTSC_RGB_COLOURSPACE
PAL_SECAM_RGB_COLOURSPACE
PROPHOTO_RGB_COLOURSPACE prophoto
REC_709_COLOURSPACE
REC_2020_COLOURSPACE
RUSSELL_RGB_COLOURSPACE
S_LOG_COLOURSPACE
SMPTE_C_RGB_COLOURSPACE
sRGB_COLOURSPACE
XTREME_RGB_COLOURSPACE
MUNSELL_VALUE_FUNCTIONS
Munsell Value Priest 1920
Munsell Value Munsell 1933
Munsell Value Moon 1943
Munsell Value Saunderson 1944
Munsell Value Ladd 1955
Munsell Value McCamy 1987
Munsell Value ASTM D1535-08 astm
UV_TO_CCT_METHODS
Ohno 2013 ohno
Robertson 1968 robertson
CCT_TO_UV_METHODS
Ohno 2013 ohno
Robertson 1968 robertson
XY_TO_CCT_METHODS
McCamy 1992 mcamy
Hernandez 1999 hernandez
CCT_TO_XY_METHODS
Kang 2002 kang
CIE Illuminant D Series d
MichaelMauderer commented 10 years ago

Looks great!

What do you think of extending the two darks to projected_dark? Just dark might be too general and give the impression of a default value.

KelSolaar commented 10 years ago

Yeah agreed, here we go:

Mapping Alias
CHROMATIC_ADAPTATION_METHODS
XYZ Scaling
Bradford
Von Kries
Fairchild
CAT02
CIECAM02_VIEWING_CONDITIONS
Average
Dim
Dark
HUNT_VIEWING_CONDITIONS
Small Areas, Uniform Background & Surrounds small_uniform
Normal Scenes normal
Television & CRT, Dim Surrounds tv_dim
Large Transparencies On Light Boxes light_boxes
Projected Transparencies, Dark Surrounds projected_dark
LLAB_VIEWING_CONDITIONS
Reference Samples & Images, Average Surround, Subtending > 4 ref_average_4_plus
Reference Samples & Images, Average Surround, Subtending < 4 ref_average_4_minus
Television & VDU Displays, Dim Surround tv_dim
Cut Sheet Transparency, Dim Surround sheet_dim
35mm Projection Transparency, Dark Surround projected_dark
RLAB_VIEWING_CONDITIONS
Average
Dim
Dark
COLOURCHECKERS
BabelColor Average average
ColorChecker 2005 crc_2005
ColorChecker 1976
COLOURCHECKERS_SPDS
BabelColor Average
ColorChecker N Ohta
BANDPASS_CORRECTION_METHODS
Stearns 1988
LIGHTNESS_FUNCTIONS
Lightness Glasser 1958
Lightness Wyszecki 1964
Lightness 1976 l_star
LUMINANCE_FUNCTIONS
Luminance Newhall 1943
Luminance 1976 l_star
Luminance ASTM D1535-08 astm
LMS_CMFS
Stockman & Sharpe 2 Degree Cone Fundamentals
RGB_CMFS
Wright & Guild 1931 2 Degree RGB CMFs
Stiles & Burch 1955 2 Degree RGB CMFs
Stiles & Burch 1959 10 Degree RGB CMFs
STANDARD_OBSERVERS_CMFS
CIE 1931 2 Degree Standard Observer cie_2_1931
CIE 1964 10 Degree Standard Observer cie_10_1964
CIE 2012 2 Degree Standard Observer
CIE 2012 10 Degree Standard Observer
CMFS
PHOTOPIC_LEFS
CIE 1924 Photopic Standard Observer cie_2_1924
Judd Modified CIE 1951 Photopic Standard Observer
Judd-Vos Modified CIE 1978 Photopic Standard Observer
CIE 1964 Photopic 10 Degree Standard Observer cie_10_1964
CIE 2008 2 Degree Physiologically Relevant LEF
CIE 2008 10 Degree Physiologically Relevant LEF
SCOTOPIC_LEFS
CIE 1951 Scotopic Standard Observer cie_1951
LEFS
ILLUMINANTS
CIE 1931 2 Degree Standard Observer cie_2_1931
CIE 1964 10 Degree Standard Observer cie_10_1964
RGB_COLOURSPACES
ACES_RGB_COLOURSPACE aces
ACES_RGB_LOG_COLOURSPACE
ACES_RGB_PROXY_10_COLOURSPACE
ACES_RGB_PROXY_12_COLOURSPACE
ADOBE_RGB_1998_COLOURSPACE adobe_1998
ADOBE_WIDE_GAMUT_RGB_COLOURSPACE
ALEXA_WIDE_GAMUT_RGB_COLOURSPACE
APPLE_RGB_COLOURSPACE
BEST_RGB_COLOURSPACE
BETA_RGB_COLOURSPACE
CIE_RGB_COLOURSPACE
C_LOG_COLOURSPACE
COLOR_MATCH_RGB_COLOURSPACE
DCI_P3_COLOURSPACE
DON_RGB_4_COLOURSPACE
ECI_RGB_V2_COLOURSPACE
EKTA_SPACE_PS_5_COLOURSPACE
MAX_RGB_COLOURSPACE
NTSC_RGB_COLOURSPACE
PAL_SECAM_RGB_COLOURSPACE
PROPHOTO_RGB_COLOURSPACE prophoto
REC_709_COLOURSPACE
REC_2020_COLOURSPACE
RUSSELL_RGB_COLOURSPACE
S_LOG_COLOURSPACE
SMPTE_C_RGB_COLOURSPACE
sRGB_COLOURSPACE
XTREME_RGB_COLOURSPACE
MUNSELL_VALUE_FUNCTIONS
Munsell Value Priest 1920
Munsell Value Munsell 1933
Munsell Value Moon 1943
Munsell Value Saunderson 1944
Munsell Value Ladd 1955
Munsell Value McCamy 1987
Munsell Value ASTM D1535-08 astm
UV_TO_CCT_METHODS
Ohno 2013 ohno
Robertson 1968 robertson
CCT_TO_UV_METHODS
Ohno 2013 ohno
Robertson 1968 robertson
XY_TO_CCT_METHODS
McCamy 1992 mcamy
Hernandez 1999 hernandez
CCT_TO_XY_METHODS
Kang 2002 kang
CIE Illuminant D Series d
MichaelMauderer commented 10 years ago

Sorry for the nitpicking:

KelSolaar commented 10 years ago

It's not nitpicking, we have to get those right! :)

Which leads me to the CAMs and others for more consistency: the CIE is trimming the first two numbers in the years: CIECAM97, CIECAM02 and you did the same for the others which is fine and consistent. I'm wondering if we shouldn't do the same for all the objects in the API?

UV_TO_CCT_METHODS = CaseInsensitiveMapping(
    {'Ohno 2013': uv_to_CCT_ohno2013,
     'Robertson 1968': uv_to_CCT_robertson1968})

Would become:

UV_TO_CCT_METHODS = CaseInsensitiveMapping(
    {'Ohno 2013': uv_to_CCT_ohno13,
     'Robertson 1968': uv_to_CCT_robertson68})

And now we could add the ohno13 and robertson68 aliases.

MichaelMauderer commented 10 years ago

I'm somewhat torn.

The names of the CIE models are just the official names, I would not change anything there, and while ohno13 and robertson68 look perfectly fine to me, there might be cases where the meaning of the number as a year might get lost and things start to look very confusing to the casual observer (e.g., cie_2_31 versus cie_10_64). Also we are in a place (well time actually...) where a lower number can denote a newer date (e.g., for the CIE 2012 Observers), which might also lead to confusion.

Overall I'd say using the whole year might be safer. Or we might compromise the name+YY for the name based aliases and the full year everywhere else.

KelSolaar commented 10 years ago

Yeah, it's not very easy to come up with something nice here (It's the main reason I have chosen the very big long descriptive names so there are no ambiguities). What about this:

Mapping Alias
CHROMATIC_ADAPTATION_METHODS
XYZ Scaling
Bradford
Von Kries
Fairchild
CAT02
CIECAM02_VIEWING_CONDITIONS
Average
Dim
Dark
HUNT_VIEWING_CONDITIONS
Small Areas, Uniform Background & Surrounds small_uniform
Normal Scenes normal
Television & CRT, Dim Surrounds tv_dim
Large Transparencies On Light Boxes light_boxes
Projected Transparencies, Dark Surrounds projected_dark
LLAB_VIEWING_CONDITIONS
Reference Samples & Images, Average Surround, Subtending > 4 ref_average_4_plus
Reference Samples & Images, Average Surround, Subtending < 4 ref_average_4_minus
Television & VDU Displays, Dim Surround tv_dim
Cut Sheet Transparency, Dim Surround sheet_dim
35mm Projection Transparency, Dark Surround projected_dark
RLAB_VIEWING_CONDITIONS
Average
Dim
Dark
COLOURCHECKERS
BabelColor Average babel_average
ColorChecker 2005 crc2005
ColorChecker 1976
COLOURCHECKERS_SPDS
BabelColor Average
ColorChecker N Ohta
BANDPASS_CORRECTION_METHODS
Stearns 1988
LIGHTNESS_FUNCTIONS
Lightness Glasser 1958
Lightness Wyszecki 1964
Lightness 1976 l_star1976
LUMINANCE_FUNCTIONS
Luminance Newhall 1943
Luminance 1976 l_star1976
Luminance ASTM D1535-08 astm2008
LMS_CMFS
Stockman & Sharpe 2 Degree Cone Fundamentals
RGB_CMFS
Wright & Guild 1931 2 Degree RGB CMFs
Stiles & Burch 1955 2 Degree RGB CMFs
Stiles & Burch 1959 10 Degree RGB CMFs
STANDARD_OBSERVERS_CMFS
CIE 1931 2 Degree Standard Observer cie_2_1931
CIE 1964 10 Degree Standard Observer cie_10_1964
CIE 2012 2 Degree Standard Observer
CIE 2012 10 Degree Standard Observer
CMFS
PHOTOPIC_LEFS
CIE 1924 Photopic Standard Observer cie_2_1924
Judd Modified CIE 1951 Photopic Standard Observer
Judd-Vos Modified CIE 1978 Photopic Standard Observer
CIE 1964 Photopic 10 Degree Standard Observer cie_10_1964
CIE 2008 2 Degree Physiologically Relevant LEF
CIE 2008 10 Degree Physiologically Relevant LEF
SCOTOPIC_LEFS
CIE 1951 Scotopic Standard Observer cie_1951
LEFS
ILLUMINANTS
CIE 1931 2 Degree Standard Observer cie_2_1931
CIE 1964 10 Degree Standard Observer cie_10_1964
RGB_COLOURSPACES
ACES_RGB_COLOURSPACE aces
ACES_RGB_LOG_COLOURSPACE
ACES_RGB_PROXY_10_COLOURSPACE
ACES_RGB_PROXY_12_COLOURSPACE
ADOBE_RGB_1998_COLOURSPACE adobe1998
ADOBE_WIDE_GAMUT_RGB_COLOURSPACE
ALEXA_WIDE_GAMUT_RGB_COLOURSPACE
APPLE_RGB_COLOURSPACE
BEST_RGB_COLOURSPACE
BETA_RGB_COLOURSPACE
CIE_RGB_COLOURSPACE
C_LOG_COLOURSPACE
COLOR_MATCH_RGB_COLOURSPACE
DCI_P3_COLOURSPACE
DON_RGB_4_COLOURSPACE
ECI_RGB_V2_COLOURSPACE
EKTA_SPACE_PS_5_COLOURSPACE
MAX_RGB_COLOURSPACE
NTSC_RGB_COLOURSPACE
PAL_SECAM_RGB_COLOURSPACE
PROPHOTO_RGB_COLOURSPACE prophoto
REC_709_COLOURSPACE
REC_2020_COLOURSPACE
RUSSELL_RGB_COLOURSPACE
S_LOG_COLOURSPACE
SMPTE_C_RGB_COLOURSPACE
sRGB_COLOURSPACE
XTREME_RGB_COLOURSPACE
MUNSELL_VALUE_FUNCTIONS
Munsell Value Priest 1920
Munsell Value Munsell 1933
Munsell Value Moon 1943
Munsell Value Saunderson 1944
Munsell Value Ladd 1955
Munsell Value McCamy 1987
Munsell Value ASTM D1535-08 astm2008
UV_TO_CCT_METHODS
Ohno 2013 ohno2013
Robertson 1968 robertson1968
CCT_TO_UV_METHODS
Ohno 2013 ohno2013
Robertson 1968 robertson1968
XY_TO_CCT_METHODS
McCamy 1992 mcamy1992
Hernandez 1999 hernandez1999
CCT_TO_XY_METHODS
Kang 2002 kang2002
CIE Illuminant D Series cie_d
MichaelMauderer commented 10 years ago

The l_starYYYY look slightly weird to me because they have an underscore in the name but none before the year. But that's consistent with the nameYYYY scheme so I can live with that.

Everything else looks fine to me.

KelSolaar commented 10 years ago

Lstar1976 so that we remove the underscore and there is no confusion between L and i?

MichaelMauderer commented 10 years ago

Sounds good. On 17 Aug 2014 23:58, "Thomas Mansencal" notifications@github.com wrote:

Lstar1976 so that we remove the underscore and there is no confusion between L and i?

— Reply to this email directly or view it on GitHub https://github.com/colour-science/colour/issues/97#issuecomment-52438375 .

KelSolaar commented 10 years ago

As devil is in details we have now un uppercase letter in the alias (Which shouldn't be an issue because of case insensitivity), oh well... Let's go for that!