bcgov / CCISS_ShinyApp

CCISS RMD knitr report graphics and Shiny App
Apache License 2.0
16 stars 3 forks source link

BGC prediction not working in CCISS_Spatial_exports.R #67

Closed cmahony closed 11 months ago

cmahony commented 11 months ago

@kdaust I'm getting a new error when i try to predict using the BGC model in CCISS_Spatial_exports.R. it's saying that table "clim" doesn't have the required columns when it does. this same code worked last week. any ideas?

> clim[,which(names(clim)%in%pred_vars), with=F]
               AHM        DD5      NFFD        PAS        SHM      CMI    PPT_MJ    PPT_JAS   CMDMax CMD.total DD_delayed
     1:  1.5117397  309.62725  99.85291 4583.35630   5.400257 5436.246 428.14027 1085.69401  0.00000    0.0000   29.40988
     2:  1.5776690  321.10787 102.23319 4415.61712   5.819768 5252.066 404.36304 1022.17033  0.00000    0.0000   29.50959
     3:  1.4787450  276.84450  91.83332 4572.62666   5.407397 5323.622 406.89341 1029.66663  0.00000    0.0000   30.01467
     4:  0.6372176   90.87122  32.56410 6250.63998   1.996669 6749.615 553.58957 1444.05177  0.00000    0.0000   40.21663
     5:  0.4515795   62.95367  20.49269 6528.27687   1.388618 6937.465 558.66371 1459.45378  0.00000    0.0000   44.43693
    ---                                                                                                                  
215189: 19.6757498 1922.00602 316.40855  104.08462 102.345124 1473.439  59.19271   92.04896 86.94349  286.8521    0.00000
215190: 20.1817954 1931.37705 316.03455  102.56971 105.413017 1445.873  57.00000   90.54890 88.19296  293.9923    0.00000
215191: 20.5542722 1933.09042 315.87339  101.03608 107.490987 1428.594  56.00000   89.24167 90.11185  298.0978    0.00000
215192: 21.1725960 1937.78818 315.84259   98.01980 109.572999 1401.380  54.00000   89.00000 89.89439  303.2678    0.00000
215193: 22.1503287 1939.23410 317.00631   90.63329 112.086337 1361.727  52.24167   87.04896 90.36134  310.7092    0.00000
> # Predict BGC
> tile_predict(clim,pred_vars=pred_vars) 
Error: Missing data in columns: PPT_MJ, PPT_JAS, CMD.total, CMI, SHM, AHM, NFFD, PAS.
In addition: Warning message:
In `[.data.table`(Y1, brks[j]:brks[j + 1], ..pred_vars) :
  Both 'pred_vars' and '..pred_vars' exist in calling scope. Please remove the '..pred_vars' variable in calling scope for clarity.
> test <- predict(BGCmodel,clim)
Error: Missing data in columns: PPT_MJ, PPT_JAS, CMD.total, CMI, SHM, AHM, NFFD, PAS.
kdaust commented 11 months ago

That's strange - are there any NAs in those columns? I'll investigate...

cmahony commented 11 months ago

I'll push the code. standby

cmahony commented 11 months ago

pushed. it's a run for BC. if you can make it work that would be ace!!

kdaust commented 11 months ago

Fixed. There were a few points (< 5) with NaN values, so I put a line to remove them. The prediction now seems to be working everywhere.