Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with kuenm_projchanges #58

Open
KitSimon opened this issue Jul 10, 2023 · 1 comment
Open

Trouble with kuenm_projchanges #58

KitSimon opened this issue Jul 10, 2023 · 1 comment

Comments

@KitSimon
Copy link

I'm trying but failing to run kuenm_projchanges as such:

sps <- dir()
out_models <- paste0(sps, "/4_Final_models")
modstats <- paste0(sps, "/6_Final_Model_Stats")

curpatt <- "1981-2010"
emscepatt <- c("ssp126", "ssp370", "ssp585")
timepatt <- c("2011-2040", "2041-2070", "2071-2100")
climpatt <- c("GFDL-ESM4", "IPSL-CM6A-LR", "MPI-ESM1-2-HR", "MRI-ESM2-0", "UKESM1-0-LL")
ext_type <- c("EC","E")
prjchn <- paste0(sps, "/7_Projection_changes")


for (i in 1:length(sps)) {
  kuenm_projchanges(occ = occ_joint[i], 
                    fmod.stats = modstats[i], 
                    threshold = 5, 
                    current = curpatt, 
                    emi.scenarios = emscepatt,
                    time.periods = timepatt,
                    clim.models = climpatt,
                    ext.type = ext_type, 
                    out.dir = prjchn[i])
}

Running the script results in the error below.

Preparing data for starting analyses, please wait...

Starting analyses, please wait...
Error in ext_types[[i]] : subscript out of bounds

The directory prjchn is correctly generated, but containing a single subdirectory "Changes_EC", which is empty.
Omitting the for-loop doesn't seem to change anything, as the error message persists. It has me stumped. How can I go about solving this?

@KitSimon
Copy link
Author

I did some digging in the kuenm_projchanges function and noticed a quirk in how the model stats are read. It presupposes median statistics if I'm correct? In that case I think the fact that I opted to only generate mean statistics with kuenm_modstats_swd in the previous step might be a contributing factor to the error.

  # Reading model names
  nstas <- list.files(fmod.stats, pattern = "med.tif$",
                  full.names = TRUE, recursive = TRUE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant