bcgov / climr

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

normal "auto" geographical checks need to be expanded? #188

Closed CeresBarros closed 9 months ago

CeresBarros commented 9 months ago

When climr_downscale(..., which_normal = "auto"), we check for whether the point data intersects BC only to decide which normals to get.

Because we currently decide between normal_composite or normal_na, I think we need to expand the geographical boundary to western NA, not just BC.

 else {
    #message("Normals not specified, using highest resolution available for each point")
    bc_outline <- rast(system.file("extdata", "bc_outline.tif", package = "climr"))
    pnts <- extract(bc_outline, xyz[, .(lon, lat)], method = "simple")
    bc_ids <- xyz[["id"]][!is.na(pnts$PPT01)]
    if (length(bc_ids) >= 1) {
      xyz_save <- xyz
      xyz <- xyz[!is.na(pnts$PPT01),]
      thebb_bc <- get_bb(xyz)
      message("for BC...")
      normal <- normal_input(dbCon = dbCon, normal = "normal_composite", bbox = thebb_bc, cache = cache)
    } else {
      normal <- normal_input(dbCon = dbCon, normal = "normal_na", bbox = thebb, cache = cache)
    }
cmahony commented 9 months ago

Indeed, and good catch. i think this is best done by @kdaust. Note however that I am hoping to produce a north american composite in pretty short order (next few weeks).

CeresBarros commented 9 months ago

When you do, will the "auto" option make sense?

cmahony commented 9 months ago

no, we will just default to the climr composite, and users can select the climateNA composite if they want it.

cmahony commented 9 months ago

We should keep normal_bc for now. the reason is that my new composites do blend into BC's northeastern boundary and it will be good to have the option of a pure BC PRISM normal.