Exemple #1
0
def colors_from_data_type(data_type):
    """Get the list of colors that should be used by default for a given data type.

    Args:
        data_type: A data type object that will be used to determine default colors.
    """
    if isinstance(data_type, Temperature):
        return Colorset.original()
    else:  # it is some type of thermal condition or delta temperature
        return Colorset.thermal_comfort()
def test_legend_value_colors():
    """Test the color_range, value_colors, and segment_colors property."""
    legend = Legend(range(5), LegendParameters(segment_count=10))

    for i, color in enumerate(legend.color_range):
        assert color == ColorRange()[i]
    assert legend.color_range.domain == ColorRange(domain=(0, 4)).domain

    assert len(legend.values) == 5
    assert len(legend.value_colors) == 5
    assert legend.value_colors[0] == Colorset.original()[0]
    assert legend.segment_colors == Colorset.original()
Exemple #3
0
def test_init_colorset():
    """Test the initialization of colorset objects."""
    colorset = Colorset()
    str(colorset)  # Test the color representation

    assert len(colorset) > 20
    assert len(colorset[0]) == 10
    for i in range(len(colorset)):
        assert len(colorset[i]) > 1

    for key in colorset._colors.keys():
        for col in colorset._colors[key]:
            assert len(col) == 3
Exemple #4
0
                     for ival, ang in zip(int_vals, angles))
            weight_result = sum(r * w for r, w in zip(w_res, patch_wghts))
            results.append(weight_result * 100 / vec_count)
    else:
        if patch_wghts:
            for int_list in int_matrix:
                weight_result = sum(r * w
                                    for r, w in zip(int_list, patch_wghts))
                results.append(weight_result * 100 / vec_count)
        else:
            results = [
                sum(int_list) * 100 / vec_count for int_list in int_matrix
            ]

    # create the mesh and legend outputs
    graphic = GraphicContainer(results, study_mesh.min, study_mesh.max,
                               legend_par_)
    graphic.legend_parameters.title = '%'
    if legend_par_ is None or legend_par_.are_colors_default:
        graphic.legend_parameters.colors = Colorset.view_study()
    title_txt = vt_str if vt_str in ('Sky Exposure', 'Sky View') else \
        '{} View'.format(vt_str)
    title = text_objects(title_txt, graphic.lower_title_location,
                         graphic.legend_parameters.text_height * 1.5,
                         graphic.legend_parameters.font)

    # create all of the visual outputs
    study_mesh.colors = graphic.value_colors
    mesh = from_mesh3d(study_mesh)
    legend = legend_objects(graphic.legend)
Exemple #5
0
    multicolored_3 = 'multicolored_3'
    nuanced = 'nuanced'
    openstudio_palette = 'openstudio_palette'
    original = 'original'
    peak_load_balance = 'peak_load_balance'
    shade_benefit = 'shade_benefit'
    shade_benefit_harm = 'shade_benefit_harm'
    shade_harm = 'shade_harm'
    shadow_study = 'shadow_study'
    therm = 'therm'
    thermal_comfort = 'thermal_comfort'
    view_study = 'view_study'


color_set = {
    'annual_comfort': Colorset.annual_comfort(),
    'benefit': Colorset.benefit(),
    'benefit_harm': Colorset.benefit_harm(),
    'black_to_white': Colorset.black_to_white(),
    'blue_green_red': Colorset.blue_green_red(),
    'cloud_cover': Colorset.cloud_cover(),
    'cold_sensation': Colorset.cold_sensation(),
    'ecotect': Colorset.ecotect(),
    'energy_balance': Colorset.energy_balance(),
    'energy_balance_storage': Colorset.energy_balance_storage(),
    'glare_study': Colorset.glare_study(),
    'harm': Colorset.harm(),
    'heat_sensation': Colorset.heat_sensation(),
    'multi_colored': Colorset.multi_colored(),
    'multicolored_2': Colorset.multicolored_2(),
    'multicolored_3': Colorset.multicolored_3(),
            22 - Black to White
            23 - Blue, Green, Red
            24 - Multicolored 2
            25 - Multicolored 3
    
    Returns:
        colors: A series of colors to be plugged into the "LB Legend Parameters"
            component.
"""

ghenv.Component.Name = 'LB Color Range'
ghenv.Component.NickName = 'ColRange'
ghenv.Component.Message = '1.0.0'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '4 :: Extra'
ghenv.Component.AdditionalHelpFromDocStrings = '1'

try:
    from ladybug.color import Colorset
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

try:
    from ladybug_rhino.color import color_to_color
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

_index_ = _index_ or 0
cs = Colorset()
colors = [color_to_color(col) for col in cs[_index_]]
Exemple #7
0
    normals = [from_vector3d(vec) for vec in study_mesh.face_normals]

    # intersect the rays with the mesh
    int_matrix, angles = intersect_mesh_rays(shade_mesh,
                                             points,
                                             rev_vec,
                                             normals,
                                             parallel=parallel_)

    # compute the results
    int_mtx = objectify_output('Sun Intersection Matrix', int_matrix)
    if _timestep_ and _timestep_ != 1:  # divide by the timestep before output
        results = [sum(int_list) / _timestep_ for int_list in int_matrix]
    else:  # no division required
        results = [sum(int_list) for int_list in int_matrix]

    # create the mesh and legend outputs
    graphic = GraphicContainer(results, study_mesh.min, study_mesh.max,
                               legend_par_)
    graphic.legend_parameters.title = 'hours'
    if legend_par_ is None or legend_par_.are_colors_default:
        graphic.legend_parameters.colors = Colorset.ecotect()
    title = text_objects('Direct Sun Hours', graphic.lower_title_location,
                         graphic.legend_parameters.text_height * 1.5,
                         graphic.legend_parameters.font)

    # create all of the visual outputs
    study_mesh.colors = graphic.value_colors
    mesh = from_mesh3d(study_mesh)
    legend = legend_objects(graphic.legend)
 def legendParameters(self):
     """Legend parameters for solar access analysis."""
     col = Colorset.Ecotect()
     return LegendParameters([0, 'max'], colors=col)
Exemple #9
0
def test_init_colorset_by_name():
    """Test the initialization of colorset objects by name."""
    assert len(Colorset.original()) > 1
    assert len(Colorset.nuanced()) > 1
    assert len(Colorset.multi_colored()) > 1
    assert len(Colorset.ecotect()) > 1
    assert len(Colorset.view_study()) > 1
    assert len(Colorset.shadow_study()) > 1
    assert len(Colorset.glare_study()) > 1
    assert len(Colorset.annual_comfort()) > 1
    assert len(Colorset.thermal_comfort()) > 1
    assert len(Colorset.thermal_comfort_utci()) > 1
    assert len(Colorset.heat_sensation()) > 1
    assert len(Colorset.cold_sensation()) > 1
    assert len(Colorset.benefit_harm()) > 1
    assert len(Colorset.harm()) > 1
    assert len(Colorset.benefit()) > 1
    assert len(Colorset.shade_benefit_harm()) > 1
    assert len(Colorset.shade_harm()) > 1
    assert len(Colorset.shade_benefit()) > 1
    assert len(Colorset.energy_balance()) > 1
    assert len(Colorset.energy_balance_storage()) > 1
    assert len(Colorset.therm()) > 1
    assert len(Colorset.cloud_cover()) > 1
    assert len(Colorset.black_to_white()) > 1
    assert len(Colorset.blue_green_red()) > 1
    assert len(Colorset.multicolored_2()) > 1
    assert len(Colorset.multicolored_3()) > 1
Exemple #10
0
 def legend_parameters(self):
     """Legend parameters for solar access analysis."""
     col = Colorset.ecotect()
     return LegendParameters(0, None, colors=col)
        elif isinstance(hb_obj, Room):
            add_room(hb_obj)
        elif isinstance(hb_obj, Face):
            add_face(hb_obj)
        elif isinstance(hb_obj, Aperture):
            add_aperture(hb_obj)
        elif isinstance(hb_obj, Door):
            add_door(hb_obj)
        elif isinstance(hb_obj, Shade):
            if hb_obj.is_indoor:
                _indoor_shades.append(hb_obj.geometry)
            else:
                _outdoor_shades.append(hb_obj.geometry)

    # color all of the geometry with its respective surface type
    palette = Colorset.openstudio_palette()
    walls = from_face3ds_to_colored_mesh(_walls, palette[0]) \
        if len(_walls) != 0 else None
    interior_walls = from_face3ds_to_colored_mesh(_interior_walls, palette[1]) \
        if len(_interior_walls) != 0 else None
    roofs = from_face3ds_to_colored_mesh(_roofs, palette[3]) \
        if len(_roofs) != 0 else None
    ceilings = from_face3ds_to_colored_mesh(_ceilings, palette[4]) \
        if len(_ceilings) != 0 else None
    exterior_floors = from_face3ds_to_colored_mesh(_exterior_floors, palette[6]) \
        if len(_exterior_floors) != 0 else None
    interior_floors = from_face3ds_to_colored_mesh(_interior_floors, palette[7]) \
        if len(_interior_floors) != 0 else None
    air_walls = from_face3ds_to_colored_mesh(_air_walls, palette[12]) \
        if len(_air_walls) != 0 else None
    apertures = from_face3ds_to_colored_mesh(_apertures, palette[9]) \
Exemple #12
0
class Colors(Enum):
    """Colors for a legend."""
    annual_comfort = Colorset.annual_comfort()
    benefit = Colorset.benefit()
    benefit_harm = Colorset.benefit_harm()
    black_to_white = Colorset.black_to_white()
    blue_green_red = Colorset.blue_green_red()
    cloud_cover = Colorset.cloud_cover()
    cold_sensation = Colorset.cold_sensation()
    ecotect = Colorset.ecotect()
    energy_balance = Colorset.energy_balance()
    energy_balance_storage = Colorset.energy_balance_storage()
    glare_study = Colorset.glare_study()
    harm = Colorset.harm()
    heat_sensation = Colorset.heat_sensation()
    multi_colored = Colorset.multi_colored()
    multicolored_2 = Colorset.multicolored_2()
    multicolored_3 = Colorset.multicolored_3()
    nuanced = Colorset.nuanced()
    openstudio_palette = Colorset.openstudio_palette()
    original = Colorset.original()
    peak_load_balance = Colorset.peak_load_balance()
    shade_benefit = Colorset.shade_benefit()
    shade_benefit_harm = Colorset.shade_benefit_harm()
    shade_harm = Colorset.shade_harm()
    shadow_study = Colorset.shadow_study()
    therm = Colorset.therm()
    thermal_comfort = Colorset.thermal_comfort()
    view_study = Colorset.view_study()