def draw_analemma_and_arcs(sp, datetimes, radius, center_pt3d): """Draw analemma and day arc Rhino geometry. Args: sp: Sunpath object for which geometry will be drawn. datetimes: A list of datetimes, which will be used to get days if daily_ is True. radius: Number for the radius of the sun path. center_pt3d: Point3D for the center of the sun path. Returns: analemma: List of Rhino curves for the analemmas daily: List of Rhino curves for the daily arcs. """ sp.daylight_saving_period = None # set here so analemmas aren't messed up center_pt, z = Point2D(center_pt3d.x, center_pt3d.y), center_pt3d.z if not daily_: if projection_ is None: analemma = [ from_polyline3d(pline) for pline in sp.hourly_analemma_polyline3d( center_pt3d, radius, True, solar_time_) ] daily = [ from_arc3d(arc) for arc in sp.monthly_day_arc3d(center_pt3d, radius) ] else: analemma = [ from_polyline2d(pline, z) for pline in sp.hourly_analemma_polyline2d( projection_, center_pt, radius, True, solar_time_) ] daily = [ from_polyline2d(arc, z) for arc in sp.monthly_day_polyline2d( projection_, center_pt3d, radius) ] else: analemma = [] # No Analemmas for a daily sun path doys = set(dt.doy for dt in datetimes) dates = [Date.from_doy(doy) for doy in doys] if projection_ is None: daily = [ from_arc3d( sp.day_arc3d(dat.month, dat.day, center_pt3d, radius)) for dat in dates ] else: daily = [] for dat in dates: pline = sp.day_polyline2d(dat.month, dat.day, projection_, center_pt, radius) daily.append(from_polyline2d(pline, z)) return analemma, daily
def draw_psych_chart(psy_chart): """Draw a given psychrometric chart object into Rhino geometry. This will NOT translate any colored meshes or data points. """ # output all of the lines/polylines for the various axes title_i = [from_polyline2d(psy_chart.chart_border, z)] temp_lines_i = [ from_linesegment2d(tl, z) for tl in psy_chart.temperature_lines ] rh_lines_i = [from_polyline2d(rhl, z) for rhl in psy_chart.rh_lines] hr_lines_i = [from_linesegment2d(hrl, z) for hrl in psy_chart.hr_lines] # add the text to the various lines title_i.append( text_objects(psy_chart.x_axis_text, plane_from_point(psy_chart.x_axis_location), psy_chart.legend_parameters.text_height * 1.5, psy_chart.legend_parameters.font, 0, 0)) title_i.append( text_objects( psy_chart.y_axis_text, plane_from_point(psy_chart.y_axis_location, Vector3D(0, 1)), psy_chart.legend_parameters.text_height * 1.5, psy_chart.legend_parameters.font, 2, 0)) temp_lines_i = temp_lines_i + small_labels( psy_chart, psy_chart.temperature_labels, psy_chart.temperature_label_points, 1, 0) rh_lines_i = rh_lines_i + small_labels(psy_chart, psy_chart.rh_labels[:-1], psy_chart.rh_label_points[:-1], 2, 3, 0.8) hr_lines_i = hr_lines_i + small_labels(psy_chart, psy_chart.hr_labels, psy_chart.hr_label_points, 0, 3) # add enthalpy or wet bulb lines if plot_wet_bulb_: enth_wb_lines_i = [ from_linesegment2d(el, z) for el in psy_chart.wb_lines ] enth_wb_lines_i = enth_wb_lines_i + small_labels( psy_chart, psy_chart.wb_labels, psy_chart.wb_label_points, 2, 3) else: enth_wb_lines_i = [ from_linesegment2d(el, z) for el in psy_chart.enthalpy_lines ] enth_wb_lines_i = enth_wb_lines_i + small_labels( psy_chart, psy_chart.enthalpy_labels, psy_chart.enthalpy_label_points, 2, 3) # add all of the objects to the bse list title.append(title_i) temp_lines.append(temp_lines_i) rh_lines.append(rh_lines_i) hr_lines.append(hr_lines_i) enth_wb_lines.append(enth_wb_lines_i)
# 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 d_meshes = month_chart.data_meshes if d_meshes is not None: data_mesh = [from_mesh2d(msh, z_val_tol) for msh in d_meshes] d_lines = month_chart.data_polylines if d_lines is not None: data_lines = [from_polyline2d(lin, z_val_tol) for lin in d_lines] borders = [from_polyline2d(month_chart.chart_border, z_val)] + \ [from_linesegment2d(line, z_val) for line in month_chart.y_axis_lines] + \ [from_linesegment2d(line, z_val_tol) for line in month_chart.month_lines] legend = legend_objects(month_chart.legend) # process all of the text-related outputs title_txt = month_chart.title_text if global_title_ is None else global_title_ txt_hgt = month_chart.legend_parameters.text_height font = month_chart.legend_parameters.font title = text_objects(title_txt, month_chart.lower_title_location, txt_hgt, font) # process the first y axis y1_txt = month_chart.y_axis_title_text1 if len( y_axis_title_) == 0 else y_axis_title_[0]
all_borders = [] all_labels = [] for i, data_coll in enumerate(_data): try: # sense when several legend parameters are connected lpar = legend_par_[i] except IndexError: lpar = None if len(legend_par_) == 0 else legend_par_[-1] # create the hourly plot object and get the main pieces of geometry hour_plot = HourlyPlot(data_coll, lpar, _base_pt_, _x_dim_, _y_dim_, _z_dim_, reverse_y_) msh = from_mesh2d(hour_plot.colored_mesh2d, _base_pt_.z) if _z_dim_ == 0 else \ from_mesh3d(hour_plot.colored_mesh3d) mesh.append(msh) border = [from_polyline2d(hour_plot.chart_border2d, _base_pt_.z)] + \ [from_linesegment2d(line, _base_pt_.z) for line in hour_plot.hour_lines2d] + \ [from_linesegment2d(line, _base_pt_.z) for line in hour_plot.month_lines2d] all_borders.append(border) legnd = legend_objects(hour_plot.legend) all_legends.append(legnd) tit_txt = text_objects(hour_plot.title_text, hour_plot.lower_title_location, hour_plot.legend_parameters.text_height, hour_plot.legend_parameters.font) title.append(tit_txt) # create the text label objects label1 = [ text_objects(txt, Plane(o=Point3D(pt.x, pt.y, _base_pt_.z)), hour_plot.legend_parameters.text_height,
if not all_to_bldg: # exclude anything with a Building key geo_data = [ geo for geo in geo_data if 'type' not in geo['properties'] or geo['properties']['type'] != 'Building' ] # convert all of the geoJSON data into Rhino geometry other_geo = [] for geo_dat in geo_data: if geo_dat['geometry']['type'] == 'LineString': coords = lon_lat_to_polygon(geo_dat['geometry']['coordinates'], origin_lon_lat, convert_facs) pts = tuple(Point2D.from_array(pt) for pt in coords) line = LineSegment2D.from_end_points(pts[0], pts[1]) \ if len(pts) == 2 else Polyline2D(pts) if con_fac != 1: line = line.scale(con_fac, pt) if len(pts) == 2: other_geo.append(from_linesegment2d(line)) else: other_geo.append(from_polyline2d(line)) else: # is's a polygon coords = lon_lat_to_polygon( geo_dat['geometry']['coordinates'][0], origin_lon_lat, convert_facs) pts = tuple(Point2D.from_array(pt) for pt in coords) poly = Polyline2D(pts) if con_fac != 1: poly = poly.scale(con_fac, pt) other_geo.append(from_polyline2d(poly))