update cost graph query

This commit is contained in:
2025-07-14 20:56:36 -04:00
parent 956729f774
commit 8a0c3341dc
2 changed files with 56 additions and 2 deletions
+26
View File
@@ -75,6 +75,12 @@ view.all_conus_landfalls <- tbl(con, "all_conus_landfalls")
# lf_id = 1
#)
agnes <- list(
storm_basin = "AL",
storm_year = 1972,
storm_name = "AGNES"
)
# helper functions
# splits full_lf_id into lf_type and lf_id
@@ -150,6 +156,26 @@ get_normalized_cost_index <- function(storm, full_lf_id) {
return(result)
}
# returns normalized mmh/mmp indexes and costs over time by storm
get_all_normalized_cost_index <- function(storm) {
query <- view.yearly_normalized_losses %>%
filter(
storm_basin == storm$storm_basin,
storm_year == storm$storm_year,
storm_name == storm$storm_name
) %>%
mutate(
full_lf_id = paste0(lf_type, lf_id)
) %>%
select(
normalization_year, mmh_index, mmp_index, mmh, mmp, full_lf_id
)
result <- query %>% collect()
return(result)
}
# returns landfalls and data at landfall from HURDAT
get_hurdat_landfalls <- function(storm) {
query <- view.hurdat_track %>%