def from_lat_long( cls, latitude, longitude, time_zone, month, day, hour, sky_type=0, north_angle=0, ground_reflectance=0.2): """Create sky with certain illuminance. Args: latitude: Location latitude between -90 and 90. longitude:Location longitude between -180 (west) and 180 (east). timezone: Time zone between -12 hours (west) and +14 hours (east). month: An intger between 1-12 for month. day: An intger between 1 to 28-31 depending on the input month. hour: A float number larger or equal to 0 and smaller than 24. sky_type: An integer between 0..5 to indicate CIE Sky Type. * 0 = Sunny with sun. Sunny sky with sun. In addition to the sky distribution function, a source description of the sun is generated. * 1 = Sunny without sun. Sunny sky without sun. The sky distribution will correspond to a standard CIE clear day. * 2 = Intermediate with sun. In addition to the sky distribution, a (somewhat subdued) sun is generated. * 3 = Intermediate without sun. The sky will correspond to a standard CIE intermediate day. * 4 = Cloudy sky. The sky distribution will correspond to a standard CIE overcast day. * 5 = Uniform cloudy sky. The sky distribution will be completely uniform. north_angle: North angle in degrees. A number between -360 and 360 for the counterclockwise difference between the North and the positive Y-axis in degrees. 90 is West and 270 is East (Default: 0). ground_reflectance: Average ground reflectance (Default: 0.2). """ # calculate altitude and azimuth using ladybug's sunpath sp = Sunpath(latitude, longitude, time_zone, north_angle) sun = sp.calculate_sun(month, day, hour) return cls(sun.altitude, sun.azimuth_from_y_axis, sky_type, ground_reflectance)
def from_lat_long(cls, latitude, longitude, time_zone, month, day, hour, direct_normal_irradiance, diffuse_horizontal_irradiance, north_angle=0, ground_reflectance=0.2): """Create sky with certain illuminance. Args: latitude: Location latitude between -90 and 90. longitude: Location longitude between -180 (west) and 180 (east). time_zone: Time zone between -12 hours (west) and +14 hours (east). If None, the time will be interpreted as solar time at the given longitude. month: An intger between 1-12 for month. day: An intger between 1 to 28-31 depending on the input month. hour: A float number larger or equal to 0 and smaller than 24. direct_normal_irradiance: Direct normal irradiance (W/m2). diffuse_horizontal_irradiance: Diffuse horizontal irradiance (W/m2). north_angle: North angle in degrees. A number between -360 and 360 for the counterclockwise difference between the North and the positive Y-axis in degrees. 90 is West and 270 is East (Default: 0). ground_reflectance: Average ground reflectance (Default: 0.2). """ # calculate altitude and azimuth using ladybug's sunpath sp = Sunpath(latitude, longitude, time_zone, north_angle) sun = sp.calculate_sun(month, day, hour) return cls(sun.altitude, sun.azimuth_from_y_axis, direct_normal_irradiance, diffuse_horizontal_irradiance, ground_reflectance)
def test_init_solar_envelope(): """Test the initialization of Sunpath and basic properties.""" # get sun positions sunpath = Sunpath(latitude=40.72, longitude=-74.02) sun_vecs = [] for hour in range(8, 16): sun = sunpath.calculate_sun(12, 21, hour) sun_vecs.append(sun.sun_vector) # load the site and the context site_mesh_file = './tests/assets/geo/mesh.json' with open(site_mesh_file) as json_file: site_mesh_data = json.load(json_file) site_mesh = Mesh3D.from_dict(site_mesh_data) context_file = './tests/assets/geo/faces.json' with open(context_file) as json_file: context_data = json.load(json_file) context_faces = [Face3D.from_dict(con) for con in context_data] # initialize solar envelope envelope = SolarEnvelope(site_mesh, context_faces, sun_vecs, solar_rights=True) str(envelope) # test the string representation envelope_mesh = envelope.envelope_mesh() assert isinstance(envelope_mesh, Mesh3D)