scripts/daily2yearly.R

source('scripts/main_pkgs.R')

# plot(TP_poly)
# plot(sp,add = TRUE)

# r <- raster::intersect(sp, TP_poly)
# # sites <- r$site %>% code_ChrVec()
# sites <- c("CN-Dan", "CN-Ha2", "CN-HaM")

# library(tidyverse)
df <- fread("E:/Research/phenology/rfluxnet/OUTPUT/fluxsites166_FULLSET_daily_v20200411 (80%).csv")

vars <- colnames(df) %>% .[grep("QC_", .)] %>% gsub("QC_", "", .)
d_mean <- df[, lapply(.SD, mean, na.rm = TRUE), .(site, year), .SDcols = vars]
d_days <- df[, lapply(.SD, . %>% {sum(is.na(.))}), .(site, year), .SDcols = vars]

# d <- df[site %in% sites]
# d$date %<>% ymd()
# ggplot(d, aes(date, GPP_DT)) + geom_point() +
#     facet_wrap(~site, ncol = 1, scales = "free_y") +
#     labs(y = expression(GPP[DT] ~ "(" * gC ~ m^-2 ~ d^-1 * ")"))

# save(d, file = "data-raw/cases/青藏高原通量站数据.rda")
rpkgs/rfluxnet documentation built on May 31, 2024, 6:57 p.m.