Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanscharf/d6942e700f6158e9820e18c02448db41 to your computer and use it in GitHub Desktop.
Save ryanscharf/d6942e700f6158e9820e18c02448db41 to your computer and use it in GitHub Desktop.
NHC operational model intensity forecast animation
library(tidyverse)
library(lubridate)
library(gganimate)
library(ggrepel)
library(ggthemes)
NHCintensityModels <- c('FSSE', 'HCCA','GFEX','RVCN','ICON','IVCN','NVGM','NVGI','AVNO','AVNI','GFSO','GFSI','EMX','EMXI','EMX2','EGRR','EGRI','EGR2','CMC','CMCI','HWRF','HWFI','CTCX','CTCI','HMON','HMNI','CLP5','SHF5','DSF5','TCLP','SHIP','DSHP','LGEM')
P <-
daATCF %>% mutate(datee = ymd(paste0(Year, Month, Day))) %>% filter(
Hour == '00' &
ModelName %in% c(
'RVCN',
'NVGI',
'AVNO',
'AVNI',
'CMC',
'CMCI',
'HWRF',
'HWFI',
'CTCI',
'HMON',
'HMNI',
'CLP5',
'SHF5',
'DSF5',
'TCLP',
'SHIP',
'DSHP',
'LGEM'
) &
Max_winds_mph > 0 #& between(datee, ymd('2019-08-28'), ymd('2019-09-01'))
) %>% ggplot(aes(x = TAU, y = Max_winds_mph, group = ModelName)) +
geom_line(aes(color = ModelName), size = 2) +
geom_label_repel(data=. %>% group_by(ModelName, datee) %>% filter(TAU==max(TAU)) %>% distinct(ModelName, TAU, Max_winds_mph),
aes(label = ModelName, color = ModelName), segment.colour="black", segment.alpha = .5, hjust = 1, nudge_x = 1000) +
theme_few() +
theme(legend.position = 'none')
anim <-
P + transition_time(datee) + labs(title = 'Init: {frame_time} 00z')
animate(
anim,
type = 'cairo',
fps = 30,
width = 600,
height = 400,
duration = 15
)
anim_save("~/realtimemodeling/intensity.gif", animation = last_animation())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment