Changeset 2205 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Oct 19, 2018, 9:30:24 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `make_colors': Function to create a palette of colors from a series of high and low values
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r2204 r2205  
    138138# list_norepeatcombos: Function to all possible (Num-1)-combinations of a Num values without repetitions
    139139# lstring_values: Function to provide a new list-string from a string which is a list of word separated by a character if some values are repeated they are not included
     140# make_colors: Function to create a palette of colors from a series of high and low values
    140141# mat_dimreshape: Function to reshape a matrix on a new one according to values along their dimensions
    141142# maxNcounts: Function to provide a value according to the maximum number of repeated values along a given axis
     
    1465414655    return newvalues
    1465514656
     14657def make_colors(highs, lows):
     14658    """ Function to create a palette of colors from a series of high and low values
     14659      highs= ',' separated list of high RGB
     14660      lows= ',' separated list of low RGB
     14661      returns string as [col1]:[col2]:...
     14662    >>> make_colors('AA','32')
     14663    #AAAA32:#AA32AA:#32AAAA:#AA3232:#32AA32:#3232AA
     14664    """
     14665    fname = 'make_colors'
     14666
     14667    hvs = highs.split(',')
     14668    lvs = lows.split(',')
     14669    Nhighs=len(hvs)
     14670    Nlows=len(lvs)
     14671
     14672    colors=''
     14673    icol = 0
     14674    for ih in range(Nhighs):
     14675        for il in range(Nlows):
     14676            if ih == 0 and il == 0:
     14677                colors = '#'+hvs[ih]+hvs[ih]+lvs[ih]
     14678                colors = colors + ':#'+hvs[ih]+lvs[ih]+hvs[ih]
     14679                colors = colors + ':#'+lvs[ih]+hvs[ih]+hvs[ih]
     14680                colors = colors + ':#'+hvs[ih]+lvs[ih]+lvs[ih]
     14681                colors = colors + ':#'+lvs[ih]+hvs[ih]+lvs[ih]
     14682                colors = colors + ':#'+lvs[ih]+lvs[ih]+hvs[ih]
     14683            else:
     14684                colors = colors + ':#'+hvs[ih]+hvs[ih]+lvs[ih]
     14685                colors = colors + ':#'+hvs[ih]+lvs[ih]+hvs[ih]
     14686                colors = colors + ':#'+lvs[ih]+hvs[ih]+hvs[ih]
     14687                colors = colors + ':#'+hvs[ih]+lvs[ih]+lvs[ih]
     14688                colors = colors + ':#'+lvs[ih]+hvs[ih]+lvs[ih]
     14689                colors = colors + ':#'+lvs[ih]+lvs[ih]+hvs[ih]
     14690
     14691    return colors
     14692
    1465614693#quit()
    1465714694
Note: See TracChangeset for help on using the changeset viewer.