bcgov / climr

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

bias in climatena time series precipitation. #252

Closed cmahony closed 6 months ago

cmahony commented 6 months ago

The climatena historical time series of mean annual precipitation is 100mm below the reference normal, gcm ts, and cru.gpcc ts. same for other precipitation variables.

pt <- data.frame(lon = c(-125.13), lat = c(48.825), elev = c(7), id = 1)

data <- climr_downscale(xyz = pt, 
                        gcm_models = list_gcm(),
                        ssp = list_ssp(),
                        max_run = 10,
                        historic_ts_dataset = c("cru.gpcc", "climatena"), 
                        historic_ts = 1901:2022,
                        gcm_hist_years = 1850:2014, 
                        gcm_ts_years = 2015:2100, 
                        vars = list_variables()
)

variable <- "MAP"
plot_timeSeries(data, variable1 = variable, historic_ts_dataset = c("cru.gpcc", "climatena"), mar=c(3,3,2,4), refline = T)

data[PERIOD=="1961_1990", get(variable)]
mean(data[GCM==list_gcm()[1] & PERIOD%in%1961:1990 & RUN=="ensembleMean", get(variable)])
mean(data[DATASET == "cru.gpcc" & PERIOD%in%1961:1990, get(variable)])
mean(data[DATASET == "climatena" & PERIOD%in%1961:1990, get(variable)])
> data[PERIOD=="1961_1990", get(variable)]
[1] 2905.102
> mean(data[GCM==list_gcm()[1] & PERIOD%in%1961:1990 & RUN=="ensembleMean", get(variable)])
[1] 2912.471
> mean(data[DATASET == "cru.gpcc" & PERIOD%in%1961:1990, get(variable)])
[1] 2909.797
> mean(data[DATASET == "climatena" & PERIOD%in%1961:1990, get(variable)])
[1] 2803.364

image

kdaust commented 6 months ago

I think this is fixed now. @cmahony can you test this on the reviseNames branch?

cmahony commented 6 months ago

@kdaust error:

data <- downscale(xyz = pt, 
                        gcms  = list_gcms()[c(1)],
                        ssps  = list_ssps(),
                        max_run = 3,
                        obs_ts_dataset  = c("cru.gpcc", "climatena"), 
                        obs_years  = 1902:2022,
                        gcm_hist_years = 1850:2014, 
                        gcm_ssp_years  = 2015:2100, 
                        vars = list_vars()
)
Tave11 calculation is not supported yet.
Tave12 calculation is not supported yet.
Error in colnamesInt(x, neworder, check_dups = FALSE) : 
  argument specifying columns received non-existing column(s): cols[14]='CMD01'