code: def build_colormap(palette, info):
          
  
          from trollimage.colormap import Colormap
          if 'palette_meanings' in palette.attrs:
              palette_indices = palette.attrs['palette_meanings']
          else:
              palette_indices = range(len(palette))
  
          sqpalette = np.asanyarray(palette).squeeze() / 255.0
          tups = [(val, tuple(tup))
                  for (val, tup) in zip(palette_indices, sqpalette)]
          colormap = Colormap(*tups)
          if 'palette_meanings' not in palette.attrs:
              sf = info.get('scale_factor', np.array(1))
              colormap.set_range(
                  *(np.array(info['valid_range']) * sf + info.get('add_offset', 0)))
  
          return colormap, sqpalette
docs: Create the colormap from the `raw_palette` and the valid_range.