Skip to content

Commit

Permalink
update to new to hourly function usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jzwart committed Feb 5, 2024
1 parent 223c9ca commit d8ea467
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions drivers/generate_stage3.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
library(minioclient)
library(gdalcubes)
library(gefs4cast)
source("https://raw.githubusercontent.com/eco4cast/neon4cast/main/R/to_hourly.R")
source("drivers/to_hourly.R")

config <- yaml::read_yaml("challenge_configuration.yaml")
driver_bucket <- stringr::word(config$driver_bucket, 1, sep = "/")
Expand All @@ -21,8 +21,7 @@ df <- arrow::open_dataset("pseudo") |>

site_list <- readr::read_csv(paste0("https://github.com/eco4cast/usgsrc4cast-ci/",
"raw/prod/USGS_site_metadata.csv"),
show_col_types = FALSE) |>
dplyr::pull(site_id)
show_col_types = FALSE)


s3_stage3 <- gefs4cast::gefs_s3_dir(product = "stage3",
Expand All @@ -32,7 +31,7 @@ s3_stage3 <- gefs4cast::gefs_s3_dir(product = "stage3",

future::plan("future::multisession", workers = 8)

furrr::future_walk(site_list, function(curr_site_id){
furrr::future_walk(dplyr::pull(site_list, site_id), function(curr_site_id){

df <- arrow::open_dataset("pseudo") |>
dplyr::filter(variable %in% c("PRES","TMP","RH","UGRD","VGRD","APCP","DSWRF","DLWRF")) |>
Expand All @@ -46,7 +45,9 @@ furrr::future_walk(site_list, function(curr_site_id){

print(curr_site_id)
df |>
to_hourly(use_solar_geom = TRUE, psuedo = TRUE) |>
to_hourly(site_list = dplyr::select(site_list, site_id, latitude, longitude),
use_solar_geom = TRUE,
psuedo = TRUE) |>
dplyr::mutate(ensemble = as.numeric(stringr::str_sub(ensemble, start = 4, end = 5))) |>
dplyr::rename(parameter = ensemble) |>
arrow::write_dataset(path = s3, partitioning = "site_id")
Expand Down
11 changes: 6 additions & 5 deletions drivers/update_stage3.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
library(gdalcubes)
library(gefs4cast)
source("https://raw.githubusercontent.com/eco4cast/neon4cast/main/R/to_hourly.R")
source("drivers/to_hourly.R")

site_list <- readr::read_csv(paste0("https://github.com/eco4cast/usgsrc4cast-ci/",
"raw/prod/USGS_site_metadata.csv"),
show_col_types = FALSE) |>
dplyr::pull(site_id)
show_col_types = FALSE)

Sys.setenv("GEFS_VERSION"="v12")

Expand All @@ -15,7 +14,7 @@ driver_path <- stringr::word(config$driver_bucket, 2, -1, sep = "/")

future::plan("future::multisession", workers = 8)

furrr::future_walk(site_list, function(curr_site_id){
furrr::future_walk(dplyr::pull(site_list, site_id), function(curr_site_id){

print(curr_site_id)

Expand Down Expand Up @@ -50,7 +49,9 @@ furrr::future_walk(site_list, function(curr_site_id){
if(nrow(psuedo_df) > 0){

df2 <- psuedo_df |>
to_hourly(use_solar_geom = TRUE, psuedo = TRUE) |>
to_hourly(site_list = dplyr::select(site_list, site_id, latitude, longitude),
use_solar_geom = TRUE,
psuedo = TRUE) |>
dplyr::mutate(ensemble = as.numeric(stringr::str_sub(ensemble, start = 4, end = 5))) |>
dplyr::rename(parameter = ensemble)

Expand Down

0 comments on commit d8ea467

Please sign in to comment.