+ "code": "\ntry:\n from ladybug_{{cad}}.togeometry import to_mesh3d\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, list_to_data_tree, \\\n data_tree_to_list\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component):\n # process the input values into a rokable format\n da_mtx = [item[-1] for item in data_tree_to_list(_DA)]\n _target_time_ = 50 if _target_time_ is None else _target_time_\n lb_meshes = [to_mesh3d(mesh) for mesh in mesh_]\n\n # determine whether each point passes or fails\n pass_fail = [[int(val > _target_time_) for val in grid] for grid in da_mtx]\n\n # compute spatial daylight autonomy from the pass/fail results\n if len(lb_meshes) == 0: # all sensors represent the same area\n sDA = [round(sum(pf_list) / len(pf_list) * 100, 2) for pf_list in pass_fail]\n else: # weight the sensors based on the area of mesh faces\n sDA = []\n for i, mesh in enumerate(lb_meshes):\n m_area = mesh.area\n weights = [fa / m_area for fa in mesh.face_areas]\n sDA.append(round(sum(v * w for v, w in zip(pass_fail[i], weights)) * 100, 2))\n\n pass_fail = list_to_data_tree(pass_fail) # convert matrix to data tree\n",
0 commit comments