Skip to content

Commit

Permalink
adding in checks for stage3
Browse files Browse the repository at this point in the history
  • Loading branch information
jzwart committed May 6, 2024
1 parent 3a8989e commit c504aea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/update_stage3.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ furrr::future_walk(dplyr::pull(site_list, site_id), function(curr_site_id){
stage3_df <- stage3_dataset |>
dplyr::filter(site_id == curr_site_id) |>
dplyr::collect()
if(nrow(stage3_df) == 0){
max_date <- NA
}else{
max_date <- stage3_df |>
dplyr::summarise(max = as.character(lubridate::as_date(max(datetime)))) |>
dplyr::pull(max)
}

max_date <- stage3_df |>
dplyr::summarise(max = as.character(lubridate::as_date(max(datetime)))) |>
dplyr::pull(max)
}else{
max_date <- NA
}
Expand All @@ -42,11 +46,11 @@ furrr::future_walk(dplyr::pull(site_list, site_id), function(curr_site_id){
endpoint = config$endpoint,
bucket = driver_bucket)

if(length(stage3_dataset$files) > 0){
if(length(stage3_dataset$files) > 0 & nrow(stage3_df) > 0){
cut_off <- as.character(lubridate::as_date(max_date) - lubridate::days(3))
}

if(length(stage3_dataset$files) > 0){
if(length(stage3_dataset$files) > 0 & nrow(stage3_df) > 0){
pseudo_df <- arrow::open_dataset(s3_pseudo) |>
dplyr::filter(variable %in% c("PRES","TMP","RH","UGRD","VGRD","APCP","DSWRF","DLWRF")) |>
dplyr::filter(site_id == curr_site_id,
Expand All @@ -69,7 +73,7 @@ furrr::future_walk(dplyr::pull(site_list, site_id), function(curr_site_id){
dplyr::mutate(ensemble = as.numeric(stringr::str_sub(ensemble, start = 4, end = 5))) |>
dplyr::rename(parameter = ensemble)

if(length(stage3_dataset$files) > 0){
if(length(stage3_dataset$files) > 0 & nrow(stage3_df) > 0){
stage3_df_update <- stage3_df |>
dplyr::filter(datetime < min(df2$datetime))

Expand Down

0 comments on commit c504aea

Please sign in to comment.