In [66]:
import pandas as pd
import numpy as np
xl = pd.ExcelFile('ColorBrewer_all_schemes_RGBonly3.XLS')
xl.sheet_names
df = xl.parse('Sheet1')[:1690]
df.tail()

# select specific data series
mask = df['ColorName'].isin(['Blues']) & df['NumOfColors'].isin([4.0]) & df['Type'].isin(['seq'])
mask
sel = df[mask]
print(sel)
index = sel.index[0] # int
# print(index[0])
# print(df['R'][36], df['R'][df.index.isin([36, 37, 38])])
df_rgb = df.loc[range(index, index+int(4.0), 1)]
# print(df['R'][index[0]])

# get color array
#TODO: get color rgb based on colorname and levels
color = np.ones((int(4.0), 4))
color[:, 0] = np.array(df_rgb['R'])
color[:, 1] = np.array(df_rgb['G'])
color[:, 2] = np.array(df_rgb['B'])
color[:, 3] = 255.0
color = color/255.
color.tolist()
# df.where(str(df['Type'] == 'seq'))  where works for ndarray

# TODO: create a colormap dropdown list with all colornames
# cm = set()
# for item in df['ColorName']:
#     if str(item) != 'nan':
#         cm.add(str(item))
# cm 


# let's say colorname is Accent and level is 4
# for item in df['ColorName']:
#     if item.isin(['Blues']):
#         print(item.keys())


   ColorName  NumOfColors Type  CritVal  ColorNum ColorLetter      R      G  \
36     Blues          4.0  seq      NaN       1.0           B  239.0  243.0   

        B SchemeType  
36  255.0        NaN  
Out[66]:
[[0.9372549019607843, 0.9529411764705882, 1.0, 1.0],
 [0.7411764705882353, 0.8431372549019608, 0.9058823529411765, 1.0],
 [0.4196078431372549, 0.6823529411764706, 0.8392156862745098, 1.0],
 [0.12941176470588237, 0.44313725490196076, 0.7098039215686275, 1.0]]

In [60]:
# sel.keys()
# blues = df[df['ColorName'].isin(['Blues'])]
# level = df[df['NumOfColors'].isin(['3.0'])]
# print(blues, level)
#TODO: apply the colormap to isosurface


   ColorName  NumOfColors Type  CritVal  ColorNum ColorLetter      R      G  \
36     Blues          4.0  seq      NaN       1.0           B  239.0  243.0   

        B SchemeType  
36  255.0        NaN  
Out[60]:
array([[ 239.,  243.,  255.,    1.],
       [ 189.,  215.,  231.,    1.],
       [ 107.,  174.,  214.,    1.],
       [  33.,  113.,  181.,    1.]])

In [41]:
import numpy as np
a = np.array(range(10) )
# a>5
a>5
# a
a = 'str'
a == 'str'


Out[41]:
True

In [ ]: