library('pacman') p_load('ggplot2') p_load('solaR') p_load('stringr') p_load('lubridate') sol = readRDS(file="sol.Rda") irradiance <- function(lat,alfa) { g = calcGef( lat, # latitude argument modeTrk='fixed', # does not track the sun modeRad='bdI', # daily irradiance dfI2Meteo(sol, time.col = 'timestamp', lat=lat, format='%Y-%m-%d %H:%M:%S'), keep.night=TRUE, sunGeometry='michalsky', beta=90, alfa=alfa, corr='none', iS=2, alb=0.0) g = as.data.frameI(g)[c('Gef')] g =tail(head(g,n=6000),n=24) g = data.frame(time=as.numeric(ymd_hms(rownames(g))),G=g$Gef, Z = paste("g",abs(alfa),sep="")) assign(paste("g",abs(alfa), sep=""), g, envir= .GlobalEnv) } R = c(-138,-48,42,132) L = c(1,1) H = 2.5 A = L*H G = c(0.5,0.5) for (i in R){ irradiance(i) } #rm(sol) #df = cbind(names(which(unlist(eapply(.GlobalEnv,is.data.frame))))) gval=0.92 g138$G=g138$G*35*gval g48$G=g48$G*15*gval g42$G=g42$G*21*gval g132$G=g132$G*15*gval df = rbind(g138,g48,g42,g132) pdf('stack3.pdf') ggplot(df, aes(x = time, y = G, fill = Z,)) + geom_area(position = 'stack') #xlim(1486960000, 1486971200) dev.off() #df2 = df*A*G #df2$time = as.numeric(ymd_hms(rownames(df2))) #df2$time = as.numeric(df2$time)