Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
868a7c6
start phase 3 rundir with incomplete README
infotroph Oct 28, 2025
688107e
copy ERA5 clim script from phase 2
infotroph Oct 28, 2025
df1fe80
typos
infotroph Oct 29, 2025
a30dbf4
add script used for gridded met NC prep
infotroph Oct 29, 2025
4e42a70
val site file creation
infotroph Oct 29, 2025
2c202ff
IC prep script
infotroph Oct 29, 2025
b9f7ea1
xml build as copied from phase 2
infotroph Oct 29, 2025
b8965f2
relocate pfts in template
infotroph Oct 29, 2025
a937341
xml build including output renaming
infotroph Oct 29, 2025
b4033e8
run_model from phase 2
infotroph Oct 29, 2025
0a8fc17
moving config to a separate step
infotroph Oct 29, 2025
7a926d7
first pass SOC validation
infotroph Oct 29, 2025
67993c1
filter to data after start year, limit n by location instead of project
infotroph Oct 31, 2025
57c27c8
move val siteinfo builder to tools
infotroph Oct 31, 2025
b92fdfd
save validation scatter by ensemble member
infotroph Nov 12, 2025
7a4f130
make site name column optional; remove from val site info
infotroph Nov 12, 2025
1dd3c83
list soil as a separate pft
infotroph Dec 2, 2025
d0bc0e4
read only the years with matching validation datapoints
infotroph Dec 2, 2025
54495e9
add CI to scatterplot, reduce digits in csv
infotroph Dec 2, 2025
5da33a9
adjust QC filters, save fit diagnostics
infotroph Dec 2, 2025
a4665d4
include events in template
infotroph Dec 9, 2025
dca8445
notes from model runs for AGU 2025 talks
infotroph Dec 10, 2025
e354871
updates for 34 sites w/2016 irrig
infotroph Dec 12, 2025
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
93 changes: 93 additions & 0 deletions 3_rowcrop/01_ERA5_nc_to_clim.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env Rscript

# Converts ERA5 meteorology data from PEcAn's standard netCDF format
# to Sipnet `clim` driver files.

# This is basically a thin wrapper around `met2model.SIPNET()`.
# Only the filenames are specific to ERA5 by assuming each file is named
# "ERA5.<ens_id>.<year>nc" with ens_id between 1 and 10.

## --------- runtime values: change for your system and simulation ---------

options <- list(
optparse::make_option("--site_era5_path",
default = "data_raw/ERA5_nc",
help = paste(
"Path to your existing ERA5 data in PEcAn CF format, organized as",
"single-site, single-year netcdfs in subdirectories per ensemble member.",
"Files should be named",
"'<site_era5_path>/ERA5_<siteid>_<ensid>/ERA5.<ensid>.<year>.nc'"
)
),
optparse::make_option("--site_sipnet_met_path",
default = "data/ERA5_SIPNET",
help = paste(
"Output path:",
"single-site, multi-year Sipnet clim files, one per ensemble member.",
"Files will be named",
"<site_sipnet_met_path>/<siteid>/ERA5.<ensid>.<start>.<end>.clim"
)
),
optparse::make_option("--site_info_file",
default = "site_info.csv",
help = "CSV file with one row per location. Only the `id` column is used",
),
optparse::make_option("--start_date",
default = "2016-01-01",
help = "Date to begin clim file",
),
optparse::make_option("--end_date",
default = "2023-12-31",
help = "Date to end clim file",
),
optparse::make_option("--n_cores",
default = 1L,
help = "number of CPUs to use in parallel",
),
optparse::make_option("--parallel_strategy",
default = "multisession",
help = "Strategy for parallel conversion, passed to future::plan()",
)
) |>
# Show default values in help message
purrr::modify(\(x) {
x@help <- paste(x@help, "[default: %default]")
x
})

args <- optparse::OptionParser(option_list = options) |>
optparse::parse_args()


# ----------- end system-specific ---------------------------------


future::plan(args$parallel_strategy, workers = args$n_cores)

site_info <- read.csv(args$site_info_file)
site_info$start_date <- args$start_date
site_info$end_date <- args$end_date


file_info <- site_info |>
dplyr::rename(site_id = id) |>
dplyr::cross_join(data.frame(ens_id = 1:10))

if (!dir.exists(args$site_sipnet_met_path)) {
dir.create(args$site_sipnet_met_path, recursive = TRUE)
}
furrr::future_pwalk(
file_info,
function(site_id, start_date, end_date, ens_id, ...) {
PEcAn.SIPNET::met2model.SIPNET(
in.path = file.path(
args$site_era5_path,
paste("ERA5", site_id, ens_id, sep = "_")
),
start_date = args$start_date,
end_date = args$end_date,
in.prefix = paste0("ERA5.", ens_id),
outfolder = file.path(args$site_sipnet_met_path, site_id)
)
}
)
Loading