コード例 #1
0
def test_from_location():
    latitude = 37.815214
    longitude = -122.040010
    time_zone = -8
    location = Location(latitude=latitude,
                        longitude=longitude,
                        time_zone=time_zone)
    sky = CIE.from_location(location, 7, 4, 14.5)
    assert round(sky.altitude, 1) == 57.0
    assert round(sky.azimuth -
                 180) == 73  # ladybug's sun position is more accurate
    assert sky.ground_reflectance == 0.2
    sky_radiance = sky.to_radiance()
    assert '!gensky -ang 57.042579 72.808289 +s -g 0.200' in sky_radiance
    assert sky.ground_hemisphere.to_radiance() in sky_radiance
    assert sky.sky_hemisphere.to_radiance() in sky_radiance
try:
    from honeybee_radiance.lightsource.sky import CIE
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_radiance:\n\t{}'.format(e))

try:  # import ladybug_rhino dependencies
    from ladybug_rhino.grasshopper import all_required_inputs
    from ladybug_rhino.togeometry import to_vector2d
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

import math

if all_required_inputs(ghenv.Component):
    # process the north input
    north_ = north_ or 0
    try:  # it's a vector
        north_ = math.degrees(
            to_vector2d(north_).angle_clockwise(Vector2D(0, 1)))
    except AttributeError:  # north angle instead of vector
        north_ = float(north_)

    # set default values if they are not set
    _type_ = 0 if _type_ is None else _type_
    _month_ = 6 if _month_ is None else _month_
    _day_ = 21 if _day_ is None else _day_
    _hour_ = 12 if _hour_ is None else _hour_

    # create the sky object
    sky = CIE.from_location(_location, _month_, _day_, _hour_, _type_, north_)