Skip to content

Commit

Permalink
Allow shift_forecast() to use new column names
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-MET committed Jan 22, 2024
1 parent 735ecce commit a3d3f19
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions R/shift_forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,21 @@ shift_forecast.default <- function(.fcst, fcst_shifts, drop_negative_lead_times
stop("Only one 'fcst_shifts' allowed per forecast model.", call. = FALSE)
}

colnames(.fcst) <- suppressWarnings(harpCore::psub(
colnames(.fcst),
c("fcdate", "validdate", "leadtime"),
c("fcst_dttm", "valid_dttm", "lead_time")
))

.fcst <- .fcst %>%
dplyr::mutate(
fcdate = .data$fcdate + fcst_shifts * 3600,
leadtime = .data$leadtime - fcst_shifts,
fcst_cycle = substr(harpIO::unixtime_to_str_datetime(.data$fcdate, harpIO::YMDh), 9, 10)
fcst_dttm = .data$fcst_dttm + fcst_shifts * 3600,
lead_time = .data$lead_time - fcst_shifts,
fcst_cycle = substr(harpIO::unixtime_to_str_datetime(.data$fcst_dttm, harpIO::YMDh), 9, 10)
)

if (drop_negative_lead_times) {
.fcst <- dplyr::filter(.fcst, .data$leadtime >= 0)
.fcst <- dplyr::filter(.fcst, .data$lead_time >= 0)
}

.fcst
Expand Down

0 comments on commit a3d3f19

Please sign in to comment.