Skip to content

Commit

Permalink
CMIP6 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Mar 19, 2024
1 parent 5d7d539 commit 3b636af
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ importFrom(rJava,.jfield)
importFrom(rJava,.jinit)
importFrom(rJava,.jnew)
importFrom(rJava,.jpackage)
importFrom(terra,`nlyr<-`)
importFrom(terra,ncell)
importFrom(terra,rast)
importFrom(terra,readStart)
Expand Down
5 changes: 2 additions & 3 deletions R/NewhallData.R
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,7 @@ newhall_cmip6_rast <- function(model,
resolution = "10m",
version = "2.1",
CMIP6_PATH = file.path(newhall_data_dir("cache"), "CMIP6"),
tiffile = list.files(file.path(CMIP6_PATH, "climate",
paste0("wc", version, "_", resolution)),
tiffile = list.files(file.path(CMIP6_PATH, paste0("wc", version, "_", resolution)),
pattern = "\\.tif$",
recursive = TRUE)) {

Expand All @@ -607,7 +606,7 @@ newhall_cmip6_rast <- function(model,
}

colnames(tif) <- c("tiffile", "version", "resolution", "variable", "model", "ssp", "month")
f <- file.path(CMIP6_PATH, "climate", paste0("wc", version, "_", resolution),
f <- file.path(CMIP6_PATH, paste0("wc", version, "_", resolution),
tif$tiffile[which(tif$resolution == resolution)])
if (length(f) != 3) {
stop("One or more CMIP6 monthly grids are missing from ",
Expand Down
4 changes: 2 additions & 2 deletions man/newhall_cmip6.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/writeRasterLayers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions misc/cmip6_demo.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library(jNSMR)
library(terra)

newhall_cmip6_cache("EC-Earth3-Veg",
f <- newhall_cmip6_cache("EC-Earth3-Veg",
resolution = "2.5m",
ssp = "585",
time = "2061-2080")
Expand All @@ -13,7 +13,6 @@ x <- newhall_cmip6_subset(b, "EC-Earth3-Veg",
resolution = "2.5m",
ssp = "585",
time = "2061-2080")

x$elev <- 0
x$awc <- 200

Expand All @@ -28,3 +27,10 @@ y$awc <- 200
res2 <- newhall_batch(y)
plot(res2$temperatureRegime, col = hcl.colors(10),
main = "PRISM Normals (4km); 1991-2020")

ncdm8c1 <- terra::project(res$numConsecutiveDaysMoistInSomePartsOver8C, res2)
df <- res2$numConsecutiveDaysMoistInSomePartsOver8C - ncdm8c1
df <- terra::crop(df, ext(ncdm8c1) * 0.95)
plot(df, col=rev(hcl.colors(50)))
title(main = "\n\nChange in Number Consecutive Days Moist in Some Parts over 8 degrees C\n
EC-Earth3-Veg (2.5 minute); SSP: 585; 2061-2080\nvs.\nPRISM Normals (4km); 1991-2020")

0 comments on commit 3b636af

Please sign in to comment.