我试图使用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点左右。UTC时间应该在18:24左右,UTC的太阳时间(如果有这样的事情)应该是17:00.
我知道这很模糊,但是有什么想法吗?
发布于 2013-06-20 12:28:05
我已经用正确的结果测试了计算机中的代码和数据。让我们用一些图形输出再现主要步骤:
library(solaR)
sol_data <- read.csv('/tmp/one_day_WSL_8.csv')
## 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'))函数local2Solar将POSIXct对象的时区转换为平均太阳时间,并将其时区设置为UTC,作为平均太阳时间的同义词。它包括两个校正:位置和时区之间的经度差异和夏令时。
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)因为你的数据属于晴天,而这个时间序列使用的是平均太阳时间,所以最大值应该在中午左右。
xyplot(z, type=c('l', 'g'))

现在我们用calcSol计算太阳几何。这里我使用的是与你不同的代码。
## local latitude
lat = 30.2669
## Computes the movement of the sun/earth
sol <- calcSol(lat, BTi=idx)
xyplot(as.zooI(sol), type=c('l', 'g'))

接下来我们计算水平表面上的辐射。
g0 <- calcG0(lat, modeRad = 'bdI', dataRad = z, corr = 'none')
xyplot(as.zooI(g0), type=c('l', 'g'))

最后,利用calcGef,我们获得了倾斜表面的辐照度:
gef <- calcGef(lat=lat, modeRad='bdI', dataRad=z)
xyplot(as.zooI(gef), type=c('l', 'g'))

我怀疑您的问题与计算机中定义的时区有关。你能检查一下这些结果吗?
lonHH('America/Chicago')
## [1] -1.570796
lonHH('CDT6CST')
## [1] -1.570796
idxLocal1 <- as.POSIXct(sol_data$time, format='%Y-%m-%d %H:%M:%S', tz = 'CST6CDT')
idxLocal2 <- as.POSIXct(sol_data$time, format='%Y-%m-%d %H:%M:%S', tz = 'America/Chicago')
idxUTC1 <- as.POSIXct(format(idxLocal1, tz='UTC'), tz='UTC')
idxUTC2 <- as.POSIXct(format(idxLocal2, tz='UTC'), tz='UTC')
all.equal(idxUTC1, idxUTC2)
## [1] TRUE也许这些技术说明有助于提供关于这一主题的更多信息:
此外,您应该查看help(timezone)的信息和示例。
发布于 2013-06-20 16:52:45
非常感谢您的直接答复和伟大的一揽子。事实证明,我们对太阳时间的解释大错特错。我看到了另一个可能的问题,不适合在评论部分。
当我跑步时:
local2Solar(as.POSIXct("2013-07-07 13:36:00",tz="America/Chicago"),lon=-97.7428)我得到了"2013-07-07 12:05:01 UTC"。根据美国国家海洋和大气局的说法,"2013-07-07 13:36:00"是那天的正午。
只是为了混淆问题,当我跑步时:
local2Solar(as.POSIXct("2013-06-07 13:30:00",tz="America/Chicago"),lon=-97.7428)我得到了"2013-06-07 11:59:01 UTC",所以它看起来非常接近。根据美国国家海洋和大气局的说法,"2013-06-07 13:30:00"是那天的正午。
如果你要跑:
local2Solar(as.POSIXct("2013-01-07 12:37:27",tz="America/Chicago"),lon=-97.7428)你会得到"2013-01-07 12:06:28 UTC"。根据美国国家海洋和大气局的说法,"2013-01-07 12:37:27""是那天的正午。
我把G·马斯特方程和solaR分开运行,得到:"2013-06-07 13:29:30 CDT" (这个版本的最高精度是每分钟),在"2013-06-07"上的第一种情况下,最大的入射功率。
https://stackoverflow.com/questions/17197654
复制相似问题