merge with solaR
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The version 0.22 of solaR includes a new method, mergesolaR. It is designed to merge daily time series of several solaR objects.
For example, we can obtain the daily irradiation of the whole set of meteorological stations of Madrid (Spain) and use this information to calculate the productivity of a grid connected PV system. It is possible to complete this process with the lapply function. Therefore, we obtain a list of ProdGCPV objects:
EstMadrid <- subset(RedEstaciones, NomProv=='Madrid') nEstMadrid <- nrow(EstMadrid) namesMadrid <- EstMadrid$NomEst prodMadrid <- lapply(1:nEstMadrid, function(x){try(prodGCPV(lat=41, modeRad='mapa', mapa=list(prov=28, est=x, start='01/01/2009', end='31/12/2010')) )}) names(prodMadrid) <- namesMadrid okMadrid <- lapply(prodMadrid, class)!='try-error' prodMadrid <- prodMadrid[okMadrid]
In order to prevent from the erroneous behaviour of some stations, the code includes the use of try.
Now it’s time for mergesolaR. Since we have a list of objects, do.call can solve the problem:
YfMadrid <- do.call(mergesolaR, prodMadrid)
The mergesolaR for a set of ProdGCPV objects merges the daily time series of the Yf variable of each object. The result is a multivariate zoo object which can be displayed (for example) with the horizonplot function.
Previously, the row mean is substracted from each column in order to show the deviation of each meteorological station from the daily mean of the set of stations.
horizonplot(YfMadrid-rowMeans(YfMadrid), origin=0, scales=list(y=list(relation='same')), colorkey=TRUE)
Besides, the function TargetDiagram is an alternative tool to show the behaviour of
the set of meteorological stations:
TargetDiagram(YfMadrid, end=as.POSIXct('2010-12-31'), ndays=c(10, 20, 30, 40, 50, 60))
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.