code: def _read_cmap(self):
          
  
          try:
              i = 0
              colormap = {0: (0, 0, 0)}
              with open(settings.COLORMAP) as cmap:
                  lines = cmap.readlines()
                  for line in lines:
                      if i == 0 and 'mode = ' in line:
                          i = 1
                          maxval = float(line.replace('mode = ', ''))
                      elif i > 0:
                          str = line.split()
                          if str == []:  # when there are empty lines at the end of the file
                              break
                          colormap.update(
                              {
                                  i: (int(round(float(str[0]) * 255 / maxval)),
                                      int(round(float(str[1]) * 255 / maxval)),
                                      int(round(float(str[2]) * 255 / maxval)))
                              }
                          )
                          i += 1
          except IOError:
              pass
  
          self.cmap = {k: v[:4] for k, v in colormap.items()}
docs: reads the colormap from a text file given in settings.py.
          See colormap_cubehelix.txt. File must contain 256 RGB values