Exemplo n.º 1
0
def testReal():
    category = 7
    heatDict = ld.profile2Dict("energyData/meterData/", "Heating:Gas")
    coolDict = ld.profile2Dict("energyData/meterData/", "Cooling:Elec")
    color_heat = colorRamp(category, "white*-red 1 (red*)", "rgb")
    color_cool = colorRamp(category, "white*-blue*", "rgb")
    length = 8760

#   for key in heatDict:
    key = "Hospital"
    testlength = 50

    heat_bp = ld.breakpt(heatDict[key][:testlength], category,
                         "quantile")
    cool_bp = ld.breakpt(coolDict[key][:testlength], category,
                         "quantile")
    arr_heat = ld.classify(heatDict[key][:testlength], heat_bp)
    arr_cool = ld.classify(coolDict[key][:testlength], cool_bp)
    arr_cl_heat = [color_heat[x] for x in arr_heat]
    arr_cl_cool = [color_cool[x] for x in arr_cool]
    mix = mixColor([arr_cl_heat, arr_cl_cool])
    arr_cl_heat = [rgb2hex(x[0], x[1], x[2]) for x in arr_cl_heat]
    arr_cl_cool = [rgb2hex(x[0], x[1], x[2]) for x in arr_cl_cool]

    gridwidth = 20
    for i in range(testlength):
        f = Canvas(master, width = gridwidth, height = gridwidth)
        f.create_rectangle(0, 0, gridwidth, gridwidth, fill =
                           arr_cl_heat[i])
        f.grid(row = 0, column = i)
        f = Canvas(master, width = gridwidth, height = gridwidth)
        f.create_rectangle(0, 0, gridwidth, gridwidth, fill =
                           arr_cl_cool[i])
        f.grid(row = 1, column = i)
        f = Canvas(master, width = gridwidth, height = gridwidth)
        f.create_rectangle(0, 0, gridwidth, gridwidth, fill = mix[i])
        f.grid(row = 2, column = i)
Exemplo n.º 2
0
def testReal_2d():
    category = 7
    heatDict = ld.profile2Dict("energyData/meterData/", "Heating:Gas")
    coolDict = ld.profile2Dict("energyData/meterData/", "Cooling:Elec")
    length = 8760
    color_2d = colorRamp_2d(category,
                            [255, 255, 255], [255, 0, 0], [0, 0, 255])
    key = "Hospital"
    testlength = 50
    arr_heat = ld.classify(heatDict[key][:testlength], category,
                           "quantile")
    arr_cool = ld.classify(coolDict[key][:testlength], category,
                           "quantile")

    # get seperate color
    color_heat = colorRamp(category, "white*-red 1 (red*)", "rgb")
    color_cool = colorRamp(category, "white*-blue*", "rgb")
    arr_cl_heat = [color_heat[x] for x in arr_heat]
    arr_cl_cool = [color_cool[x] for x in arr_cool]
    arr_cl_heat = [rgb2hex(x[0], x[1], x[2]) for x in arr_cl_heat]
    arr_cl_cool = [rgb2hex(x[0], x[1], x[2]) for x in arr_cl_cool]

    gridwidth = 20
    for i in range(testlength):
        f = Canvas(master, width = gridwidth, height = gridwidth)
        f.create_rectangle(0, 0, gridwidth, gridwidth, fill =
                           arr_cl_heat[i])
        f.grid(row = 0, column = i)
        f = Canvas(master, width = gridwidth, height = gridwidth)
        f.create_rectangle(0, 0, gridwidth, gridwidth, fill =
                           arr_cl_cool[i])
        f.grid(row = 1, column = i)
        f = Canvas(master, width = gridwidth, height = gridwidth)
        f.create_rectangle(0, 0, gridwidth, gridwidth,
                           fill = color_2d[arr_cool[i]][arr_heat[i]])
        f.grid(row = 2, column = i)