def __init__(self, name, colorDict={}, readonly=0, colortype=None, info='', sortedkeys=None, lookupMember=None): if len(colorDict) > 0: if sortedkeys is None: labels = colorDict.keys() values = colorDict.values() else: labels = sortedkeys values = [] for label in labels: values.append(colorDict[label]) else: labels = None values = None print values ColorMap.__init__(self, name=name, ramp=values, labels=labels) self.readonly = readonly self.info = info #self.viewer = None self.sortedkeys = sortedkeys if colortype is None: self.colortype = self.FLOAT self.lookupMember = lookupMember
def __init__(self, results, master=None, mini=None, maxi=None, cmap=None, cmap_name='cmap', ramp=None, npixels=10): assert isinstance(results, type(numpy.array(list(range(4))))) assert len(results.shape)==2 # a copy of the input array is used self.results = numpy.array(results[:]) self.results = results self.master = master #for a numpy array, self.x_number = results.shape[0] #number of rows self.y_number = results.shape[1] #number of columns self.results = results self.npixels = npixels if mini is None: mini=min(results.ravel()) else: for x in range(self.x_number): for y in range(self.y_number): if self.results[x][y]<mini: self.results[x][y]=mini self.mini = mini if maxi is None: maxi=max(results.ravel()) else: for x in range(self.x_number): for y in range(self.y_number): if self.results[x][y]>maxi: self.results[x][y]=maxi self.maxi = maxi self.cmap = cmap if cmap is None: if ramp is None: ramp = RedWhiteRamp() self.cmap = ColorMap(cmap_name, mini=mini, maxi=maxi, ramp=ramp)
def __init__(self, name='textured2DArray', check=1, redo=1, **kw): # default colormap self.colormap = ColorMap('default', RGBARamp()) # 2d array self.array = None if not kw.has_key('inheritMaterial'): kw['inheritMaterial'] = 0 if not kw.has_key('culling'): kw['culling'] = 'none' if not kw.has_key('blendFunctions'): kw['blendFunctions'] = ('GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA') if not kw.has_key('frontPolyMode'): kw['frontPolyMode'] = 'fill' if not kw.has_key('backPolyMode'): kw['backPolyMode'] = 'fill' if not kw.has_key('shading'): kw['shading'] = 'flat' if not kw.has_key('vertices'): kw['vertices'] = ((0.,0,0), (1,0,0), (1,1,0), (0,1,0)) kw['faces'] = ((0,1,2,3),) #kw['faces'] = ( (0, 1, 2), (0, 2, 3) ) apply( IndexedPolygons.__init__, (self, name, check), kw)
def _lookup(self, name): #print "_lookup", name, type(name) try: col = ColorMap._lookup(self, name) if len(col) == 4: return col[:3] else: return col except: return (0., 1., 0.)
def getColors(self): from DejaVu.colorTool import Map, RGBRamp,RedWhiteBlueRamp from DejaVu.colorMap import ColorMap #from DejaVu.colorMapLegend import ColorMapLegend ramp = RedWhiteBlueRamp()#RGBRamp() self.cmap = ColorMap(name="tetra", ramp=ramp) cmlOptions = {'width':10, 'height':1, 'name':"tetra", 'ramp':ramp,"visible":True} # self.legend = ColorMapLegend(**cmlOptions) # self.helper.AddObject(self.legend) self.ncolors = {} if self.nvars is not None : for k,v in self.nvars.items(): self.ncolors[k] = Map(v, ramp) self.ccolors = {} if self.cvars is not None : for k,v in self.cvars.items(): colors = Map(v, ramp) cols = [] for c in colors: cols.extend( (c,)*4 ) self.ccolors[k] = cols
""" Copyright (C) <2010> Autin L. This file ePMV_git/apbs_map.py is part of ePMV. ePMV is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ePMV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ePMV. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>. """ from DejaVu.colorMap import ColorMap cm = ColorMap(name='cmap') cfg = {'mini': -9.7678934313589334, 'maxi': 9.7678934313589334, 'labels': None, 'ramp': [[1.0, 0.0, 0.0, 1.0], [1.0, 0.0060000000000000053, 0.0060000000000000053, 1.0], [1.0, 0.01100000000000001, 0.01100000000000001, 1.0], [1.0, 0.02300000000000002, 0.02300000000000002, 1.0], [1.0, 0.029000000000000026, 0.029000000000000026, 1.0], [1.0, 0.03400000000000003, 0.03400000000000003, 1.0], [1.0, 0.046000000000000041, 0.046000000000000041, 1.0], [1.0, 0.051000000000000045, 0.051000000000000045, 1.0], [1.0, 0.057000000000000051, 0.057000000000000051, 1.0], [1.0, 0.06899999999999995, 0.06899999999999995, 1.0], [1.0, 0.073999999999999955, 0.073999999999999955, 1.0], [1.0, 0.085999999999999965, 0.085999999999999965, 1.0], [1.0, 0.09099999999999997, 0.09099999999999997, 1.0], [1.0, 0.096999999999999975, 0.096999999999999975, 1.0], [1.0, 0.10899999999999999, 0.10899999999999999, 1.0], [1.0, 0.11399999999999999, 0.11399999999999999, 1.0], [1.0, 0.12, 0.12, 1.0], [1.0, 0.13100000000000001, 0.13100000000000001, 1.0], [1.0, 0.13700000000000001, 0.13700000000000001, 1.0], [1.0, 0.14300000000000002, 0.14300000000000002, 1.0], [1.0, 0.15400000000000003, 0.15400000000000003, 1.0], [1.0, 0.16000000000000003, 0.16000000000000003, 1.0], [1.0, 0.17100000000000004, 0.17100000000000004, 1.0], [1.0, 0.17700000000000005, 0.17700000000000005, 1.0], [1.0, 0.18300000000000005, 0.18300000000000005, 1.0], [1.0, 0.19399999999999995, 0.19399999999999995, 1.0], [1.0, 0.19999999999999996, 0.19999999999999996, 1.0], [1.0, 0.20599999999999996, 0.20599999999999996, 1.0], [1.0, 0.21699999999999997, 0.21699999999999997, 1.0], [1.0, 0.22299999999999998, 0.22299999999999998, 1.0], [1.0, 0.23399999999999999, 0.23399999999999999, 1.0], [1.0, 0.23999999999999999, 0.23999999999999999, 1.0], [1.0, 0.246, 0.246, 1.0], [1.0, 0.25700000000000001, 0.25700000000000001, 1.0], [1.0, 0.26300000000000001, 0.26300000000000001, 1.0], [1.0, 0.26900000000000002, 0.26900000000000002, 1.0], [1.0, 0.28000000000000003, 0.28000000000000003, 1.0], [1.0, 0.28600000000000003, 0.28600000000000003, 1.0], [1.0, 0.29100000000000004, 0.29100000000000004, 1.0], [1.0, 0.30300000000000005, 0.30300000000000005, 1.0], [1.0, 0.30900000000000005, 0.30900000000000005, 1.0], [1.0, 0.31999999999999995, 0.31999999999999995, 1.0], [1.0, 0.32599999999999996, 0.32599999999999996, 1.0], [1.0, 0.33099999999999996, 0.33099999999999996, 1.0], [1.0, 0.34299999999999997, 0.34299999999999997, 1.0], [1.0, 0.34899999999999998, 0.34899999999999998, 1.0], [1.0, 0.35399999999999998, 0.35399999999999998, 1.0], [1.0, 0.36599999999999999, 0.36599999999999999, 1.0], [1.0, 0.371, 0.371, 1.0], [1.0, 0.377, 0.377, 1.0], [1.0, 0.38900000000000001, 0.38900000000000001, 1.0], [1.0, 0.39400000000000002, 0.39400000000000002, 1.0], [1.0, 0.40600000000000003, 0.40600000000000003, 1.0], [1.0, 0.41100000000000003, 0.41100000000000003, 1.0], [1.0, 0.41700000000000004, 0.41700000000000004, 1.0], [1.0, 0.42900000000000005, 0.42900000000000005, 1.0], [1.0, 0.43400000000000005, 0.43400000000000005, 1.0], [1.0, 0.43999999999999995, 0.43999999999999995, 1.0], [1.0, 0.45099999999999996, 0.45099999999999996, 1.0], [1.0, 0.45699999999999996, 0.45699999999999996, 1.0], [1.0, 0.46899999999999997, 0.46899999999999997, 1.0], [1.0, 0.47399999999999998, 0.47399999999999998, 1.0], [1.0, 0.47999999999999998, 0.47999999999999998, 1.0], [1.0, 0.49099999999999999, 0.49099999999999999, 1.0], [1.0, 0.497, 0.497, 1.0], [1.0, 0.503, 0.503, 1.0], [1.0, 0.51400000000000001, 0.51400000000000001, 1.0], [1.0, 0.52000000000000002, 0.52000000000000002, 1.0], [1.0, 0.52600000000000002, 0.52600000000000002, 1.0], [1.0, 0.53699999999999992, 0.53699999999999992, 1.0], [1.0, 0.54299999999999993, 0.54299999999999993, 1.0], [1.0, 0.55400000000000005, 0.55400000000000005, 1.0], [1.0, 0.56000000000000005, 0.56000000000000005, 1.0], [1.0, 0.56600000000000006, 0.56600000000000006, 1.0], [1.0, 0.57699999999999996, 0.57699999999999996, 1.0], [1.0, 0.58299999999999996, 0.58299999999999996, 1.0], [1.0, 0.58899999999999997, 0.58899999999999997, 1.0], [1.0, 0.59999999999999998, 0.59999999999999998, 1.0], [1.0, 0.60599999999999998, 0.60599999999999998, 1.0], [1.0, 0.61699999999999999, 0.61699999999999999, 1.0], [1.0, 0.623, 0.623, 1.0], [1.0, 0.629, 0.629, 1.0], [1.0, 0.64000000000000001, 0.64000000000000001, 1.0], [1.0, 0.64600000000000002, 0.64600000000000002, 1.0], [1.0, 0.65100000000000002, 0.65100000000000002, 1.0], [1.0, 0.66300000000000003, 0.66300000000000003, 1.0], [1.0, 0.66900000000000004, 0.66900000000000004, 1.0], [1.0, 0.67399999999999993, 0.67399999999999993, 1.0], [1.0, 0.68599999999999994, 0.68599999999999994, 1.0], [1.0, 0.69100000000000006, 0.69100000000000006, 1.0], [1.0, 0.70300000000000007, 0.70300000000000007, 1.0], [1.0, 0.70900000000000007, 0.70900000000000007, 1.0], [1.0, 0.71399999999999997, 0.71399999999999997, 1.0], [1.0, 0.72599999999999998, 0.72599999999999998, 1.0], [1.0, 0.73099999999999998, 0.73099999999999998, 1.0], [1.0, 0.73699999999999999, 0.73699999999999999, 1.0], [1.0, 0.749, 0.749, 1.0], [1.0, 0.754, 0.754, 1.0], [1.0, 0.76000000000000001, 0.76000000000000001, 1.0], [1.0, 0.77100000000000002, 0.77100000000000002, 1.0], [1.0, 0.77700000000000002, 0.77700000000000002, 1.0], [1.0, 0.78900000000000003, 0.78900000000000003, 1.0], [1.0, 0.79400000000000004, 0.79400000000000004, 1.0], [1.0, 0.80000000000000004, 0.80000000000000004, 1.0], [1.0, 0.81099999999999994, 0.81099999999999994, 1.0], [1.0, 0.81699999999999995, 0.81699999999999995, 1.0], [1.0, 0.82299999999999995, 0.82299999999999995, 1.0], [1.0, 0.83399999999999996, 0.83399999999999996, 1.0], [1.0, 0.83999999999999997, 0.83999999999999997, 1.0], [1.0, 0.85099999999999998, 0.85099999999999998, 1.0], [1.0, 0.85699999999999998, 0.85699999999999998, 1.0], [1.0, 0.86299999999999999, 0.86299999999999999, 1.0], [1.0, 0.874, 0.874, 1.0], [1.0, 0.88, 0.88, 1.0], [1.0, 0.88600000000000001, 0.88600000000000001, 1.0], [1.0, 0.89700000000000002, 0.89700000000000002, 1.0], [1.0, 0.90300000000000002, 0.90300000000000002, 1.0], [1.0, 0.90900000000000003, 0.90900000000000003, 1.0], [1.0, 0.92000000000000004, 0.92000000000000004, 1.0], [1.0, 0.92600000000000005, 0.92600000000000005, 1.0], [1.0, 0.93700000000000006, 0.93700000000000006, 1.0], [1.0, 0.94299999999999995, 0.94299999999999995, 1.0], [1.0, 0.94899999999999995, 0.94899999999999995, 1.0], [1.0, 0.95999999999999996, 0.95999999999999996, 1.0], [1.0, 0.96599999999999997, 0.96599999999999997, 1.0], [1.0, 0.97099999999999997, 0.97099999999999997, 1.0], [1.0, 0.98299999999999998, 0.98299999999999998, 1.0], [1.0, 0.98899999999999999, 0.98899999999999999, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [0.98902199999999996, 0.98899999999999999, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [0.97105799999999998, 0.97099999999999997, 1.0, 1.0], [0.96606800000000004, 0.96599999999999997, 1.0, 1.0], [0.95409199999999994, 0.95399999999999996, 1.0, 1.0], [0.949102, 0.94899999999999995, 1.0, 1.0], [0.93712600000000013, 0.93700000000000006, 1.0, 1.0], [0.93113800000000013, 0.93100000000000005, 1.0, 1.0], [0.92614800000000008, 0.92600000000000005, 1.0, 1.0], [0.9141720000000001, 0.91400000000000003, 1.0, 1.0], [0.90918200000000005, 0.90900000000000003, 1.0, 1.0], [0.90319400000000005, 0.90300000000000002, 1.0, 1.0], [0.89121800000000007, 0.89100000000000001, 1.0, 1.0], [0.88622800000000013, 0.88600000000000001, 1.0, 1.0], [0.87425200000000003, 0.874, 1.0, 1.0], [0.86926200000000009, 0.86899999999999999, 1.0, 1.0], [0.8632740000000001, 0.86299999999999999, 1.0, 1.0], [0.85129800000000011, 0.85099999999999998, 1.0, 1.0], [0.84630800000000006, 0.84599999999999997, 1.0, 1.0], [0.84032000000000007, 0.83999999999999997, 1.0, 1.0], [0.82934200000000002, 0.82899999999999996, 1.0, 1.0], [0.82335400000000014, 0.82299999999999995, 1.0, 1.0], [0.81137800000000004, 0.81099999999999994, 1.0, 1.0], [0.80638800000000022, 0.80600000000000005, 1.0, 1.0], [0.80040000000000022, 0.80000000000000004, 1.0, 1.0], [0.78942200000000018, 0.78900000000000003, 1.0, 1.0], [0.78343400000000019, 0.78300000000000003, 1.0, 1.0], [0.77744600000000019, 0.77700000000000002, 1.0, 1.0], [0.76646800000000015, 0.76600000000000001, 1.0, 1.0], [0.76048000000000016, 0.76000000000000001, 1.0, 1.0], [0.74950200000000011, 0.749, 1.0, 1.0], [0.74351400000000023, 0.74299999999999999, 1.0, 1.0], [0.73752600000000013, 0.73699999999999999, 1.0, 1.0], [0.72654800000000019, 0.72599999999999998, 1.0, 1.0], [0.72056000000000009, 0.71999999999999997, 1.0, 1.0], [0.71457200000000021, 0.71399999999999997, 1.0, 1.0], [0.70359400000000027, 0.70300000000000007, 1.0, 1.0], [0.69760600000000028, 0.69700000000000006, 1.0, 1.0], [0.68662800000000013, 0.68599999999999994, 1.0, 1.0], [0.68064000000000013, 0.67999999999999994, 1.0, 1.0], [0.67465200000000014, 0.67399999999999993, 1.0, 1.0], [0.66367400000000032, 0.66300000000000003, 1.0, 1.0], [0.65768600000000021, 0.65700000000000003, 1.0, 1.0], [0.64670800000000028, 0.64600000000000002, 1.0, 1.0], [0.64072000000000018, 0.64000000000000001, 1.0, 1.0], [0.6347320000000003, 0.63400000000000001, 1.0, 1.0], [0.62375400000000025, 0.623, 1.0, 1.0], [0.61776600000000026, 0.61699999999999999, 1.0, 1.0], [0.61177800000000027, 0.61099999999999999, 1.0, 1.0], [0.60080000000000022, 0.59999999999999998, 1.0, 1.0], [0.59481200000000023, 0.59399999999999997, 1.0, 1.0], [0.58383400000000019, 0.58299999999999996, 1.0, 1.0], [0.5778460000000003, 0.57699999999999996, 1.0, 1.0], [0.5718580000000002, 0.57099999999999995, 1.0, 1.0], [0.56088000000000027, 0.56000000000000005, 1.0, 1.0], [0.55489200000000038, 0.55400000000000005, 1.0, 1.0], [0.54990200000000022, 0.54899999999999993, 1.0, 1.0], [0.53792600000000024, 0.53699999999999992, 1.0, 1.0], [0.53193800000000035, 0.53100000000000003, 1.0, 1.0], [0.52096000000000031, 0.52000000000000002, 1.0, 1.0], [0.51497200000000032, 0.51400000000000001, 1.0, 1.0], [0.50998200000000038, 0.50900000000000001, 1.0, 1.0], [0.49800600000000028, 0.497, 1.0, 1.0], [0.49201800000000029, 0.49099999999999999, 1.0, 1.0], [0.48702800000000035, 0.48599999999999999, 1.0, 1.0], [0.47505200000000036, 0.47399999999999998, 1.0, 1.0], [0.47006200000000031, 0.46899999999999997, 1.0, 1.0], [0.45808600000000033, 0.45699999999999996, 1.0, 1.0], [0.45209800000000033, 0.45099999999999996, 1.0, 1.0], [0.44710800000000028, 0.44599999999999995, 1.0, 1.0], [0.43513200000000041, 0.43400000000000005, 1.0, 1.0], [0.43014200000000047, 0.42900000000000005, 1.0, 1.0], [0.42415400000000048, 0.42300000000000004, 1.0, 1.0], [0.41217800000000038, 0.41100000000000003, 1.0, 1.0], [0.40718800000000044, 0.40600000000000003, 1.0, 1.0], [0.39521200000000045, 0.39400000000000002, 1.0, 1.0], [0.3902220000000004, 0.38900000000000001, 1.0, 1.0], [0.38423400000000041, 0.38300000000000001, 1.0, 1.0], [0.37225800000000042, 0.371, 1.0, 1.0], [0.36726800000000037, 0.36599999999999999, 1.0, 1.0], [0.36128000000000038, 0.35999999999999999, 1.0, 1.0], [0.35030200000000045, 0.34899999999999998, 1.0, 1.0], [0.34431400000000045, 0.34299999999999997, 1.0, 1.0], [0.33233800000000036, 0.33099999999999996, 1.0, 1.0], [0.32734800000000042, 0.32599999999999996, 1.0, 1.0], [0.32136000000000042, 0.31999999999999995, 1.0, 1.0], [0.31038200000000049, 0.30900000000000005, 1.0, 1.0], [0.3043940000000005, 0.30300000000000005, 1.0, 1.0], [0.29241800000000051, 0.29100000000000004, 1.0, 1.0], [0.28742800000000046, 0.28600000000000003, 1.0, 1.0], [0.28144000000000047, 0.28000000000000003, 1.0, 1.0], [0.27046200000000054, 0.26900000000000002, 1.0, 1.0], [0.26447400000000054, 0.26300000000000001, 1.0, 1.0], [0.25848600000000055, 0.25700000000000001, 1.0, 1.0], [0.24750800000000051, 0.246, 1.0, 1.0], [0.24152000000000051, 0.23999999999999999, 1.0, 1.0], [0.23054200000000047, 0.22899999999999998, 1.0, 1.0], [0.22455400000000048, 0.22299999999999998, 1.0, 1.0], [0.21856600000000048, 0.21699999999999997, 1.0, 1.0], [0.20758800000000044, 0.20599999999999996, 1.0, 1.0], [0.20160000000000045, 0.19999999999999996, 1.0, 1.0], [0.19561200000000045, 0.19399999999999995, 1.0, 1.0], [0.18463400000000063, 0.18300000000000005, 1.0, 1.0], [0.17864600000000064, 0.17700000000000005, 1.0, 1.0], [0.16766800000000059, 0.16600000000000004, 1.0, 1.0], [0.1616800000000006, 0.16000000000000003, 1.0, 1.0], [0.15569200000000061, 0.15400000000000003, 1.0, 1.0], [0.14471400000000056, 0.14300000000000002, 1.0, 1.0], [0.13872600000000057, 0.13700000000000001, 1.0, 1.0], [0.13273800000000058, 0.13100000000000001, 1.0, 1.0], [0.12176000000000053, 0.12, 1.0, 1.0], [0.11577200000000054, 0.11399999999999999, 1.0, 1.0], [0.10479400000000061, 0.10299999999999998, 1.0, 1.0], [0.098806000000000616, 0.096999999999999975, 1.0, 1.0], [0.092818000000000622, 0.09099999999999997, 1.0, 1.0], [0.081840000000000579, 0.07999999999999996, 1.0, 1.0], [0.075852000000000586, 0.073999999999999955, 1.0, 1.0], [0.070862000000000536, 0.06899999999999995, 1.0, 1.0], [0.05888600000000066, 0.057000000000000051, 1.0, 1.0], [0.052898000000000667, 0.051000000000000045, 1.0, 1.0], [0.041920000000000623, 0.040000000000000036, 1.0, 1.0], [0.03593200000000063, 0.03400000000000003, 1.0, 1.0], [0.030942000000000691, 0.029000000000000026, 1.0, 1.0], [0.018966000000000705, 0.017000000000000015, 1.0, 1.0], [0.012978000000000711, 0.01100000000000001, 1.0, 1.0], [0.0020000000000006679, 0.0, 1.0, 1.0]], 'name': 'cmap'} cm.configure(*(), **cfg)
## Automatically adapted for numpy.oldnumeric Jul 23, 2007 by from DejaVu.colorMap import ColorMap from numpy.oldnumeric import array cm = ColorMap('rgb256') cfg = { 'name': 'rgb256', 'ramp': array( [[0., 0., 1., 1.], [0., 0.015625, 1., 1.], [0., 0.03125, 1., 1.], [0., 0.046875, 1., 1.], [0., 0.0625, 1., 1.], [0., 0.078125, 1., 1.], [0., 0.09375, 1., 1.], [0., 0.109375, 1., 1.], [0., 0.125, 1., 1.], [0., 0.140625, 1., 1.], [0., 0.15625, 1., 1.], [0., 0.171875, 1., 1.], [0., 0.1875, 1., 1.], [0., 0.203125, 1., 1.], [0., 0.21875, 1., 1.], [0., 0.234375, 1., 1.], [0., 0.25, 1., 1.], [0., 0.265625, 1., 1.], [0., 0.28125, 1., 1.], [0., 0.296875, 1., 1.], [0., 0.3125, 1., 1.], [0., 0.328125, 1., 1.], [0., 0.34375, 1., 1.], [0., 0.359375, 1., 1.], [0., 0.375, 1., 1.], [0., 0.390625, 1., 1.], [0., 0.40625, 1., 1.], [0., 0.421875, 1., 1.], [0., 0.4375, 1., 1.], [0., 0.453125, 1., 1.], [0., 0.46875, 1., 1.], [0., 0.484375, 1., 1.], [0., 0.5, 1., 1.], [0., 0.515625, 1., 1.], [0., 0.53125, 1., 1.], [0., 0.546875, 1., 1.], [0., 0.5625, 1., 1.], [0., 0.578125, 1., 1.], [0., 0.59375, 1., 1.], [0., 0.609375, 1., 1.], [0., 0.625, 1., 1.], [0., 0.640625, 1., 1.], [0., 0.65625, 1., 1.], [0., 0.671875, 1., 1.], [0., 0.6875, 1., 1.], [0., 0.703125, 1., 1.], [0., 0.71875, 1., 1.], [0., 0.734375, 1., 1.], [0., 0.75, 1., 1.], [0., 0.765625, 1., 1.], [0., 0.78125, 1., 1.], [0., 0.796875, 1., 1.], [0., 0.8125, 1., 1.], [0., 0.828125, 1., 1.], [0., 0.84375, 1., 1.], [0., 0.859375, 1., 1.], [0., 0.875, 1., 1.], [0., 0.890625, 1., 1.], [0., 0.90625, 1., 1.], [0., 0.921875, 1., 1.],
from DejaVu.colorMap import ColorMap cm = ColorMap(name='cmap') cfg = {'mini': -9.7678934313589334, 'maxi': 9.7678934313589334, 'labels': None, 'ramp': [[1.0, 0.0, 0.0, 1.0], [1.0, 0.0060000000000000053, 0.0060000000000000053, 1.0], [1.0, 0.01100000000000001, 0.01100000000000001, 1.0], [1.0, 0.02300000000000002, 0.02300000000000002, 1.0], [1.0, 0.029000000000000026, 0.029000000000000026, 1.0], [1.0, 0.03400000000000003, 0.03400000000000003, 1.0], [1.0, 0.046000000000000041, 0.046000000000000041, 1.0], [1.0, 0.051000000000000045, 0.051000000000000045, 1.0], [1.0, 0.057000000000000051, 0.057000000000000051, 1.0], [1.0, 0.06899999999999995, 0.06899999999999995, 1.0], [1.0, 0.073999999999999955, 0.073999999999999955, 1.0], [1.0, 0.085999999999999965, 0.085999999999999965, 1.0], [1.0, 0.09099999999999997, 0.09099999999999997, 1.0], [1.0, 0.096999999999999975, 0.096999999999999975, 1.0], [1.0, 0.10899999999999999, 0.10899999999999999, 1.0], [1.0, 0.11399999999999999, 0.11399999999999999, 1.0], [1.0, 0.12, 0.12, 1.0], [1.0, 0.13100000000000001, 0.13100000000000001, 1.0], [1.0, 0.13700000000000001, 0.13700000000000001, 1.0], [1.0, 0.14300000000000002, 0.14300000000000002, 1.0], [1.0, 0.15400000000000003, 0.15400000000000003, 1.0], [1.0, 0.16000000000000003, 0.16000000000000003, 1.0], [1.0, 0.17100000000000004, 0.17100000000000004, 1.0], [1.0, 0.17700000000000005, 0.17700000000000005, 1.0], [1.0, 0.18300000000000005, 0.18300000000000005, 1.0], [1.0, 0.19399999999999995, 0.19399999999999995, 1.0], [1.0, 0.19999999999999996, 0.19999999999999996, 1.0], [1.0, 0.20599999999999996, 0.20599999999999996, 1.0], [1.0, 0.21699999999999997, 0.21699999999999997, 1.0], [1.0, 0.22299999999999998, 0.22299999999999998, 1.0], [1.0, 0.23399999999999999, 0.23399999999999999, 1.0], [1.0, 0.23999999999999999, 0.23999999999999999, 1.0], [1.0, 0.246, 0.246, 1.0], [1.0, 0.25700000000000001, 0.25700000000000001, 1.0], [1.0, 0.26300000000000001, 0.26300000000000001, 1.0], [1.0, 0.26900000000000002, 0.26900000000000002, 1.0], [1.0, 0.28000000000000003, 0.28000000000000003, 1.0], [1.0, 0.28600000000000003, 0.28600000000000003, 1.0], [1.0, 0.29100000000000004, 0.29100000000000004, 1.0], [1.0, 0.30300000000000005, 0.30300000000000005, 1.0], [1.0, 0.30900000000000005, 0.30900000000000005, 1.0], [1.0, 0.31999999999999995, 0.31999999999999995, 1.0], [1.0, 0.32599999999999996, 0.32599999999999996, 1.0], [1.0, 0.33099999999999996, 0.33099999999999996, 1.0], [1.0, 0.34299999999999997, 0.34299999999999997, 1.0], [1.0, 0.34899999999999998, 0.34899999999999998, 1.0], [1.0, 0.35399999999999998, 0.35399999999999998, 1.0], [1.0, 0.36599999999999999, 0.36599999999999999, 1.0], [1.0, 0.371, 0.371, 1.0], [1.0, 0.377, 0.377, 1.0], [1.0, 0.38900000000000001, 0.38900000000000001, 1.0], [1.0, 0.39400000000000002, 0.39400000000000002, 1.0], [1.0, 0.40600000000000003, 0.40600000000000003, 1.0], [1.0, 0.41100000000000003, 0.41100000000000003, 1.0], [1.0, 0.41700000000000004, 0.41700000000000004, 1.0], [1.0, 0.42900000000000005, 0.42900000000000005, 1.0], [1.0, 0.43400000000000005, 0.43400000000000005, 1.0], [1.0, 0.43999999999999995, 0.43999999999999995, 1.0], [1.0, 0.45099999999999996, 0.45099999999999996, 1.0], [1.0, 0.45699999999999996, 0.45699999999999996, 1.0], [1.0, 0.46899999999999997, 0.46899999999999997, 1.0], [1.0, 0.47399999999999998, 0.47399999999999998, 1.0], [1.0, 0.47999999999999998, 0.47999999999999998, 1.0], [1.0, 0.49099999999999999, 0.49099999999999999, 1.0], [1.0, 0.497, 0.497, 1.0], [1.0, 0.503, 0.503, 1.0], [1.0, 0.51400000000000001, 0.51400000000000001, 1.0], [1.0, 0.52000000000000002, 0.52000000000000002, 1.0], [1.0, 0.52600000000000002, 0.52600000000000002, 1.0], [1.0, 0.53699999999999992, 0.53699999999999992, 1.0], [1.0, 0.54299999999999993, 0.54299999999999993, 1.0], [1.0, 0.55400000000000005, 0.55400000000000005, 1.0], [1.0, 0.56000000000000005, 0.56000000000000005, 1.0], [1.0, 0.56600000000000006, 0.56600000000000006, 1.0], [1.0, 0.57699999999999996, 0.57699999999999996, 1.0], [1.0, 0.58299999999999996, 0.58299999999999996, 1.0], [1.0, 0.58899999999999997, 0.58899999999999997, 1.0], [1.0, 0.59999999999999998, 0.59999999999999998, 1.0], [1.0, 0.60599999999999998, 0.60599999999999998, 1.0], [1.0, 0.61699999999999999, 0.61699999999999999, 1.0], [1.0, 0.623, 0.623, 1.0], [1.0, 0.629, 0.629, 1.0], [1.0, 0.64000000000000001, 0.64000000000000001, 1.0], [1.0, 0.64600000000000002, 0.64600000000000002, 1.0], [1.0, 0.65100000000000002, 0.65100000000000002, 1.0], [1.0, 0.66300000000000003, 0.66300000000000003, 1.0], [1.0, 0.66900000000000004, 0.66900000000000004, 1.0], [1.0, 0.67399999999999993, 0.67399999999999993, 1.0], [1.0, 0.68599999999999994, 0.68599999999999994, 1.0], [1.0, 0.69100000000000006, 0.69100000000000006, 1.0], [1.0, 0.70300000000000007, 0.70300000000000007, 1.0], [1.0, 0.70900000000000007, 0.70900000000000007, 1.0], [1.0, 0.71399999999999997, 0.71399999999999997, 1.0], [1.0, 0.72599999999999998, 0.72599999999999998, 1.0], [1.0, 0.73099999999999998, 0.73099999999999998, 1.0], [1.0, 0.73699999999999999, 0.73699999999999999, 1.0], [1.0, 0.749, 0.749, 1.0], [1.0, 0.754, 0.754, 1.0], [1.0, 0.76000000000000001, 0.76000000000000001, 1.0], [1.0, 0.77100000000000002, 0.77100000000000002, 1.0], [1.0, 0.77700000000000002, 0.77700000000000002, 1.0], [1.0, 0.78900000000000003, 0.78900000000000003, 1.0], [1.0, 0.79400000000000004, 0.79400000000000004, 1.0], [1.0, 0.80000000000000004, 0.80000000000000004, 1.0], [1.0, 0.81099999999999994, 0.81099999999999994, 1.0], [1.0, 0.81699999999999995, 0.81699999999999995, 1.0], [1.0, 0.82299999999999995, 0.82299999999999995, 1.0], [1.0, 0.83399999999999996, 0.83399999999999996, 1.0], [1.0, 0.83999999999999997, 0.83999999999999997, 1.0], [1.0, 0.85099999999999998, 0.85099999999999998, 1.0], [1.0, 0.85699999999999998, 0.85699999999999998, 1.0], [1.0, 0.86299999999999999, 0.86299999999999999, 1.0], [1.0, 0.874, 0.874, 1.0], [1.0, 0.88, 0.88, 1.0], [1.0, 0.88600000000000001, 0.88600000000000001, 1.0], [1.0, 0.89700000000000002, 0.89700000000000002, 1.0], [1.0, 0.90300000000000002, 0.90300000000000002, 1.0], [1.0, 0.90900000000000003, 0.90900000000000003, 1.0], [1.0, 0.92000000000000004, 0.92000000000000004, 1.0], [1.0, 0.92600000000000005, 0.92600000000000005, 1.0], [1.0, 0.93700000000000006, 0.93700000000000006, 1.0], [1.0, 0.94299999999999995, 0.94299999999999995, 1.0], [1.0, 0.94899999999999995, 0.94899999999999995, 1.0], [1.0, 0.95999999999999996, 0.95999999999999996, 1.0], [1.0, 0.96599999999999997, 0.96599999999999997, 1.0], [1.0, 0.97099999999999997, 0.97099999999999997, 1.0], [1.0, 0.98299999999999998, 0.98299999999999998, 1.0], [1.0, 0.98899999999999999, 0.98899999999999999, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [0.98902199999999996, 0.98899999999999999, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [0.97105799999999998, 0.97099999999999997, 1.0, 1.0], [0.96606800000000004, 0.96599999999999997, 1.0, 1.0], [0.95409199999999994, 0.95399999999999996, 1.0, 1.0], [0.949102, 0.94899999999999995, 1.0, 1.0], [0.93712600000000013, 0.93700000000000006, 1.0, 1.0], [0.93113800000000013, 0.93100000000000005, 1.0, 1.0], [0.92614800000000008, 0.92600000000000005, 1.0, 1.0], [0.9141720000000001, 0.91400000000000003, 1.0, 1.0], [0.90918200000000005, 0.90900000000000003, 1.0, 1.0], [0.90319400000000005, 0.90300000000000002, 1.0, 1.0], [0.89121800000000007, 0.89100000000000001, 1.0, 1.0], [0.88622800000000013, 0.88600000000000001, 1.0, 1.0], [0.87425200000000003, 0.874, 1.0, 1.0], [0.86926200000000009, 0.86899999999999999, 1.0, 1.0], [0.8632740000000001, 0.86299999999999999, 1.0, 1.0], [0.85129800000000011, 0.85099999999999998, 1.0, 1.0], [0.84630800000000006, 0.84599999999999997, 1.0, 1.0], [0.84032000000000007, 0.83999999999999997, 1.0, 1.0], [0.82934200000000002, 0.82899999999999996, 1.0, 1.0], [0.82335400000000014, 0.82299999999999995, 1.0, 1.0], [0.81137800000000004, 0.81099999999999994, 1.0, 1.0], [0.80638800000000022, 0.80600000000000005, 1.0, 1.0], [0.80040000000000022, 0.80000000000000004, 1.0, 1.0], [0.78942200000000018, 0.78900000000000003, 1.0, 1.0], [0.78343400000000019, 0.78300000000000003, 1.0, 1.0], [0.77744600000000019, 0.77700000000000002, 1.0, 1.0], [0.76646800000000015, 0.76600000000000001, 1.0, 1.0], [0.76048000000000016, 0.76000000000000001, 1.0, 1.0], [0.74950200000000011, 0.749, 1.0, 1.0], [0.74351400000000023, 0.74299999999999999, 1.0, 1.0], [0.73752600000000013, 0.73699999999999999, 1.0, 1.0], [0.72654800000000019, 0.72599999999999998, 1.0, 1.0], [0.72056000000000009, 0.71999999999999997, 1.0, 1.0], [0.71457200000000021, 0.71399999999999997, 1.0, 1.0], [0.70359400000000027, 0.70300000000000007, 1.0, 1.0], [0.69760600000000028, 0.69700000000000006, 1.0, 1.0], [0.68662800000000013, 0.68599999999999994, 1.0, 1.0], [0.68064000000000013, 0.67999999999999994, 1.0, 1.0], [0.67465200000000014, 0.67399999999999993, 1.0, 1.0], [0.66367400000000032, 0.66300000000000003, 1.0, 1.0], [0.65768600000000021, 0.65700000000000003, 1.0, 1.0], [0.64670800000000028, 0.64600000000000002, 1.0, 1.0], [0.64072000000000018, 0.64000000000000001, 1.0, 1.0], [0.6347320000000003, 0.63400000000000001, 1.0, 1.0], [0.62375400000000025, 0.623, 1.0, 1.0], [0.61776600000000026, 0.61699999999999999, 1.0, 1.0], [0.61177800000000027, 0.61099999999999999, 1.0, 1.0], [0.60080000000000022, 0.59999999999999998, 1.0, 1.0], [0.59481200000000023, 0.59399999999999997, 1.0, 1.0], [0.58383400000000019, 0.58299999999999996, 1.0, 1.0], [0.5778460000000003, 0.57699999999999996, 1.0, 1.0], [0.5718580000000002, 0.57099999999999995, 1.0, 1.0], [0.56088000000000027, 0.56000000000000005, 1.0, 1.0], [0.55489200000000038, 0.55400000000000005, 1.0, 1.0], [0.54990200000000022, 0.54899999999999993, 1.0, 1.0], [0.53792600000000024, 0.53699999999999992, 1.0, 1.0], [0.53193800000000035, 0.53100000000000003, 1.0, 1.0], [0.52096000000000031, 0.52000000000000002, 1.0, 1.0], [0.51497200000000032, 0.51400000000000001, 1.0, 1.0], [0.50998200000000038, 0.50900000000000001, 1.0, 1.0], [0.49800600000000028, 0.497, 1.0, 1.0], [0.49201800000000029, 0.49099999999999999, 1.0, 1.0], [0.48702800000000035, 0.48599999999999999, 1.0, 1.0], [0.47505200000000036, 0.47399999999999998, 1.0, 1.0], [0.47006200000000031, 0.46899999999999997, 1.0, 1.0], [0.45808600000000033, 0.45699999999999996, 1.0, 1.0], [0.45209800000000033, 0.45099999999999996, 1.0, 1.0], [0.44710800000000028, 0.44599999999999995, 1.0, 1.0], [0.43513200000000041, 0.43400000000000005, 1.0, 1.0], [0.43014200000000047, 0.42900000000000005, 1.0, 1.0], [0.42415400000000048, 0.42300000000000004, 1.0, 1.0], [0.41217800000000038, 0.41100000000000003, 1.0, 1.0], [0.40718800000000044, 0.40600000000000003, 1.0, 1.0], [0.39521200000000045, 0.39400000000000002, 1.0, 1.0], [0.3902220000000004, 0.38900000000000001, 1.0, 1.0], [0.38423400000000041, 0.38300000000000001, 1.0, 1.0], [0.37225800000000042, 0.371, 1.0, 1.0], [0.36726800000000037, 0.36599999999999999, 1.0, 1.0], [0.36128000000000038, 0.35999999999999999, 1.0, 1.0], [0.35030200000000045, 0.34899999999999998, 1.0, 1.0], [0.34431400000000045, 0.34299999999999997, 1.0, 1.0], [0.33233800000000036, 0.33099999999999996, 1.0, 1.0], [0.32734800000000042, 0.32599999999999996, 1.0, 1.0], [0.32136000000000042, 0.31999999999999995, 1.0, 1.0], [0.31038200000000049, 0.30900000000000005, 1.0, 1.0], [0.3043940000000005, 0.30300000000000005, 1.0, 1.0], [0.29241800000000051, 0.29100000000000004, 1.0, 1.0], [0.28742800000000046, 0.28600000000000003, 1.0, 1.0], [0.28144000000000047, 0.28000000000000003, 1.0, 1.0], [0.27046200000000054, 0.26900000000000002, 1.0, 1.0], [0.26447400000000054, 0.26300000000000001, 1.0, 1.0], [0.25848600000000055, 0.25700000000000001, 1.0, 1.0], [0.24750800000000051, 0.246, 1.0, 1.0], [0.24152000000000051, 0.23999999999999999, 1.0, 1.0], [0.23054200000000047, 0.22899999999999998, 1.0, 1.0], [0.22455400000000048, 0.22299999999999998, 1.0, 1.0], [0.21856600000000048, 0.21699999999999997, 1.0, 1.0], [0.20758800000000044, 0.20599999999999996, 1.0, 1.0], [0.20160000000000045, 0.19999999999999996, 1.0, 1.0], [0.19561200000000045, 0.19399999999999995, 1.0, 1.0], [0.18463400000000063, 0.18300000000000005, 1.0, 1.0], [0.17864600000000064, 0.17700000000000005, 1.0, 1.0], [0.16766800000000059, 0.16600000000000004, 1.0, 1.0], [0.1616800000000006, 0.16000000000000003, 1.0, 1.0], [0.15569200000000061, 0.15400000000000003, 1.0, 1.0], [0.14471400000000056, 0.14300000000000002, 1.0, 1.0], [0.13872600000000057, 0.13700000000000001, 1.0, 1.0], [0.13273800000000058, 0.13100000000000001, 1.0, 1.0], [0.12176000000000053, 0.12, 1.0, 1.0], [0.11577200000000054, 0.11399999999999999, 1.0, 1.0], [0.10479400000000061, 0.10299999999999998, 1.0, 1.0], [0.098806000000000616, 0.096999999999999975, 1.0, 1.0], [0.092818000000000622, 0.09099999999999997, 1.0, 1.0], [0.081840000000000579, 0.07999999999999996, 1.0, 1.0], [0.075852000000000586, 0.073999999999999955, 1.0, 1.0], [0.070862000000000536, 0.06899999999999995, 1.0, 1.0], [0.05888600000000066, 0.057000000000000051, 1.0, 1.0], [0.052898000000000667, 0.051000000000000045, 1.0, 1.0], [0.041920000000000623, 0.040000000000000036, 1.0, 1.0], [0.03593200000000063, 0.03400000000000003, 1.0, 1.0], [0.030942000000000691, 0.029000000000000026, 1.0, 1.0], [0.018966000000000705, 0.017000000000000015, 1.0, 1.0], [0.012978000000000711, 0.01100000000000001, 1.0, 1.0], [0.0020000000000006679, 0.0, 1.0, 1.0]], 'name': 'cmap'} apply( cm.configure, (), cfg)
## Automatically adapted for numpy.oldnumeric Jul 23, 2007 by from DejaVu.colorMap import ColorMap from numpy.oldnumeric import array cm = ColorMap('rgb10') cfg = {'name': 'rgb10', 'ramp': array([[ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0. , 0.442 , 1. , 1. ],
class PixelMap2D: """ PixelMap2D: Used to display 2D representations of 2D numpy arrays of data, colored by magnitude. Its cmap, a DejaVu.colorMap, provides a mapping from each data value to an entry in a 'ramp' which is a list of lists of 3 floats between 0-1. (By default, a RedWhiteRamp is used. Each entry defines a color for that value.) The property range is set by default from the 'mini' and 'maxi' values of the results array but it can be set by specifying values for 'mini' and 'maxi'. In the latter case, the values of the result array are clamped to be greater than 'mini' and less than 'maxi'. A copy of the original data is used. Its method to display data "show_image" -> [x,y] produces an array of pixels colored by magnitude of corresponding x,y result and is implemented using PIL.Image show_image. "On Unix platforms, this saves the image to a temporary PPM file, and calls the xv utility. On Windows, it saves the image to a temporary BMP file, and uses the standard BMP display utility to show it."" (F.Lundh, http://effbot.org/imagingbook/image.htm) Its method to display the corresponding color map legend "show_legend" produces an array of pixels, 1-by-nsteps, showing the range of the colormap. This legend is displayed using xv on Unix platforms """ def __init__(self, results, master=None, mini=None, maxi=None, cmap=None, cmap_name='cmap', ramp=None, npixels=10): assert isinstance(results, type(numpy.array(list(range(4))))) assert len(results.shape)==2 # a copy of the input array is used self.results = numpy.array(results[:]) self.results = results self.master = master #for a numpy array, self.x_number = results.shape[0] #number of rows self.y_number = results.shape[1] #number of columns self.results = results self.npixels = npixels if mini is None: mini=min(results.ravel()) else: for x in range(self.x_number): for y in range(self.y_number): if self.results[x][y]<mini: self.results[x][y]=mini self.mini = mini if maxi is None: maxi=max(results.ravel()) else: for x in range(self.x_number): for y in range(self.y_number): if self.results[x][y]>maxi: self.results[x][y]=maxi self.maxi = maxi self.cmap = cmap if cmap is None: if ramp is None: ramp = RedWhiteRamp() self.cmap = ColorMap(cmap_name, mini=mini, maxi=maxi, ramp=ramp) def show_image(self): #'RGB' requires a tuple (r,g,b) where r,g,b are ints in range 0-255 #'RGBA' requires a tuple (r,g,b,a) where r,g,b,a are ints in range 0-255 values = self.cmap.Map(self.results.ravel()) self.image = Image.fromstring('RGBA', (self.x_number,self.y_number), (values*255).astype('B').tostring()) self.image.show() def show_legend(self, steps=20, horizontal=True): delta = (self.maxi-self.mini)/(steps-1) vals = self.vals= [] for i in range(steps-1): vals.append(self.mini+i*delta) self.vals.append(self.maxi) values = self.cmap.Map(vals) if horizontal: self.legend = Image.fromstring('RGBA', (steps, 1), (values*255).astype('B').tostring()) else: self.legend = Image.fromstring('RGBA', (1,steps), (values*255).astype('B').tostring()) self.legend.show()
def doit(self, ramp, labels): #print "doit" ColorMap.configure(self.vf.colorByAtomType.palette, ramp=ramp, labels=labels)
class textured2DArray(IndexedPolygons): """Draw a quad with a 2D array textured mapped on it using a colormap""" keywords = IndexedPolygons.keywords + [ 'array', # 2D array of data to be turned into texture 'colormap', # colormap used for mapping data inot colors 'min', # min value used for mapping data inot colors 'max', # max value used for mapping data inot colors ] def __init__(self, name='textured2DArray', check=1, redo=1, **kw): # default colormap self.colormap = ColorMap('default', RGBARamp()) # 2d array self.array = None if not kw.has_key('inheritMaterial'): kw['inheritMaterial'] = 0 if not kw.has_key('culling'): kw['culling'] = 'none' if not kw.has_key('blendFunctions'): kw['blendFunctions'] = ('GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA') if not kw.has_key('frontPolyMode'): kw['frontPolyMode'] = 'fill' if not kw.has_key('backPolyMode'): kw['backPolyMode'] = 'fill' if not kw.has_key('shading'): kw['shading'] = 'flat' if not kw.has_key('vertices'): kw['vertices'] = ((0.,0,0), (1,0,0), (1,1,0), (0,1,0)) kw['faces'] = ((0,1,2,3),) #kw['faces'] = ( (0, 1, 2), (0, 2, 3) ) apply( IndexedPolygons.__init__, (self, name, check), kw) def Set(self, check=1, redo=1, updateOwnGui=True, **kw): """set data for this object: Set polylines's vertices check=1 : verify that all the keywords present can be handle by this func redo=1 : append self to viewer.objectsNeedingRedo updateOwnGui=True : allow to update owngui at the end this func """ redoFlags = apply( IndexedPolygons.Set, (self, check, 0), kw ) redoFlags |= self._redoFlags['redoViewerDisplayListFlag'] rebuildTexture=False val = kw.get( 'array') if val is not None: array = Numeric.array(val) assert len(array.shape)==2 self.array = val rebuildTexture=True val = kw.get( 'colormap') if val is not None: assert isinstance(val, ColorMap) self.colormap = val rebuildTexture=True setMinMax = False val = kw.get( 'max') if val: maxi = float(val) setMinMax = True else: maxi = self.colormap.maxi val = kw.get( 'min') if val: mini = float(val) setMinMax = True else: mini = self.colormap.mini if mini<= maxi and setMinMax: self.colormap.configure(mini=mini, maxi=maxi, updateGui=True) if rebuildTexture and self.array is not None: tex, texCoords = self.buildTexture() self.Set(texture=tex, textureCoords=texCoords) return self.redoNow(redo, updateOwnGui, redoFlags) def buildTexture(self): """Build a 2D Texture object and compute texture coordinates for self.array, using self.colormap to colorize the texture. """ width, height = self.array.shape # find smallest power of 2 larger than shape dim1=dim2=1 while dim1<width: dim1 = dim1<<1 while dim2<height: dim2 = dim2<<1 # compute texture indices r1=float(width)/float(dim1) r2=float(height)/float(dim2) textCoords = ((0,0), (r1,0), (r1, r2), (0, r2)) # build texture object for DejaVu sl = Numeric.array(Numeric.transpose(self.array)) # use this line when new color map will be used colors = self.colormap.Map(sl.ravel()) colors.shape = (height, width, -1) colors = colors*255 colors = colors.astype('B') tex2DimageArr = Numeric.zeros((dim2,dim1,colors.shape[2]), 'B') tex2DimageArr[:height,:width] = colors tex = Texture() tex.Set(enable=1, image=tex2DimageArr, auto=0) tex.width = dim1 tex.height = dim2 return tex, textCoords
## Automatically adapted for numpy.oldnumeric Jul 23, 2007 by from DejaVu.colorMap import ColorMap from numpy.oldnumeric import array cm = ColorMap('rgb128') cfg = { 'name': 'rgb128', 'ramp': [[0.0, 0.0, 1.0, 1.0], [0.0, 0.03125, 1.0, 1.0], [0.0, 0.0625, 1.0, 1.0], [0.0, 0.09375, 1.0, 1.0], [0.0, 0.125, 1.0, 1.0], [0.0, 0.15625, 1.0, 1.0], [0.0, 0.1875, 1.0, 1.0], [0.0, 0.21875, 1.0, 1.0], [0.0, 0.25, 1.0, 1.0], [0.0, 0.28125, 1.0, 1.0], [0.0, 0.3125, 1.0, 1.0], [0.0, 0.34375, 1.0, 1.0], [0.0, 0.375, 1.0, 1.0], [0.0, 0.40625, 1.0, 1.0], [0.0, 0.4375, 1.0, 1.0], [0.0, 0.46875, 1.0, 1.0], [0.0, 0.5, 1.0, 1.0], [0.0, 0.53125, 1.0, 1.0], [0.0, 0.5625, 1.0, 1.0], [0.0, 0.59375, 1.0, 1.0], [0.0, 0.625, 1.0, 1.0], [0.0, 0.65625, 1.0, 1.0], [0.0, 0.6875, 1.0, 1.0], [0.0, 0.71875, 1.0, 1.0], [0.0, 0.75, 1.0, 1.0], [0.0, 0.78125, 1.0, 1.0], [0.0, 0.8125, 1.0, 1.0], [0.0, 0.84375, 1.0, 1.0], [0.0, 0.875, 1.0, 1.0], [0.0, 0.90625, 1.0, 1.0], [0.0, 0.9375, 1.0, 1.0], [0.0, 0.96875, 1.0, 1.0], [0.0, 1.0, 1.0, 1.0], [0.0, 1.0, 0.96875, 1.0], [0.0, 1.0, 0.9375, 1.0], [0.0, 1.0, 0.90625, 1.0], [0.0, 1.0, 0.875, 1.0], [0.0, 1.0, 0.84375, 1.0], [0.0, 1.0, 0.8125, 1.0], [0.0, 1.0, 0.78125, 1.0], [0.0, 1.0, 0.75, 1.0], [0.0, 1.0, 0.71875, 1.0], [0.0, 1.0, 0.6875, 1.0], [0.0, 1.0, 0.65625, 1.0], [0.0, 1.0, 0.625, 1.0], [0.0, 1.0, 0.59375, 1.0],
## Automatically adapted for numpy.oldnumeric Jul 23, 2007 by from DejaVu.colorMap import ColorMap from numpy.oldnumeric import array cm = ColorMap('wb256') cfg = {'name': 'wb256', 'ramp': array([[ 0.002 , 0. , 1. , 1. ], [ 0.002 , 0. , 1. , 1. ], [ 0.007988 , 0.006 , 1. , 1. ], [ 0.012978 , 0.011 , 1. , 1. ], [ 0.012978 , 0.011 , 1. , 1. ], [ 0.018966 , 0.017 , 1. , 1. ], [ 0.024954 , 0.023 , 1. , 1. ], [ 0.024954 , 0.023 , 1. , 1. ], [ 0.030942 , 0.029 , 1. , 1. ], [ 0.035932 , 0.034 , 1. , 1. ], [ 0.035932 , 0.034 , 1. , 1. ], [ 0.04192 , 0.04 , 1. , 1. ], [ 0.047908 , 0.046 , 1. , 1. ], [ 0.047908 , 0.046 , 1. , 1. ], [ 0.052898 , 0.051 , 1. , 1. ], [ 0.058886 , 0.057 , 1. , 1. ], [ 0.058886 , 0.057 , 1. , 1. ], [ 0.064874 , 0.063 , 1. , 1. ], [ 0.070862 , 0.069 , 1. , 1. ], [ 0.075852 , 0.074 , 1. , 1. ], [ 0.075852 , 0.074 , 1. , 1. ], [ 0.08184 , 0.08 , 1. , 1. ], [ 0.087828 , 0.086 , 1. , 1. ], [ 0.087828 , 0.086 , 1. , 1. ], [ 0.092818 , 0.091 , 1. , 1. ], [ 0.098806 , 0.097 , 1. , 1. ],
## Automatically adapted for numpy.oldnumeric Jul 23, 2007 by from DejaVu.colorMap import ColorMap from numpy.oldnumeric import array cm = ColorMap('rwb128') cfg = { 'name': 'rwb128', 'ramp': [[0.002, 0.0, 1.0, 1.0], [0.012978, 0.011, 1.0, 1.0], [0.030942, 0.029, 1.0, 1.0], [0.047908, 0.046, 1.0, 1.0], [0.064874, 0.063, 1.0, 1.0], [0.075852, 0.074, 1.0, 1.0], [0.092818, 0.091, 1.0, 1.0], [0.110782, 0.109, 1.0, 1.0], [0.127748, 0.126, 1.0, 1.0], [0.144714, 0.143, 1.0, 1.0], [0.155692, 0.154, 1.0, 1.0], [0.172658, 0.171, 1.0, 1.0], [0.190622, 0.189, 1.0, 1.0], [0.207588, 0.206, 1.0, 1.0], [0.218566, 0.217, 1.0, 1.0], [0.235532, 0.234, 1.0, 1.0], [0.252498, 0.251, 1.0, 1.0], [0.270462, 0.269, 1.0, 1.0], [0.287428, 0.286, 1.0, 1.0], [0.298406, 0.297, 1.0, 1.0], [0.315372, 0.314, 1.0, 1.0], [0.332338, 0.331, 1.0, 1.0], [0.350302, 0.349, 1.0, 1.0], [0.36128, 0.36, 1.0, 1.0], [0.378246, 0.377, 1.0, 1.0], [0.395212, 0.394, 1.0, 1.0], [0.412178, 0.411, 1.0, 1.0], [0.430142, 0.429, 1.0, 1.0], [0.44112, 0.44, 1.0, 1.0], [0.458086, 0.457, 1.0, 1.0], [0.475052, 0.474, 1.0, 1.0], [0.492018, 0.491, 1.0, 1.0], [0.503994, 0.503, 1.0, 1.0], [0.52096, 0.52, 1.0, 1.0], [0.537926, 0.537, 1.0, 1.0], [0.554892, 0.554, 1.0, 1.0], [0.571858, 0.571, 1.0, 1.0], [0.583834, 0.583, 1.0, 1.0], [0.6008, 0.6, 1.0, 1.0], [0.617766, 0.617, 1.0, 1.0], [0.634732, 0.634, 1.0, 1.0], [0.646708, 0.646, 1.0, 1.0], [0.663674, 0.663, 1.0, 1.0], [0.68064, 0.68, 1.0, 1.0], [0.697606, 0.697, 1.0, 1.0], [0.714572, 0.714, 1.0, 1.0],
def apply(self): ColorMap.configure(self.vf.colorByResidueType.palette, ramp=self.paletteGUI.ramp, labels=self.paletteGUI.labels) geoms = self.vf.colorByResidueType.getAvailableGeoms(self.vf.Mols) self.cleanup() #otherwise this was failing first time around self.vf.colorByResidueType(self.vf.Mols, geoms)
## Automatically adapted for numpy.oldnumeric Jul 23, 2007 by from DejaVu.colorMap import ColorMap from numpy.oldnumeric import array cm = ColorMap('rwb256') cfg = {'name': 'rwb256', 'ramp': array([[ 1. , 0. , 0. , 1. ], [ 0.00798478, 0.006 , 1. , 1. ], [ 0.01297748, 0.011 , 1. , 1. ], [ 0.02495463, 0.023 , 1. , 1. ], [ 0.03094184, 0.029 , 1. , 1. ], [ 0.03593225, 0.034 , 1. , 1. ], [ 0.04790861, 0.046 , 1. , 1. ], [ 0.0528977 , 0.051 , 1. , 1. ], [ 0.06487406, 0.063 , 1. , 1. ], [ 0.07086179, 0.069 , 1. , 1. ], [ 0.07585198, 0.074 , 1. , 1. ], [ 0.0878282 , 0.086 , 1. , 1. ], [ 0.09281833, 0.091 , 1. , 1. ], [ 0.09880612, 0.097 , 1. , 1. ], [ 0.11078227, 0.109 , 1. , 1. ], [ 0.11577237, 0.114 , 1. , 1. ], [ 0.12774806, 0.126 , 1. , 1. ], [ 0.13273776, 0.131 , 1. , 1. ], [ 0.13872601, 0.13699999, 1. , 1. ], [ 0.15070179, 0.149 , 1. , 1. ], [ 0.15569188, 0.154 , 1. , 1. ], [ 0.16168009, 0.16 , 1. , 1. ], [ 0.17265806, 0.171 , 1. , 1. ], [ 0.17864597, 0.177 , 1. , 1. ], [ 0.19062206, 0.189 , 1. , 1. ], [ 0.1956121 , 0.19400001, 1. , 1. ],