Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run dam workflow #77

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions R/pagasa_forecasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ forecasts_get_regional_summary <- function(.text) {
#'

forecasts_get_weather <- function(.text) {
which(stringr::str_detect(string = .text, pattern = "Weather: "))[-1] |>
df <- which(stringr::str_detect(string = .text, pattern = "Weather: "))[-1] |>
(\(x)
{
cbind(
Expand All @@ -315,20 +315,23 @@ forecasts_get_weather <- function(.text) {
) |>
unlist() |>
unique() |>
paste(collapse = "|")
#paste(collapse = "|")
(\(x) paste0("\\b", x) |> paste(collapse = "|"))()
) |>
stringr::str_remove_all(pattern = "Weather: ") |>
stringr::str_split(pattern = "\\s{2,}", simplify = TRUE),
.text[x + 1] |>
stringr::str_remove_all(
pattern = stringr::str_split(
string = pagasa_forecast_regions$geographic_unit,
pattern = stringr::boundary("word")
#pattern = stringr::boundary("word")
pattern = " "
) |>
unlist() |>
unique() |>
(\(x) paste0("\\b", x) |> paste(collapse = "|"))()
) |>
stringr::str_remove_all(pattern = "Weather: ") |>
stringr::str_split(pattern = "\\s{2,}", simplify = TRUE)
)
}
Expand All @@ -341,6 +344,8 @@ forecasts_get_weather <- function(.text) {
)
}
)()

df
}

#'
Expand Down
3 changes: 2 additions & 1 deletion _targets_forecasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ forecasts_data_targets <- tar_plan(
name = forecasts_archive_pdfs,
command = list.files(
path = "data-raw/forecasts", full.names = TRUE, recursive = TRUE
)
),
cue = tar_cue("always")
),
### Extract raw PAGASA forecasts data ----
tar_target(
Expand Down
19 changes: 19 additions & 0 deletions data-raw/dam/dam_level_2024-09-09.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"Date Retrieved","Dam Name","Observation Time & Date","Reservoir Water Level (RWL) (m)","Water Level Deviation Hr","Water Level Deviation Amount","Normal High Water Level (NHWL) (m)","Deviation from NHWL (m)","Rule Curve Elevation (m)","Deviation from Rule Curve (m)","Gate Opening Gates","Gate Opening Meters","Estimated (cms) Inflow","Estimated (cms) Outflow"
2024-09-09,"Ambuklao",2024-09-09 08:00:00,751.49,24,-0.2,752,-0.51,745,6.49,1,0.3,NA,NA
2024-09-09,"Ambuklao",2024-09-08 08:00:00,751.69,24,-0.2,752,-0.31,745,6.69,2,0.8,NA,NA
2024-09-09,"Angat",2024-09-09 08:00:00,194.59,24,0.27,210,-15.41,184.19,10.4,NA,NA,NA,NA
2024-09-09,"Angat",2024-09-08 08:00:00,194.32,24,0.27,210,-15.68,184.11,10.21,NA,NA,NA,NA
2024-09-09,"Binga",2024-09-08 08:00:00,574.67,24,-0.32,575,-0.33,565,9.67,1,0.5,NA,NA
2024-09-09,"Binga",2024-09-09 08:00:00,574.35,24,-0.32,575,-0.65,565,9.35,1,0.3,NA,NA
2024-09-09,"Caliraya",2024-09-09 08:00:00,287.56,24,0.75,0,0,0,0,NA,NA,NA,NA
2024-09-09,"Caliraya",2024-09-08 08:00:00,286.81,24,0.75,0,0,0,0,NA,NA,NA,NA
2024-09-09,"Ipo",2024-09-09 08:00:00,100.69,24,0.2,101.1,-0.41,0,0,NA,NA,NA,NA
2024-09-09,"Ipo",2024-09-08 08:00:00,100.49,24,0.2,101.1,-0.61,0,0,NA,NA,NA,NA
2024-09-09,"La Mesa",2024-09-09 08:00:00,79.32,24,-0.09,80.15,-0.83,0,0,NA,NA,NA,NA
2024-09-09,"La Mesa",2024-09-08 08:00:00,79.41,24,-0.09,80.15,-0.74,0,0,NA,NA,NA,NA
2024-09-09,"Magat Dam",2024-09-09 08:00:00,185.17,24,0.12,190,-4.83,183.55,1.62,NA,NA,NA,NA
2024-09-09,"Magat Dam",2024-09-08 08:00:00,185.05,24,0.12,190,-4.95,183.43,1.62,NA,NA,NA,NA
2024-09-09,"Pantabangan",2024-09-09 08:00:00,194.2,24,0.33,216,-21.8,213.63,-19.43,NA,NA,NA,NA
2024-09-09,"Pantabangan",2024-09-08 08:00:00,193.87,24,0.33,216,-22.13,213.51,-19.64,NA,NA,NA,NA
2024-09-09,"San Roque",2024-09-09 08:00:00,261.07,24,1.25,280,-18.93,257.73,3.34,NA,NA,NA,NA
2024-09-09,"San Roque",2024-09-08 08:00:00,259.82,24,1.25,280,-20.18,257.22,2.6,NA,NA,NA,NA
Loading