src.functions.SOLWEIGpython.UTIL¶
functions.SOLWEIGpython.UTIL.Perez_v3¶
- src.functions.SOLWEIGpython.UTIL.Perez_v3.Perez_v3(zen, azimuth, radD, radI, jday, patchchoice, patch_option)[source]¶
This unchanged function calculates distribution of luminance on the skyvault based on Perez luminince distribution model.
Created by: Fredrik Lindberg 20120527, fredrikl@gvc.gu.se Gothenburg University, Sweden Urban Climte Group
- Inputs:
zen: Zenith angle of the Sun (in degrees) azimuth: Azimuth angle of the Sun (in degrees) radD: Horizontal diffuse radiation (W m-2) radI: Direct radiation perpendicular to the Sun beam (W m-2) jday: Day of year
- Returns:
lv – Relative luminance map (same dimensions as theta. gamma)
- Return type:
np.array
functions.SOLWEIGpython.UTIL.Solweig_v2015_metdata_noload¶
- src.functions.SOLWEIGpython.UTIL.Solweig_v2015_metdata_noload.Solweig_2015a_metdata_noload(inputdata, location, UTC)[source]¶
This function is used to process the input meteorological file. It also calculates Sun position based on the time specified in the met-file
- Parameters:
inputdata
location
UTC
functions.SOLWEIGpython.UTIL.clearnessindex_2013b¶
- src.functions.SOLWEIGpython.UTIL.clearnessindex_2013b.clearnessindex_2013b(zen, jday, Ta, RH, radG, location, P)[source]¶
Unchanged function: Clearness Index at the Earth’s surface calculated from Crawford and Duchon 1999
- Parameters:
zen – zenith angle in radians
jday – day of year
Ta – air temperature
RH – relative humidity
radG – global shortwave radiation
location – distionary including lat, lon and alt
P – pressure
functions.SOLWEIGpython.UTIL.create_patches¶
- src.functions.SOLWEIGpython.UTIL.create_patches.create_patches(patch_option)[source]¶
Unchanged function generating a discretized sky vault with altitude and azimuth angles corresponding to a specific patch configuration. Patch configurations divide the hemisphere into discrete sky segments (patches) according to different established or experimental schemes.
- Input:
- patch_option (int):
- Patch discretization scheme:
1: 145 patches (Robinson & Stone, 2004 based on Tregenza, 1987)
2: 153 patches (Wallenberg et al., 2022 modification)
3: 306 patches (experimental: doubling patch count of option 2)
4: 612 patches (experimental: finer resolution using 15 annuli)
- Returns:
skyvaultalt (np.ndarray) – 1D array of patch center altitudes (in degrees).
skyvaultazi (np.ndarray) – 1D array of patch center azimuths (in degrees).
annulino (np.ndarray) – Altitude angles (in degrees) marking the annular boundaries from zenith to horizon.
skyvaultaltint (np.ndarray) – Altitude angles (in degrees) for patch center positions in each annulus.
patches_in_band (np.ndarray) – Number of azimuthal patches per annular band.
skyvaultaziint (np.ndarray) – Angular width of each patch in azimuth (degrees).
azistart (np.ndarray) – Azimuth offset for each band, used to rotate starting position to avoid patch alignment across bands.
functions.SOLWEIGpython.UTIL.diffusefraction¶
- src.functions.SOLWEIGpython.UTIL.diffusefraction.diffusefraction(radG, altitude, Kt, Ta, RH)[source]¶
Unchanged function: Estimate diffuse and direct beam solar radiation using the Reindl et al. (1990) model.
- Parameters:
radG (float) – Global horizontal irradiance [W/m²].
altitude (float) – Solar altitude angle [degrees].
Kt (float) – Clearness index (ratio of global radiation at surface to that at the top of atmosphere).
Ta (float) – Air temperature [°C].
RH (float) – Relative humidity [%].
- Returns:
radI (float) – Direct beam radiation [W/m²].
radD (float) – Diffuse radiation [W/m²].
functions.SOLWEIGpython.UTIL.shadowingfunction_wallheight_13_cupy¶
- src.functions.SOLWEIGpython.UTIL.shadowingfunction_wallheight_13_cupy.shadowingfunction_wallheight_13(amaxvalue, a, azimuth, altitude, scale, walls, aspect)[source]¶
Computes shadow masks for buildings on a terrain, and shadow height for on building walls, using a stepped projection method, based on sun position (azimuth, altitude) and elevation data. This is a CuPy-accelerated version optimized for GPU use.
The function simulates shadow casting by iteratively stepping through the DSM grid along the direction of the sun, lowering the sun’s ray with each step, and comparing it to terrain heights to determine shadowed pixels.
- Parameters:
a (cp.ndarray) – DSM.
azimuth (float) – Sun azimuth in degrees (clockwise from north).
altitude (float) – Sun altitude in degrees (0° = horizon, 90° = zenith).
scale (float) – Scale factor (pixel size in meters)
amaxvalue (float) – Maximum vertical height to simulate in the shadow projection.
walls (cp.ndarray) – DSM layer representing wall heights [m].
aspect (cp.ndarray) – Aspect (orientation) of building walls [radians].
- Returns:
sh (cp.ndarray) – Shadow map of ground and roof (1 = shadow, 0 = sunlit).
wallsh (cp.ndarray) – Shadow height on walls [m].
wallsun (cp.ndarray) – Sunlit height of walls [m].
facesh (cp.ndarray) – Shadow mask from wall self-shadowing (1 = shadow, 0 = sunlit).
facesun (cp.ndarray) – Sunlit mask of walls (1 = sunlit, 0 = shadow).
- src.functions.SOLWEIGpython.UTIL.shadowingfunction_wallheight_13_cupy.shadowingfunction_wallheight_13_3d(amaxvalue, a, azimuth, altitude, scale, walls, aspect)[source]¶
Computes 3D building shadows based on sun position using stepped projection.
This CuPy-accelerated method calculates shadow masks from a layered DSM (building & gap heights), and calculates shadow height for on building walls. It simulates how shadows are cast given sun azimuth and altitude. Works on a 3D stack of DSM layers.
- Parameters:
a (cp.ndarray) – 3D Layered DSM.
azimuth (float) – Sun azimuth in degrees (clockwise from north).
altitude (float) – Sun altitude in degrees (0° = horizon, 90° = zenith).
scale (float) – Scale factor (pixel size in meters)
amaxvalue (float) – Maximum vertical height to simulate in the shadow projection.
walls (cp.ndarray) – DSM layer representing wall heights at base layer [m].
aspect (cp.ndarray) – Aspect (orientation) of building walls at base layer[radians].
- Returns:
sh (cp.ndarray) – Shadow map of ground and roof at base layer (1 = shadow, 0 = sunlit).
wallsh (cp.ndarray) – Shadow height on walls at base layer [m].
wallsun (cp.ndarray) – Sunlit height of walls at base layer [m].
facesh (cp.ndarray) – Shadow mask from wall self-shadowing at base layer (1 = shadow, 0 = sunlit).
facesun (cp.ndarray) – Sunlit mask of walls at base layer (1 = sunlit, 0 = shadow).
functions.SOLWEIGpython.UTIL.shadowingfunction_wallheight_23_cupy¶
- src.functions.SOLWEIGpython.UTIL.shadowingfunction_wallheight_23_cupy.shadowingfunction_23_3d(a, vegdem, vegdem2, azimuth, altitude, scale, amaxvalue, bush, walls, aspect)[source]¶
Computes 3D building shadows and Vegetation shadows based on sun position using stepped projection. This CuPy-accelerated method calculates shadow masks from a layered DSM (building & gap heights) & a CHM, and calculates shadow height for on building walls. It simulates how shadows are cast given sun azimuth and altitude. Works on a 3D stack of DSM layers.
- Parameters:
a (cp.ndarray) – 3D Layered DSM.
vegdem (cp.ndarray) – Vegetation height layer (CHM).
vegdem2 (cp.ndarray) – Secondary vegetation height layer (trunk heights).
azimuth (float) – Sun azimuth in degrees (clockwise from north).
altitude (float) – Sun altitude in degrees (0° = horizon, 90° = zenith).
scale (float) – Scale factor (pixel size in meters)
amaxvalue (float) – Maximum vertical height to simulate in the shadow projection.
bush (cp.ndarray) – Bush indicator array (values > 1 indicate presence).
walls (cp.ndarray) – DSM layer representing wall heights [m].
aspect (cp.ndarray) – Aspect (orientation) of building walls [radians].
- Returns:
vegsh (cp.ndarray) – Vegetation shadow mask (1 = sunlit, 0 = shadow).
sh (cp.ndarray) – Shadow map of ground and roof (1 = shadow, 0 = sunlit).
wallsh (cp.ndarray) – Shadow height on walls [m].
wallshve (cp.ndarray) – Additional wall shadowing caused by vegetation [m].
wallsun (cp.ndarray) – Sunlit height of walls [m].
facesh (cp.ndarray) – Shadow mask from wall self-shadowing (1 = shadow, 0 = sunlit).
facesun (cp.ndarray) – Sunlit mask of walls (1 = sunlit, 0 = shadow).
- src.functions.SOLWEIGpython.UTIL.shadowingfunction_wallheight_23_cupy.shadowingfunction_wallheight_23(a, vegdem, vegdem2, azimuth, altitude, scale, amaxvalue, bush, walls, aspect)[source]¶
Computes shadow masks for buildings and vegetation on a terrain, and shadow height on building walls, using a stepped projection method, based on sun position (azimuth, altitude) and elevation data. This is a CuPy-accelerated version optimized for GPU use.
The function simulates shadow casting by iteratively stepping through the DSM and CHM along the direction of the sun, lowering the sun’s ray with each step, and comparing it to terrain heights to determine shadowed pixels.
- Parameters:
a (cp.ndarray) – DSM.
vegdem (cp.ndarray) – Vegetation height layer (CHM).
vegdem2 (cp.ndarray) – Secondary vegetation height layer (trunk heights).
azimuth (float) – Sun azimuth in degrees (clockwise from north).
altitude (float) – Sun altitude in degrees (0° = horizon, 90° = zenith).
scale (float) – Scale factor (pixel size in meters)
amaxvalue (float) – Maximum vertical height to simulate in the shadow projection.
bush (cp.ndarray) – Bush indicator array (values > 1 indicate presence).
walls (cp.ndarray) – DSM layer representing wall heights [m].
aspect (cp.ndarray) – Aspect (orientation) of building walls [radians].
- Returns:
vegsh (cp.ndarray) – Vegetation shadow mask (1 = sunlit, 0 = shadow).
sh (cp.ndarray) – Shadow map of ground and roof (1 = shadow, 0 = sunlit).
wallsh (cp.ndarray) – Shadow height on walls [m].
wallshve (cp.ndarray) – Additional wall shadowing caused by vegetation [m].
wallsun (cp.ndarray) – Sunlit height of walls [m].
facesh (cp.ndarray) – Shadow mask from wall self-shadowing (1 = shadow, 0 = sunlit).
facesun (cp.ndarray) – Sunlit mask of walls (1 = sunlit, 0 = shadow).