Skip to content

Commit

Permalink
update process
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkunst committed Sep 25, 2023
1 parent 7b21de8 commit 4951a6d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
16 changes: 8 additions & 8 deletions dev/00-download-data-raw-monthly-agromet.R
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand All @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions dev/00-download-data-raw-monthly-dmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ try(
fs::file_delete()
)

walk(pers, function(per = 202304){
walk(pers, function(per = 202307){

figletr::figlet(per)

Expand All @@ -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
Expand All @@ -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)))
Expand Down
28 changes: 14 additions & 14 deletions dev/99-run-00-01-02.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 4951a6d

Please sign in to comment.