Skip to content

Commit 8765972

Browse files
committed
cleaned up cm definition code
1 parent f495e82 commit 8765972

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

cmocean/cm.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from __future__ import absolute_import
1212

13-
import matplotlib
1413
import numpy as np
1514
import os
1615

@@ -20,21 +19,20 @@
2019
datadir = os.path.join(os.path.split(__file__)[0], 'rgb')
2120

2221
# List of colormap names
23-
cmaps = ['thermal', 'haline', 'solar', 'ice', 'gray', 'oxy', 'deep', 'dense',
24-
'algae', 'matter', 'turbid', 'speed', 'amp', 'tempo', 'phase',
25-
'balance', 'delta', 'curl']
22+
cmapnames = ['thermal', 'haline', 'solar', 'ice', 'gray', 'oxy', 'deep',
23+
'dense', 'algae', 'matter', 'turbid', 'speed', 'amp', 'tempo',
24+
'phase', 'balance', 'delta', 'curl']
2625

2726
# initialize dictionary to contain colormaps
2827
cmap_d = dict()
2928

3029
# add colormaps and reversed to dictionary
31-
for cmap in cmaps:
32-
# rgb = np.loadtxt(cmap + '-rgb.txt')
33-
rgb = np.loadtxt(os.path.join(datadir, cmap + '-rgb.txt'))
34-
cmap_d[cmap] = tools.cmap(rgb, N=256)
35-
cmap_d[cmap].name = cmap
36-
cmap_d[cmap + '_r'] = tools.cmap(rgb[::-1, :], N=256)
37-
cmap_d[cmap + '_r'].name = cmap + '_r'
30+
for cmapname in cmapnames:
31+
rgb = np.loadtxt(os.path.join(datadir, cmapname + '-rgb.txt'))
32+
cmap_d[cmapname] = tools.cmap(rgb, N=256)
33+
cmap_d[cmapname].name = cmapname
34+
cmap_d[cmapname + '_r'] = tools.cmap(rgb[::-1, :], N=256)
35+
cmap_d[cmapname + '_r'].name = cmapname + '_r'
3836

3937
# make colormaps available to call
4038
locals().update(cmap_d)

0 commit comments

Comments
 (0)