Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 倾斜表面上辐射的太阳时间戳_R_Time Series - Fatal编程技术网

R 倾斜表面上辐射的太阳时间戳

R 倾斜表面上辐射的太阳时间戳,r,time-series,R,Time Series,我试图使用R软件包solaR来计算倾斜平面上的辐照度,给定水平面上的测量辐照度。我可以让代码工作,但最终的输出时间戳没有意义 可以找到此代码的数据。这是德克萨斯州奥斯汀一天的实测辐照度(全球水平——ghz、直接法线——dir、漫反射水平——dhz和室外温度ta)。时间戳是本地“CST6CDT”时间。数据是针对晴天的,因此全球水平线(ghz)的最大值应大致对应于太阳正午(太阳穿过当地子午线的时间) 我的代码如下: library(solaR) sol_data <- read.csv(fi

我试图使用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)
库(太阳能)

sol_data我已经用正确的方法测试了我计算机中的代码和数据 结果。让我们用一些图形重现主要步骤 产出:

因为您的数据属于晴天,并且此时间序列使用 平均太阳时,最大值应位于中午左右

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'))

我怀疑您的问题与中定义的时区有关 你的电脑。你能检查一下这些结果吗

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
lonHH(“美国/芝加哥”)
## [1] -1.570796
lonHH('CDT6CST')
## [1] -1.570796

idxLocal1非常感谢您的直接回复和出色的软件包。事实证明我们对太阳时间的解释是错误的。我看到一个不同的可能问题,它不适合评论部分

当我跑步时:

local2Solar(as.POSIXct("2013-07-07 13:36:00",tz="America/Chicago"),lon=-97.7428)
local2Solar(as.POSIXct("2013-06-07 13:30:00",tz="America/Chicago"),lon=-97.7428)
我得到了
“2013-07-07 12:05:01 UTC”
。据NOAA称,
“2013-07-07 13:36:00”
是当天的太阳正午

只是想弄糊涂,当我跑的时候:

local2Solar(as.POSIXct("2013-07-07 13:36:00",tz="America/Chicago"),lon=-97.7428)
local2Solar(as.POSIXct("2013-06-07 13:30:00",tz="America/Chicago"),lon=-97.7428)
我得到了
“2013-06-07 11:59:01 UTC”
,所以它看起来非常接近。据NOAA称,
“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”
。根据NOAA的说法,
“2013-01-07 12:37:27”
是当天的太阳正午


我分别运行了G.Master方程组和solaR方程组,得到了:
“2013-06-07 13:29:30 CDT”
(此版本的最高精度为每分钟一次)
“2013-06-07”上第一个案例的最大入射功率时间“

谢谢!我需要对上述代码进行一次编辑。在水平面或倾斜面上计算辐射之前,我认为z需要更改为Meteo对象:
z我认为我的主要问题是我们的代码偏离了
sol@user1813094
solaR
0.36在使用
calcG0
calcGef
之前不需要从
zoo
Meteo
的中间转换。使用CRAN提供的最新版本尝试此代码。
local2Solar(as.POSIXct("2013-07-07 13:36:00",tz="America/Chicago"),lon=-97.7428)
local2Solar(as.POSIXct("2013-06-07 13:30:00",tz="America/Chicago"),lon=-97.7428)
local2Solar(as.POSIXct("2013-01-07 12:37:27",tz="America/Chicago"),lon=-97.7428)