Add and use a user-defined colormap

  1. Look at the Colormaps page in epygram doc, and try out some of these to see their characteristics - basically, 3 kinds:

    • continuous (default)

    • normalized (e.g. rr1h), i.e. each value interval occupy a normalized size in colormap

    • and normalized-centered (e.g. ptype), i.e. normalized, with interval centered on defined values

  2. Once you found the one which characteristics you would like to imitate, copy its .json file from EPYGRAM_INSTALL_DIR/epygram/data/colormaps/ to wherever you want (say, /path/to/my_cmap.json)

  3. Modify the name of the new colormap, its colors (RGB, optional transparency) and colorsteps in the json file.

  4. Register your colormap in your HOME/.epygram/userconfig.py: usercolormaps = {'my_cmap':'/path/to/my_cmap.json'}

An example below of a normalized-centered colormap

[1]:
%matplotlib inline
# for figures in notebook

# import & initialize epygram
import epygram
epygram.init_env()

import os
INPUTS_DIR = os.path.join('..', 'inputs')
[2]:
r = epygram.formats.resource(os.path.join(INPUTS_DIR, 'grid.arome-forecast.guyane0025+0024:00.grib'), 'r')
[3]:
f = r.readfield('parameterCategory:1,parameterNumber:19,typeOfStatisticalProcessing:0')
[4]:
fig, ax = f.cartoplot(colormap='ptype')
../../_images/gallery_A.1-H2D_plots_10.userdefined_colormap_6_0.png
[ ]: