How to use the trollimage.colormap.rainbow function in trollimage

To help you get started, we’ve selected a few trollimage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pytroll / fogpy / fogpy / algorithms.py View on Github external
name = self.__class__.__name__
        savedir = os.path.join(dir, name + '_clusters_' +
                               datetime.strftime(self.time,
                                                 '%Y%m%d%H%M') + '.png')
        # Using Trollimage if available, else matplotlib is used to plot
        try:
            from trollimage.image import Image
            from trollimage.colormap import rainbow
        except ImportError:
            logger.info("{} results can't be plotted to: {}". format(name,
                                                                     self.dir))
            return 0
        # Create image from data
        cluster_img = Image(self.clusters.squeeze(), mode='L', fill_value=None)
        cluster_img.stretch("crude")
        cluster_img.colorize(rainbow)
        cluster_img.resize((self.clusters.shape[0] * 5,
                            self.clusters.shape[1] * 5))
        if save:
            cluster_img.save(savedir)
            logger.info("{} results are plotted to: {}". format(name,
                                                                self.dir))
        else:
            cluster_img.show()
github pytroll / mpop / mpop / tools.py View on Github external
# convert to masked array
    # convert form km to meter
    height = np.ma.masked_where(height <= 0, height, copy=False) * 1000.

    if False:
        from trollimage.image import Image as trollimage
        from trollimage.colormap import rainbow
        from copy import deepcopy 
        # cloud top height
        prop = height
        min_data = prop.min()
        max_data = prop.max()
        print " estimated CTH(meter) (min/max): ", min_data, max_data
        min_data =     0
        max_data = 12000    
        colormap = deepcopy(rainbow)
        colormap.set_range(min_data, max_data)
        img = trollimage(prop, mode="L") #, fill_value=[0,0,0]
        img.colorize(colormap)
        img.show()

    # return cloud top height in meter
    return height