create_amerifluxLBL_drivers_for_maat.Rmd
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), gapfilling the CF driver data, and converting to model-specific drivers for the MAAT model. These variables are defined in the PEcAn documentation.
In this example we will download 6 years of met data from the Willow Creek Eddy Covariance tower site (US-WCr). It has an Ameriflux SITE_ID
of US-WCr
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.
First make sure you have the nescessary PEcAn package for processing met data
devtools::install_github("pecanproject/pecan", ref = "develop", subdir = "modules/data.atmosphere")
library(knitr)
library(ggplot2)
library(ggthemes)
library(PEcAn.data.atmosphere)
bety <- list(user='bety', password='bety', host='localhost',
dbname='bety', driver='PostgreSQL',write=TRUE)
con <- PEcAn.DB::db.open(bety)
bety$con <- con
format.id <- 5000000002
format <- PEcAn.DB::query.format.vars(format.id=format.id,bety = bety)
format$time_zone <- "America/Chicago"
download.AmerifluxLBL(sitename = "US-WCr", outfolder = "~/scratch/met2model_testing",
start_date = "2000-01-01", end_date = "2005-12-31", overwrite = TRUE, verbose = TRUE)
met2CF.AmerifluxLBL(in.path = "~/scratch/met2model_testing/", in.prefix = "AMF_US-WCr", outfolder = "~/scratch/met2model_testing/CF/",
start_date = "2000-01-01", end_date = "2005-12-31",format=format)
metgapfill(in.path = "~/scratch/met2model_testing/CF/", in.prefix = "AMF_US-WCr_BASE_HH_14-5",
outfolder = "~/scratch/met2model_testing/CF/gapfill/", start_date = "2000-01-01", end_date = "2005-12-31")
in.path <- "~/scratch/met2model_testing/CF/gapfill/"
in.prefix <- "AMF_US-WCr_BASE_HH_14-5"
outfolder <- "~/scratch/met2model_testing/CF/gapfill/maat_drivers/"
start_date <- "2000-01-01"
end_date <- "2005-12-31"
overwrite <- TRUE
verbose <- TRUE
leap_year = TRUE
PEcAn.MAAT::met2model.MAAT(in.path, in.prefix, outfolder, start_date, end_date,
overwrite = overwrite, verbose = verbose)