Ejemplo n.º 1
0
def test_sun_sky_sources():
    sun, sky = sun_sky_sources(model='blended')
    sun, sky = sun_sky_sources(model='sun_soc')
    sun, sky = sun_sky_sources(model='blended', normalisation=1)
    numpy.testing.assert_almost_equal(sun[2].sum() + sky[2].sum(), 1)
    assert sun[2].sum() > 0.75
    sun, sky = sun_sky_sources(model='blended',
                               normalisation=1,
                               attenuation=0.2)
    assert sky[2].sum() > 0.99
Ejemplo n.º 2
0
def illuminate(g, isolated=True, density=9, clear_sky=False, daydate=_daydate, longitude=_longitude, latitude=_latitude,
               altitude=_altitude, timezone=_timezone):
    """ Illuminate a plant
    Args:
        isolated : is the plant isolated or within a canopy ?
        clear_sky: use clear_sky (homogeneous sky is used otherwise)
        irradiance: (float) sum of horizontal irradiance of all sources. If None
         diffuse horizontal clear_sky irradiance are used for clear_sky type and
          20% attenuated clear_sky global horizontal irradiances are used for
          soc and uoc types.
        dates: A pandas datetime index (as generated by pandas.date_range). If
            None, hourly values for daydate are used.
        daydate: (str) yyyy-mm-dd (not used if dates is not None).
        longitude: (float) in degrees
        latitude: (float) in degrees
        altitude: (float) in meter
        timezone:(str) the time zone (not used if dates are already localised)

    Returns:
        elevation (degrees), azimuth (degrees, from North positive clockwise),
        and horizontal irradiance of sources
    """
    if not clear_sky:
        light = light_sources(*sky_sources())
    else:
        sun, sky = sun_sky_sources(daydate=daydate, longitude=longitude, latitude=latitude, altitude=altitude,
                                   timezone=timezone, normalisation=1)
        light = light_sources(*sun) + light_sources(*sky)
    inter_row = 80
    inter_plant = 1. / density / (inter_row / 100.) * 100
    pattern = (-0.5 * inter_row, -0.5 * inter_plant,
               0.5 * inter_row, 0.5 * inter_plant)
    cs = CaribuScene(g, light=light, pattern=pattern, scene_unit='cm')
    raw, agg = cs.run(direct=True, simplify=True, infinite=not isolated)
    return cs, raw, agg
Ejemplo n.º 3
0
def test_twilight():
    sun, sky = sun_sky_sources(ghi=1.0,
                               dates=pandas.Timestamp(
                                   '2017-08-17 19:00:00+0400',
                                   tz='Indian/Reunion'),
                               latitude=-21.32,
                               longitude=55.5,
                               timezone='Indian/Reunion')
    el, az, irr = sun
    assert len(irr) == 0
    el, az, irr = sky
    numpy.testing.assert_almost_equal(1, irr.sum())