Пример #1
0
def test_init_compass():
    """Test the initialization of Compass and basic properties."""
    compass = Compass()

    str(compass)  # test the string representation
    hash(compass)  # test to be sure the compass is hash-able
    assert compass.radius == 100
    assert compass.center == Point2D()
    assert compass.north_angle == 0
    assert compass.north_vector == Vector2D(0, 1)
    assert compass.spacing_factor == 0.15
    assert compass.min_point.is_equivalent(Point2D(-115.0, -115.0), 0.01)
    assert compass.max_point.is_equivalent(Point2D(115.0, 115.0), 0.01)
    assert isinstance(compass.inner_boundary_circle, Arc2D)
    assert len(compass.all_boundary_circles) == 3
    for circ in compass.all_boundary_circles:
        assert isinstance(circ, Arc2D)
    assert len(compass.major_azimuth_points) == len(compass.MAJOR_AZIMUTHS)
    for pt in compass.major_azimuth_points:
        assert isinstance(pt, Point2D)
    assert len(compass.major_azimuth_ticks) == len(compass.MAJOR_AZIMUTHS)
    for lin in compass.major_azimuth_ticks:
        assert isinstance(lin, LineSegment2D)
    assert len(compass.minor_azimuth_points) == len(compass.MINOR_AZIMUTHS)
    for pt in compass.minor_azimuth_points:
        assert isinstance(pt, Point2D)
    assert len(compass.minor_azimuth_ticks) == len(compass.MINOR_AZIMUTHS)
    for lin in compass.minor_azimuth_ticks:
        assert isinstance(lin, LineSegment2D)
    assert isinstance(compass.min_point3d(), Point3D)
    assert isinstance(compass.max_point3d(), Point3D)
Пример #2
0
            # move the center point so sun paths are not on top of one another
            fac = i * radius * 3
            center_pt_i = Point2D(center_pt.x + fac, center_pt.y)
            center_pt3d_i = Point3D(center_pt3d.x + fac, center_pt3d.y,
                                    center_pt3d.z)

            # create the ladybug compass object
            lb_compass = Compass(radius, center_pt_i, north_)

            # create a graphic container to generate colors and legends
            n_data = data.filter_by_moys(
                moys)  # filter data collection by sun-up hours
            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)
Пример #3
0
        all_colors = []
        all_col_pts = []
        all_legends = []
        for i, data in enumerate(data_):
            # move the center point so sun paths are not on top of one another
            fac = i* radius * 3
            center_pt_i = Point2D(center_pt.x + fac, center_pt.y)
            center_pt3d_i = Point3D(center_pt3d.x + fac, center_pt3d.y, center_pt3d.z)

            # create the ladybug compass object
            lb_compass = Compass(radius, center_pt_i, north_)

            # create a graphic container to generate colors and legends
            n_data = data.filter_by_moys(moys)  # filter data collection by sun-up hours
            graphic = GraphicContainer(
                n_data.values, lb_compass.min_point3d(z), lb_compass.max_point3d(z),
                legend_par_, 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