Changeset 2698 in lmdz_wrf for trunk


Ignore:
Timestamp:
Aug 16, 2019, 11:06:08 AM (5 years ago)
Author:
lfita
Message:

Adding:

  • `pastel_deccolor': Transforming a decimal color to a 'pastel' tone
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r2694 r2698  
    193193# oper_submatrix: Function to perform an operation of a given matrix along a sub-set of values along its dimensions
    194194# operations: Function to perform different operations to a pair of matrices of values
     195# pastel_deccolor: Transforming a decimal color to a 'pastel' tone
    195196# period_information_360d: Function to provide the information of a given period idate, edate (dates in
    196197#  [YYYY][MM][DD][HH][MI][SS] format) in a 360 years calendar
     
    1693616937    return area, areakm
    1693716938
     16939def pastel_deccolor(color, pdeg=0.8):
     16940    """ Transforming a decimal color to a 'pastel' tone
     16941      color: decimal color ([0,1.], [0,1.], [0,1.])
     16942      pdeg: degree of 'pastel' (0.8, default)
     16943    >>> pastel_deccolor([1.,0.,0.])
     16944    [ 1.   0.8  0.8]
     16945    >>> pastel_deccolor([1.,0.5,0.3])
     16946    [ 1.    0.4   0.56]
     16947    """
     16948    fname = 'pastel_deccolor'
     16949
     16950    pastelc = np.array(color)
     16951
     16952    # Looking for the maximum
     16953    cmax = np.max(pastelc)
     16954
     16955    # Increasing any, except cmax up to 0.8cmax
     16956    pastelc = np.where(pastelc != cmax, (1.-pastelc)*0.8*cmax, pastelc)
     16957
     16958    return pastelc
     16959
    1693816960#quit()
    1693916961
Note: See TracChangeset for help on using the changeset viewer.