Load the package. This contains all the necessary wrapper functions to set up and run SOFUN and read its output.
library(rsofun)
library(dplyr)
library(readr)
library(purrr)
library(lubridate)
Specify the data read from FLUXNET2015 files as a vector of variable names corresponding to their naming in the FLUXNET2015 datasets.
getvars <- c(
"TA_F_NIGHT", # Nighttime temperature, degC
"TA_F_NIGHT_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"TA_F_DAY", # Daytime temperature, degC
"TA_F_DAY_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"SW_IN_F", # Shortwave incoming W m-2
"SW_IN_F_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"VPD_F", # Vapour pressure deficit hPa
"VPD_F_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"VPD_F_DAY", # Daytime vapour pressure deficit hPa
"PA_F", # Atmospheric pressure kPa
"PA_F_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"P_F", # precipitation, mm
"P_F_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"WS_F", # wind speed, m s-1
"WS_F_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"USTAR", # u-star m s-1
"USTAR_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"NETRAD", # net radiation, W m-2
"NETRAD_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"H_F_MDS", # sensible heat flux, W m-2 -> J m-2 d-1 or H_CORR (corrected by energy balance closure factor)?
"H_F_MDS_QC", # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
"LE_F_MDS", # latent heat flux, W m-2 -> J m-2 d-1
"LE_F_MDS_QC" # DD: % measured or good qual gapfilled; HH: 0=measured, 1=good qual gapfill, 2=medium, 3=poor
)
The site selection is a critical step. (Some) meta information for the FLUXNET2015 Tier 1 sites is available through the rsofun
package. Let’s use a selection of sites based on Manuela Balzarolo’s selection, intersected with the sites that belong to one of the clusters where Beni’s NN analysis worked (meaning that the data seems reliable in and is large enough).
df_siteinfo <- read_csv("/alphadata01/bstocker/data/FLUXNET-2015_Tier1/meta/siteselection_mbalzarolo_AND_fLUEclusters_cDD_cGR_cLS.csv")
## Parsed with column specification:
## cols(
## sitename = col_character(),
## cluster = col_character(),
## lon = col_double(),
## lat = col_double(),
## elv = col_double(),
## year_start = col_double(),
## year_end = col_double(),
## years_data = col_double(),
## classid = col_character(),
## whc = col_double(),
## c4 = col_logical(),
## koeppen_code = col_character(),
## kgnumber = col_double(),
## koeppen_code_extr = col_character()
## )
Read the data. Let’s do it here only for one site ("AU-How"
) because we’re reading also the half-hourly VPD data in order to get daytime-only VPD. This is missing otherwise from the daily data distribution. Do ?get_obs_bysite_fluxnet2015
to get the documentation.
sitelist <- "AU-How"
# sitelist <- df_siteinfo$sitename UNCOMMENT THIS TO RUN IT FOR ALL SITES SELECTED ABOVE
ddf <- purrr::map(
as.list(sitelist),
~get_obs_bysite_fluxnet2015(
sitename = .,
path_fluxnet2015 = "/alphadata01/bstocker/data/FLUXNET-2015_Tier1/20160128/point-scale_none_1d/original/unpacked/",
path_fluxnet2015_hh = "/alphadata01/bstocker/data/FLUXNET-2015_Tier1/20160128/point-scale_none_0.5h/original/unpacked/",
timescale = "d",
getvars = getvars,
getswc = TRUE,
threshold_GPP = 0.5,
threshold_LE = 0.5,
threshold_H = 0.5,
threshold_SWC = 0.5,
threshold_WS = 0.5,
threshold_USTAR = 0.5,
threshold_T = 0.5,
threshold_NETRAD = 0.5,
verbose = FALSE
) ) %>%
bind_rows( .id = "sitename" )
## Parsed with column specification:
## cols(
## .default = col_double(),
## SW_OUT = col_logical(),
## LW_OUT = col_logical(),
## RECO_SR = col_logical(),
## RECO_SR_N = col_logical()
## )
## See spec(...) for full column specifications.
## Warning: 5436 parsing failures.
## row col expected actual file
## 1098 SW_OUT 1/0/T/F/TRUE/FALSE 24.9791666667 '/alphadata01/bstocker/data/FLUXNET-2015_Tier1/20160128/point-scale_none_1d/original/unpacked/FLX_AU-How_FLUXNET2015_FULLSET_DD_2001-2014_1-3.csv'
## 1099 SW_OUT 1/0/T/F/TRUE/FALSE 38.5625 '/alphadata01/bstocker/data/FLUXNET-2015_Tier1/20160128/point-scale_none_1d/original/unpacked/FLX_AU-How_FLUXNET2015_FULLSET_DD_2001-2014_1-3.csv'
## 1100 SW_OUT 1/0/T/F/TRUE/FALSE 47.1351351351 '/alphadata01/bstocker/data/FLUXNET-2015_Tier1/20160128/point-scale_none_1d/original/unpacked/FLX_AU-How_FLUXNET2015_FULLSET_DD_2001-2014_1-3.csv'
## 1103 SW_OUT 1/0/T/F/TRUE/FALSE 16.5454545455 '/alphadata01/bstocker/data/FLUXNET-2015_Tier1/20160128/point-scale_none_1d/original/unpacked/FLX_AU-How_FLUXNET2015_FULLSET_DD_2001-2014_1-3.csv'
## 1105 SW_OUT 1/0/T/F/TRUE/FALSE 39.3461538462 '/alphadata01/bstocker/data/FLUXNET-2015_Tier1/20160128/point-scale_none_1d/original/unpacked/FLX_AU-How_FLUXNET2015_FULLSET_DD_2001-2014_1-3.csv'
## .... ...... .................. ............. ..................................................................................................................................................
## See problems(...) for more details.
## Parsed with column specification:
## cols(
## .default = col_double()
## )
## See spec(...) for full column specifications.
## [1] "Writing file with daytime VPD as: /alphadata01/bstocker/data/FLUXNET-2015_Tier1/20160128/point-scale_none_0.5h/original/unpacked/FLX_AU-How_FLUXNET2015_FULLSET_DD_2001-2014_1-3_VPD_DAY.csv"
## Warning: Unknown columns: `TA_F_NIGHT_QC_QC`, `TA_F_DAY_QC_QC`,
## `SW_IN_F_QC_QC`, `VPD_F_QC_QC`, `PA_F_QC_QC`, `P_F_QC_QC`, `WS_F_QC_QC`,
## `USTAR_QC_QC`, `NETRAD_QC_QC`, `H_F_MDS_QC_QC`, `LE_F_MDS_QC_QC`
## Warning: Unknown columns: `TA_F_NIGHT_QC_QC`, `TA_F_DAY_QC_QC`,
## `SW_IN_F_QC_QC`, `VPD_F_QC_QC`, `PA_F_QC_QC`, `P_F_QC_QC`, `WS_F_QC_QC`,
## `USTAR_QC_QC`, `NETRAD_QC_QC`, `H_F_MDS_QC_QC`, `LE_F_MDS_QC_QC`