Skip to content

Commit

Permalink
Merge pull request #22 from zssherman/crameri_michelson
Browse files Browse the repository at this point in the history
ENH: Updating cmweather for Crameri Michelson colormaps.
  • Loading branch information
mgrover1 committed Oct 18, 2023
2 parents 8ce63b1 + b649352 commit 9062a84
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmweather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
* balance
* ChaseSpectral
* SpectralExtended
* CM_depol
* CM_rhohv
"""
from pkg_resources import DistributionNotFound, get_distribution
Expand Down
10 changes: 10 additions & 0 deletions cmweather/_cm_colorblind.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,19 @@ def yuv_rainbow_24(nc):

# HomeyerRainbow developed by Cameron Homeyer with assistance from Bobby Jackson

# Crameri and Michelson colormaps were modified Oleron and Roma colormaps from
# the work done in Crameri et al. (2020), but modified by Michelson for
# depolarization ratio and rhohv moments in radar.

cm_oleron_depol_vals = np.genfromtxt(os.path.join(data_dir, 'crameri-michelson-oleron-depol.txt'))

cm_roma_rhohv_vals = np.genfromtxt(os.path.join(data_dir, 'crameri-michelson-roma-rhohv.txt'))

datad = {
'HomeyerRainbow': yuv_rainbow_24(15),
'balance': bal_rgb_vals,
'ChaseSpectral': chase_spectral_rgb_vals,
'SpectralExtended': spectral_ext_rgb_vals,
'CM_depol': cm_oleron_depol_vals,
'CM_rhohv': cm_roma_rhohv_vals,
}
13 changes: 13 additions & 0 deletions cmweather/cm_colorblind.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
* balance
* ChaseSpectral
* SpectralExtended
* CM_depol
* CM_rhohv
CM_dopol and CM_rhohv are based on the work by:
Crameri, F., G.E. Shephard and P.J. Heron, 2020: The misuse of colour in science
communication. Nat Commun 11, 5444 https://doi.org/10.1038/s41467-020-19160-7
Michelson D., B. Hansen, D. Jacques, F. Lemay, and P Rodriguez, 2020: Monitoring
the impact of weather radar data quality control for quantitative application
at the continental scale. Meteorol. Appl. 2020;27:e1929. 12 pp.
https://doi.org/10.1002/met.1929
"""

import warnings
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/test_cm_colorblind.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def test_colormaps_exist():
assert isinstance(cm_colorblind.ChaseSpectral_r, matplotlib.colors.Colormap)
assert isinstance(cm_colorblind.SpectralExtended, matplotlib.colors.Colormap)
assert isinstance(cm_colorblind.SpectralExtended_r, matplotlib.colors.Colormap)
assert isinstance(cm_colorblind.CM_depol, matplotlib.colors.Colormap)
assert isinstance(cm_colorblind.CM_depol_r, matplotlib.colors.Colormap)
assert isinstance(cm_colorblind.CM_rhohv, matplotlib.colors.Colormap)
assert isinstance(cm_colorblind.CM_rhohv_r, matplotlib.colors.Colormap)


def test_colormaps_registered():
Expand All @@ -41,3 +45,15 @@ def test_colormaps_registered():

cmap = matplotlib.colormaps.get_cmap('SpectralExtended_r')
assert isinstance(cmap, matplotlib.colors.Colormap)

cmap = matplotlib.colormaps.get_cmap('CM_depol')
assert isinstance(cmap, matplotlib.colors.Colormap)

cmap = matplotlib.colormaps.get_cmap('CM_depol_r')
assert isinstance(cmap, matplotlib.colors.Colormap)

cmap = matplotlib.colormaps.get_cmap('CM_rhohv')
assert isinstance(cmap, matplotlib.colors.Colormap)

cmap = matplotlib.colormaps.get_cmap('CM_rhohv_r')
assert isinstance(cmap, matplotlib.colors.Colormap)

0 comments on commit 9062a84

Please sign in to comment.