Пример #1
0
def deconstruct_sky_matrix(_sky_mtx):
    """Copied from Ladybug 'IncidentRadiation' Component
    
    Arguments:
        _sky_mtx: A Ladybug Sky Matrix for the season
    Returns: (tuple)
        sky_vecs: (list: _ )
        total_sky_rad: (list: _ )
    """

    mtx = de_objectify_output(_sky_mtx)
    total_sky_rad = [
        dir_rad + dif_rad for dir_rad, dif_rad in izip(mtx[1], mtx[2])
    ]
    lb_vecs = view_sphere.tregenza_dome_vectors if len(total_sky_rad) == 145 \
        else view_sphere.reinhart_dome_vectors
    if mtx[0][0] != 0:  # there is a north input for sky; rotate vectors
        north_angle = math.radians(mtx[0][0])
        lb_vecs = [vec.rotate_xy(north_angle) for vec in lb_vecs]
    sky_vecs = [from_vector3d(vec) for vec in lb_vecs]

    return sky_vecs, total_sky_rad
    workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count(
    )

    # create the gridded mesh from the geometry
    study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size)
    points = [
        from_point3d(pt.move(vec * _offset_dist_))
        for pt, vec in zip(study_mesh.face_centroids, study_mesh.face_normals)
    ]
    hide_output(ghenv.Component, 1)

    # mesh the geometry and context
    shade_mesh = join_geometry_to_mesh(_geometry + context_)

    # deconstruct the matrix and get the sky dome vectors
    mtx = de_objectify_output(_sky_mtx)
    total_sky_rad = [
        dir_rad + dif_rad for dir_rad, dif_rad in zip(mtx[1], mtx[2])
    ]
    ground_rad = [(sum(total_sky_rad) / len(total_sky_rad)) * mtx[0][1]
                  ] * len(total_sky_rad)
    all_rad = total_sky_rad + ground_rad
    lb_vecs = view_sphere.tregenza_dome_vectors if len(total_sky_rad) == 145 \
        else view_sphere.reinhart_dome_vectors
    if mtx[0][0] != 0:  # there is a north input for sky; rotate vectors
        north_angle = math.radians(mtx[0][0])
        lb_vecs = tuple(vec.rotate_xy(north_angle) for vec in lb_vecs)
    lb_grnd_vecs = tuple(vec.reverse() for vec in lb_vecs)
    all_vecs = [from_vector3d(vec) for vec in lb_vecs + lb_grnd_vecs]

    # intersect the rays with the mesh
Пример #3
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()


if all_required_inputs(ghenv.Component):
    # load the data and perform and time-slicing operations on it
    data_mtx = de_objectify_output(_comf_mtx)
    header = data_mtx[0][0].header
    if sim_step_ is not None:
        values = [
            data[sim_step_] for data_list in data_mtx for data in data_list
        ]
        time_text = data_mtx[0][0].datetimes[sim_step_]
    elif period_ is not None:
        new_data = [[
            data.filter_by_analysis_period(period_) for data in data_list
        ] for data_list in data_mtx]
        values = [data.average for data_list in new_data for data in data_list]
        time_text = period_
    else:
        values = [data.average for data_list in data_mtx for data in data_list]
        time_text = header.analysis_period
Пример #4
0
    return dome_mesh, dome_compass, dome_legend, dome_title, values


if all_required_inputs(ghenv.Component):
    # set defaults for global variables
    _scale_ = 1 if _scale_ is None else _scale_
    radius = (100 * _scale_) / conversion_to_meters()
    if _center_pt_ is not None:  # process the center point into a Point2D
        center_pt3d = to_point3d(_center_pt_)
        z = center_pt3d.z
    else:
        center_pt3d, z = Point3D(), 0

    # deconstruct the sky matrix and derive key data from it
    metadata, direct, diffuse = de_objectify_output(_sky_mtx)
    north = metadata[0]  # first item is the north angle
    sky_type = 1 if len(direct) == 145 else 2  # i for tregenza; 2 for reinhart
    total = [dirr + difr
             for dirr, difr in zip(direct, diffuse)]  # total radiation

    # override the legend default min and max to make sense for domes
    l_par = legend_par_.duplicate(
    ) if legend_par_ is not None else LegendParameters()
    if l_par.min is None:
        l_par.min = 0
    if l_par.max is None:
        l_par.max = max(total)

    # output patch patch vectors
    patch_vecs_lb = view_sphere.tregenza_dome_vectors if len(total) == 145 \
Пример #5
0
    val_mtx = [dat.values for dat in poly_data]
    merged_values = []
    for hr_data in zip(*val_mtx):
        hr_val = 1 if 1 in hr_data else 0
        merged_values.append(hr_val)
    return merged_values


if all_required_inputs(ghenv.Component):
    # unpack any passive strategy parameters
    if strategy_par_ is None:
        day_above, night_below, fan_spd, bal_temp, solar_cap, tim_c = \
            (12.0, 3.0, 1.0, 12.8, 50.0, 8)
    else:
        day_above, night_below, fan_spd, bal_temp, solar_cap, tim_c = \
            de_objectify_output(strategy_par_)

    # convert the temperature values to C if the polygon is in IP
    assert isinstance(_psych_chart, PsychrometricChart), 'PolygonPMV ' \
        'psychrometric chart must be a ladybug PsychrometricChart. ' \
        'Got {}.'.format(type(_psych_chart))
    z = _psych_chart.z
    offset = _psych_chart.x_dim * 0.25
    if _psych_chart.use_ip:
        _mrt_ = PolygonPMV.TEMP_TYPE.to_unit(_mrt_, 'C', 'F')

    # create the PolygonPMV object
    poly_obj = PolygonPMV(_psych_chart,
                          _mrt_,
                          _air_speed_,
                          _met_rate_,
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>

"""
Deconstruct a Ladybug Matrix object into a Grasshopper Data Tree of values.
-

    Args:
        _matrix: A Ladybug Matrix object such as the intersection matrices output
            from any of the ray-tracing components (eg. "LB Direct Sun Hours").

    Returns:
        values: The numerical values of the matrix as a Grasshopper Data Tree.
"""

ghenv.Component.Name = "LB Deconstruct Matrix"
ghenv.Component.NickName = 'XMatrix'
ghenv.Component.Message = '1.2.0'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '4 :: Extra'
ghenv.Component.AdditionalHelpFromDocStrings = '0'

try:
    from ladybug_rhino.grasshopper import all_required_inputs, de_objectify_output, \
        list_to_data_tree
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component):
    values = list_to_data_tree(de_objectify_output(_matrix))
Deconstruct a Ladybug Matrix object into a Grasshopper Data Tree of values.
-

    Args:
        _matrix: A Ladybug Matrix object such as the intersection matrices output
            from any of the ray-tracing components (eg. "LB Direct Sun Hours").

    Returns:
        values: The numerical values of the matrix as a Grasshopper Data Tree.
"""

ghenv.Component.Name = "LB Deconstruct Matrix"
ghenv.Component.NickName = 'XMatrix'
ghenv.Component.Message = '1.5.0'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '4 :: Extra'
ghenv.Component.AdditionalHelpFromDocStrings = '0'

try:
    from ladybug_rhino.grasshopper import all_required_inputs, de_objectify_output, \
        list_to_data_tree, merge_data_tree
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component):
    values = []
    for i, mtx in enumerate(_matrix):
        values.append(list_to_data_tree(de_objectify_output(mtx),
                                        root_count=i))
    values = merge_data_tree(values)