Add and use a user-defined colormap¶
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
Once you found the one which characteristics you would like to imitate, copy its
.json
file fromEPYGRAM_INSTALL_DIR/epygram/data/colormaps/
to wherever you want (say,/path/to/my_cmap.json
)Modify the name of the new colormap, its colors (RGB, optional transparency) and colorsteps in the json file.
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')
[ ]: