Skip to content

Instantly share code, notes, and snippets.

@dagss
Last active December 14, 2015 21:28
Show Gist options
  • Save dagss/5151234 to your computer and use it in GitHub Desktop.
Save dagss/5151234 to your computer and use it in GitHub Desktop.
class PlanckUniversalColormap(Colormap):
name = "planckuniv"
def __init__(self, cmap):
Colormap.__init__(self, "planckuniv-" + cmap.name, cmap.N)
self.cmap = cmap
self.N = self.cmap.N
def __call__(self, xi, alpha=1.0, **kw):
x = xi * (1e7+1e3) - 1e3
yi = self.modsinh(x)
# range 0-1
yi = (yi + 3)/10.
return self.cmap(yi, alpha)
def modsinh(self, x):
return np.log10(0.5*(x + np.sqrt(x**2 + 4)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment