code: def create_colormap(palette):
      
      from trollimage.colormap import Colormap
      fname = palette.get('filename', None)
      if fname:
          data = np.load(fname)
          cmap = []
          num = 1.0 * data.shape[0]
          for i in range(int(num)):
              cmap.append((i / num, (data[i, 0] / 255., data[i, 1] / 255.,
                                     data[i, 2] / 255.)))
          return Colormap(*cmap)
  
      colors = palette.get('colors', None)
      if isinstance(colors, list):
          cmap = []
          values = palette.get('values', None)
          for idx, color in enumerate(colors):
              if values:
                  value = values[idx]
              else:
                  value = idx / float(len(colors) - 1)
              cmap.append((value, tuple(color)))
          return Colormap(*cmap)
  
      if isinstance(colors, str):
          from trollimage import colormap
          import copy
          return copy.copy(getattr(colormap, colors))
  
      return None
docs: Create colormap of the given numpy file, color vector or colormap.