38 golden_ratio = (1. + math.sqrt(5.)) / 2.
41 def colour_from_instruments(instruments, colours = {
42 "G1": numpy.array((0.0, 1.0, 1.0)),
43 "H1": numpy.array((1.0, 0.0, 0.0)),
44 "H2": numpy.array((0.0, 0.0, 1.0)),
45 "L1": numpy.array((0.0, 0.7, 0.0)),
46 "E1": numpy.array((1.0, 0.0, 0.0)),
47 "E2": numpy.array((0.0, 0.8, 0.0)),
48 "E3": numpy.array((1.0, 0.0, 1.0)),
49 "V1": numpy.array((1.0, 0.0, 1.0)),
50 "K1": numpy.array((0.0, 0.0, 1.0)),
53 colour = sum(map(colours.__getitem__, instruments))
55 if len(instruments) > 1:
57 colour += len(instruments) - 1
59 colour /= colour.max()
72 floatpattern = re.compile(
"([+-]?[.0-9]+)[Ee]([+-]?[0-9]+)")
76 Convert a string of the form "d.dddde-dd" to "d.dddd \\times 77 10^{-dd}". Strings that contain neither an "e" nor an "E" are 80 if "e" not in s
and "E" not in s:
82 m, e = floatpattern.match(s).groups()
83 return r"%s \times 10^{%d}" % (m, int(e))
88 Escapes "\\" and "_" characters, and replaces " " with "~" 91 return s.replace(
"\\",
"\\\\").replace(
"_",
"\\_").replace(
" ",
"~")