'Spherical': 'Spherical', 'SkyExposure': 'Sky Exposure', 'SkyView': 'Sky View', '0': 'Horizontal Radial', '1': 'Horizontal 30-Degree Offset', '2': 'Spherical', '3': 'Sky Exposure', '4': 'Sky View' } if all_required_inputs(ghenv.Component) and _run: # process the view_type_ and set the default values vt_str = VIEW_TYPES[_view_type] _resolution_ = _resolution_ if _resolution_ is not None else 1 _offset_dist_ = _offset_dist_ if _offset_dist_ is not None \ else 0.1 / conversion_to_meters() if _geo_block_ is None: _geo_block_ = True if vt_str in ('Sky Exposure', 'Sky View') else False # create the gridded mesh from the geometry study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size, _offset_dist_) points = [from_point3d(pt) for pt in study_mesh.face_centroids] hide_output(ghenv.Component, 1) # get the view vectors based on the view type patch_wghts = None if vt_str == 'Horizontal Radial': lb_vecs = view_sphere.horizontal_radial_vectors(30 * _resolution_) elif vt_str == 'Horizontal 30-Degree Offset': patch_mesh, lb_vecs = view_sphere.horizontal_radial_patches( 30, _resolution_)
try: from ladybug_rhino.config import conversion_to_meters from ladybug_rhino.togeometry import to_joined_gridded_mesh3d from ladybug_rhino.fromgeometry import from_mesh3d, from_point3d, from_vector3d from ladybug_rhino.fromobjects import legend_objects from ladybug_rhino.text import text_objects from ladybug_rhino.intersect import join_geometry_to_mesh, intersect_mesh_rays from ladybug_rhino.grasshopper import all_required_inputs, hide_output, \ show_output, objectify_output, de_objectify_output, recommended_processor_count except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component) and _run: # set the default offset distance and _cpu_count _offset_dist_ = _offset_dist_ if _offset_dist_ is not None \ else 0.1 / conversion_to_meters() 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
elif lower_fname.endswith('.idf'): cmd_name = 'model-from-idf' else: raise ValueError( 'Failed to recongize the input _gbxml file type.\n' 'Make sure that it has an appropriate file extension.') # Execute the honybee CLI to obtain the model JSON via CPython shell = True if os.name == 'nt' else False cmds = [ folders.python_exe_path, '-m', 'honeybee_energy', 'translate', cmd_name, _gbxml ] process = subprocess.Popen(cmds, stdout=subprocess.PIPE, shell=shell) stdout = process.communicate() model_dict = json.loads(stdout[0]) # load the model from the JSON dictionary and convert it to Rhino model units model = Model.from_dict(model_dict) model_units_tolerance_check(model) # given that most other software lets doors go to the edge, move them slightly for HB move_vec = Vector3D(0, 0, 0.02 / conversion_to_meters()) for room in model.rooms: for face in room.faces: doors = face.doors for door in doors: door.move(move_vec) if len(doors) != 0: face._punched_geometry = None
check_energyplus_version() # set defaults for COP _heat_cop_ = 1 if _heat_cop_ is None else _heat_cop_ _cool_cop_ = 1 if _cool_cop_ is None else _cool_cop_ # create the Model from the _rooms and shades_ _model = Model('Annual_Loads', _rooms, orphaned_shades=shades_, units=units_system(), tolerance=tolerance, angle_tolerance=angle_tolerance) floor_area = _model.floor_area assert floor_area != 0, 'Connected _rooms have no floors with which to compute EUI.' floor_area = floor_area * conversion_to_meters()**2 mults = {rm.identifier.upper(): rm.multiplier for rm in _model.rooms} mults = None if all(mul == 1 for mul in mults.values()) else mults # process the simulation folder name and the directory directory = os.path.join(folders.default_simulation_folder, _model.identifier) sch_directory = os.path.join(directory, 'schedules') nukedir(directory) # delete any existing files in the directory # create simulation parameters for the coarsest/fastest E+ sim possible _sim_par_ = SimulationParameter() _sim_par_.timestep = _timestep_ if _timestep_ is not None else 1 _sim_par_.shadow_calculation.solar_distribution = 'FullExterior' _sim_par_.output.add_zone_energy_use() _sim_par_.output.reporting_frequency = 'Monthly'
assert -360.0 <= north_ <= 360.0, 'The north orientation must be greater ' \ 'then -360 and less then 360 to plot the wind rose. ' \ 'Got: {}'.format(north_) else: north_ = 0.0 # set default values for the chart dimensions _center_pt_ = to_point3d( _center_pt_) if _center_pt_ is not None else Point3D() center_pt_2d = Point2D(_center_pt_.x, _center_pt_.y) # set defaults frequency hours and distance so chart is same scale as other LB plots if _freq_hours_ is None: _freq_hours_ = 50.0 if _freq_dist_ is None: _freq_dist_ = 5.0 / conversion_to_meters() # set default show_freq and _show_calmrose_ _show_calmrose_ = False if _show_calmrose_ is None else _show_calmrose_ _show_freq_ = True if _show_freq_ is None else _show_freq_ # set up empty lists of objects to be filled all_wind_avg_val = [] all_wind_frequency = [] all_windrose_lines = [] all_mesh = [] all_compass = [] all_orient_line = [] all_freq_line = [] all_legends = [] all_title = []
from ladybug_rhino.config import tolerance from ladybug_rhino.togeometry import to_point2d from ladybug_rhino.fromgeometry import from_mesh3d, from_mesh2d, \ from_polyline2d, from_linesegment2d from ladybug_rhino.text import text_objects from ladybug_rhino.fromobjects import legend_objects from ladybug_rhino.grasshopper import all_required_inputs except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # set default values for the chart dimensions z_val = _base_pt_.Z if _base_pt_ is not None else 0 z_val_tol = z_val + tolerance _base_pt_ = to_point2d(_base_pt_) if _base_pt_ is not None else Point2D() _x_dim_ = _x_dim_ if _x_dim_ is not None else 10.0 / conversion_to_meters() _y_dim_ = _y_dim_ if _y_dim_ is not None else 40.0 / conversion_to_meters() stack_ = stack_ if stack_ is not None else False percentile_ = percentile_ if percentile_ is not None else 34.0 lpar = legend_par_[0] if len(legend_par_) != 0 else None # create the monthly chart object and get the main pieces of geometry month_chart = MonthlyChart(_data, lpar, _base_pt_, _x_dim_, _y_dim_, stack_, percentile_) if len(legend_par_) > 1: if legend_par_[1].min is not None: month_chart.set_minimum_by_index(legend_par_[1].min, 1) if legend_par_[1].max is not None: month_chart.set_maximum_by_index(legend_par_[1].max, 1) # get the main pieces of geometry
ghenv.Component.Name = 'HB Apply Abolute Load Values' ghenv.Component.NickName = 'AbsoluteLoadVals' ghenv.Component.Message = '1.2.0' ghenv.Component.Category = 'HB-Energy' ghenv.Component.SubCategory = '3 :: Loads' ghenv.Component.AdditionalHelpFromDocStrings = '2' try: from ladybug_rhino.grasshopper import all_required_inputs, longest_list from ladybug_rhino.config import conversion_to_meters except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): conversion = conversion_to_meters() rooms = [room.duplicate() for room in _rooms] # duplicate the initial objects # assign the person_count_ if len(person_count_) != 0: for i, room in enumerate(rooms): room.properties.energy.abolute_people( longest_list(person_count_, i), conversion) # assign the lighting_watts_ if len(lighting_watts_) != 0: for i, room in enumerate(rooms): room.properties.energy.abolute_lighting( longest_list(lighting_watts_, i), conversion)
try: north_ = math.degrees( to_vector2d(north_).angle_clockwise(Vector2D(0, 1))) except AttributeError: # north angle instead of vector north_ = float(north_) else: north_ = 0 if _center_pt_ is not None: # process the center point into a Point2D center_pt, center_pt3d = to_point2d(_center_pt_), to_point3d( _center_pt_) z = center_pt3d.z else: center_pt, center_pt3d = Point2D(), Point3D() z = 0 _scale_ = 1 if _scale_ is None else _scale_ # process the scale into a radius radius = (100 * _scale_) / conversion_to_meters() solar_time_ = False if solar_time_ is None else solar_time_ # process solar time projection_ = projection_.title() if projection_ is not None else None # create a intersection of the input hoys_ and the data hoys if len(data_) > 0 and len(hoys_) > 0: all_aligned = all(data_[0].is_collection_aligned(d) for d in data_[1:]) assert all_aligned, 'All collections input to data_ must be aligned for ' \ 'each Sunpath.\nGrafting the data_ and suplying multiple grafted ' \ '_center_pt_ can be used to view each data on its own path.' if statement_ is not None: data_ = HourlyContinuousCollection.filter_collections_by_statement( data_, statement_) data_hoys = set(dt.hoy for dt in data_[0].datetimes) hoys_ = list(data_hoys.intersection(set(hoys_)))
except ImportError as e: raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) try: from ladybug_rhino.config import conversion_to_meters from ladybug_rhino.togeometry import to_joined_gridded_mesh3d, to_face3d, \ to_vector3d from ladybug_rhino.fromgeometry import from_mesh3d, from_point3d from ladybug_rhino.grasshopper import all_required_inputs, hide_output except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component) and _run: # set the default offset distance _height_limit_ = _height_limit_ if _height_limit_ is not None \ else 100 / conversion_to_meters() # convert geometry, objstacles, and vectors to ladybug_geomtery study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size) obstacle_faces = [g for geo in _obstacles for g in to_face3d(geo)] sun_vectors = [to_vector3d(vec) for vec in _vectors] # compute the solar envelope solar_obj = SolarEnvelope( study_mesh, obstacle_faces, sun_vectors, _height_limit_, solar_rights_) lb_mesh = solar_obj.envelope_mesh() mesh = from_mesh3d(lb_mesh) points = [from_point3d(pt) for pt in lb_mesh.vertices] hide_output(ghenv.Component, 1)
raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e)) try: from ladybug_rhino.togeometry import to_point3d from ladybug_rhino.config import conversion_to_meters from ladybug_rhino.grasshopper import all_required_inputs, longest_list, \ give_warning except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # duplicate the initial objects rooms = [room.duplicate() for room in _rooms] # set default values and perform checks dist_from_floor = 0.8 / conversion_to_meters() if len(_sensor_points_) != 0: assert len(_sensor_points_) == len(_rooms), 'Number of sensor points ({}) ' \ 'must align exactly with the number of rooms ({}).'.format( len(_sensor_points_), len(_rooms)) _ill_setpoint_ = [300] if len(_ill_setpoint_) == 0 else _ill_setpoint_ _control_fract_ = [1] if len(_control_fract_) == 0 else _control_fract_ _min_power_in_ = [0.3] if len(_min_power_in_) == 0 else _min_power_in_ _min_light_out_ = [0.2] if len(_min_light_out_) == 0 else _min_light_out_ off_at_min_ = [False] if len(off_at_min_) == 0 else off_at_min_ # loop through the rooms and assign daylight sensors unassigned_rooms = [] if len(_sensor_points_) == 0: for i, room in enumerate(rooms): dl_control = room.properties.energy.add_daylight_control_to_center(
from honeybee_radiance.sensorgrid import SensorGrid except ImportError as e: raise ImportError('\nFailed to import honeybee_radiance:\n\t{}'.format(e)) try: # import ladybug_rhino dependencies from ladybug_rhino.config import conversion_to_meters, tolerance from ladybug_rhino.togeometry import to_joined_gridded_mesh3d from ladybug_rhino.fromgeometry import from_mesh3d, from_point3d, from_face3d from ladybug_rhino.grasshopper import all_required_inputs, 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): # set defaults for any blank inputs if _dist_floor_ is None: _dist_floor_ = 0.8 / conversion_to_meters() # create lists to be filled with content grid = [] points = [] mesh = [] for room in _rooms: # get all of the floor faces of the room as Breps floor_faces = [ from_face3d(face.geometry.flip()) for face in room.faces if isinstance(face.type, Floor) ] if len(floor_faces) != 0: # create the gridded ladybug Mesh3D
try: pressure = float(pr) except Exception: # assume that it's a data collection assert pr.header.unit == 'Pa', '_pressure_ input must be in Pa.' pressure = pr.average # sense if the input temperature is in Farenheit use_ip = False if isinstance(temperature, BaseCollection): if temperature.header.unit != 'C': # convert to C and set chart to use_ip temperature = temperature.to_si() use_ip = True # set default values for the chart dimensions _scale_ = 1.0 if _scale_ is None else _scale_ x_dim = _scale_ * 2 / conversion_to_meters() y_dim = (_scale_ * 2 * 1500) / conversion_to_meters() y_dim = y_dim * (9 / 5) if use_ip else y_dim t_min, t_max = (-5, 115) if use_ip else (-20, 50) if _temp_range_ is not None: t_min, t_max = _temp_range_ y_move_dist = -y_dim * 0.04 * j base_pt = bp.move(Vector2D(0, y_move_dist)) # apply any analysis periods and conditional statements to the input collections original_temperature = temperature all_data = data_ + [temperature, rel_humid] if period_ is not None: all_data = [ coll.filter_by_analysis_period(period_) for coll in all_data ]
try: from ladybug_rhino.grasshopper import all_required_inputs, give_warning from ladybug_rhino.config import conversion_to_meters except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component): # extract any rooms from input Models and convert geo to meters if necessary rooms = [] for hb_obj in _model: if isinstance(hb_obj, Model): rooms.extend(hb_obj.rooms) else: rooms.append(hb_obj) m_convert = conversion_to_meters() if m_convert != 1: # duplicate and scale all objects to meters rooms = [room.duplicate() for room in rooms] [room.scale(m_convert) for room in rooms] # match the data with the rooms match_tups = match_rooms_to_data(_data, rooms) # divide the individual data collections by floor area total_area = 0 room_data = [] for tup in match_tups: total_flr_area = tup[0].floor_area * tup[2] # includes effect of multiplier total_area += total_flr_area try: room_data.append(tup[1].normalize_by_area(total_flr_area, 'm2'))
if all_required_inputs(ghenv.Component): # process the north input if specified if north_ is not None: # process the north_ try: north_ = math.degrees( to_vector2d(north_).angle_clockwise(Vector2D(0, 1))) except AttributeError: # north angle instead of vector north_ = float(north_) else: north_ = 0 # set the default point count, height, and cpu_count if unspecified _pt_count_ = _pt_count_ if _pt_count_ is not None else 1 _height_ = _height_ if _height_ is not None else 1.8 / conversion_to_meters( ) workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count( ) # create the points representing the human geometry human_points = [] human_line = [] for pos in _position: hpts, hlin = human_height_points(pos, _height_, _pt_count_) human_points.extend(hpts) human_line.append(hlin) if _run: # mesh the context for the intersection calculation shade_mesh = join_geometry_to_mesh(_context)
from honeybee_radiance.sensorgrid import SensorGrid except ImportError as e: raise ImportError('\nFailed to import honeybee_radiance:\n\t{}'.format(e)) try: # import ladybug_rhino dependencies from ladybug_rhino.config import conversion_to_meters, tolerance from ladybug_rhino.togeometry import to_joined_gridded_mesh3d, to_vector3d from ladybug_rhino.fromgeometry import from_mesh3d, from_point3d, from_face3d from ladybug_rhino.grasshopper import all_required_inputs, 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): # set defaults for any blank inputs and process the quad_only_ _dist_floor_ = 0.8 / conversion_to_meters() if _dist_floor_ is None else _dist_floor_ try: x_axis = to_vector3d(quad_only_) except AttributeError: x_axis = None # create lists to be filled with content grid = [] points = [] mesh = [] rooms = [] for obj in _rooms: if isinstance(obj, Model): rooms.extend(obj.rooms) elif isinstance(obj, Room): rooms.append(obj)
try: from ladybug_rhino.togeometry import to_point2d from ladybug_rhino.fromgeometry import from_point2d, from_linesegment2d, \ from_polyline2d from ladybug_rhino.config import tolerance, angle_tolerance, units_system, \ conversion_to_meters from ladybug_rhino.grasshopper import all_required_inputs except ImportError as e: raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e)) if all_required_inputs(ghenv.Component) and _import: # set default inputs if not specified pt = to_point2d(_point_) if _point_ is not None else Point2D(0, 0) all_to_bldg = bool(all_to_bldg_) # handle case of None model_units, con_fac = units_system(), 1 / conversion_to_meters() # convert the geoJSON to a dragonfly Model model, location = Model.from_geojson(_geojson, point=pt, all_polygons_to_buildings=all_to_bldg, units=model_units, tolerance=tolerance, angle_tolerance=angle_tolerance) point = from_point2d(pt) # if other geometry has been requested, then import it if other_geo_: # parse the geoJSON into a dictionary and get lat/lon converters with open(_geojson, 'r') as fp: data = json.load(fp)