forked from eco4cast/neon4cast-shiny
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlead_time.R
39 lines (29 loc) · 1.14 KB
/
lead_time.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Forecast skill vs lead time plot
d2 <- data_date_model()
## get target date & site
date = "2021-06-26"
site = "HARV"
targ <- targets() %>% filter(siteID == site)
hor <- list()
## for each model
models = unique(d2$team)
for(m in seq_along(models)){
## organize data by horizon
hor[[models[m]]] = d2 %>% filter(team == models[m],time == date, siteID == site) %>%
pivot_wider(names_from="statistic",values_from="gcc_90") #%>%
}
yrng = c(min(sapply(hor,function(x){min(x$lower95)})),
max(sapply(hor,function(x){max(x$upper95)})))
xrng = as.Date(range(sapply(hor,function(x){range(as.Date(x$forecast_start_time))})),origin = "1970-01-01")
plot(xrng,yrng,xlim=xrng,ylim=yrng,type='n',
xlab="Lead Time",ylab="gcc90")
for(m in seq_along(models)){
leadTime = as.Date(hor[[m]]$forecast_start_time)
ecoforecastR::ciEnvelope(leadTime,
hor[[m]]$lower95,
hor[[m]]$upper95,
col=ecoforecastR::col.alpha(m,0.5))
lines(x=leadTime,y=hor[[m]]$mean,col=m)
}
leadTime = xrng[1]:xrng[2]
lines(leadTime,rep(targ$gcc_90[which(targ$time == date)],length(leadTime)),lwd=3)