Exemple #1
0
    def as_flat(cls,
                x_min_max=None,
                shaded=False,
                y_ground=Y_GROUND,
                surface_params=[]):
        """Build a horizontal flat ground surface, made of 1 PV segment.

        Parameters
        ----------
        x_min_max : tuple, optional
            List of minimum and maximum x coordinates for the flat surface [m]
            (Default = None)
        shaded : bool, optional
            Shaded status of the created PV surfaces (Default = False)
        y_ground : float, optional
            Location of flat ground on y axis in [m] (Default = Y_GROUND)
        surface_params : list of str, optional
            Names of the surface parameters, eg reflectivity, total incident
            irradiance, temperature, etc. (Default = [])
        """
        # Get ground boundaries
        if x_min_max is None:
            x_min, x_max = MIN_X_GROUND, MAX_X_GROUND
        else:
            x_min, x_max = x_min_max
        # Create PV segment for flat ground
        coords = [(x_min, y_ground), (x_max, y_ground)]
        seg = PVSegment.from_linestring_coords(coords,
                                               shaded=shaded,
                                               normal_vector=[0., 1.],
                                               surface_params=surface_params)
        return cls(list_segments=[seg], original_linestring=LineString(coords))
Exemple #2
0
def test_cast_shadow_segment():
    """Test shadow casting on PVSegment"""
    seg = PVSegment.from_linestring_coords([(0, 0), (2, 0)],
                                           shaded=False,
                                           index=0)
    shadow = LineString([(0.5, 0), (1.5, 0)])
    seg.cast_shadow(shadow)

    assert seg.length == 2
    assert seg.shaded_length == 1
    assert seg.index == 0
Exemple #3
0
def test_cast_shadow_segment_precision_error():
    """Test shadow casting on PVSegment when using inexact projection.
    In shapely, need to use ``buffer`` method for the intersection to be
    calculated correctly
    """
    coords = [(0, 0), (3, 2)]
    seg = PVSegment.from_linestring_coords(coords, shaded=False, index=0)
    # Project point on line
    pt = Point(0, 2)
    line = seg.illum_collection.list_surfaces[0]  # LineString(coords)
    vector = [1, -1]
    proj = projection(pt, vector, line)
    # Use result of projection to create shadow
    shadow = LineString([Point(0, 0), proj])
    seg.cast_shadow(shadow)

    np.testing.assert_almost_equal(seg.length, 3.60555127546)
    np.testing.assert_almost_equal(seg.shaded_collection.length, 1.44222051019)
    assert len(seg.shaded_collection.list_surfaces) == 1
    assert len(seg.illum_collection.list_surfaces) == 1
    np.testing.assert_almost_equal(
        seg.shaded_collection.list_surfaces[0].length, 1.44222051019)
    np.testing.assert_almost_equal(
        seg.illum_collection.list_surfaces[0].length, 2.1633307652783933)