Closed JoanViana closed 6 years ago
Hi,
I have reviewed your code and the data, but unfortunately I cannot find the cause of the problem. I suspect there is a problem with the time index of the data, but nowadays I have no time to prove it.
I have prepared code (extracted from help(calcG0)
) with a different data to show that solaR
is performing correctly. You may want to adapt it to your data in order to find the problem.
##NREL-MIDC
##La Ola, Lanai
##Latitude: 20.76685o North
##Longitude: 156.92291o West
##Elevation: 381 meters AMSL
##Time Zone: -10.0
latitud <- 20.77
longitud <- -156.94
NRELurl <- 'http://goo.gl/fFEBN'
dat <- read.table(NRELurl, header=TRUE, sep=',')
names(dat) <- c('date', 'hour', 'G0', 'B', 'D0', 'Ta')
##B is direct normal. We need direct horizontal.
dat$B0 <- dat$G0-dat$D0
##http://www.nrel.gov/midc/la_ola_lanai/instruments.html:
##The datalogger program runs using Greenwich Mean Time (GMT),
##data is converted to Hawaiin Standard Time (HST) after data collection
idxLocal <- with(dat, as.POSIXct(paste(date, hour), format='%m/%d/%Y %H:%M', tz='HST'))
idx <- local2Solar(idxLocal, lon=-156.9339)
NRELMeteo <- zoo(dat[,c('G0', 'D0', 'B0', 'Ta')], idx)
## Alpha and Beta combinations
M <- expand.grid(alfa = seq(-75, 75, 25),
beta = seq(0, 60, 15))
## Auxiliary function, a wrapper around calcGef
myFoo <- function(ab, datos)
{
cat(ab, '\n')
p <- calcGef(lat = latitud,
modeRad = 'bdI', dataRad = datos,
corr = 'BRL',
horizBright = FALSE,
alfa = ab[1], beta = ab[2])
## Return the aggregated value of calcGef
sum(as.data.frameD(p, complete = TRUE)$Gefd)/1000
}
## Apply the function to each combination of alpha/beta
M$Gef <- apply(M, 1, myFoo, datos = NRELMeteo)
levelplot(Gef/max(Gef) ~ alfa * beta, data = M,
contour = TRUE,
par.settings = custom.theme.2)
On the other hand, you should consider this simpler version of the funcion to read your data:
library("solaR")
readSIAR <- function(x)
{
datos <- read.csv2(x, fileEncoding = 'UTF-16LE')
datos <- datos[, c("Fecha", "HoraMin",
"Radiación..W.m2.", "Temp.Media..ºC.")]
tt <- with(datos,
as.POSIXct(paste0(
Fecha, ' ',
paste(HoraMin%/%100, HoraMin%%100, '00', sep = ':')),
format = '%d/%m/%Y %H:%M:%S'))
datos$time <- local2Solar(tt, longitud)
datos[, c("Fecha", "HoraMin")] <- NULL
names(datos) <- c("G0", "Ta", "time")
datos
}
pica02 <- readSIAR('/tmp/datos/V17_Picassent_01_01_2002_31_12_2002.csv')
xyplot(G0 ~ as.numeric(format(time, "%H%M"))/100 - 12, data = pica02, grid = TRUE)
meteo02 = dfI2Meteo(file = pica02,
lat = latitud,
time.col = 'time',
source = 'Picassent')
xyplot(meteo02, grid = TRUE)
I close this issue because there has been no answer after several months.
First of all, you will allow me to give thanks because your work is so useful for my thesis!
My problem: Using SIAR data and prodGCPV for multiple orientations (beta, alfa) i get a nice contour plot of the Surface Orientation Factor. However, it is always moved 30 degrees (two hours) to west: I attach my project (1MB) here: Controller (Main), data (SIAR), example plot and results in rData.
I suppose the error was in time data (solar, local, utc) but the hourly sumatory (for a year) is symetric and centered on 12:00. I used several SIAR stations and years taking into account:
Controller code: