diff --git a/ladybug_grasshopper/icon/LB View Percent.png b/ladybug_grasshopper/icon/LB View Percent.png index 284791d..08f390a 100644 Binary files a/ladybug_grasshopper/icon/LB View Percent.png and b/ladybug_grasshopper/icon/LB View Percent.png differ diff --git a/ladybug_grasshopper/icon/LB Visibility Percent.png b/ladybug_grasshopper/icon/LB Visibility Percent.png index 27b1a20..e7b44df 100644 Binary files a/ladybug_grasshopper/icon/LB Visibility Percent.png and b/ladybug_grasshopper/icon/LB Visibility Percent.png differ diff --git a/ladybug_grasshopper/json/LB_Direct_Sun_Hours.json b/ladybug_grasshopper/json/LB_Direct_Sun_Hours.json index 36b8822..22a352f 100644 --- a/ladybug_grasshopper/json/LB_Direct_Sun_Hours.json +++ b/ladybug_grasshopper/json/LB_Direct_Sun_Hours.json @@ -1,5 +1,5 @@ { - "version": "1.8.2", + "version": "1.8.3", "nickname": "DirectSunHours", "outputs": [ [ @@ -120,7 +120,7 @@ } ], "subcategory": "3 :: Analyze Geometry", - "code": "\ntry:\n from ladybug.color import Colorset\n from ladybug.graphic import GraphicContainer\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import conversion_to_meters\n from ladybug_{{cad}}.togeometry import to_joined_gridded_mesh3d, to_vector3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d, from_point3d, from_vector3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.intersect import join_geometry_to_mesh, intersect_mesh_rays\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, hide_output, \\\n show_output, objectify_output, recommended_processor_count\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component) and _run:\n # set the default offset distance and _cpu_count_\n if _offset_dist_ is None:\n _offset_dist_ = 0.1 / conversion_to_meters() \\\n if geo_block_ or geo_block_ is None else 0\n workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count()\n\n # create the gridded mesh from the geometry\n study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size)\n points = [from_point3d(pt.move(vec * _offset_dist_)) for pt, vec in\n zip(study_mesh.face_centroids, study_mesh.face_normals)]\n hide_output(ghenv.Component, 1)\n\n # mesh the geometry and context\n shade_mesh = join_geometry_to_mesh(_geometry + context_) \\\n if geo_block_ or geo_block_ is None else join_geometry_to_mesh(context_)\n\n # get the study points and reverse the sun vectors (for backward ray-tracting)\n rev_vec = [from_vector3d(to_vector3d(vec).reverse()) for vec in _vectors]\n normals = [from_vector3d(vec) for vec in study_mesh.face_normals] \\\n if geo_block_ or geo_block_ is None else None\n\n # intersect the rays with the mesh\n int_matrix, angles = intersect_mesh_rays(\n shade_mesh, points, rev_vec, normals, cpu_count=workers)\n\n # compute the results\n int_mtx = objectify_output('Sun Intersection Matrix', int_matrix)\n if _timestep_ and _timestep_ != 1: # divide by the timestep before output\n results = [sum(int_list) / _timestep_ for int_list in int_matrix]\n else: # no division required\n results = [sum(int_list) for int_list in int_matrix]\n\n # create the mesh and legend outputs\n graphic = GraphicContainer(results, study_mesh.min, study_mesh.max, legend_par_)\n graphic.legend_parameters.title = 'hours'\n if legend_par_ is None or legend_par_.are_colors_default:\n graphic.legend_parameters.colors = Colorset.ecotect()\n title = text_objects('Direct Sun Hours', graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # create all of the visual outputs\n study_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(study_mesh)\n legend = legend_objects(graphic.legend)\n", + "code": "\ntry:\n from ladybug.color import Colorset\n from ladybug.graphic import GraphicContainer\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import conversion_to_meters\n from ladybug_{{cad}}.togeometry import to_joined_gridded_mesh3d, to_vector3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d, from_point3d, from_vector3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.intersect import join_geometry_to_mesh, intersect_mesh_rays\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, hide_output, \\\n show_output, objectify_output, recommended_processor_count\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component) and _run:\n # set the default offset distance and _cpu_count_\n if _offset_dist_ is None:\n _offset_dist_ = 0.1 / conversion_to_meters() \\\n if geo_block_ or geo_block_ is None else 0\n workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count()\n\n # create the gridded mesh from the geometry\n study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size)\n points = [from_point3d(pt.move(vec * _offset_dist_)) for pt, vec in\n zip(study_mesh.face_centroids, study_mesh.face_normals)]\n hide_output(ghenv.Component, 1)\n\n # mesh the geometry and context\n shade_mesh = join_geometry_to_mesh([from_mesh3d(study_mesh)] + context_) \\\n if geo_block_ or geo_block_ is None else join_geometry_to_mesh(context_)\n\n # get the study points and reverse the sun vectors (for backward ray-tracting)\n rev_vec = [from_vector3d(to_vector3d(vec).reverse()) for vec in _vectors]\n normals = [from_vector3d(vec) for vec in study_mesh.face_normals] \\\n if geo_block_ or geo_block_ is None else None\n\n # intersect the rays with the mesh\n int_matrix, angles = intersect_mesh_rays(\n shade_mesh, points, rev_vec, normals, cpu_count=workers)\n\n # compute the results\n int_mtx = objectify_output('Sun Intersection Matrix', int_matrix)\n if _timestep_ and _timestep_ != 1: # divide by the timestep before output\n results = [sum(int_list) / _timestep_ for int_list in int_matrix]\n else: # no division required\n results = [sum(int_list) for int_list in int_matrix]\n\n # create the mesh and legend outputs\n graphic = GraphicContainer(results, study_mesh.min, study_mesh.max, legend_par_)\n graphic.legend_parameters.title = 'hours'\n if legend_par_ is None or legend_par_.are_colors_default:\n graphic.legend_parameters.colors = Colorset.ecotect()\n title = text_objects('Direct Sun Hours', graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # create all of the visual outputs\n study_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(study_mesh)\n legend = legend_objects(graphic.legend)\n", "category": "Ladybug", "name": "LB Direct Sun Hours", "description": "Calculate the number of hours of direct sunlight received by geometry using sun\nvectors obtained from the \"LB SunPath\" component.\n_\nSuch direct sun calculations can be used for shadow studies of outdoor enviroments\nor can be used to estimate glare potential from direct sun on the indoors.\n_\nNote that this component uses the CAD environment's ray intersection methods,\nwhich can be fast for geometries with low complexity but does not scale well\nfor complex geometries or many test points. For such complex studies,\nhoneybee-radiance should be used.\n-" diff --git a/ladybug_grasshopper/json/LB_Incident_Radiation.json b/ladybug_grasshopper/json/LB_Incident_Radiation.json index 03fce89..6be2fe6 100644 --- a/ladybug_grasshopper/json/LB_Incident_Radiation.json +++ b/ladybug_grasshopper/json/LB_Incident_Radiation.json @@ -1,5 +1,5 @@ { - "version": "1.8.0", + "version": "1.8.1", "nickname": "IncidentRadiation", "outputs": [ [ @@ -120,7 +120,7 @@ } ], "subcategory": "3 :: Analyze Geometry", - "code": "\nimport math\ntry: # python 2\n from itertools import izip as zip\nexcept ImportError: # python 3\n pass\n\ntry:\n from ladybug.viewsphere import view_sphere\n from ladybug.graphic import GraphicContainer\n from ladybug.legend import LegendParameters\n from ladybug.color import Colorset\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import conversion_to_meters\n from ladybug_{{cad}}.togeometry import to_joined_gridded_mesh3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d, from_point3d, from_vector3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.intersect import join_geometry_to_mesh, intersect_mesh_rays\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, hide_output, \\\n show_output, objectify_output, de_objectify_output, recommended_processor_count\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component) and _run:\n # set the default offset distance and _cpu_count\n _offset_dist_ = _offset_dist_ if _offset_dist_ is not None \\\n else 0.1 / conversion_to_meters()\n workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count()\n\n # create the gridded mesh from the geometry\n study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size)\n points = [from_point3d(pt.move(vec * _offset_dist_)) for pt, vec in\n zip(study_mesh.face_centroids, study_mesh.face_normals)]\n hide_output(ghenv.Component, 1)\n\n # mesh the geometry and context\n shade_mesh = join_geometry_to_mesh(_geometry + context_)\n\n # deconstruct the matrix and get the sky dome vectors\n mtx = de_objectify_output(_sky_mtx)\n total_sky_rad = [dir_rad + dif_rad for dir_rad, dif_rad in zip(mtx[1], mtx[2])]\n ground_rad = [(sum(total_sky_rad) / len(total_sky_rad)) * mtx[0][1]] * len(total_sky_rad)\n all_rad = total_sky_rad + ground_rad \n lb_vecs = view_sphere.tregenza_dome_vectors if len(total_sky_rad) == 145 \\\n else view_sphere.reinhart_dome_vectors\n if mtx[0][0] != 0: # there is a north input for sky; rotate vectors\n north_angle = math.radians(mtx[0][0])\n lb_vecs = tuple(vec.rotate_xy(north_angle) for vec in lb_vecs)\n lb_grnd_vecs = tuple(vec.reverse() for vec in lb_vecs)\n all_vecs = [from_vector3d(vec) for vec in lb_vecs + lb_grnd_vecs]\n\n # intersect the rays with the mesh\n normals = [from_vector3d(vec) for vec in study_mesh.face_normals]\n int_matrix_init, angles = intersect_mesh_rays(\n shade_mesh, points, all_vecs, normals, cpu_count=workers)\n\n # compute the results\n results = []\n int_matrix = []\n for int_vals, angs in zip(int_matrix_init, angles):\n pt_rel = [ival * math.cos(ang) for ival, ang in zip(int_vals, angs)]\n int_matrix.append(pt_rel)\n rad_result = sum(r * w for r, w in zip(pt_rel, all_rad))\n results.append(rad_result)\n\n # convert to irradiance if requested\n study_name = 'Incident Radiation'\n if irradiance_:\n study_name = 'Incident Irradiance'\n factor = 1000 / _sky_mtx.wea_duration if hasattr(_sky_mtx, 'wea_duration') \\\n else 1000 / (((mtx[0][3] - mtx[0][2]).total_seconds() / 3600) + 1)\n results = [r * factor for r in results]\n\n # output the intersection matrix and compute total radiation\n int_mtx = objectify_output('Geometry/Sky Intersection Matrix', int_matrix)\n unit_conv = conversion_to_meters() ** 2\n total = 0\n for rad, area in zip(results, study_mesh.face_areas):\n total += rad * area * unit_conv\n\n # create the mesh and legend outputs\n l_par = legend_par_ if legend_par_ is not None else LegendParameters()\n if hasattr(_sky_mtx, 'benefit_matrix') and _sky_mtx.benefit_matrix is not None:\n study_name = '{} Benefit/Harm'.format(study_name)\n if l_par.are_colors_default:\n l_par.colors = reversed(Colorset.benefit_harm())\n if l_par.min is None:\n l_par.min = min((min(results), -max(results)))\n if l_par.max is None:\n l_par.max = max((-min(results), max(results)))\n graphic = GraphicContainer(results, study_mesh.min, study_mesh.max, l_par)\n graphic.legend_parameters.title = 'kWh/m2' if not irradiance_ else 'W/m2'\n title = text_objects(\n study_name, graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # create all of the visual outputs\n study_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(study_mesh)\n legend = legend_objects(graphic.legend)\n", + "code": "\nimport math\ntry: # python 2\n from itertools import izip as zip\nexcept ImportError: # python 3\n pass\n\ntry:\n from ladybug.viewsphere import view_sphere\n from ladybug.graphic import GraphicContainer\n from ladybug.legend import LegendParameters\n from ladybug.color import Colorset\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import conversion_to_meters\n from ladybug_{{cad}}.togeometry import to_joined_gridded_mesh3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d, from_point3d, from_vector3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.intersect import join_geometry_to_mesh, intersect_mesh_rays\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, hide_output, \\\n show_output, objectify_output, de_objectify_output, recommended_processor_count\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component) and _run:\n # set the default offset distance and _cpu_count\n _offset_dist_ = _offset_dist_ if _offset_dist_ is not None \\\n else 0.1 / conversion_to_meters()\n workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count()\n\n # create the gridded mesh from the geometry\n study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size)\n points = [from_point3d(pt.move(vec * _offset_dist_)) for pt, vec in\n zip(study_mesh.face_centroids, study_mesh.face_normals)]\n hide_output(ghenv.Component, 1)\n\n # mesh the geometry and context\n shade_mesh = join_geometry_to_mesh([from_mesh3d(study_mesh)] + context_)\n\n # deconstruct the matrix and get the sky dome vectors\n mtx = de_objectify_output(_sky_mtx)\n total_sky_rad = [dir_rad + dif_rad for dir_rad, dif_rad in zip(mtx[1], mtx[2])]\n ground_rad = [(sum(total_sky_rad) / len(total_sky_rad)) * mtx[0][1]] * len(total_sky_rad)\n all_rad = total_sky_rad + ground_rad \n lb_vecs = view_sphere.tregenza_dome_vectors if len(total_sky_rad) == 145 \\\n else view_sphere.reinhart_dome_vectors\n if mtx[0][0] != 0: # there is a north input for sky; rotate vectors\n north_angle = math.radians(mtx[0][0])\n lb_vecs = tuple(vec.rotate_xy(north_angle) for vec in lb_vecs)\n lb_grnd_vecs = tuple(vec.reverse() for vec in lb_vecs)\n all_vecs = [from_vector3d(vec) for vec in lb_vecs + lb_grnd_vecs]\n\n # intersect the rays with the mesh\n normals = [from_vector3d(vec) for vec in study_mesh.face_normals]\n int_matrix_init, angles = intersect_mesh_rays(\n shade_mesh, points, all_vecs, normals, cpu_count=workers)\n\n # compute the results\n results = []\n int_matrix = []\n for int_vals, angs in zip(int_matrix_init, angles):\n pt_rel = [ival * math.cos(ang) for ival, ang in zip(int_vals, angs)]\n int_matrix.append(pt_rel)\n rad_result = sum(r * w for r, w in zip(pt_rel, all_rad))\n results.append(rad_result)\n\n # convert to irradiance if requested\n study_name = 'Incident Radiation'\n if irradiance_:\n study_name = 'Incident Irradiance'\n factor = 1000 / _sky_mtx.wea_duration if hasattr(_sky_mtx, 'wea_duration') \\\n else 1000 / (((mtx[0][3] - mtx[0][2]).total_seconds() / 3600) + 1)\n results = [r * factor for r in results]\n\n # output the intersection matrix and compute total radiation\n int_mtx = objectify_output('Geometry/Sky Intersection Matrix', int_matrix)\n unit_conv = conversion_to_meters() ** 2\n total = 0\n for rad, area in zip(results, study_mesh.face_areas):\n total += rad * area * unit_conv\n\n # create the mesh and legend outputs\n l_par = legend_par_ if legend_par_ is not None else LegendParameters()\n if hasattr(_sky_mtx, 'benefit_matrix') and _sky_mtx.benefit_matrix is not None:\n study_name = '{} Benefit/Harm'.format(study_name)\n if l_par.are_colors_default:\n l_par.colors = reversed(Colorset.benefit_harm())\n if l_par.min is None:\n l_par.min = min((min(results), -max(results)))\n if l_par.max is None:\n l_par.max = max((-min(results), max(results)))\n graphic = GraphicContainer(results, study_mesh.min, study_mesh.max, l_par)\n graphic.legend_parameters.title = 'kWh/m2' if not irradiance_ else 'W/m2'\n title = text_objects(\n study_name, graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # create all of the visual outputs\n study_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(study_mesh)\n legend = legend_objects(graphic.legend)\n", "category": "Ladybug", "name": "LB Incident Radiation", "description": "Calculate the incident radiation on geometry using a sky matrix from the \"Cumulative\nSky Matrix\" component.\n_\nSuch studies of incident radiation can be used to apprxomiate the energy that can\nbe collected from photovoltaic or solar thermal systems. They are also useful\nfor evaluating the impact of a building's orientation on both energy use and the\nsize/cost of cooling systems. For studies of photovoltaic potential or building\nenergy use impact, a sky matrix from EPW radiation should be used. For studies\nof cooling system size/cost, a sky matrix derived from the STAT file's clear sky\nradiation should be used.\n_\nNOTE THAT NO REFLECTIONS OF SOLAR ENERGY ARE INCLUDED\nIN THE ANALYSIS PERFORMED BY THIS COMPONENT.\n_\nGround reflected irradiance is crudely acounted for by means of an emissive\n\"ground hemisphere,\" which is like the sky dome hemisphere and is derived from\nthe ground reflectance that is associated with the connected _sky_mtx. This\nmeans that including geometry that represents the ground surface will effectively\nblock such crude ground reflection.\n_\nAlso note that this component uses the CAD environment's ray intersection methods,\nwhich can be fast for geometries with low complexity but does not scale well for\ncomplex geometries or many test points. For such complex cases and situations\nwhere relfection of solar energy are important, honeybee-radiance should be used.\n-" diff --git a/ladybug_grasshopper/json/LB_View_Percent.json b/ladybug_grasshopper/json/LB_View_Percent.json index 236e964..9fc0979 100644 --- a/ladybug_grasshopper/json/LB_View_Percent.json +++ b/ladybug_grasshopper/json/LB_View_Percent.json @@ -1,5 +1,5 @@ { - "version": "1.8.0", + "version": "1.8.1", "nickname": "ViewPercent", "outputs": [ [ @@ -127,7 +127,7 @@ } ], "subcategory": "3 :: Analyze Geometry", - "code": "\nimport math\ntry: # python 2\n from itertools import izip as zip\nexcept ImportError: # python 3\n pass\n\ntry:\n from ladybug.viewsphere import view_sphere\n from ladybug.color import Colorset\n from ladybug.graphic import GraphicContainer\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import conversion_to_meters\n from ladybug_{{cad}}.togeometry import to_joined_gridded_mesh3d, to_vector3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d, from_point3d, from_vector3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.intersect import join_geometry_to_mesh, intersect_mesh_rays\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, hide_output, \\\n show_output, objectify_output, recommended_processor_count\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\n# dictionary to record all available view types\nVIEW_TYPES = {\n 'HorizontalRadial': 'Horizontal Radial',\n 'Horizontal30DegreeOffset': 'Horizontal 30-Degree Offset',\n 'Spherical': 'Spherical',\n 'SkyExposure': 'Sky Exposure',\n 'SkyView': 'Sky View',\n '0': 'Horizontal Radial',\n '1': 'Horizontal 30-Degree Offset',\n '2': 'Spherical',\n '3': 'Sky Exposure',\n '4': 'Sky View'\n}\n\n\nif all_required_inputs(ghenv.Component) and _run:\n # process the view_type_ and set the default values\n vt_str = VIEW_TYPES[_view_type]\n _resolution_ = _resolution_ if _resolution_ is not None else 1\n _offset_dist_ = _offset_dist_ if _offset_dist_ is not None \\\n else 0.1 / conversion_to_meters()\n if _geo_block_ is None:\n _geo_block_ = True if vt_str in ('Sky Exposure', 'Sky View') else False\n workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count()\n\n # create the gridded mesh from the geometry\n study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size)\n points = [from_point3d(pt.move(vec * _offset_dist_)) for pt, vec in\n zip(study_mesh.face_centroids, study_mesh.face_normals)]\n hide_output(ghenv.Component, 1)\n\n # get the view vectors based on the view type\n patch_wghts = None\n if vt_str == 'Horizontal Radial':\n lb_vecs = view_sphere.horizontal_radial_vectors(30 * _resolution_)\n elif vt_str == 'Horizontal 30-Degree Offset':\n patch_mesh, lb_vecs = view_sphere.horizontal_radial_patches(30, _resolution_)\n patch_wghts = view_sphere.horizontal_radial_patch_weights(30, _resolution_)\n elif vt_str == 'Spherical':\n patch_mesh, lb_vecs = view_sphere.sphere_patches(_resolution_)\n patch_wghts = view_sphere.sphere_patch_weights(_resolution_)\n else:\n patch_mesh, lb_vecs = view_sphere.dome_patches(_resolution_)\n patch_wghts = view_sphere.dome_patch_weights(_resolution_)\n view_vecs = [from_vector3d(pt) for pt in lb_vecs]\n\n # mesh the geometry and context\n shade_mesh = join_geometry_to_mesh(_geometry + context_) if _geo_block_ \\\n else join_geometry_to_mesh(context_)\n\n # intersect the rays with the mesh\n if vt_str == 'Sky View': # account for the normals of the surface\n normals = [from_vector3d(vec) for vec in study_mesh.face_normals]\n int_matrix, angles = intersect_mesh_rays(\n shade_mesh, points, view_vecs, normals, cpu_count=workers)\n else:\n int_matrix, angles = intersect_mesh_rays(\n shade_mesh, points, view_vecs, cpu_count=workers)\n\n # compute the results\n int_mtx = objectify_output('View Intersection Matrix', int_matrix)\n vec_count = len(view_vecs)\n results = []\n if vt_str == 'Sky View': # weight intersections by angle before output\n for int_vals, angles in zip(int_matrix, angles):\n w_res = (ival * 2 * math.cos(ang) for ival, ang in zip(int_vals, angles))\n weight_result = sum(r * w for r, w in zip(w_res, patch_wghts))\n results.append(weight_result * 100 / vec_count)\n else:\n if patch_wghts:\n for int_list in int_matrix:\n weight_result = sum(r * w for r, w in zip(int_list, patch_wghts))\n results.append(weight_result * 100 / vec_count)\n else:\n results = [sum(int_list) * 100 / vec_count for int_list in int_matrix]\n\n # create the mesh and legend outputs\n graphic = GraphicContainer(results, study_mesh.min, study_mesh.max, legend_par_)\n graphic.legend_parameters.title = '%'\n if legend_par_ is None or legend_par_.are_colors_default:\n graphic.legend_parameters.colors = Colorset.view_study()\n title_txt = vt_str if vt_str in ('Sky Exposure', 'Sky View') else \\\n '{} View'.format(vt_str)\n title = text_objects(\n title_txt, graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # create all of the visual outputs\n study_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(study_mesh)\n legend = legend_objects(graphic.legend)\n", + "code": "\nimport math\ntry: # python 2\n from itertools import izip as zip\nexcept ImportError: # python 3\n pass\n\ntry:\n from ladybug.viewsphere import view_sphere\n from ladybug.color import Colorset\n from ladybug.graphic import GraphicContainer\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import conversion_to_meters\n from ladybug_{{cad}}.togeometry import to_joined_gridded_mesh3d, to_vector3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d, from_point3d, from_vector3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.intersect import join_geometry_to_mesh, intersect_mesh_rays\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, hide_output, \\\n show_output, objectify_output, recommended_processor_count\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\n# dictionary to record all available view types\nVIEW_TYPES = {\n 'HorizontalRadial': 'Horizontal Radial',\n 'Horizontal30DegreeOffset': 'Horizontal 30-Degree Offset',\n 'Spherical': 'Spherical',\n 'SkyExposure': 'Sky Exposure',\n 'SkyView': 'Sky View',\n '0': 'Horizontal Radial',\n '1': 'Horizontal 30-Degree Offset',\n '2': 'Spherical',\n '3': 'Sky Exposure',\n '4': 'Sky View'\n}\n\n\nif all_required_inputs(ghenv.Component) and _run:\n # process the view_type_ and set the default values\n vt_str = VIEW_TYPES[_view_type]\n _resolution_ = _resolution_ if _resolution_ is not None else 1\n _offset_dist_ = _offset_dist_ if _offset_dist_ is not None \\\n else 0.1 / conversion_to_meters()\n if _geo_block_ is None:\n _geo_block_ = True if vt_str in ('Sky Exposure', 'Sky View') else False\n workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count()\n\n # create the gridded mesh from the geometry\n study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size)\n points = [from_point3d(pt.move(vec * _offset_dist_)) for pt, vec in\n zip(study_mesh.face_centroids, study_mesh.face_normals)]\n hide_output(ghenv.Component, 1)\n\n # get the view vectors based on the view type\n patch_wghts = None\n if vt_str == 'Horizontal Radial':\n lb_vecs = view_sphere.horizontal_radial_vectors(30 * _resolution_)\n elif vt_str == 'Horizontal 30-Degree Offset':\n patch_mesh, lb_vecs = view_sphere.horizontal_radial_patches(30, _resolution_)\n patch_wghts = view_sphere.horizontal_radial_patch_weights(30, _resolution_)\n elif vt_str == 'Spherical':\n patch_mesh, lb_vecs = view_sphere.sphere_patches(_resolution_)\n patch_wghts = view_sphere.sphere_patch_weights(_resolution_)\n else:\n patch_mesh, lb_vecs = view_sphere.dome_patches(_resolution_)\n patch_wghts = view_sphere.dome_patch_weights(_resolution_)\n view_vecs = [from_vector3d(pt) for pt in lb_vecs]\n\n # mesh the geometry and context\n shade_mesh = join_geometry_to_mesh([from_mesh3d(study_mesh)] + context_) \\\n if _geo_block_ else join_geometry_to_mesh(context_)\n\n # intersect the rays with the mesh\n if vt_str == 'Sky View': # account for the normals of the surface\n normals = [from_vector3d(vec) for vec in study_mesh.face_normals]\n int_matrix, angles = intersect_mesh_rays(\n shade_mesh, points, view_vecs, normals, cpu_count=workers)\n else:\n int_matrix, angles = intersect_mesh_rays(\n shade_mesh, points, view_vecs, cpu_count=workers)\n\n # compute the results\n int_mtx = objectify_output('View Intersection Matrix', int_matrix)\n vec_count = len(view_vecs)\n results = []\n if vt_str == 'Sky View': # weight intersections by angle before output\n for int_vals, angles in zip(int_matrix, angles):\n w_res = (ival * 2 * math.cos(ang) for ival, ang in zip(int_vals, angles))\n weight_result = sum(r * w for r, w in zip(w_res, patch_wghts))\n results.append(weight_result * 100 / vec_count)\n else:\n if patch_wghts:\n for int_list in int_matrix:\n weight_result = sum(r * w for r, w in zip(int_list, patch_wghts))\n results.append(weight_result * 100 / vec_count)\n else:\n results = [sum(int_list) * 100 / vec_count for int_list in int_matrix]\n\n # create the mesh and legend outputs\n graphic = GraphicContainer(results, study_mesh.min, study_mesh.max, legend_par_)\n graphic.legend_parameters.title = '%'\n if legend_par_ is None or legend_par_.are_colors_default:\n graphic.legend_parameters.colors = Colorset.view_study()\n title_txt = vt_str if vt_str in ('Sky Exposure', 'Sky View') else \\\n '{} View'.format(vt_str)\n title = text_objects(\n title_txt, graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # create all of the visual outputs\n study_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(study_mesh)\n legend = legend_objects(graphic.legend)\n", "category": "Ladybug", "name": "LB View Percent", "description": "Evaluate the percent view to the outdoors or sky from input geometry through context.\n_\nSuch view calculations can be used to estimate the quality of a view to the\noutdoors from a given location on the indoors. They can also be used on\nthe outdoors to evaluate the openness of street canyons to the sky, which has\nimplications for the pedestrian expereince as well as the rate of radiant heat\nloss from urban surfaces and the sky at night.\n_\nNote that this component uses the CAD environment's ray intersection methods,\nwhich can be fast for geometries with low complexity but does not scale well\nfor complex geometries or many test points. For such complex studies,\nhoneybee-radiance should be used.\n-" diff --git a/ladybug_grasshopper/json/LB_Visibility_Percent.json b/ladybug_grasshopper/json/LB_Visibility_Percent.json index 4492fd2..344a35d 100644 --- a/ladybug_grasshopper/json/LB_Visibility_Percent.json +++ b/ladybug_grasshopper/json/LB_Visibility_Percent.json @@ -1,5 +1,5 @@ { - "version": "1.8.0", + "version": "1.8.1", "nickname": "VisibilityPercent", "outputs": [ [ @@ -127,7 +127,7 @@ } ], "subcategory": "3 :: Analyze Geometry", - "code": "\ntry:\n from ladybug.color import Colorset\n from ladybug.graphic import GraphicContainer\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import conversion_to_meters\n from ladybug_{{cad}}.togeometry import to_joined_gridded_mesh3d, to_vector3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d, from_point3d, from_vector3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.intersect import join_geometry_to_mesh, intersect_mesh_lines\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, hide_output, \\\n show_output, objectify_output, recommended_processor_count\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component) and _run:\n # set the default values\n _offset_dist_ = _offset_dist_ if _offset_dist_ is not None \\\n else 0.1 / conversion_to_meters()\n if pt_weights_:\n assert len(pt_weights_) == len(_view_points), \\\n 'The number of pt_weights_({}) must match the number of _view_points ' \\\n '({}).'.format(len(pt_weights_), len(_view_points))\n workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count()\n\n # create the gridded mesh from the geometry\n study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size)\n points = [from_point3d(pt.move(vec * _offset_dist_)) for pt, vec in\n zip(study_mesh.face_centroids, study_mesh.face_normals)]\n hide_output(ghenv.Component, 1)\n\n # mesh the geometry and context\n shade_mesh = join_geometry_to_mesh(_geometry + context_) if _geo_block_ \\\n or _geo_block_ is None else join_geometry_to_mesh(context_)\n\n # intersect the lines with the mesh\n int_matrix = intersect_mesh_lines(\n shade_mesh, points, _view_points, max_dist_, cpu_count=workers)\n\n # compute the results\n int_mtx = objectify_output('Visibility Intersection Matrix', int_matrix)\n vec_count = len(_view_points)\n if pt_weights_: # weight intersections by the input point weights\n tot_wght = sum(pt_weights_) / vec_count\n adj_weights = [wght / tot_wght for wght in pt_weights_]\n results = []\n for int_vals in int_matrix:\n w_res = [ival * wght for ival, wght in zip(int_vals, adj_weights)]\n results.append(sum(w_res) * 100 / vec_count)\n else: # no need to wieght results\n results = [sum(int_list) * 100 / vec_count for int_list in int_matrix]\n\n # create the mesh and legend outputs\n graphic = GraphicContainer(results, study_mesh.min, study_mesh.max, legend_par_)\n graphic.legend_parameters.title = '%'\n if legend_par_ is None or legend_par_.are_colors_default:\n graphic.legend_parameters.colors = Colorset.view_study()\n title = text_objects(\n 'Visibility Percent', graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # create all of the visual outputs\n study_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(study_mesh)\n legend = legend_objects(graphic.legend)\n", + "code": "\ntry:\n from ladybug.color import Colorset\n from ladybug.graphic import GraphicContainer\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.config import conversion_to_meters\n from ladybug_{{cad}}.togeometry import to_joined_gridded_mesh3d, to_vector3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d, from_point3d, from_vector3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.intersect import join_geometry_to_mesh, intersect_mesh_lines\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, hide_output, \\\n show_output, objectify_output, recommended_processor_count\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component) and _run:\n # set the default values\n _offset_dist_ = _offset_dist_ if _offset_dist_ is not None \\\n else 0.1 / conversion_to_meters()\n if pt_weights_:\n assert len(pt_weights_) == len(_view_points), \\\n 'The number of pt_weights_({}) must match the number of _view_points ' \\\n '({}).'.format(len(pt_weights_), len(_view_points))\n workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count()\n\n # create the gridded mesh from the geometry\n study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size)\n points = [from_point3d(pt.move(vec * _offset_dist_)) for pt, vec in\n zip(study_mesh.face_centroids, study_mesh.face_normals)]\n hide_output(ghenv.Component, 1)\n\n # mesh the geometry and context\n shade_mesh = join_geometry_to_mesh([from_mesh3d(study_mesh)] + context_) \\\n if _geo_block_ or _geo_block_ is None else join_geometry_to_mesh(context_)\n\n # intersect the lines with the mesh\n int_matrix = intersect_mesh_lines(\n shade_mesh, points, _view_points, max_dist_, cpu_count=workers)\n\n # compute the results\n int_mtx = objectify_output('Visibility Intersection Matrix', int_matrix)\n vec_count = len(_view_points)\n if pt_weights_: # weight intersections by the input point weights\n tot_wght = sum(pt_weights_) / vec_count\n adj_weights = [wght / tot_wght for wght in pt_weights_]\n results = []\n for int_vals in int_matrix:\n w_res = [ival * wght for ival, wght in zip(int_vals, adj_weights)]\n results.append(sum(w_res) * 100 / vec_count)\n else: # no need to wieght results\n results = [sum(int_list) * 100 / vec_count for int_list in int_matrix]\n\n # create the mesh and legend outputs\n graphic = GraphicContainer(results, study_mesh.min, study_mesh.max, legend_par_)\n graphic.legend_parameters.title = '%'\n if legend_par_ is None or legend_par_.are_colors_default:\n graphic.legend_parameters.colors = Colorset.view_study()\n title = text_objects(\n 'Visibility Percent', graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # create all of the visual outputs\n study_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(study_mesh)\n legend = legend_objects(graphic.legend)\n", "category": "Ladybug", "name": "LB Visibility Percent", "description": "Evaluate the percent visibility from geometry to a specific set of points.\n_\nSuch visibility calculations can be used to understand the portions of a building\nfacade that can see a skyline or landmark when used on the outdoors. When used\non the indoors, they can evaluate the spectator view of a stage, screen, or other\npoint of interest.\n-" diff --git a/ladybug_grasshopper/src/LB Direct Sun Hours.py b/ladybug_grasshopper/src/LB Direct Sun Hours.py index d52feeb..edb78ae 100644 --- a/ladybug_grasshopper/src/LB Direct Sun Hours.py +++ b/ladybug_grasshopper/src/LB Direct Sun Hours.py @@ -84,7 +84,7 @@ ghenv.Component.Name = "LB Direct Sun Hours" ghenv.Component.NickName = 'DirectSunHours' -ghenv.Component.Message = '1.8.2' +ghenv.Component.Message = '1.8.3' ghenv.Component.Category = 'Ladybug' ghenv.Component.SubCategory = '3 :: Analyze Geometry' ghenv.Component.AdditionalHelpFromDocStrings = '1' @@ -122,7 +122,7 @@ hide_output(ghenv.Component, 1) # mesh the geometry and context - shade_mesh = join_geometry_to_mesh(_geometry + context_) \ + shade_mesh = join_geometry_to_mesh([from_mesh3d(study_mesh)] + context_) \ if geo_block_ or geo_block_ is None else join_geometry_to_mesh(context_) # get the study points and reverse the sun vectors (for backward ray-tracting) diff --git a/ladybug_grasshopper/src/LB Incident Radiation.py b/ladybug_grasshopper/src/LB Incident Radiation.py index 5ab90ce..768c36d 100644 --- a/ladybug_grasshopper/src/LB Incident Radiation.py +++ b/ladybug_grasshopper/src/LB Incident Radiation.py @@ -102,7 +102,7 @@ ghenv.Component.Name = "LB Incident Radiation" ghenv.Component.NickName = 'IncidentRadiation' -ghenv.Component.Message = '1.8.0' +ghenv.Component.Message = '1.8.1' ghenv.Component.Category = 'Ladybug' ghenv.Component.SubCategory = '3 :: Analyze Geometry' ghenv.Component.AdditionalHelpFromDocStrings = '1' @@ -147,7 +147,7 @@ hide_output(ghenv.Component, 1) # mesh the geometry and context - shade_mesh = join_geometry_to_mesh(_geometry + context_) + shade_mesh = join_geometry_to_mesh([from_mesh3d(study_mesh)] + context_) # deconstruct the matrix and get the sky dome vectors mtx = de_objectify_output(_sky_mtx) diff --git a/ladybug_grasshopper/src/LB View Percent.py b/ladybug_grasshopper/src/LB View Percent.py index c8a3a22..cc09638 100644 --- a/ladybug_grasshopper/src/LB View Percent.py +++ b/ladybug_grasshopper/src/LB View Percent.py @@ -125,7 +125,7 @@ ghenv.Component.Name = "LB View Percent" ghenv.Component.NickName = 'ViewPercent' -ghenv.Component.Message = '1.8.0' +ghenv.Component.Message = '1.8.1' ghenv.Component.Category = 'Ladybug' ghenv.Component.SubCategory = '3 :: Analyze Geometry' ghenv.Component.AdditionalHelpFromDocStrings = '2' @@ -203,8 +203,8 @@ view_vecs = [from_vector3d(pt) for pt in lb_vecs] # mesh the geometry and context - shade_mesh = join_geometry_to_mesh(_geometry + context_) if _geo_block_ \ - else join_geometry_to_mesh(context_) + shade_mesh = join_geometry_to_mesh([from_mesh3d(study_mesh)] + context_) \ + if _geo_block_ else join_geometry_to_mesh(context_) # intersect the rays with the mesh if vt_str == 'Sky View': # account for the normals of the surface diff --git a/ladybug_grasshopper/src/LB Visibility Percent.py b/ladybug_grasshopper/src/LB Visibility Percent.py index 57847f1..b23c7de 100644 --- a/ladybug_grasshopper/src/LB Visibility Percent.py +++ b/ladybug_grasshopper/src/LB Visibility Percent.py @@ -85,7 +85,7 @@ ghenv.Component.Name = "LB Visibility Percent" ghenv.Component.NickName = 'VisibilityPercent' -ghenv.Component.Message = '1.8.0' +ghenv.Component.Message = '1.8.1' ghenv.Component.Category = 'Ladybug' ghenv.Component.SubCategory = '3 :: Analyze Geometry' ghenv.Component.AdditionalHelpFromDocStrings = '2' @@ -126,8 +126,8 @@ hide_output(ghenv.Component, 1) # mesh the geometry and context - shade_mesh = join_geometry_to_mesh(_geometry + context_) if _geo_block_ \ - or _geo_block_ is None else join_geometry_to_mesh(context_) + shade_mesh = join_geometry_to_mesh([from_mesh3d(study_mesh)] + context_) \ + if _geo_block_ or _geo_block_ is None else join_geometry_to_mesh(context_) # intersect the lines with the mesh int_matrix = intersect_mesh_lines( diff --git a/ladybug_grasshopper/user_objects/LB Direct Sun Hours.ghuser b/ladybug_grasshopper/user_objects/LB Direct Sun Hours.ghuser index 29c40ce..e24344a 100644 Binary files a/ladybug_grasshopper/user_objects/LB Direct Sun Hours.ghuser and b/ladybug_grasshopper/user_objects/LB Direct Sun Hours.ghuser differ diff --git a/ladybug_grasshopper/user_objects/LB Incident Radiation.ghuser b/ladybug_grasshopper/user_objects/LB Incident Radiation.ghuser index d23e513..f8b7291 100644 Binary files a/ladybug_grasshopper/user_objects/LB Incident Radiation.ghuser and b/ladybug_grasshopper/user_objects/LB Incident Radiation.ghuser differ diff --git a/ladybug_grasshopper/user_objects/LB View Percent.ghuser b/ladybug_grasshopper/user_objects/LB View Percent.ghuser index 6f6701d..91715c2 100644 Binary files a/ladybug_grasshopper/user_objects/LB View Percent.ghuser and b/ladybug_grasshopper/user_objects/LB View Percent.ghuser differ diff --git a/ladybug_grasshopper/user_objects/LB Visibility Percent.ghuser b/ladybug_grasshopper/user_objects/LB Visibility Percent.ghuser index 7dd1fba..2edce2d 100644 Binary files a/ladybug_grasshopper/user_objects/LB Visibility Percent.ghuser and b/ladybug_grasshopper/user_objects/LB Visibility Percent.ghuser differ