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

Add version number to filenames #104

Merged
merged 1 commit into from
Jan 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
3 changes: 2 additions & 1 deletion synoptic/L1.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ f <- function(dir_name, dirs_to_process, out_dir) {
root_dir = out_dir,
data_level = "L1",
site = site,
version = params$L1_VERSION,
write_plots = params$write_plots)

# Add any OOB flags to the flag database
Expand Down Expand Up @@ -247,7 +248,7 @@ for(dd in data_dirs) {
md <- md[-site_info_pos]

# Write the final metadata file
mdfn <- paste0(dd, "_metadata.txt")
mdfn <- paste0(dd, "_L1v", params$L1_VERSION, "_metadata.txt")
message("\tWriting ", mdfn, "...")
writeLines(md, file.path(L1, dd, mdfn))
}
Expand Down
8 changes: 5 additions & 3 deletions synoptic/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ read_csv_group <- function(files, col_types = NULL,
# This is used to split the data for sorting into <yyyy>_<mm> folders
# Returns a list of filenames written (names) and number of data lines (values)
write_to_folders <- function(x, root_dir, data_level, site,
logger, table, quiet = FALSE, write_plots = TRUE) {
logger, table, version = "???",
quiet = FALSE, write_plots = TRUE) {
years <- year(x$TIMESTAMP)
months <- sprintf("%02i", month(x$TIMESTAMP)) # add leading zero if needed
vversion <- paste0("v", version)

lines_written <- list()
for(y in unique(years)) {
Expand Down Expand Up @@ -122,7 +124,7 @@ write_to_folders <- function(x, root_dir, data_level, site,
na_string <- NA_STRING_L1
} else if(data_level == "L1") {
folder <- file.path(root_dir, paste(site, y, sep = "_"))
filename <- paste0(paste(site, time_period, data_level, sep = "_"), ".csv")
filename <- paste0(paste(site, time_period, data_level, vversion, sep = "_"), ".csv")
na_string <- NA_STRING_L1
write_this_plot <- TRUE
p <- ggplot(x, aes(TIMESTAMP, value, group = design_link)) +
Expand All @@ -132,7 +134,7 @@ write_to_folders <- function(x, root_dir, data_level, site,
theme(axis.text = element_text(size = 6))
} else if(data_level == "L2") {
folder <- file.path(root_dir, paste(site, y, sep = "_"))
filename <- paste0(paste(site, time_period, table, data_level, sep = "_"), ".csv")
filename <- paste0(paste(site, time_period, table, data_level, vversion, sep = "_"), ".csv")
na_string <- NA_STRING_L2
} else {
stop("Unkown data_level ", data_level)
Expand Down