graphic = GraphicContainer(n_data.values, lb_compass.min_point3d(z), lb_compass.max_point3d(z), lpar, n_data.header.data_type, n_data.header.unit) all_legends.append(legend_objects(graphic.legend)) title.append( text_objects(title_text(n_data), graphic.lower_title_location, graphic.legend_parameters.text_height, graphic.legend_parameters.font)) # create points, analemmas, daily arcs, and compass geometry sun_pts_init = draw_sun_positions(suns, radius, center_pt3d_i) analemma_i, daily_i = draw_analemma_and_arcs( sp, datetimes, radius, center_pt3d_i) compass_i = compass_objects(lb_compass, z, None, projection_, graphic.legend_parameters.font) all_analemma.append(analemma_i) all_daily.append(daily_i) all_compass.append(compass_i) # produce a visualization of colored points cols = [color_to_color(col) for col in graphic.value_colors] col_pts = [] for pt, col in zip(sun_pts_init, cols): col_pt = ColoredPoint(pt) col_pt.color = col col_pts.append(col_pt) all_sun_pts.append(sun_pts_init) all_col_pts.append(col_pts) # convert all nested lists to data trees
# Make the mesh mesh = from_mesh2d(windrose.colored_mesh, _center_pt_.z) # Make the graphic outputs legend = legend_objects(windrose.legend) freq_per = windrose._frequency_hours / \ len([b for a in windrose.histogram_data for b in a]) freq_text = '\nEach closed polyline shows frequency of {}% = {} hours.'.format( round(freq_per * 100, 1), windrose._frequency_hours) title = text_objects( title_text(speed_data) + calm_text + freq_text, windrose.container.lower_title_location, windrose.legend_parameters.text_height, windrose.legend_parameters.font) compass = compass_objects(windrose.compass, _center_pt_.z, None) orient_line = [ from_linesegment2d(seg, _center_pt_.z) for seg in windrose.orientation_lines ] freq_line = [from_polygon2d(poly) for poly in windrose.frequency_lines] windrose_lines = [ from_polygon2d(poly) for poly in windrose.windrose_lines ] fac = (i + 1) * windrose.compass_radius * 3 center_pt_2d = Point2D(_center_pt_.x + fac, _center_pt_.y) # Add histogram hist_mtx = objectify_output('WindRose {}'.format(i), windrose.histogram_data)
def draw_dome(dome_data, center, dome_name, legend_par): """Draw the dome mesh, compass, legend, and title for a sky dome. Args: dome_data: List of radiation values for the dome data center: Point3D for the center of the sun path. dome_name: Text for the dome name, which will appear in the title. legend_par: Legend parameters to be used for the dome Returns: dome_mesh: A colored mesh for the dome based on dome_data. dome_compass: A compass for the dome. dome_legend: A leend for the colored dome mesh. dome_title: A title for the dome. values: A list of radiation values that align with the dome_mesh faces. """ # create the dome mesh and ensure patch values align with mesh faces if len(dome_data) == 145: # tregenza sky lb_mesh = view_sphere.tregenza_dome_mesh_high_res.scale(radius) values = [] # high res dome has 3 x 3 faces per patch; we must convert tot_i = 0 # track the total number of patches converted for patch_i in view_sphere.TREGENZA_PATCHES_PER_ROW: row_vals = [] for val in dome_data[tot_i:tot_i + patch_i]: row_vals.extend([val] * 3) for i in range(3): values.extend(row_vals) tot_i += patch_i values = values + [dome_data[-1] ] * 18 # last patch has triangular faces else: #reinhart sky lb_mesh = view_sphere.reinhart_dome_mesh.scale(radius) values = dome_data + [dome_data[-1] ] * 11 # last patch has triangular faces # move and/or rotate the mesh as needed if north != 0: lb_mesh = lb_mesh.rotate_xy(math.radians(north), Point3D()) if center != Point3D(): lb_mesh = lb_mesh.move(Vector3D(center.x, center.y, center.z)) # project the mesh if requested if projection_ is not None: if projection_.title() == 'Orthographic': pts = (Compass.point3d_to_orthographic(pt) for pt in lb_mesh.vertices) elif projection_.title() == 'Stereographic': pts = (Compass.point3d_to_stereographic(pt, radius, center) for pt in lb_mesh.vertices) else: raise ValueError( 'Projection type "{}" is not recognized.'.format(projection_)) pts3d = tuple(Point3D(pt.x, pt.y, z) for pt in pts) lb_mesh = Mesh3D(pts3d, lb_mesh.faces) # output the dome visualization, including legend and compass move_fac = radius * 0.15 min_pt = lb_mesh.min.move(Vector3D(-move_fac, -move_fac, 0)) max_pt = lb_mesh.max.move(Vector3D(move_fac, move_fac, 0)) graphic = GraphicContainer(values, min_pt, max_pt, legend_par) graphic.legend_parameters.title = 'kWh/m2' lb_mesh.colors = graphic.value_colors dome_mesh = from_mesh3d(lb_mesh) dome_legend = legend_objects(graphic.legend) dome_compass = compass_objects( Compass(radius, Point2D(center.x, center.y), north), z, None, projection_, graphic.legend_parameters.font) # construct a title from the metadata st, end = metadata[2], metadata[3] time_str = '{} - {}'.format(st, end) if st != end else st title_txt = '{} Radiation\n{}\n{}'.format( dome_name, time_str, '\n'.join([dat for dat in metadata[4:]])) dome_title = text_objects(title_txt, graphic.lower_title_location, graphic.legend_parameters.text_height, graphic.legend_parameters.font) return dome_mesh, dome_compass, dome_legend, dome_title, values