Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Black <[email protected]>
  • Loading branch information
Sweetdevil144 and infotroph authored Aug 30, 2024
1 parent 4f9320e commit e9367b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions base/db/R/dbfiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,10 @@ dbfile.file <- function(type, id, con, hostname = PEcAn.remote::fqdn()) {
PEcAn.logger::logger.warn("multiple files found for", id, "returned; using the first one found")
return(invisible(file.path(files[1, "file_path"], files[1, "file_name"])))
} else if (nrow(files) == 1) {
(invisible(file.path(files[1, "file_path"], files[1, "file_name"])))
return(invisible(file.path(files[1, "file_path"], files[1, "file_name"])))
} else {
PEcAn.logger::logger.warn("no files found for ", id, "in database")
invisible(NA)
return(invisible(NA))
}
}

Expand Down
17 changes: 5 additions & 12 deletions modules/data.atmosphere/R/met.process.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ met.process <- function(site, input_met, start_date, end_date, model,
# Change to Site Level - Standardized Met (i.e. ready for conversion to model specific format)
if (stage$standardize) {
standardize_result <- list()
is_standardized <- FALSE
ready.id <- list(input.id = NULL, dbfile.id = NULL)

for (i in seq_along(cf.id[[1]])) {
Expand All @@ -305,10 +304,9 @@ met.process <- function(site, input_met, start_date, end_date, model,
host = host,
overwrite = overwrite$standardize)
# Expand to support ensemble names in the future
is_standardized <- TRUE
} else if (register$scale == "site") {
##### Site Level Processing
standardize_result[[i]] <- .metgapfill.module(cf.id = list(input.id = cf.id$input.id[i], dbfile.id = cf.id$dbfile.id[i]),
id_stdized <- .metgapfill.module(cf.id = list(input.id = cf.id$input.id[i], dbfile.id = cf.id$dbfile.id[i]),
register = register,
dir = dir,
met = met,
Expand All @@ -319,18 +317,13 @@ met.process <- function(site, input_met, start_date, end_date, model,
host = host,
overwrite = overwrite$standardize,
ensemble_name = i)
is_standardized <- TRUE
} else {
is_standardized <- FALSE
# No action taken. These ids will be dropped from ready.id
id_stdized <- NULL
}

if(is_standardized) {
ready.id$input.id <- c(ready.id$input.id, standardize_result[[i]]$input.id)
ready.id$dbfile.id <- c(ready.id$dbfile.id, standardize_result[[i]]$dbfile.id)
} else {
ready.id$input.id <- c(ready.id$input.id, NA)
ready.id$dbfile.id <- c(ready.id$dbfile.id, NA)
}
ready.id$input.id <- c(ready.id$input.id, id_stdized$input.id)
ready.id$dbfile.id <- c(ready.id$dbfile.id, id_stdized$dbfile.id)

} # End for loop

Expand Down

0 comments on commit e9367b5

Please sign in to comment.