Subversion Repositories lagranto.ecmwf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
35 michaesp 1
# coding: utf-8
2
 
3
from matplotlib.colors import ListedColormap, BoundaryNorm
4
import numpy as np
5
from _cm import cmaps
6
 
7
 
8
def get_cm(name, levels=None):
9
    """ return a ListedColormap, a norm and the levels"""
10
    array = np.array(cmaps[name]['array'])
11
    if levels is None:
12
        levels = cmaps[name]['levels']
13
    cm = ListedColormap(array/255)
14
    norm = BoundaryNorm(levels, cm.N)
15
    return cm, norm, levels
16
 
17
# the dictionary to store the colormap
18
cmap_d = dict()
19
 
20
for cmap in cmaps:
21
    cmap_d[cmap] = get_cm(cmap)
22
 
23
locals().update(cmap_d)