Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for v3 #72

Merged
merged 7 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Imports:
rvest,
zoo,
lubridate,
recipes
recipes,
readr,
here
Suggests:
knitr,
rmarkdown,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export(fdk_process_lsm)
export(fdk_release)
export(fdk_setup_sofun)
export(fdk_smooth_ts)
export(fill_netrad)
export(site_exceptions)
14 changes: 14 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,18 @@
#' as their meta-data
#'
#' @format DataFrame
#' \describe{
#' \item{sitename}{Site name}
#' \item{lon}{Longitude of site}
#' \item{lat}{Latitude of site}
#' \item{elv}{elevation}
#' \item{year_start}{start year of data availability}
#' \item{year_end}{end year of data availability}
#' \item{koeppen_code}{Koeppen Geiger code}
#' \item{igbp_land_use}{IGBP land cover type}
#' \item{whc}{Total root zone water holding capacity}
#' \item{product}{Data taken from published product}
#' }
#'

"fdk_site_info"
4 changes: 2 additions & 2 deletions R/fdk_convert_lsm.R
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,14 @@ fdk_convert_lsm <- function(

# loop over all rows (variables)
for (i in seq_len(nrow(replacements))){
try(all <-tibble::add_column(all,
try(all <- tibble::add_column(all,
!!(replacements[i, 'variable']) := replacements[i, 'value']
),
silent = TRUE
)

all <- all |>
select(
dplyr::select(
-ends_with(".1")
)
}
Expand Down
4 changes: 2 additions & 2 deletions R/fdk_downsample_fluxnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fdk_downsample_fluxnet <- function(
TA_F_MDS = mean(TA_F_MDS, na.rm = FALSE),
TA_F_QC = mean(TA_F_QC < 1, na.rm = FALSE),

# temperature is the mean of the HH values
# shortwave radiation is the mean of the HH values
SW_IN_F_MDS = mean(SW_IN_F_MDS, na.rm = FALSE),
SW_IN_F_MDS_QC = mean(SW_IN_F_MDS_QC < 1, na.rm = FALSE),

Expand All @@ -174,7 +174,7 @@ fdk_downsample_fluxnet <- function(
WS_F = mean(WS_F, na.rm = FALSE),
WS_F_QC = mean(WS_F_QC < 1, na.rm = FALSE),

# temperature is the mean of the HH values
# atmospheric pressure is the mean of the HH values
PA_F = mean(PA_F, na.rm = FALSE),
PA_F_QC = mean(PA_F_QC < 1, na.rm = FALSE),

Expand Down
4 changes: 2 additions & 2 deletions R/fdk_process_lsm.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fdk_process_lsm <- function(

} else {

if ( x['product'] == "icos" ){
if ( x['product'] == "icos_warmwinter2020" || x['product'] == "icos_drought2018" ){
infile <- FluxnetLSM::get_fluxnet_files(
x['data_path'],
x['sitename'],
Expand All @@ -145,7 +145,7 @@ fdk_process_lsm <- function(
)
}

if ( x['product'] == "oneflux" ){
if ( x['product'] == "ameriflux" ){
infile <- FluxnetLSM::get_fluxnet_files(
x['data_path'],
x['sitename'],
Expand Down
13 changes: 6 additions & 7 deletions analysis/00_batch_convert_LSM_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
options(tidyverse.quiet = TRUE)
options(dplyr.summarise.inform = FALSE)
lapply(list.files("R/","*.R", full.names = TRUE), source)
#library(FluxDataKit)
library(FluxDataKit)
library(FluxnetLSM)
library(dplyr)
library(ingestr)
library(rsofun)

input_path <- "/data/scratch/FDK_inputs"
output_path <- "/data/scratch/beta-v4"
input_path <- "~/data/FluxDataKit/FDK_inputs" # "/data/scratch/FDK_inputs"
output_path <- "~/data/FluxDataKit/v3" # "/data/scratch/beta-v4"

# read in all site meta-data, only test on
# FR-Pue to debug FluxnetLSM for now
Expand All @@ -19,16 +19,13 @@ sites <- FluxDataKit::fdk_site_info |>
data_path = file.path(input_path, "flux_data/")
)

# CH-Lae
# CH-Dav
#
#---- create a new release ----

fdk_release(
df = sites,
input_path = input_path,
output_path = output_path,
overwrite = TRUE
overwrite = FALSE
)

#---- create matching plots ----
Expand Down Expand Up @@ -70,3 +67,5 @@ failed_sites <- lapply(sites$sitename, function(site){

return(NULL)
})


3 changes: 2 additions & 1 deletion analysis/01_visualize_fdk_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ failed_sites <- lapply(sites$sitename, function(site){
df <- suppressWarnings(try(fdk_convert_lsm(
site = site,
fluxnet_format = FALSE,
path = "/data/scratch/beta-v2/lsm/"
path = "~/data/FluxDataKit/v3"
)
))

print(head(df))

})

2 changes: 1 addition & 1 deletion analysis/02_batch_format_rsofun_drivers.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ library(ingestr)
library(rsofun)
lapply(list.files("R/","*.R", full.names = TRUE), source)

input_path <- "/data/scratch/beta-v4/fluxnet/"
input_path <- "~/data/FluxDataKit/v3"

# read in sites to process
sites <- FluxDataKit::fdk_site_info
Expand Down
2 changes: 1 addition & 1 deletion analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Scripts need to be run in chronological order

## Scripts

- 00_batch_convert_LSM_data.R - converts FLUXNET data to LSM data
- 00_batch_convert_LSM_data.R - converts FLUXNET data (standard CSV files) to LSM data (NetCDF)
- the output is land surface model (LSM) compatible data in a netcdf format
- 01_visualize_fdk_data.R - Plots all converted data for visual checks (not mandatory)
- 03_batch_convert_to_CSV_data.R - converts LSM data to FLUXNET compatible CSVs
Expand Down
3 changes: 2 additions & 1 deletion data-raw/00_download_plumber_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
library(rvest)

# set destination path
dest_path <- "/data/scratch/FDK_inputs/flux_data/plumber/"
# dest_path <- "/data/scratch/FDK_inputs/flux_data/plumber/"
dest_path <- "~/data/FluxDataKit/FDK_inputs/plumber/"

# set catalogues
catalogues <- data.frame(
Expand Down
Loading
Loading