bcgov / climr

An R package for downscaling monthly climate data for North America
https://bcgov.github.io/climr/
16 stars 5 forks source link

year 2100 is broken for gcm time series #225

Closed cmahony closed 7 months ago

cmahony commented 7 months ago

the final year of GCM time series is broken:

image

image

it may or may not be broken for SSP126. image

the problem is not just isolated to CanESM5: image

I wondered whether the SSP126 run was being recycled for the other ssps, or alternatively that the year 2015 value was being recycled, but neither is the case.

> projected.ssp126$Tmax07[which(projected.ssp585$RUN=="ensembleMean" & projected.ssp585$PERIOD %in% c(2015, 2100))]
[1] 22.30238 21.89006
> projected.ssp245$Tmax07[which(projected.ssp245$RUN=="ensembleMean" & projected.ssp585$PERIOD %in% c(2015, 2100))]
[1] 21.38033 21.29707
> projected.ssp585$Tmax07[which(projected.ssp585$RUN=="ensembleMean" & projected.ssp585$PERIOD %in% c(2015, 2100))]
[1] 20.66922 21.48682
cmahony commented 7 months ago

Reprex:

library(climr)
points_downscale_ref <- readRDS("C:/Users/CMAHONY/OneDrive - Government of BC/Projects/2023_climr/climr/tests/testthat/data/points_downscale_ref.rds")
pt <- points_downscale_ref[1,]
projected <- climr_downscale(pt, 
                             gcm_models = list_gcm()[1],
                             ssp = list_ssp()[c(4)],
                             max_run = 10,
                             gcm_hist_years = 1851:2014, 
                             gcm_ts_years = 2015:2100, 
                             vars = "Tmax07"
)

gcms <- na.omit(unique(projected$GCM))[1]
ssps <- na.omit(unique(projected$SSP))[1]
runs <- unique(projected$RUN)
runs <- runs[grep("r", runs)]

par(mar=c(3,3,0.1, 0.1), mgp=c(1.5, 0.25, 0), tck=-0.01)
plot(projected$PERIOD, projected$Tmax07, col="white")
for(run in runs){
  s <- which(projected$RUN==run)
  lines(projected$PERIOD[s], projected$Tmax07[s], col=which(runs==run))
  # Sys.sleep(1)
}
lines(projected$PERIOD[projected$RUN=="ensembleMean"], projected$Tmax07[projected$RUN=="ensembleMean"], col=1, lwd=3)
mtext(paste(gcms, ssps), side=3, line=-1.5, adj=0.05)
kdaust commented 7 months ago

Should be fixed now: image