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

Problem with parameterList during runLPJ. #55

Open
Mareena0409 opened this issue Dec 23, 2024 · 6 comments
Open

Problem with parameterList during runLPJ. #55

Mareena0409 opened this issue Dec 23, 2024 · 6 comments

Comments

@Mareena0409
Copy link

Mareena0409 commented Dec 23, 2024

Dear developers,
I am trying to run the rLPJGUESS v.1.1.0 using the LPJ-GUESS v.3.1 (as suggested in the r package). But I get the following error that parameter list is invalid. the expected class of parameterList object is Matrix but it returns both Matrix and array as its class. I have not changed any settings as of now and I am trying to do the test run using the given code and files. Any help would be greatly appreciated.
Thank you

graphics.off()
rm(list = ls())
library(rLPJGUESS)
typeList <- c("cmass", "lai")
scaleLPJ_SPP <- "europe"
scaleLPJ_PFT <- "global"
LPJparameters_SPP <- getParameterList(scale = scaleLPJ_SPP, list = F)
LPJparameters_PFT <- as.matrix(getParameterList(scale = scaleLPJ_PFT, list = F))
setwd("E:/Testcode/Testcode")
mainDir <- file.path(getwd(), "LPJrunTest")
LPJsettings_PFT <- list(file.co2 = file.path(mainDir, "crudata",

  •                                          "co2_1765-2500_RCP3.txt"), file.cru = file.path(mainDir, 
    
  •                                                                                          "crudata", "cru_1901_2006.bin"), file.cru.misc = file.path(mainDir, 
    
  •                                                                                                                                                     "crudata", "cru_1901_2006misc.bin"), file.ndep = file.path(mainDir, 
    
  •                                                                                                                                                                                                                "crudata", "GlobalNitrogenDeposition.bin"), file.temp = file.path(mainDir, 
    
  •                                                                                                                                                                                                                                                                                  "temp.nc"), file.prec = file.path(mainDir, "prec.nc"), file.insol = file.path(mainDir, 
    
  •                                                                                                                                                                                                                                                                                                                                                                "rad.nc"), variable.temp = "temp", variable.insol = "rad", 
    
  •                     variable.prec = "prec", delete = F, save = F, processing = T, 
    
  •                     plot.data = F, save.plots = F, scale = scaleLPJ_PFT, mode = "cf", 
    
  •                     gridList = "gridlist.txt")
    

designLPJ <- getDesign(scale = scaleLPJ_PFT, list = T)
class(designLPJ)
[1] "list"
designLPJ$run_vegmode <- "cohort"
designLPJ$run_ifcentury <- 0
designLPJ$run_iffire <- 0
designLPJ$run_ifnlim <- 0
designLPJ$run_ifstochestab <- 0
designLPJ$run_ifstochmort <- 0
designLPJ$run_patcharea <- 25^2
designLPJ$run_npatch <- 1
designLPJ$run_ifdisturb <- 0
designLPJ$run_nyear_spinup <- 1
designLPJ$run_freenyears <- 0
designLPJ$run_save_state <- 0
designLPJ$run_restart <- 0
designLPJ$run_state_path <- mainDir
LPJsettings_PFT$design <- designLPJ
LPJsetup <- mainDir
spp <- as.matrix(LPJparameters_PFT[grep("_include", rownames(LPJparameters_PFT)),

  • ])

class(spp)
[1] "matrix" "array"
PFTs <- c("TeNE", "TeBS", "IBS", "TeBE", "C3G")
PFTsRows <- c()
for (i in PFTs) PFTsRows <- c(PFTsRows, grep(i, rownames(spp)))
spp[-PFTsRows, 1] <- 0
parameterStandard_PFT <- as.matrix(LPJparameters_PFT[-grep("_include",

  •                                                        rownames(LPJparameters_PFT)), ])
    

parameterStandard_PFT <- rbind(parameterStandard_PFT, spp)
parameterStandard_PFT <- as.matrix(parameterStandard_PFT)
class(parameterStandard_PFT)
[1] "matrix" "array"
ptm <- proc.time()
results_PFT <- runLPJ(x = mainDir, parameterList = parameterStandard_PFT,

  •                   typeList = typeList, settings = LPJsettings_PFT)
    

Using package template (template 1)
Saving package template in the mainDir
Using package template (template 2)
Saving package template in the mainDir
Error in if (class(parameterList) == "matrix") { :
the condition has length > 1
In addition: Warning messages:
1: In createSingleObject(x, typeList, settings) :
The file.wetdays has not been provided
2: In createSingleObject(x, typeList, settings) :
The file.minTemp has not been provided
3: In createSingleObject(x, typeList, settings) :
The file.maxTemp has not been provided
4: In createSingleObject(x, typeList, settings) :
The variable.wetdays has not been provided
5: In createSingleObject(x, typeList, settings) :
The variable.minTemp has not been provided
6: In createSingleObject(x, typeList, settings) :
The variable.maxTemp has not been provided
Error in runLPJ(x = mainDir, parameterList = parameterStandard_PFT, typeList = typeList, :
Invalid parameterList provided

@florianhartig
Copy link
Member

Hi,

which 3.1 version are you running, i.e. where did you get it from?

Best
Florian

@Mareena0409
Copy link
Author

Mareena0409 commented Dec 24, 2024

Hi,

which 3.1 version are you running, i.e. where did you get it from?

Best Florian

Hi Florian,
Thank you very much for the response.
I downloaded the LPJ-GUESS version 3.1 from the official LPJ-GUESS zenodo page by Lund University. I compiled the LPJ-GUESS using Cmake 3.31.0-rc1 and Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.11.5.
Thanks and Regards
Mareena

@Mareena0409
Copy link
Author

Mareena0409 commented Dec 27, 2024 via email

@florianhartig
Copy link
Member

Hi Mareena,

OK, I see, thanks!

I have to look at this in more detail. The issue is that different versions of the model (although all labeled 3.1) had different parameter / configuration / output files. At the time, our R package only worked with the model version from the Lund repository, but not with other 3.1 versions that were used in different research groups, including the educational 3.1 version that was downloadable from the LPJ-GUESS website.

I had a PhD student that had worked with a later LPJ-GUESS version from Munich and adopted the code of the package for that purpose. He also changed the code so that it's easier adoptable to other configuration / output files. This updated code of the R package is available as a pull request here https://github.com/biometry/rLPJGUESS/pulls and you could try if it works for you, but there is no guarantee as I didn't have the personpower to test how well this works for different LPJ-GUESS releases.

If you're interested in trying this out and / or further adopting the R code, I'd be happy to assist in that.

Best
Florian

@Mareena0409
Copy link
Author

Dear Florian,

Yes I am interested to to work on it further. I tried to copy the changed files from the pull request that you mentioned and copy it to the corresponding files in the .tar.gz file of stable release (rLPJGUESS v1.1.0). But I am unable to make changes inside that.

I also tried to make the changes after extracting it and then tried to compress back into .tar.gz file, but then it shows error in installation.

Next, I downloaded the pre-release version (https://github.com/biometry/rLPJGUESS/releases/download/v1.1.2/rLPJGUESS_1.1.2.tar.gz) which includes the changed files from the pull request and tried to run using the original instruction (given in the appendix documents). but I am getting an error (given below).
Thank you for your time, and I hope to work it out with you.
Mareena

designLPJ <- getDesign(scaleLPJ_PFT, list = T)
designLPJ$run_vegmode <- "cohort"
designLPJ$run_ifcentury <- 0
designLPJ$run_iffire <- 0
designLPJ$run_ifnlim <- 0
designLPJ$run_ifstochestab <- 0
designLPJ$run_ifstochmort <- 0
designLPJ$run_patcharea <- 25^2
designLPJ$run_npatch <- 1
designLPJ$run_ifdisturb <- 0
designLPJ$run_nyear_spinup <- 1
designLPJ$run_freenyears <- 0
designLPJ$run_save_state <- 0
designLPJ$run_restart <- 0
designLPJ$run_state_path <- mainDir
LPJsettings_PFT$design <- designLPJ
LPJsetup <- mainDir
spp <- as.matrix(LPJparameters_PFT[grep("_include", rownames(LPJparameters_PFT)),

  • ])
    Error in h(simpleError(msg, call)) :
    error in evaluating the argument 'x' in selecting a method for function 'as.matrix': incorrect number of dimensions

@florianhartig
Copy link
Member

Hi Mareena,

with very high likelihood, the problem is simply that the structure of the configuration files is different to what it was when we worked with the 3.1 version at the time. So, this will likely need to be changed in the R code.

I will try to put someone to work on this, but am unsure how swift we can solve this problem. Alternatively, if you can work on it and feel you have the skills, please go for it. Depending on your employment status and location, I could even put a small bounty / payment on this (if you're interested, to be discussed via email).

Best
Florian

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

2 participants