def test_bounds():
    """ Testing that the geometry bounds are calculated correctly """

    linestring = LineString([Point(0, 1), Point(1, 0)])
    registry = ArrayBase.initialize_line_registry()
    line_pvarray = LinePVArray(geometry=linestring,
                               line_type='ground',
                               shaded=True)
    _ = registry.pvgeometry.add([line_pvarray])
    assert registry.pvgeometry.bounds.values[0].tolist() == [0., 0., 1., 1.]
def test_add_linepvarray_to_registry():
    """ Testing that the lines are added correctly to the registry """

    linestring = LineString([Point(0, 1), Point(1, 0)])
    registry = ArrayBase.initialize_line_registry()
    line_pvarray = LinePVArray(geometry=linestring,
                               line_type='ground',
                               shaded=True)
    _ = registry.pvgeometry.add([line_pvarray])

    assert registry.geometry.values[0] == linestring
def test_split_ground_geometry_from_edge_points():
    """ Testing that the geometry bounds are calculated correctly """

    linestring = LineString([Point(0, 0), Point(2, 0)])
    registry = ArrayBase.initialize_line_registry()
    line_pvarray = LinePVArray(geometry=linestring,
                               line_type='ground',
                               shaded=True)
    _ = registry.pvgeometry.add([line_pvarray])

    list_edge_points = [Point(1, 0)]
    registry.pvgeometry.split_ground_geometry_from_edge_points(
        list_edge_points)

    assert (registry.geometry.values[0] == LineString([(0, 0), (1, 0)]))
    assert (registry.geometry.values[1] == LineString([(1, 0), (2, 0)]))
def test_split_pvrow_geomtry():
    """ Testing that the pvrow geometry is split up correctly by line """

    linestring = LineString([Point(0, 0), Point(2, 2)])
    registry = ArrayBase.initialize_line_registry()
    line_pvarray = LinePVArray(geometry=linestring,
                               line_type='pvrow',
                               shaded=True)
    _ = registry.pvgeometry.add([line_pvarray])

    linestring_shadow = LineString([Point(0, 2), Point(2, 0)])

    # Split pvrow using shadow linestring
    registry.pvgeometry.split_pvrow_geometry(0, linestring_shadow, Point(2, 2))

    assert registry.geometry.values[0] == LineString([(1, 1), (2, 2)])
    assert registry.geometry.values[1] == LineString([(0, 0), (1, 1)])
Exemple #5
0
    def create_lines(self, tilt, index):
        """
        Create the :class:`pvcore.LinePVArray` objects that the PV row
        is made out of, based on the inputted geometrical parameters.

        :param float tilt: tilt angle of the PV row [deg]
        :param int index: PV row index, used to distinguish different PV rows
        :return: [line_pvarray], highest_point, lowest_point,
                right_point, left_point, director_vector, normal_vector // which
                are: list of :class:`pvcore.LinePVArray`;
                :class:`shapely.Point` of the line with biggest y coordinate;
                :class:`shapely.Point` of the line with smallest y coordinate;
                :class:`shapely.Point` of the line with biggest x coordinate;
                :class:`shapely.Point` of the line with smallest x coordinate;
                list of 2 coordinates for director vector of the line; list of
                2 coordinates for normal vector of the line
        """
        tilt_rad = np.radians(tilt)

        # Create the three trackers
        radius = self.width / 2.
        x1 = radius * np.cos(tilt_rad + np.pi) + self.x_center
        y1 = radius * np.sin(tilt_rad + np.pi) + self.y_center
        x2 = radius * np.cos(tilt_rad) + self.x_center
        y2 = radius * np.sin(tilt_rad) + self.y_center

        highest_point = Point(x2, y2) if y2 >= y1 else Point(x1, y1)
        lowest_point = Point(x1, y1) if y2 >= y1 else Point(x2, y2)
        right_point = Point(x2, y2) if x2 >= x1 else Point(x1, y1)
        left_point = Point(x1, y1) if x2 >= x1 else Point(x2, y2)

        # making sure director_vector[0] >= 0
        director_vector = [x2 - x1, y2 - y1]
        # making sure normal_vector[1] >= 0
        normal_vector = [-director_vector[1], director_vector[0]]
        geometry = LineString([(x1, y1), (x2, y2)])
        line_pvarray = LinePVArray(geometry=geometry,
                                   line_type='pvrow',
                                   shaded=False,
                                   pvrow_index=index)
        return ([line_pvarray], highest_point, lowest_point, right_point,
                left_point, director_vector, normal_vector)
def test_cut_pvrow_geometry():
    """ Testing that the pvrow geometry is discretized as expected """

    linestring = LineString([Point(0, 0), Point(2, 2)])
    registry = ArrayBase.initialize_line_registry()
    line_pvarray = LinePVArray(geometry=linestring,
                               line_type='pvrow',
                               shaded=True)
    _ = registry.pvgeometry.add([line_pvarray])
    registry['surface_side'] = 'front'
    registry['pvrow_index'] = 0

    list_points = [Point(1, 1)]
    pvrow_index = 0
    side = 'front'

    registry.pvgeometry.cut_pvrow_geometry(list_points, pvrow_index, side)

    assert registry.geometry.values[1] == LineString([(1, 1), (2, 2)])
    assert registry.geometry.values[0] == LineString([(0, 0), (1, 1)])
Exemple #7
0
    def create_lines(self, tilt, index):
        """
        Create the :class:`pvcore.LinePVArray` objects that the PV row
        is made out of, based on the inputted geometrical parameters.

        :param float tilt: Surface tilt angles in decimal degrees.
            surface_tilt must be >=0 and <=180.
            The tilt angle is defined as degrees from horizontal
        :param int index: PV row index, used to distinguish different PV rows
        :return: [line_pvarray], highest_point, lowest_point,
                right_point, left_point / which
                are: list of :class:`pvcore.LinePVArray`;
                :class:`shapely.Point` of the line with biggest y coordinate;
                :class:`shapely.Point` of the line with smallest y coordinate;
                :class:`shapely.Point` of the line with biggest x coordinate;
                :class:`shapely.Point` of the line with smallest x coordinate
        """
        tilt_rad = np.radians(tilt)

        # Create the three trackers
        radius = self.width / 2.
        x1 = radius * np.cos(tilt_rad + np.pi) + self.x_center
        y1 = radius * np.sin(tilt_rad + np.pi) + self.y_center
        x2 = radius * np.cos(tilt_rad) + self.x_center
        y2 = radius * np.sin(tilt_rad) + self.y_center

        highest_point = Point(x2, y2)
        lowest_point = Point(x1, y1)
        right_point = Point(x2, y2) if x2 >= x1 else Point(x1, y1)
        left_point = Point(x1, y1) if x2 >= x1 else Point(x2, y2)

        geometry = LineString([(x1, y1), (x2, y2)])
        line_pvarray = LinePVArray(geometry=geometry,
                                   line_type='pvrow',
                                   shaded=False,
                                   pvrow_index=index)
        return ([line_pvarray], highest_point, lowest_point, right_point,
                left_point)