added option to output RGB palette on terminal
number of colors is now variable (default 32) warning issued if MSC path not valid new "redblue" sym colormap
This commit is contained in:
parent
ac342ad682
commit
3a0911ca89
|
@ -5,3 +5,4 @@ green 0.33333,0.9,0.1 0.33333,0.1,0.9
|
||||||
blue 0.66667,0.9,0.1 0.66667,0.1,0.9
|
blue 0.66667,0.9,0.1 0.66667,0.1,0.9
|
||||||
seaweed 0.78,1.0,0.1 0.4,0.1,0.9
|
seaweed 0.78,1.0,0.1 0.4,0.1,0.9
|
||||||
redgreen 0.00000,0.2,0.9 0.33333,0.2,0.9 symmetric
|
redgreen 0.00000,0.2,0.9 0.33333,0.2,0.9 symmetric
|
||||||
|
redblue 0.00000,0.2,0.9 0.66667,0.2,0.9 symmetric
|
||||||
|
|
|
@ -30,8 +30,7 @@ for release,subdirs in sorted(releases.items(),reverse=True):
|
||||||
try:
|
try:
|
||||||
from py_mentat import *
|
from py_mentat import *
|
||||||
except:
|
except:
|
||||||
print('error: no valid Mentat release found in %s'%MSCpath)
|
print('warning: no valid Mentat release found in %s'%MSCpath)
|
||||||
sys.exit(-1)
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
@ -144,12 +143,18 @@ parser.add_option("-s","--symmetric", action = "store_true",
|
||||||
parser.add_option("-i","--inverse", action = "store_true",
|
parser.add_option("-i","--inverse", action = "store_true",
|
||||||
dest = "inverse", \
|
dest = "inverse", \
|
||||||
help = "invert legend [%default]")
|
help = "invert legend [%default]")
|
||||||
|
parser.add_option( "--palette", action = "store_true",
|
||||||
|
dest = "palette", \
|
||||||
|
help = "output plain rgb palette values [%default]")
|
||||||
parser.add_option("-p", "--port", type = "int",\
|
parser.add_option("-p", "--port", type = "int",\
|
||||||
dest = "port",\
|
dest = "port",\
|
||||||
help = "Mentat connection port [%default]")
|
help = "Mentat connection port [%default]")
|
||||||
parser.add_option("-b", "--baseindex", type = "int",\
|
parser.add_option("-b", "--baseindex", type = "int",\
|
||||||
dest = "baseIdx",\
|
dest = "baseIdx",\
|
||||||
help = "base index of colormap [%default]")
|
help = "base index of colormap [%default]")
|
||||||
|
parser.add_option("-n", "--colorcount", type = "int",\
|
||||||
|
dest = "colorcount",\
|
||||||
|
help = "number of colors [%default]")
|
||||||
parser.add_option("-c", "--config", type='string', \
|
parser.add_option("-c", "--config", type='string', \
|
||||||
dest = "config",\
|
dest = "config",\
|
||||||
help = "configuration file [%default]")
|
help = "configuration file [%default]")
|
||||||
|
@ -159,9 +164,11 @@ parser.add_option("-v", "--verbose", action="store_true",\
|
||||||
|
|
||||||
parser.set_defaults(port = 40007)
|
parser.set_defaults(port = 40007)
|
||||||
parser.set_defaults(baseIdx = 32)
|
parser.set_defaults(baseIdx = 32)
|
||||||
|
parser.set_defaults(colorcount = 32)
|
||||||
parser.set_defaults(config = 'colorMap.config')
|
parser.set_defaults(config = 'colorMap.config')
|
||||||
parser.set_defaults(symmetric = False)
|
parser.set_defaults(symmetric = False)
|
||||||
parser.set_defaults(inverse = False)
|
parser.set_defaults(inverse = False)
|
||||||
|
parser.set_defaults(palette = False)
|
||||||
parser.set_defaults(verbose = False)
|
parser.set_defaults(verbose = False)
|
||||||
|
|
||||||
msg = []
|
msg = []
|
||||||
|
@ -198,15 +205,14 @@ if msg != []:
|
||||||
|
|
||||||
### interpolate hls values
|
### interpolate hls values
|
||||||
|
|
||||||
nColors = 32
|
|
||||||
if options.symmetric:
|
if options.symmetric:
|
||||||
hlsColors = [ [ syminterpolate(comp, hlsColor_range[0][j], hlsColor_range[1][j], float(idx)/(nColors-1))
|
hlsColors = [ [ syminterpolate(comp, hlsColor_range[0][j], hlsColor_range[1][j], float(idx)/(options.colorcount-1))
|
||||||
for j,comp in enumerate(["hue","lightness","saturation"]) ]
|
for j,comp in enumerate(["hue","lightness","saturation"]) ]
|
||||||
for idx in range(nColors) ]
|
for idx in range(options.colorcount) ]
|
||||||
else:
|
else:
|
||||||
hlsColors = [ [ interpolate(hlsColor_range[0][j], hlsColor_range[1][j], float(idx)/(nColors-1))
|
hlsColors = [ [ interpolate(hlsColor_range[0][j], hlsColor_range[1][j], float(idx)/(options.colorcount-1))
|
||||||
for j,comp in enumerate(["hue","lightness","saturation"]) ]
|
for j,comp in enumerate(["hue","lightness","saturation"]) ]
|
||||||
for idx in range(nColors) ]
|
for idx in range(options.colorcount) ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,8 +221,11 @@ else:
|
||||||
rgbColors = [ hls_to_rgb(hlsColor[0], hlsColor[1], hlsColor[2])
|
rgbColors = [ hls_to_rgb(hlsColor[0], hlsColor[1], hlsColor[2])
|
||||||
for hlsColor in hlsColors ]
|
for hlsColor in hlsColors ]
|
||||||
|
|
||||||
|
if options.palette:
|
||||||
|
for rgb in rgbColors:
|
||||||
|
print '\t'.join(map(lambda x: str(int(255*x)),rgb))
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
### connect to mentat and change colorMap
|
### connect to mentat and change colorMap
|
||||||
|
|
||||||
outputLocals = {}
|
outputLocals = {}
|
||||||
|
|
Loading…
Reference in New Issue