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

Update find_met_files.r: forward simulation time bugfix #100

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 11 additions & 1 deletion r/src/find_met_files.r
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
find_met_files <- function(t_start, met_file_format, n_hours, met_path) {
require(dplyr)

n_hours_per_met_file <- 6
is_backward <- n_hours < 0

# TODO: implement n_hours_per_met_file to better determine file names at
Expand All @@ -27,7 +28,16 @@ find_met_files <- function(t_start, met_file_format, n_hours, met_path) {
range() %>%
(function(x) seq(x[1], x[2], by = 'hour')) %>%
strftime(tz = 'UTC', format = met_file_format)

# patch to retrieve correct met files for forward simulations
if(!is_backward){
request <- seq(
as.POSIXct(t_start, tz='UTC')-as.difftime(n_hours_per_met_file,units="hours")
, as.POSIXct(t_start, tz='UTC')+as.difftime(n_hours,units="hours")
, by = 60*60
) %>%
strftime(tz = 'UTC', format = met_file_format)
}#end if(n_hours>0)

available <- dir(met_path, full.names = T, recursive = T)
available <- available[!grepl('.lock', available)]

Expand Down