# Copyright (c) 2010 John Glover, National University of Ireland, Maynooth
# 
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# These colour maps are based on the colour schemes in gheat:
# http://code.google.com/p/gheat/

classic_colours = [
    [0.200, 0.200, 0.239],
    [0.188, 0.188, 0.247],
    [0.173, 0.173, 0.255],
    [0.157, 0.157, 0.263],
    [0.137, 0.137, 0.267],
    [0.114, 0.114, 0.275],
    [0.094, 0.094, 0.278],
    [0.075, 0.075, 0.286],
    [0.055, 0.055, 0.298],
    [0.039, 0.039, 0.302],
    [0.027, 0.027, 0.310],
    [0.020, 0.020, 0.333],
    [0.012, 0.016, 0.361],
    [0.004, 0.020, 0.396],
    [0.004, 0.031, 0.431],
    [0.000, 0.047, 0.471],
    [0.000, 0.071, 0.514],
    [0.000, 0.102, 0.557],
    [0.000, 0.137, 0.596],
    [0.000, 0.180, 0.635],
    [0.000, 0.227, 0.671],
    [0.000, 0.278, 0.706],
    [0.000, 0.337, 0.741],
    [0.000, 0.388, 0.769],
    [0.000, 0.439, 0.796],
    [0.000, 0.478, 0.816],
    [0.000, 0.545, 0.855],
    [0.000, 0.612, 0.894],
    [0.000, 0.678, 0.925],
    [0.000, 0.737, 0.957],
    [0.000, 0.792, 0.980],
    [0.000, 0.839, 0.996],
    [0.000, 0.878, 1.000],
    [0.000, 0.910, 1.000],
    [0.000, 0.918, 0.996],
    [0.000, 0.918, 0.973],
    [0.000, 0.918, 0.949],
    [0.000, 0.918, 0.918],
    [0.000, 0.918, 0.882],
    [0.000, 0.918, 0.839],
    [0.000, 0.906, 0.796],
    [0.000, 0.890, 0.745],
    [0.000, 0.871, 0.698],
    [0.000, 0.847, 0.647],
    [0.000, 0.835, 0.612],
    [0.000, 0.820, 0.576],
    [0.000, 0.804, 0.541],
    [0.000, 0.788, 0.506],
    [0.000, 0.776, 0.471],
    [0.000, 0.761, 0.439],
    [0.000, 0.749, 0.408],
    [0.000, 0.737, 0.373],
    [0.000, 0.729, 0.345],
    [0.000, 0.722, 0.314],
    [0.000, 0.714, 0.290],
    [0.000, 0.710, 0.267],
    [0.000, 0.706, 0.243],
    [0.004, 0.706, 0.224],
    [0.024, 0.710, 0.208],
    [0.047, 0.714, 0.188],
    [0.075, 0.722, 0.173],
    [0.106, 0.733, 0.157],
    [0.141, 0.745, 0.145],
    [0.176, 0.761, 0.133],
    [0.216, 0.776, 0.122],
    [0.259, 0.792, 0.110],
    [0.298, 0.812, 0.098],
    [0.345, 0.827, 0.090],
    [0.388, 0.847, 0.082],
    [0.431, 0.867, 0.075],
    [0.478, 0.886, 0.067],
    [0.525, 0.906, 0.059],
    [0.573, 0.925, 0.055],
    [0.620, 0.941, 0.047],
    [0.663, 0.957, 0.043],
    [0.706, 0.969, 0.035],
    [0.749, 0.984, 0.031],
    [0.788, 0.988, 0.027],
    [0.827, 0.988, 0.024],
    [0.863, 0.988, 0.020],
    [0.898, 0.988, 0.016],
    [0.929, 0.988, 0.012],
    [0.957, 0.988, 0.008],
    [0.980, 0.988, 0.004],
    [1.000, 0.984, 0.000],
    [1.000, 0.969, 0.000],
    [1.000, 0.949, 0.000],
    [1.000, 0.922, 0.000],
    [1.000, 0.890, 0.000],
    [1.000, 0.855, 0.000],
    [1.000, 0.816, 0.000],
    [1.000, 0.776, 0.000],
    [1.000, 0.733, 0.000],
    [1.000, 0.686, 0.000],
    [1.000, 0.639, 0.000],
    [1.000, 0.588, 0.000],
    [1.000, 0.537, 0.000],
    [1.000, 0.486, 0.000],
    [1.000, 0.435, 0.000],
    [1.000, 0.388, 0.000]
]

pbj_colours = [
    [0.106, 0.016, 0.267],
    [0.110, 0.016, 0.267],
    [0.114, 0.016, 0.263],
    [0.114, 0.000, 0.263],
    [0.114, 0.000, 0.263],
    [0.122, 0.016, 0.263],
    [0.125, 0.016, 0.263],
    [0.125, 0.016, 0.263],
    [0.129, 0.000, 0.259],
    [0.129, 0.000, 0.259],
    [0.133, 0.000, 0.259],
    [0.137, 0.000, 0.255],
    [0.145, 0.000, 0.259],
    [0.149, 0.000, 0.259],
    [0.149, 0.000, 0.255],
    [0.153, 0.000, 0.255],
    [0.157, 0.000, 0.251],
    [0.161, 0.000, 0.251],
    [0.165, 0.000, 0.251],
    [0.165, 0.000, 0.251],
    [0.169, 0.000, 0.247],
    [0.176, 0.000, 0.247],
    [0.180, 0.000, 0.243],
    [0.184, 0.000, 0.243],
    [0.188, 0.000, 0.243],
    [0.196, 0.000, 0.243],
    [0.200, 0.000, 0.239],
    [0.204, 0.000, 0.235],
    [0.212, 0.000, 0.235],
    [0.216, 0.000, 0.235],
    [0.224, 0.016, 0.231],
    [0.227, 0.016, 0.231],
    [0.235, 0.016, 0.227],
    [0.235, 0.016, 0.224],
    [0.243, 0.016, 0.220],
    [0.247, 0.016, 0.224],
    [0.255, 0.020, 0.220],
    [0.263, 0.020, 0.216],
    [0.267, 0.020, 0.212],
    [0.278, 0.020, 0.212],
    [0.286, 0.020, 0.208],
    [0.290, 0.020, 0.204],
    [0.294, 0.024, 0.200],
    [0.302, 0.027, 0.200],
    [0.310, 0.027, 0.196],
    [0.318, 0.027, 0.192],
    [0.325, 0.035, 0.188],
    [0.333, 0.039, 0.188],
    [0.341, 0.039, 0.180],
    [0.349, 0.043, 0.176],
    [0.357, 0.047, 0.173],
    [0.365, 0.051, 0.169],
    [0.380, 0.055, 0.165],
    [0.384, 0.059, 0.161],
    [0.392, 0.067, 0.157],
    [0.404, 0.071, 0.149],
    [0.416, 0.078, 0.149],
    [0.427, 0.086, 0.145],
    [0.435, 0.090, 0.137],
    [0.443, 0.098, 0.133],
    [0.455, 0.106, 0.129],
    [0.471, 0.114, 0.125],
    [0.478, 0.114, 0.122],
    [0.486, 0.122, 0.118],
    [0.502, 0.129, 0.114],
    [0.510, 0.137, 0.110],
    [0.518, 0.145, 0.106],
    [0.525, 0.149, 0.106],
    [0.545, 0.165, 0.102],
    [0.549, 0.169, 0.098],
    [0.561, 0.176, 0.094],
    [0.569, 0.180, 0.090],
    [0.580, 0.192, 0.090],
    [0.592, 0.200, 0.090],
    [0.604, 0.208, 0.086],
    [0.612, 0.212, 0.082],
    [0.624, 0.220, 0.082],
    [0.635, 0.227, 0.082],
    [0.643, 0.235, 0.078],
    [0.651, 0.243, 0.078],
    [0.667, 0.251, 0.078],
    [0.675, 0.259, 0.078],
    [0.682, 0.263, 0.078],
    [0.686, 0.267, 0.078],
    [0.694, 0.271, 0.078],
    [0.706, 0.282, 0.078],
    [0.714, 0.282, 0.078],
    [0.722, 0.290, 0.078],
    [0.733, 0.294, 0.082],
    [0.741, 0.306, 0.082],
    [0.745, 0.310, 0.082],
    [0.753, 0.318, 0.086],
    [0.765, 0.322, 0.086],
    [0.773, 0.322, 0.086],
    [0.780, 0.333, 0.090],
    [0.784, 0.337, 0.090],
    [0.792, 0.341, 0.090],
    [0.800, 0.349, 0.090],
    [0.808, 0.353, 0.090],
    [0.820, 0.357, 0.094]
]

def classic(heat):
    if heat < 0.0:
        return classic_colours[0]
    elif heat > 1.0:
        return classic_colours[-1]
    else:
        return classic_colours[int(heat * (len(classic_colours)-1))]

def pbj(heat):
    if heat < 0.0:
        return pbj_colours[0]
    elif heat > 1.0:
        return pbj_colours[-1]
    else:
        return pbj_colours[int(heat * (len(pbj_colours)-1))]