# NOT RUN {
# Create surface grid
grid = surfaceGrid(
obstacles = build[1, ],
obstacles_height_field = "BLDG_HT",
res = 2
)
solar_pos = tmy[, c("sun_az", "sun_elev")]
solar_pos = as.matrix(solar_pos)
# Summed 10-hour radiation estimates for two 3D points
rad1 = radiation(
grid = grid[1:2, ],
obstacles = build,
obstacles_height_field = "BLDG_HT",
solar_pos = solar_pos[8:17, , drop = FALSE],
solar_normal = tmy$solar_normal[8:17],
solar_diffuse = tmy$solar_diffuse[8:17],
returnList = TRUE
)
rad1
# }
# NOT RUN {
# Same, using 'time' instead of 'solar_pos'
rad2 = radiation(
grid = grid[1:2, ],
obstacles = build,
obstacles_height_field = "BLDG_HT",
time = as.POSIXct(tmy$time[8:17], tz = "Asia/Jerusalem"),
solar_normal = tmy$solar_normal[8:17],
solar_diffuse = tmy$solar_diffuse[8:17],
returnList = TRUE
)
rad2
# Differences due to the fact that 'tmy' data come with their own
# solar positions, not exactly matching those calulated using 'maptools::solarpos'
rad1$direct - rad2$direct
rad1$diffuse - rad2$diffuse
# }
# NOT RUN {
# }
# NOT RUN {
### Warning! The calculation below takes some time.
# Annual radiation estimates for entire surface of one building
rad = radiation(
grid = grid,
obstacles = build,
obstacles_height_field = "BLDG_HT",
solar_pos = solar_pos,
solar_normal = tmy$solar_normal,
solar_diffuse = tmy$solar_diffuse,
parallel = 3
)
# 3D plot of the results
library(plot3D)
opar = par(mfrow=c(1, 3))
scatter3D(
x = coordinates(grid)[, 1],
y = coordinates(grid)[, 2],
z = coordinates(grid)[, 3],
colvar = rad$direct / 1000,
scale = FALSE,
theta = 55,
pch = 20,
cex = 1.35,
clab = expression(paste("kWh / ", m^2)),
main = "Direct radiation"
)
scatter3D(
x = coordinates(grid)[, 1],
y = coordinates(grid)[, 2],
z = coordinates(grid)[, 3],
colvar = rad$diffuse / 1000,
scale = FALSE,
theta = 55,
pch = 20,
cex = 1.35,
clab = expression(paste("kWh / ", m^2)),
main = "Diffuse radiation"
)
scatter3D(
x = coordinates(grid)[, 1],
y = coordinates(grid)[, 2],
z = coordinates(grid)[, 3],
colvar = rad$total / 1000,
scale = FALSE,
theta = 55,
pch = 20,
cex = 1.35,
clab = expression(paste("kWh / ", m^2)),
main = "Total radiation"
)
par(opar)
# }
Run the code above in your browser using DataLab