예제 #1
0
파일: base.py 프로젝트: soreva/pvfactors
    def cut_at_point(self, point):
        """Cut PV segment at point if the segment contains it.

        Parameters
        ----------
        point : :py:class:`shapely.geometry.Point`
            Point where to cut collection geometry, if the latter contains the
            former
        """
        if contains(self, point):
            if contains(self._illum_collection, point):
                self._illum_collection.cut_at_point(point)
            else:
                self._shaded_collection.cut_at_point(point)
예제 #2
0
파일: base.py 프로젝트: soreva/pvfactors
    def cut_at_point(self, point):
        """Cut collection at point if the collection contains it.

        Parameters
        ----------
        point : :py:class:`shapely.geometry.Point`
            Point where to cut collection geometry, if the latter contains the
            former
        """
        for idx, surface in enumerate(self.list_surfaces):
            if contains(surface, point):
                # Make sure that not hitting a boundary
                b1, b2 = surface.boundary
                not_hitting_b1 = b1.distance(point) > DISTANCE_TOLERANCE
                not_hitting_b2 = b2.distance(point) > DISTANCE_TOLERANCE
                if not_hitting_b1 and not_hitting_b2:
                    coords_1 = [b1, point]
                    coords_2 = [point, b2]
                    # TODO: not sure what to do about index yet
                    new_surf_1 = PVSurface(coords_1,
                                           normal_vector=surface.n_vector,
                                           shaded=surface.shaded,
                                           param_names=surface.param_names)
                    new_surf_2 = PVSurface(coords_2,
                                           normal_vector=surface.n_vector,
                                           shaded=surface.shaded,
                                           param_names=surface.param_names)
                    # Now update collection
                    self.list_surfaces[idx] = new_surf_1
                    self.list_surfaces.append(new_surf_2)
                    self.update_geom_collection(self.list_surfaces)
                    # No need to continue the loop
                    break
예제 #3
0
파일: base.py 프로젝트: soreva/pvfactors
    def cut_at_point(self, point):
        """Cut Side at point if the side contains it.

        Parameters
        ----------
        point : :py:class:`shapely.geometry.Point`
            Point where to cut side geometry, if the latter contains the
            former
        """
        if contains(self, point):
            for segment in self.list_segments:
                # Nothing will happen to the segments that do not contain
                # the point
                segment.cut_at_point(point)
예제 #4
0
def test_orderedpvarray_almost_flat():
    """Making sure that things are correct when the pvarray is almost flat
    and the sun is very low, which means that the shadows on the ground, and
    the edge points will be outside of ground range (since not infinite)"""

    params = {
        'n_pvrows': 3,
        'pvrow_height': 2.5,
        'pvrow_width': 2.,
        'surface_azimuth': 90.,  # east oriented modules
        'axis_azimuth': 0.,  # axis of rotation towards North
        'surface_tilt': 0.01,  # almost flat
        'gcr': 0.4,
        'solar_zenith': 89.9,  # sun super low
        'solar_azimuth': 90.,  # sun located in the east
    }

    pvarray = OrderedPVArray.from_dict(params)
    pvarray.cast_shadows()
    pvarray.cuts_for_pvrow_view()
    view_matrix = pvarray.view_matrix

    ground_seg = pvarray.ground.list_segments[0]
    # there should be no visible shadow on the ground
    assert len(ground_seg.shaded_collection.list_surfaces) == 0
    # all of the edge points should be outside of range of ground geometry
    for edge_pt in pvarray.edge_points:
        assert not contains(pvarray.ground.original_linestring, edge_pt)

    # Check values of view matrix mask, to make sure that front does not
    # see the ground
    vm_mask = np.where(view_matrix > 0, 1, 0)
    expected_vm_mask = [
        [0, 0, 1, 0, 1, 0, 1, 1],  # ground
        [0, 0, 0, 0, 1, 0, 0, 1],  # front
        [1, 0, 0, 0, 0, 0, 0, 1],  # back
        [0, 0, 0, 0, 0, 0, 1, 1],  # front
        [1, 1, 0, 0, 0, 0, 0, 1],  # back
        [0, 0, 0, 0, 0, 0, 0, 1],  # front
        [1, 0, 0, 1, 0, 0, 0, 1],  # back
        [0, 0, 0, 0, 0, 0, 0, 0]
    ]
    np.testing.assert_array_equal(vm_mask, expected_vm_mask)
예제 #5
0
def test_contains_on_side():
    """Check that ``contains`` function works on a BaseSide instance"""
    coords = [(0, 0), (2, 0)]
    side = BaseSide.from_linestring_coords(coords)
    point = Point(1, 0)
    assert contains(side, point)