我正在尝试使用 R 包solaR来计算倾斜平面上的辐照度,给定水平面上的测量辐照度。我可以让代码工作,但最终的输出时间戳没有意义。
可以在此处找到此代码的数据。这是德克萨斯州奥斯汀一天测量的辐照度(全球水平 - ghz、直接法线 - dir、漫射水平 - dhz 和室外温度 ta)。时间戳是本地“CST6CDT”时间。数据是晴天,所以全球水平(ghz)的最大值应该与太阳正午(太阳穿过当地子午线的时间)大致对应。
我的代码如下:
library(solaR)
sol_data <- read.csv(file)
# The data must be named a certain way.
names(sol_data) <- c('time', 'G0', 'B', 'D0', 'Ta')
# The negatives are an artifact of the sensor and are set to 0.
sol_data$G0 <- ifelse(sol_data$G0 < 0, 0, sol_data$G0)
sol_data$B <- ifelse(sol_data$B < 0, 0, sol_data$B)
sol_data$D0 <- ifelse(sol_data$D0 < 0, 0, sol_data$D0)
# This calculates the beam incidence on the horizontal plane.
sol_data$B0 <- sol_data$G0 - sol_data$D0
sol_data$B0 <- ifelse(sol_data$B0 < 0, 0, sol_data$B0)
# This takes the data and assigns the timestamp to a certain format and timezone
idxLocal <- with(sol_data, as.POSIXct(time, format='%Y-%m-%d %H:%M:%S', tz = 'CST6CDT'))
# This converts the timestamp to solar time
idx <- local2Solar(idxLocal, lon = -97.7428)
# Creates a zoo object needed to make the Meteo file for input
z <- zoo(sol_data[,c('G0', 'D0', 'B0', 'Ta')], idx)
# local latitude
lat = 30.2669
# Creates a Meteo file
My_Meteo <- zoo2Meteo(z, lat=lat)
# Finds the start and end date of the input file
start <- idx[1]
end <- idx[length(idx)]
# Returns a base time for the calculations
BTd <- fBTd(mode = 'serie', year = '2013', start = start, end = end, format = '%Y-%m-%d %H:%M:%S')
# Computes the movement of the sun/earth
sol <- calcSol(lat = 30.2669, BTd, sample = 'min')
# Creates a G0 file for solar rad on horizontal surface
compI <- calcG0(30.2669, modeRad = 'bdI', dataRad = My_Meteo, corr = 'none')
# creates the angles for calculation of the rad on a tilted surface
angGen <- fTheta(sol = sol, beta = 0, alfa = 0)
# Calculates the irradiance on a tilted surface
irad_tilt <- fInclin(compI, angGen)
当我使用 beta = 0, alfa = 0(平面)时,我应该得到与我的输入大致相同的输出。但是,当我搜索全局水平辐照度的最大值时:
x <- which.max(irad_tilt$G)
irad_tilt[x,]
我让它在 2013-05-05 10:43:01 返回最大值,我无法弄清楚这次是什么/为什么。不是当地时间,应该是13:24左右。当地太阳时应在 12:00 左右。UTC时间应该是18:24左右,UTC太阳时(如果有的话)应该是17:00...
我知道这很模糊,但有什么想法吗?