usa-npn / cales-thermal-calendars

Estimating trends in phenology in the northeastern US
https://usa-npn.github.io/cales-thermal-calendars/spatial-trends-report.html
MIT License
0 stars 0 forks source link

summarize_normals fails if the stack does not contain all years 1991:2020 #13

Closed diazrenata closed 4 months ago

diazrenata commented 4 months ago
          Error on getting to the `normals_summary` targets:
Last error message:
    error in evaluating the argument 'x' in selecting a method for function 'app': [subset] invalid name(s)
Last error traceback:
    summarize_normals(gdd_doy_stack_1000)
    terra::app(stack[[as.character(years)]], function(x) c(mean = mean(x,   ...
    stack[[as.character(years)]]
    stack[[as.character(years)]]
    .local(x, i, j = j, ...)
    subset(x, i, NSE = FALSE)
    subset(x, i, NSE = FALSE)
    .local(x, ...)
    error("subset", "invalid name(s)")
    stop("[", f, "] ", emsg, ..., call. = FALSE)
    .handleSimpleError(function (cond)  .Internal(C_tryCatchHelper(addr, 1L,...
    h(simpleError(msg, call))
    .handleSimpleError(function (condition)  {     state$error <- build_mess...
    h(simpleError(msg, call))

Originally posted by @diazrenata in https://github.com/usa-npn/cales-thermal-calendars/issues/7#issuecomment-2050245897

diazrenata commented 4 months ago

If stack does not have layers for all years in years, this function will fail. It failed for me because I was running on 1990:2000.

You could set the pipeline to pass the years being run as the years argument. Or, #14 should patch this from within the function.

Aariq commented 4 months ago

got this fixed now, thanks.