def test_read_colormap(self): cl = utils.read_colormap('topo') * 256 assert_allclose(cl[4, :], (177, 242, 196)) assert_allclose(cl[-1, :], (235, 233, 235)) cl = utils.read_colormap('dem') * 256 assert_allclose(cl[4, :], (153, 100, 43)) assert_allclose(cl[-1, :], (255, 255, 255))
def test_read_colormap(self): cl = utils.read_colormap("topo") * 256 assert_allclose(cl[4, :], (177, 242, 196)) assert_allclose(cl[-1, :], (235, 233, 235)) cl = utils.read_colormap("dem") * 256 assert_allclose(cl[4, :], (153, 100, 43)) assert_allclose(cl[-1, :], (255, 255, 255))
def get_cmap(cmap='viridis'): """Get a colormap from mpl, and also those defined by Salem. Currently we have: topo, dem, nrwc see https://github.com/fmaussion/salem-sample-data/tree/master/colormaps """ try: return plt.get_cmap(cmap) except ValueError: cl = utils.read_colormap(cmap) return LinearSegmentedColormap.from_list(cmap, cl, N=256)