From 4951a6de18e478d7d3f5c2579a3c0893e33732af Mon Sep 17 00:00:00 2001 From: Joshua Kunst Date: Mon, 25 Sep 2023 16:45:58 -0300 Subject: [PATCH] update process --- dev/00-download-data-raw-monthly-agromet.R | 16 ++++++------- dev/00-download-data-raw-monthly-dmc.R | 9 +++---- dev/99-run-00-01-02.R | 28 +++++++++++----------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/dev/00-download-data-raw-monthly-agromet.R b/dev/00-download-data-raw-monthly-agromet.R index 8cfbfb4..8655c8b 100644 --- a/dev/00-download-data-raw-monthly-agromet.R +++ b/dev/00-download-data-raw-monthly-agromet.R @@ -6,7 +6,7 @@ library(yyyymm) # data mensual ------------------------------------------------------------ pers <- ym_seq(201501, format(Sys.time(), "%Y%m")) -pers <- rev(pers) +pers <- sample(pers) folder_data <- "dev/data-raw-agromet/" @@ -19,14 +19,14 @@ fs::dir_create(folder_data) # fs::file_delete() # ) -try( - dir(folder_data, full.names = TRUE) |> - tail(2) |> - str_replace("raw", "daily") |> - fs::file_delete() -) +# try( +# dir(folder_data, full.names = TRUE) |> +# tail(2) |> +# str_replace("raw", "daily") |> +# fs::file_delete() +# ) -walk(sample(pers), function(per = 202202){ +walk(pers, function(per = 202202){ figletr::figlet(per) diff --git a/dev/00-download-data-raw-monthly-dmc.R b/dev/00-download-data-raw-monthly-dmc.R index f5b8de6..0796e01 100644 --- a/dev/00-download-data-raw-monthly-dmc.R +++ b/dev/00-download-data-raw-monthly-dmc.R @@ -26,7 +26,7 @@ try( fs::file_delete() ) -walk(pers, function(per = 202304){ +walk(pers, function(per = 202307){ figletr::figlet(per) @@ -36,14 +36,15 @@ walk(pers, function(per = 202304){ if(fs::file_exists(fout)) return(TRUE) - date_start <- ym_to_date(per, day = 1) |> as_datetime() - date_end <- date_start + months(1) - seconds(1) + date_start <- (ym_to_date(per, day = 1) |> as_datetime()) + hours(4) + date_end <- (date_start + months(1) - seconds(1)) # date_start <- format(date_start, "%Y-%m-%d %H:%M:%S") # date_end <- format(date_end, "%Y-%m-%d %H:%M:%S") dres <- agrometR::get_agro_data_dmc( agrometR::estaciones_dmc[["codigoNacional"]], + # "330020", date_start = date_start, date_end = date_end, verbose = TRUE @@ -52,7 +53,7 @@ walk(pers, function(per = 202304){ # agrometR::get_agro_data_from_api_dmc(950001, date_start = date_start, date_end = date_end) # corroboramos que todo esté dentro del periodo - stopifnot(nrow(dres) == nrow(filter(dres, format(momento, "%Y%m") == per))) + # stopifnot(nrow(dres) == nrow(filter(dres, format(momento, "%Y%m") == per))) # dres <- dres %>% # filter(if_any(c(temp_promedio_aire:horas_frio), negate(is.na))) diff --git a/dev/99-run-00-01-02.R b/dev/99-run-00-01-02.R index 5fa1f31..2856555 100644 --- a/dev/99-run-00-01-02.R +++ b/dev/99-run-00-01-02.R @@ -4,24 +4,24 @@ library(tidyverse) # 2. borra los dos ultimos meses dmc/ran dailies y los genera # 3. borra toda la bbdd y sube dailies -c( - "dev/00-download-data-raw-monthly-agromet.R", - # "dev/01-daily-aggregation-agromet.R" - ) |> - purrr::walk(source, echo = TRUE, encoding = "UTF-8") +# c( +# "dev/00-download-data-raw-monthly-agromet.R", +# "dev/01-daily-aggregation-agromet.R" +# ) |> +# purrr::walk(source, echo = TRUE, encoding = "UTF-8") c( "dev/00-download-data-raw-monthly-dmc.R", - # "dev/01-daily-aggregation-dmc.R" + "dev/01-daily-aggregation-dmc.R" ) |> purrr::walk(source, echo = TRUE, encoding = "UTF-8") -c( - # "dev/00-download-data-raw-monthly-agromet.R", - # "dev/00-download-data-raw-monthly-dmc.R", - "dev/01-daily-aggregation-agromet.R", - "dev/01-daily-aggregation-dmc.R" - # "dev/02-upload-data-to-sql.R" -) |> - purrr::walk(source, echo = TRUE, encoding = "UTF-8") +# c( +# # "dev/00-download-data-raw-monthly-agromet.R", +# # "dev/00-download-data-raw-monthly-dmc.R", +# "dev/01-daily-aggregation-agromet.R", +# "dev/01-daily-aggregation-dmc.R" +# # "dev/02-upload-data-to-sql.R" +# ) |> +# purrr::walk(source, echo = TRUE, encoding = "UTF-8")