This is a demonstration of the PEcAn utilities for downloading met data, converting it to the PEcAn-CF format (which is based on the Climate Forecasting conventions and similar to MsTMIP). These variables are defined in the PEcAn documentation.
In this example we will download 12 years of met data from the Bondville
Ameriflux site. It has an Ameriflux SITE_ID
of
US-Bo1
The PEcAn.data.atmosphere source code is in modules/data.atmosphere
and the documentation can be found with either
package?PEcAn.data.atmosphere
or in the data.atmosphere
package documentation.
NB: this is not required within PEcAn; used here for convenience. See
documentation for NCO
ncrcat
function.
Using the load.cfmet
convenience function. Ameriflux is
provided at 30 min intervals. If needed at a finer resolution, see
?cfmet.downscale.time
(which works with subdaily and daily
data). There is no cfmet.upscale.time
function, but would
be straightforward to implement if needed.
bondville.nc <- nc_open("/tmp/out/US-Bo11996-2008.nc")
bondville.cfmet <- load.cfmet(bondville.nc, lat = 40.0061988830566, lon = -88.290397644043, start.date = "1996-08-25", end.date = "2008-04-10")[!is.na(air_pressure)]
theme_set(theme_tufte())
p1 <- ggplot() + geom_line(data = bondville.cfmet, aes(x = date, y = surface_downwelling_shortwave_flux_in_air)) + ylab(paste(bondville.nc$var$surface_downwelling_shortwave_flux_in_air$longname, bondville.nc$var$surface_downwelling_shortwave_flux_in_air$units))
p2 <- ggplot() + geom_line(data = bondville.cfmet, aes(x = date, y = surface_downwelling_longwave_flux_in_air)) +
ylab(paste(bondville.nc$var$surface_downwelling_longwave_flux_in_air$longname, bondville.nc$var$surface_downwelling_longwave_flux_in_air$units))
p3 <- ggplot() + geom_line(data = bondville.cfmet, aes(x = date, y = surface_downwelling_photosynthetic_photon_flux_in_air)) + ylab("PAR umol/m2/s")
p4 <- ggplot() + geom_line(data = bondville.cfmet, aes(x = date, y = air_pressure)) +
ylab(paste(bondville.nc$var$air_pressure$longname, bondville.nc$var$air_pressure$units))
p5 <- ggplot() + geom_line(data = bondville.cfmet, aes(x = date, y = air_temperature )) +
ylab(paste(bondville.nc$var$air_temperature$longname, bondville.nc$var$air_temperature$units))
p6 <- ggplot(data = bondville.cfmet, aes(x = date)) +
geom_line(aes(y = wind_speed)) +
#geom_line(aes(y = northward_wind), color = 'blue', alpha = 0.3) +
#geom_line(aes(y = eastward_wind), color = 'red', alpha = 0.3) +
#ggtitle("wind speed: scalar (black) north vector (blue) and east vector (red) ") +
ylab(paste(bondville.nc$var$wind_speed$longname, bondville.nc$var$wind_speed$units))
p7 <- ggplot() + geom_line(data = bondville.cfmet, aes(x = date, y = relative_humidity )) +
ylab(paste(bondville.nc$var$relative_humidity$longname, bondville.nc$var$relative_humidity$units))
p8 <- ggplot() + geom_line(data = bondville.cfmet, aes(x = date, y = specific_humidity )) +
ylab(paste(bondville.nc$var$specific_humidity$longname, bondville.nc$var$specific_humidity$units))
p9 <- ggplot() + geom_line(data = bondville.cfmet, aes(x = date, y = precipitation_flux)) +
ylab(paste(bondville.nc$var$ precipitation_flux$longname, bondville.nc$var$precipitation_flux$units))
plots <- list(p1, p2, p3, p4, p5, p6, p7, p8, p9)
To use the data, you can convert these to a model specific format