Last active
December 19, 2015 05:19
-
-
Save oscarperpinan/5903278 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(solaR) | |
## Download data from NREL (see help(calcG0)) | |
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) | |
lat=20.77 | |
## Compute irradiance on a tilted plane | |
gefNREL <- calcGef(lat=lat, modeRad='bdI', dataRad=NRELMeteo, corr='none') | |
## Extract result as a "zoo" time series. Use complete to obtain all the variables | |
zNREL <- as.zooI(gefNREL, complete=TRUE, day=TRUE) | |
names(zNREL) | |
## [1] "w" "aman" "cosThzS" "AlS" "AzS" "Bo0" | |
## [7] "rd" "rg" "decl" "eo" "ws" "Bo0d" | |
## [13] "EoT" "G0d" "D0d" "B0d" "Fd" "Ktd" | |
## [19] "kt" "fd" "G0" "D0" "B0" "Ta" | |
## [25] "Beta" "Alfa" "cosTheta" "Bod" "Bnd" "Gd" | |
## [31] "Dd" "Bd" "Gefd" "Defd" "Befd" "Bo" | |
## [37] "Bn" "G" "D" "Di" "Dc" "B" | |
## [43] "R" "FTb" "FTd" "FTr" "Dief" "Dcef" | |
## [49] "Gef" "Def" "Bef" "Ref" | |
## Change the time index and use the local time | |
zNRELlocal <- zoo(zNREL, idxLocal) | |
xyplot(zNRELlocal[,c('Gef', 'G0', 'Bo0')], superpose=TRUE) | |
oneDay <- window(zNRELlocal, | |
start=as.POSIXct('2010-11-01'), | |
end=as.POSIXct('2010-11-01 23:59:59', tz='HST')) | |
## Display results: lattice will display the time index paying attention to the local time zone | |
Sys.setenv(TZ='HST') | |
xyplot(oneDay[,c('Gef', 'G0', 'Bo0')], superpose=TRUE) | |
Sys.setenv(TZ='UTC') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment