Skip to content

Commit

Permalink
Removed rsofun mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
marcadella committed Oct 24, 2024
1 parent 71466ed commit 8b19960
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 209 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ data-raw/cloud_cover/
data-raw/modis/
data/tmp/
docs/
.idea/
1 change: 0 additions & 1 deletion analysis/00_batch_convert_LSM_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ library(FluxDataKit)
library(FluxnetLSM)
library(dplyr)
library(ingestr)
library(rsofun)

input_path <- "/data_2/FluxDataKit/FDK_inputs/"
output_path <- "/data_2/FluxDataKit/v3.4/"
Expand Down
77 changes: 77 additions & 0 deletions analysis/03_screen_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Determine longest good-quality sequence by site
library(tidyverse)
library(FluxDataKit)

path <- "/data_2/FluxDataKit/v3.4"

sites <- FluxDataKit::fdk_site_info |>
filter(!(sitename %in% c("MX-Tes", "US-KS3")))

# # site subset------------------
# # xxx debug
# # chose representative sites for LES book
# use_sites <- c(
# # "FI-Hyy", # Boreal Forests/Taiga
# # "US-SRM", # Deserts & Xeric Shrublands
# # "FR-Pue", # Mediterranean Forests, Woodlands & Scrub
# # "DE-Hai", # Temperate Broadleaf & Mixed Forests
# "IT-Ro1"
# # "US-Tw1", # Temperate Grasslands, Savannas & Shrublands
# # "AU-How", # Tropical & Subtropical Grasslands, Savannas & Shrubland
# # "BR-Sa3", # Tropical
# # "ZM-Mon", # Tropical deciduous forest (xeric woodland)
# # "US-ICh" # Tundra
# )
# sites <- sites |>
# filter(sitename %in% use_sites)
# #----------------------------

# determine longest sequence of good-quality data for each site
list_seq <- lapply(sites$sitename, function(site){
message(sprintf("Analysing %s ----", site))

# get file name path
filn <- list.files(
file.path(path, "fluxnet"),
pattern = paste0("FLX_", site, ".*_FULLSET_DD.*.csv"),
recursive = TRUE
)

df <- read.csv(file.path(file.path(path, "fluxnet"), filn))

df_seq <- suppressMessages(
suppressWarnings(
try(fdk_get_sequence(
df,
site = site,
qc_threshold = 0.25,
leng_threshold = 90,
do_plot = TRUE,
out_path = file.path(path, "plots")
)
)
)
)

if(inherits(df_seq, "try-error")){
message("!!! plotting failed !!!")
return(NULL)
}

return(df_seq)
})


fdk_site_fullyearsequence <- bind_rows(list_seq)

# write CSV file
save(fdk_site_fullyearsequence,
file = here::here("data/fdk_site_fullyearsequence.rda"),
compress = "xz"
)

# write CSV file for upload to Zenodo
readr::write_csv(
fdk_site_fullyearsequence,
file = "/data_2/FluxDataKit/v3.4/fdk_site_fullyearsequence.csv"
)
202 changes: 0 additions & 202 deletions analysis/03_screen_rsofun_data.R

This file was deleted.

9 changes: 6 additions & 3 deletions analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ Scripts need to be run in chronological order
- 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
- 03_screen_data.R - converts LSM data to FLUXNET compatible CSVs
- this data is downsampled to a daily time step
- the data sticks to FLUXNET formatting
- 04_batch_format_rsofun_drivers.R - converts data to `rsofun` model inputs
- conversion to ensure compatibility with the `rsofun` package for modelling
- 04_create_zenodo_upload.R

Optional scripts:
- b_02_batch_format_rsofun_drivers.R
- b_06_p-model_run.R
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions vignettes/03_data_generation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,16 @@ library(rsofun)
# processing of the half hourly data to
# p-model input drivers for rsofun
rsofun_data <- fdk_format_drivers(
rsofun_driver <- rsofun::fdk_format_drivers(
site_info = FluxDataKit::fdk_site_info |>
filter(sitename == "FR-Fon"),
path = paste0(tempdir(),"/"),
verbose = TRUE
)
# Please make sure the parameter names correspond to your version of rsofun.
# See rsofun documentation
# optimized parameters from previous work
params_modl <- list(
kphio = 0.09423773,
Expand All @@ -181,7 +184,7 @@ params_modl <- list(
# run the model for these parameters
output <- rsofun::runread_pmodel_f(
rsofun_data,
rsofun_driver,
par = params_modl
)
Expand All @@ -194,7 +197,7 @@ print(head(model_data))

```{r eval = evaluate}
validation_data <- rsofun_data |>
validation_data <- rsofun_driver |>
filter(sitename == "FR-Fon") |>
tidyr::unnest(forcing)
Expand Down

0 comments on commit 8b19960

Please sign in to comment.