The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
The CAMS radiation service provides time series of global, direct, and diffuse Irradiations on horizontal surface, and direct Irradiation on normal plane for the actual weather conditions as well as for clear-sky conditions. The data can be accessed manually on the CAMS radiation service site. The service is part of the Copernicus Atmosphere Monitoring Service (CAMS).
To access the CAMS radiation service you need to register at http://www.soda-pro.com/web-services/radiation/cams-radiation-service. The email you use at the registration step will be used for authentication, and need to be set with cams_set_user()
.
# Authentication
cams_set_user("your@email.com") # An email registered at soda-pro.com
cams_get_radiation()
and cams_get_radiation()
are convenience wrappers that retrieves CAMS solar data straight into a R data frame. The example bellow retrieves hourly radiation data for the location 60° latitude and 15° longitude for the period 2016-01-01 to 2016-01-15.
library(camsRad)
df <- cams_get_radiation(
lat=60, lng=15, # Latitude & longitude coordinates
date_begin="2016-07-01", date_end="2016-07-01", # Date range
time_step="PT01H") # Use hourly time step
As seen above the cams_get_radiation()
prints additional information about the data, these can be suppressed by wrapping the call with suppressMessages()
. Next the date frame is printed.
print(df)
The first column holds the timestamp information. It follows the convention of giving solar radiation as the sum during the previous hour. E.g. the timestamp of 14:00 shows the solar radiation during 13:00-14:00.
To use other data formats and to save data to the disk we need to use the cams_api()
. The example bellow writes daily solar radiation in netCDF format to the disk. You need to have the ncdf4
package installed.
library(ncdf4)
filename <- paste0(tempfile(), ".nc")
r <- cams_api(
60, 15, "2016-06-01", "2016-07-1", # Latitude/longitude and date range
format="application/x-netcdf", # specifies output format as netCDF
time_step = "P01D", # daily sum is specified
filename=filename)
# Access the on disk stored netCDF file
nc <- nc_open(r$response$content)
# List names of available variables
names(nc$var)
# Create data.frame with datetime and global horizontal irradiation
df <- data.frame(
timestamp = as.POSIXct(nc$dim$time$vals, "UTC", origin="1970-01-01"),
GHI = ncvar_get(nc, "GHI"))
df$timestamp <- df$timestamp-3600*24 # shift timestamp 24 hours backwards
nc_close(nc) # close connection
# And plot it
par(mar=c(4.5,4,0.8,1))
plot(df, type="b", ylab="GHI, Wh/m2,day", xlab="2016")
Note that the timestamp follows the convention of giving solar radiation as the sum during the previous time step. This is often correct when working with hourly data. But when working with daily (or monthly) data it is more common to have the timestamp at the starting point of summation. The df$timestamp-3600*24
part achieves this for daily data.
To get the data in csv or json format instead of netCDF, just change the format parameter to “application/csv” or “application/json” (and the filename extension to .csv or .json respectively).
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.