RNCan / BioSimClient_R

An R client for the BioSIM Web API
2 stars 1 forks source link

Eliot's bug #9

Open donenrique24 opened 2 weeks ago

donenrique24 commented 2 weeks ago

Eliot McIntire reported the following bug:

library(BioSIM)
l <- structure(list(
    Name = c("ID1", "ID2", "ID3", "ID4", "ID5", "ID6"), 
    X = c(-116.623960, -116.459132, -116.294005, 
          -116.128578, -115.962854, -115.796835), 
    Y = c(58.2332800, 
          58.2638898, 58.2942755, 58.3244365, 58.3543720, 
          58.3840815), 
    elev = c(326, 315, 301, 287, 275, 267)), row.names = c(NA, 6L), class = "data.frame")
generateWeather(fromYr = 2020, toYr = 2020,
                l$Name,
                latDeg = l$Y, longDeg = l$X,
                elevM = l$elev,
                modelNames = "MPB_SLR",
                rcp = "RCP85", climModel = "GCM4")

#Starting local Java server...
#If you are using BioSIM Web API for a scientific publication, please cite it. Type citation("BioSIM") in #your R console to obtain the full citation.
#Error in .checkForExceptionInCallback(callback) : 
#  java.lang.NoSuchFieldException: size
#java.lang.Class.getField(Unknown Source)
#j4r.lang.codetranslator.REnvironment.processField(REnvironment.java:384)
#j4r.lang.codetranslator.REnvironment.processCode(REnvironment.java:234)
#j4r.net.server.JavaGatewayServer$JavaGatewayClientThread.processRequest(JavaGatewayServer.java:177)
#j4r.net.server.JavaGatewayServer$JavaGatewayClientThread.run(JavaGatewayServer.java:116)
#java.lang.Thread.run(Unknown Source)
donenrique24 commented 2 weeks ago

It seems the model MPB_SLR requires the MTS from the current and previous years in order to provide the prediction for the current year. Consequently, setting fromYr = 2020 and toYear = 2020 fails. To obtain the prediction for year 2020, the fromYr argument should be set to 2019. The model help is not explicit on this. It should be improved.

eliotmcintire commented 2 weeks ago

Thank you!

It looks like these models work if there are at least 2 years, but fail with 1 year. Importantly, when supplying more than 1 year, some of these will only return the final year. i.e., if 2010 to 2020 is supplied, it will only return data from 2020. (See @donenrique24 next comment)

 [1] "BudBurst"                                            "Climate_Mosture_Index_Annual"                       
 [3] "EmeraldAshBorerColdHardiness_Annual"                 "Gypsy_Moth_Seasonality"                             
 [5] "HemlockWoollyAdelgid_Annual"                         "HemlockWoollyAdelgid_Daily"                         
 [7] "MPB_Cold_Tolerance_Annual"                           "MPB_Cold_Tolerance_Daily"                           
 [9] "MPB_SLR"                                             "PlantHardinessCanada"                               
[11] "PlantHardinessUSA"                                   "Spruce_Budworm_Biology_Annual"                      
[13] "SpruceBeetle"                                        "Standardised_Precipitation_Evapotranspiration_Index"**
donenrique24 commented 2 weeks ago

You are right with MPB_SLR. However, I just checked with "Climate_Mosture_Index_Annual" because I have been using it recently. When I supply 2015 and 2021 as initial and final years, I get the CMI for all those years except 2015. Same thing for "Gypsy_Moth_Seasonality".

I'll check the others when I am back to the office.