Skip to content

Commit

Permalink
Updated formatting for DMR web map; 0 and 100 change to <1 and >99 pe…
Browse files Browse the repository at this point in the history
…rcent; updated forecast tables with changes
  • Loading branch information
jevanilla committed Aug 20, 2024
1 parent 43f65b7 commit 3b3cab6
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 67 deletions.
2 changes: 1 addition & 1 deletion R/dmr_webpage_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ write_forecast_tables <- function(user_config) {

suppressMessages(readr::write_csv(t_1, file.path(user_config$output$current_forecast)))

t_2 <- read_forecast(new_only=TRUE, id=FALSE) |>
t_2 <- read_forecast(new_only=TRUE, id=FALSE, format=TRUE) |>
dplyr::arrange(dplyr::desc(.data$p_3)) |>
format_webpage_table()

Expand Down
15 changes: 4 additions & 11 deletions R/forecast_io.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,10 @@ read_forecast <- function(format = FALSE,

if (format) {
forecast <- forecast |>
dplyr::mutate(prob_0 = format_probs(.data$p_0),
prob_1 = format_probs(.data$p_1),
prob_2 = format_probs(.data$p_2),
prob_3 = format_probs(.data$p_3)) |>
dplyr::select(-.data$version,
-.data$class_bins,
-.data$ensemble_n,
-.data$p_0,
-.data$p_1,
-.data$p_2,
-.data$p_3)
dplyr::mutate(p_0 = format_probs(.data$p_0),
p_1 = format_probs(.data$p_1),
p_2 = format_probs(.data$p_2),
p_3 = format_probs(.data$p_3))
}

if (id) {
Expand Down
2 changes: 2 additions & 0 deletions R/format_probs.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ format_probs <- function(probs) {

no_zero <- sapply(to_char, function(x) if (x == "0") {x = "<1"} else {x})

no_hundred <- sapply(no_zero, function(x) if (x == "100") {x = ">99"} else {x})

r <- sapply(no_zero, function(x) {return(paste(x, "%", sep=""))})

return(r)
Expand Down
3 changes: 0 additions & 3 deletions inst/forecastdb/current_forecast.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version,ensemble_n,location,date,name,lat,lon,class_bins,forecast_start_date,forecast_end_date,p_0,p_1,p_2,p_3,p3_sd,p_3_min,p_3_max,predicted_class,f_id
v0.3.0,10,PSP12.21,2024-08-05,Fort St. George,43.75373,-69.78983,"0,10,30,80",2024-08-09,2024-08-15,70,24,5,1,0.40440561375715295,0.14267105143517256,1.540609821677208,0,PSP12.21_2024-08-05
v0.3.0,10,PSP12.34,2024-08-12,Head Beach,43.71711,-69.84999,"0,10,30,80",2024-08-16,2024-08-22,69,24,6,1,0.4788252121448886,0.6911404430866241,2.209136076271534,0,PSP12.34_2024-08-12
v0.3.0,10,PSP10.11,2024-08-13,Ogunquit River,43.2503,-70.5954,"0,10,30,80",2024-08-17,2024-08-23,95,5,0,0,0.00535397760590587,0.00136772450787248,0.01828385138651356,0,PSP10.11_2024-08-13
v0.3.0,10,PSP10.33,2024-08-13,Spurwink River,43.56632,-70.27305,"0,10,30,80",2024-08-17,2024-08-23,95,4,0,0,0.00394192340808114,9.07773028302472e-4,0.01282946177525445,0,PSP10.33_2024-08-13
Expand All @@ -10,7 +9,6 @@ v0.3.0,10,PSP12.01,2024-08-12,Basin Pt.,43.73848,-70.04343,"0,10,30,80",2024-08-
v0.3.0,10,PSP12.03,2024-08-12,Potts Pt.,43.73064,-70.02556,"0,10,30,80",2024-08-16,2024-08-22,84,15,1,0,0.01453069508627702,0.0082789767475333,0.05114831146784127,0,PSP12.03_2024-08-12
v0.3.0,10,PSP12.13,2024-08-12,Lumbos Hole,43.79553,-69.94557,"0,10,30,80",2024-08-16,2024-08-22,98,2,0,0,3.814142752473752e-4,3.1078611755219754e-4,0.00151737431224319,0,PSP12.13_2024-08-12
v0.3.0,10,PSP12.28,2024-08-12,Bear Island,43.78556,-69.87415,"0,10,30,80",2024-08-16,2024-08-22,97,2,0,0,0.00125510981382541,0.00135069785756059,0.00562808745598886,0,PSP12.28_2024-08-12
v0.3.0,10,PSP14.05,2024-08-05,Griffith Head,43.784,-69.722,"0,10,30,80",2024-08-09,2024-08-15,80,18,2,0,0.1320008252568706,0.04659545957110822,0.4879832733422518,0,PSP14.05_2024-08-05
v0.3.0,10,PSP14.21,2024-08-07,Newagen,43.78639,-69.65778,"0,10,30,80",2024-08-11,2024-08-17,93,7,0,0,0.01932009979603969,0.00355999072780832,0.06919746519997716,0,PSP14.21_2024-08-07
v0.3.0,10,PSP15.25,2024-08-14,Christmas Cove Town Landing,43.84476,-69.55365,"0,10,30,80",2024-08-18,2024-08-24,94,5,0,0,0.01177996698581249,0.00622991065029054,0.03893274115398526,0,PSP15.25_2024-08-14
v0.3.0,10,PSP16.41,2024-08-14,Port Clyde,43.92526,-69.259,"0,10,30,80",2024-08-18,2024-08-24,97,3,0,0,0.00122431109140799,0.00186139477591495,0.00612038566032424,0,PSP16.41_2024-08-14
Expand All @@ -19,7 +17,6 @@ v0.3.0,10,PSP19.15,2024-08-14,Stonington,44.15419,-68.65947,"0,10,30,80",2024-08
v0.3.0,10,PSP19.33,2024-08-07,Blue Hill Falls,44.37713,-68.5612,"0,10,30,80",2024-08-11,2024-08-17,97,3,0,0,0.0011183836857125,5.2768172054129536e-5,0.00357665121555328,0,PSP19.33_2024-08-07
v0.3.0,10,PSP21.09,2024-08-14,Bass Hbr.,44.23824,-68.34792,"0,10,30,80",2024-08-18,2024-08-24,94,6,0,0,0.0159331301973968,0.01793136616470292,0.06412088987417519,0,PSP21.09_2024-08-14
v0.3.0,10,PSP23.07,2024-08-11,Corea Hbr.,44.39319,-67.97628,"0,10,30,80",2024-08-15,2024-08-21,91,8,1,0,0.05909791282172384,0.07759732543490827,0.26230199728161097,0,PSP23.07_2024-08-11
v0.3.0,10,PSP24.08,2024-08-05,Ripley Pt.,44.52198,-67.79233,"0,10,30,80",2024-08-09,2024-08-15,96,4,0,0,0.00558830188080049,9.796553058549762e-4,0.01894350862130522,0,PSP24.08_2024-08-05
v0.3.0,10,PSP25.06,2024-08-13,Kelley Pt.,44.53205,-67.5655,"0,10,30,80",2024-08-17,2024-08-23,96,4,0,0,0.00392130907036587,0.00160482122737448,0.01325916382484138,0,PSP25.06_2024-08-13
v0.3.0,10,PSP26.07,2024-08-13,Cutler Hbr.,44.65701,-67.20525,"0,10,30,80",2024-08-17,2024-08-23,85,12,2,0,0.15932280724116243,0.26486064307391644,0.7848865352571011,0,PSP26.07_2024-08-13
v0.3.0,10,PSP26.15,2024-08-12,Lubec Channel,44.85891,-66.98028,"0,10,30,80",2024-08-16,2024-08-22,96,3,0,0,0.00370021956624289,0.00164346292876871,0.01281095319427549,0,PSP26.15_2024-08-12
Expand Down
49 changes: 23 additions & 26 deletions inst/forecastdb/dmr_webpage_table.csv
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
DMR Station ID,Forecast Initialized Date,Location,Latitude,Longitude,Forecast Start Date,Forecast End Date,Closure-level PSP Probability,Predicted Class
PSP12.21,2024-08-05,Fort St. George,43.75373,-69.78983,2024-08-09,2024-08-15,1%,Low
PSP12.34,2024-08-12,Head Beach,43.71711,-69.84999,2024-08-16,2024-08-22,1%,Low
PSP10.11,2024-08-13,Ogunquit River,43.2503,-70.5954,2024-08-17,2024-08-23,0%,Low
PSP10.33,2024-08-13,Spurwink River,43.56632,-70.27305,2024-08-17,2024-08-23,0%,Low
PSP11.110,2024-08-12,CAS BA2 Bangs island,43.728,-70.095,2024-08-16,2024-08-22,0%,Low
PSP11.115,2024-08-12,CAS BASK,43.73316,-70.16358,2024-08-16,2024-08-22,0%,Low
PSP11.117,2024-08-12,CAS CF3,43.7119,-70.18787,2024-08-16,2024-08-22,0%,Low
PSP12.01,2024-08-12,Basin Pt.,43.73848,-70.04343,2024-08-16,2024-08-22,0%,Low
PSP12.03,2024-08-12,Potts Pt.,43.73064,-70.02556,2024-08-16,2024-08-22,0%,Low
PSP12.13,2024-08-12,Lumbos Hole,43.79553,-69.94557,2024-08-16,2024-08-22,0%,Low
PSP12.28,2024-08-12,Bear Island,43.78556,-69.87415,2024-08-16,2024-08-22,0%,Low
PSP14.05,2024-08-05,Griffith Head,43.784,-69.722,2024-08-09,2024-08-15,0%,Low
PSP14.21,2024-08-07,Newagen,43.78639,-69.65778,2024-08-11,2024-08-17,0%,Low
PSP15.25,2024-08-14,Christmas Cove Town Landing,43.84476,-69.55365,2024-08-18,2024-08-24,0%,Low
PSP16.41,2024-08-14,Port Clyde,43.92526,-69.259,2024-08-18,2024-08-24,0%,Low
PSP19.12,2024-08-14,IAH Town Dock,44.0737,-68.64,2024-08-18,2024-08-24,0%,Low
PSP19.15,2024-08-14,Stonington,44.15419,-68.65947,2024-08-18,2024-08-24,0%,Low
PSP19.33,2024-08-07,Blue Hill Falls,44.37713,-68.5612,2024-08-11,2024-08-17,0%,Low
PSP21.09,2024-08-14,Bass Hbr.,44.23824,-68.34792,2024-08-18,2024-08-24,0%,Low
PSP23.07,2024-08-11,Corea Hbr.,44.39319,-67.97628,2024-08-15,2024-08-21,0%,Low
PSP24.08,2024-08-05,Ripley Pt.,44.52198,-67.79233,2024-08-09,2024-08-15,0%,Low
PSP25.06,2024-08-13,Kelley Pt.,44.53205,-67.5655,2024-08-17,2024-08-23,0%,Low
PSP26.07,2024-08-13,Cutler Hbr.,44.65701,-67.20525,2024-08-17,2024-08-23,0%,Low
PSP26.15,2024-08-12,Lubec Channel,44.85891,-66.98028,2024-08-16,2024-08-22,0%,Low
PSP27.05,2024-08-12,Gove Pt.,44.90545,-67.05621,2024-08-16,2024-08-22,0%,Low
PSP27.46,2024-08-13,Gleason Cove,44.97084,-67.05254,2024-08-17,2024-08-23,0%,Low
PSP10.11,2024-08-13,Ogunquit River,43.2503,-70.5954,2024-08-17,2024-08-23,<1%%,Low
PSP10.33,2024-08-13,Spurwink River,43.56632,-70.27305,2024-08-17,2024-08-23,<1%%,Low
PSP11.110,2024-08-12,CAS BA2 Bangs island,43.728,-70.095,2024-08-16,2024-08-22,<1%%,Low
PSP11.115,2024-08-12,CAS BASK,43.73316,-70.16358,2024-08-16,2024-08-22,<1%%,Low
PSP11.117,2024-08-12,CAS CF3,43.7119,-70.18787,2024-08-16,2024-08-22,<1%%,Low
PSP12.01,2024-08-12,Basin Pt.,43.73848,-70.04343,2024-08-16,2024-08-22,<1%%,Low
PSP12.03,2024-08-12,Potts Pt.,43.73064,-70.02556,2024-08-16,2024-08-22,<1%%,Low
PSP12.13,2024-08-12,Lumbos Hole,43.79553,-69.94557,2024-08-16,2024-08-22,<1%%,Low
PSP12.28,2024-08-12,Bear Island,43.78556,-69.87415,2024-08-16,2024-08-22,<1%%,Low
PSP14.21,2024-08-07,Newagen,43.78639,-69.65778,2024-08-11,2024-08-17,<1%%,Low
PSP15.25,2024-08-14,Christmas Cove Town Landing,43.84476,-69.55365,2024-08-18,2024-08-24,<1%%,Low
PSP16.41,2024-08-14,Port Clyde,43.92526,-69.259,2024-08-18,2024-08-24,<1%%,Low
PSP19.12,2024-08-14,IAH Town Dock,44.0737,-68.64,2024-08-18,2024-08-24,<1%%,Low
PSP19.15,2024-08-14,Stonington,44.15419,-68.65947,2024-08-18,2024-08-24,<1%%,Low
PSP19.33,2024-08-07,Blue Hill Falls,44.37713,-68.5612,2024-08-11,2024-08-17,<1%%,Low
PSP21.09,2024-08-14,Bass Hbr.,44.23824,-68.34792,2024-08-18,2024-08-24,<1%%,Low
PSP23.07,2024-08-11,Corea Hbr.,44.39319,-67.97628,2024-08-15,2024-08-21,<1%%,Low
PSP25.06,2024-08-13,Kelley Pt.,44.53205,-67.5655,2024-08-17,2024-08-23,<1%%,Low
PSP26.07,2024-08-13,Cutler Hbr.,44.65701,-67.20525,2024-08-17,2024-08-23,<1%%,Low
PSP26.15,2024-08-12,Lubec Channel,44.85891,-66.98028,2024-08-16,2024-08-22,<1%%,Low
PSP27.05,2024-08-12,Gove Pt.,44.90545,-67.05621,2024-08-16,2024-08-22,<1%%,Low
PSP27.46,2024-08-13,Gleason Cove,44.97084,-67.05254,2024-08-17,2024-08-23,<1%%,Low
PSP12.34,2024-08-12,Head Beach,43.71711,-69.84999,2024-08-16,2024-08-22,1%%,Low
Loading

0 comments on commit 3b3cab6

Please sign in to comment.