Giter VIP home page Giter VIP logo

rlpjguess's Introduction

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Build Status

rLPJGUESS

A R package that wraps the LPJ-GUESS model

Recommended installation

Install the latest stable release from https://github.com/biometry/rLPJGUESS/releases.

You can download the binary and install it as follows

install.packages("/path/to/binary/rLPJGUESS_1.1.0.tar.gz", repos = NULL, type = "source")

Or you can install it directly from the download link

library(devtools)
install_url("https://github.com/biometry/rLPJGUESS/releases/download/v1.1.0/rLPJGUESS_1.1.0.tar.gz", 
dependencies = T, build_vignettes = T)
library(rLPJGUESS)
?rLPJGUESS

Note: rLPJGUESS relies on two packages for parallelization:

  • snow (for SOCK cluster, if you use PC/laptop)
  • Rmpi (for MPI clusters)

Installing "Rmpi" might be complicated, and it is not strictly required: If you are thinking of using rLPJGUESS on a laptop or workstation, you will be dealing with SOCK clusters and you do not need Rmpi.

Development release

If you want to install the current (development) version from this repository, run

devtools::install_github(repo = "biometry/rLPJGUESS", subdir = "rLPJGUESS", 
dependencies = T, build_vignettes = T)

Below the status of the automatic Travis CI tests on the master branch

Build Status

Build the package yourself

Clone the package to your computer, and build with hand or Rstudio. If you need help see here http://biometry.github.io/APES/R/R70-PackageDevelopment.html

In Rstudio, the vignette may not be built per default. You will turn this on in your project options, or run

devtools::build_vignettes("rLPJGUESS")

rlpjguess's People

Contributors

florianhartig avatar mauriziobagnara avatar rasilgon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rlpjguess's Issues

Help files

Update help files to match new package capabilities

need help

what is the "file.cru.misc " , What does it mean? and

Merge 4.x update

Create a new issue to discuss the 4.x update. What I would suggest is

a) @JohannesOberpriller - can you create a branch for this, and possibly a pre-release (compiled), so that people can beta-test it?

b) I will then do the merge.

One question: will this then remain compatible with 3.1?

finish unit tests

Hi Ramiro,

I have included the test folder structure in the unit tests and started a few simple tests - could you maybe see if you could add more? I found it a bit difficult to write the tests because the help is sometimes not 100% clear how stuff works. I'll write an extra ticket about this

parameter format to match BayesianTools?

give as input a vector/matrix of parameter values, and build the nested list internally?

also: identify the subset of parameter to calibrate by index instead of name?

lost Wiki...

I have noticed that after changing the repo name, the Wiki is empty. Do we have copies of the wiki contents?

Create design option

Include an option to pass a design for the general parameters (mortality, disturbance, etc).
Question: as part of settings or as a new parameter?

add default parameter values function

Would be nice/important to have a function that returns parameter names, default values, mode when they are used (global/europe), original names,and so on. The returned object can be structured as a matrix or dataframe.

LPJ individual mode

I tried to run Rlpj in "individual" mode (one of the design option), the model crashes without any error message in the log file. Running from terminal, the messages look like this:

[LPJ-GUESS  Fri Jan 27 11:27:21 2017]



--------------------------------------------------
LPJ-GUESS cohort mode - European species
--------------------------------------------------

Commencing simulation for gridcell at (10.454,51.0802)
Description: Hainich
Using soil code and Nitrogen deposition for (10.0,51.0)
Segmentation fault: 11

It seems to be a problem with netcdf input files, probably they need to have a different structure. Have we ever tested it? Ramiro?

data locations

we have to talk about the locations for the test data

I put the LPJ folder structure from Maurizio in tests. But there is also data-raw and inst/extdata

I would put data that is only used for the tests in the test folder, but not sure ...

Commented code in the vignette

In the vignette, there are various code places that are commented out, to avoid that the model is run, such as

# and lets check what it has been written in the template
# if no value was provided for the parameters, they have been set to default values
template [c(156:166)]

# Next step is to call the model
# but we skip it
# runLPJ(mainDir, runDir, "global_cru.ins")

This is not good style - you should solve this via an extra chunk, setting eval = F, which suppresses the code execution

Problem with runLPJ

Hi,
I am totally new to the model so apologies if my question is a silly one. I am trying to follow the code in the appendix of your EMS paper. Specifically I can run with no errors appendix 1. But when it cums to run the model my output is the following:

`> 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
Starting run
Calling LPJ-GUESS

/home/gian/Testcode/LPJrunTest/guess -input cf /home/gian/Testcode/LPJrunTest/runDirectory/global_cf.ins
Error in getLPJData(runObject$outDir, runObject$typeList, runObject, runObject$processing) :
There are not model outputs. Please check the guess.log files
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
7: running command '/home/gian/Testcode/LPJrunTest/guess -input cf /home/gian/Testcode/LPJrunTest/runDirectory/global_cf.ins' had status 99
8: In getLPJData(runObject$outDir, runObject$typeList, runObject, runObject$processing) :
There is no cmass.out
9: In getLPJData(runObject$outDir, runObject$typeList, runObject, runObject$processing) :
There is no lai.out
Error in runLPJ(x = mainDir, parameterList = parameterStandard_PFT, typeList = typeList, :
Error when running the model
`

It seems that the model cannot create output files and then does not find them. The guess.log file is created and contains the following:
"In /home/gian/Testcode/LPJrunTest/runDirectory/global.ins, line 135, "lcfrac_fixed":
Error: Undefined identifier
Bad instruction file!"

And this is the line into the global.ins which the guess.log file refers to:
"lcfrac_fixed run_lcfrac_fixed ! use landcover fractions (%) below (1) or read from input file (0)"

Any help will be much appreciated.

Gianluca

help files in general

a comment about the help - when I was writing the unit tests now, I realized that the help does not do a good job in showing the context in which functions are being used.

Take as example plotLPJData - this function requires running getLPJData first, but this is nowhere documented, it just says that the input variable x is an LPJData object.

A good help should have

  • a link to getLPJData in the help of x
  • a link to getLPJData with the @Seealso tag
  • a shared help file that shows both functions in context, see also comment in #39

see, for example, ?DHARMa::plot.DHARMa

Provided more options in template cf

Up to now, users can pass path to the nc input files , but not the name of the variable:

param "file_temp"     (str "path_to_temp.nc")
param "variable_temp" (str "temp")

However, the variable_temp values must be also modified because it determined by nc file.

We could either provide more options on modifying this or let users pass the right template.
The first implies changes in code, the second does not.

About some question on LPJ model and the package

Dear developer, thank you for your great work! Recently, l just started to study LPJ-GUESS model. l have some question about the package, and l hope you can help me.
1, l have compiled the LPJ-GUESS and there are some files in the build folder, but l do not which one to use create a link to the guess executable, the guesscmd or guess? l am in the window system.
2, I'm confused about ‘gridlist.txt’, In this document, we should import the longitude and latitude of the simulated region? or all the grid size in the analyzed region?
Finally, l take the liberty of asking for a request: can you share with me the data used in this package test? . l think that can help me understand the model.
Thank you for you again!

Add more settings for template creation

Ideally, it should be possible to edit/specify all the following settings/options directly from R:

`!///////////////////////////////////////////////////////////////////////////////////////
!// RUN PARAMETERS AND OPTIONS
!

vegmode "cohort" ! "cohort", "individual" or "population"
nyear_spinup 500 ! number of years to spin up the simulation for
ifcalcsla 1 ! whether ctonto calculate SLA from leaf longevity
! (PFT-specific value can be specified in this file instead)
ifcalccton 1 ! whether to calculate leaf C:N min from leaf longevity
! (PFT-specific value can be specified in this file instead)
iffire 1 ! whether to implement fire (1) or not (0)
npatch 25 ! number of replicate patches to simulate
patcharea 10000 ! patch area (m2)
estinterval 1 ! years between establishment events in cohort mode
ifdisturb 1 ! whether generic patch-destroying disturbances enabled
distinterval 200 ! average return time for generic patch-destroying disturbances
! Hickler et al. (2011) used 200
ifbgestab 1 ! whether background establishment enabled
ifsme 1 ! whether spatial mass effect enabled
ifstochestab 1 ! whether establishment stochastic
ifstochmort 1 ! whether mortality stochastic
ifcdebt 1 ! whether to allow vegetation C storage (1) or not (0)
wateruptake "rootdist"! "wcont", "rootdist", "smart" or "speciesspecific",
! see documentation for water_uptake()

!///////////////////////////////////////////////////////////////////////////////
! PROCESS SETTINGS SPECIFIC TO NITROGEN
!///////////////////////////////////////////////////////////////////////////////

ifcentury 1 ! whether to use CENTURY SOM dynamics (mandatory for N cycling)
ifnlim 0 ! whether plant growth limited by available N
freenyears 100 ! number of years to spin up without N limitation (needed to build up a N pool)
nfix_a 0.234 ! first term in N fixation eqn (Conservative 0.102, Central 0.234, Upper 0.367)
nfix_b -0.172 ! second term in N fixation eqn (Conservative 0.524, Central -0.172, Upper -0.754)
nrelocfrac 0.5 ! fraction of N retranslocated prior to leaf and root shedding

!///////////////////////////////////////////////////////////////////////////////
! SERIALIZATION SETTINGS
!///////////////////////////////////////////////////////////////////////////////
!state_year ! year to save/start state file (no setting = after spinup)
restart 0 ! wheter to start from a state file
save_state 0 ! wheter to save a state file
state_path "" ! directory to put state files in

ifsmoothgreffmort 1 ! whether to vary mort_greff smoothly with growth efficiency (1)
! or to use the standard step-function (0)
! greff_min values below calibrated for the smooth (1) option
ifdroughtlimitedestab 1 ! whether establishment is limited by growing season drought
ifrainonwetdaysonly 1 ! whether to rain on wet days only (1), or to rain a bit every day (0)
ifbvoc 0 ! whether to include BVOC calculations (1) or not (0)

!!!!!!!!!!!! landcover parameters !!!!!!!!!!!!!!

run_landcover 0 ! whether to use (and change) landcover fractions (1) or not (0)

run_urban 0 ! whether to simulate barren land (1) or not (0)
run_crop 1 ! whether to simulate crop vegetation (1) or not (0)
run_forest 0 ! whether to simulate managed forest (1) or not (0)
run_pasture 0 ! whether to simulate pasture (1) or not (0)
run_natural 1 ! whether to simulate natural vegetation (1) or not (0)
run_peatland 1 ! whether to simulate peatland (1) or not (0)

lcfrac_fixed 0 ! use landcover fractions (%) below (1) or read from input file (0)
lc_fixed_urban 0 ! URBAN
lc_fixed_cropland 50 ! CROPLAND
lc_fixed_pasture 0 ! PASTURE
lc_fixed_forest 0 ! FOREST
lc_fixed_natural 25 ! NATURAL
lc_fixed_peatland 25 ! PEATLAND
equal_landcover_area 0 ! divide gridcell into equal active landcover fractions`

As always, default values should be used if not specified otherwise by the user.

Package distribution

Hey guys, we should find another solution for the source packages, it's not good style to have this in the repo.

First of all, I assume the reason why you do this is that otherwise the vignette doesn't build properly? Because if that wasn't a problem, you could install directly from github http://www.inside-r.org/packages/cran/devtools/docs/install_github

Secondly, the better way to distribute binaries is to do proper releases via https://help.github.com/articles/creating-releases/ - I think you can upload binaries there. We should then link to the release on the main page.

Install instructions

Ramiro, if we have sorted out the distribution issue #1, can you

  • Create some basic install instructions in the readme.md file
  • Create a project website in settings -> automatic page generator, which describes the package in a few words and also includes the install instructions - on the long term, people should be directed to the website and not to the code folder

Check if outputs are written

Not a priority, but would be good to check if outputs are actually written, to avoid reading in outputs from a previous run

help for LPJDataClass

Ramiro, there is a weird line in the help, can you have a look?

Loading rLPJGUESS
Warning: @method [LPJDataClass.R#42]: can have at most 2 words
Warning: @method [LPJDataClass.R#72]: can have at most 2 words
Setting env vars ----------------------------------------------------

corrupted dataset

I re-installed the package on the ubuntu department server, the installaton went fine but when I try to use it I get the following error message:

Error in getParameterList("europe", list = FALSE) : lazy-load database '/home/maurizio/R/x86_64-pc-linux-gnu-library/3.2/Rlpj/R/sysdata.rdb' is corrupt In addition: Warning message: In getParameterList("europe", list = FALSE) : internal error -3 in R_decompress1
I uninstalled it and tried again, same error. It worked fine on my mac this morning but I'm not taking chances retrying it. Any ideas?

Include subsetting to S4 Data Class

so that, the information can be accessed:

  • using [ ] instead of @ : result["dataTypes"]
  • without naming slots (e.g. result["aaet"] instead of result["dataTypes"]["aaet"]) or result["gridListCell"] instead of result["runInfo"]["gridListCell"]

Error handling: Snow for SOCK clusters

In version 0.1.3, a try statement is implemented for the call to the snow cluster apply function. This prevents R from browsing after an Error.

In both cases, with and without the try statement, snow cluster apply function will try to run all processes on the cores using tryCatch(). This means that if any one of the nodes produces error, the processing will not stop. Theoretically, this is good and not an issue. Please note, however, that for a very large number of runs, thousands or hundreds of thousands, the error will be returned after checking all single jobs, which might take a significant amount of time.

The package checks input parameters to ensure that they exist and/or have corrected values. If an error is found, the parallel processing will not be started. This error handling has some limitations. It does not cover errors with templates and parameter values out of the supported range by LPJ-GUESS.

It is up to the users to provide error-free templates (the package includes them) and parameters values within the range.

Option to save outputs

Include an option that allow users whether to save the outputs as RData or not.
Currently, it always saves them in the runInfo folder.

introduce setting argument on runLPJ

Introduce a "settings" argument to include the followings:
plot.data, save.plots, file.co2, file.cru, file.cru.misc,file.ndep, file.temp, file.prec, file.insol,delete,
scale, mode, template1, template2, gridList,processing, parallel .

Add function to visualize all possible settings and default values.

runLPJ should look like this at the end:
runLPJ(setupObject, typeList, parameterList, settings)

In addition: remove mainDir argument and use setupObject$mainDir

Model outputs

Maurizio, can you tell me again which outputs you want for which temporal resolutions? If you have already an idea about how to best organize this you can also add it here (note that files could get quite large).

Licence

I have set the licence to GPL 3, standard on CRAN - everyone OK with that?

LICENSE

The package license we previously had include a file, LICENSE, that has further specifications to GPL-3. Should be kept or deleted?

The Rlpj package is licenced under GPL-3, with the following additions (permitted under section 7 of the GPL-3):

  1. Attribution: any derivatives of this work must prominently acknowledge the original authors (either the authors of the entire package, or, if only a particular function is used, the author specified in the help file)

  2. Tracking of modifications: any derivatives must keep a record that allows to see how the original work has been modified, either via a changelog, or through publically accessible version control.

  3. Preservation of the additions: licencing of any derivatives of this work must maintain requirements 1,2.

europe_cru template

europe_cru template does not replace the correct gridlist file name.

europe.cf: param "file_gridlist" (str "path_to_gridlist")

europe_cru: param "file_gridlist" (str "gridlist.txt")

They should be the same

runLPJ() crash on cluster

in runLPJ(): setting plot.data=TRUE returns error message in MPI and SOCK mode on bwUniCluster:
Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, :
unable to start device PNG
In addition: Warning message:
In png(file.path(outDir, paste(prefix, typeList.valid[[i]], ".png", :
unable to open connection to X11 display ''

No errors if plot.data=FALSE and save.plots=FALSE.
Specify in help files.

CRAN Checks

I just ran the CRAN checks over the current main branch, and there was one error in the unit tests, and several notes

LPJ on windows server

Compile LPJ on the windows department server and test Rlpj.
To get access, ask Holger and let me know if there are any problems. Ideally this should be done within this week/beginning of the next.

plotLPJData: plot from parallel output

Currently plotLPJData allows to plot the output of runLPJ ( a LPJData class object)
If runLPJ was used for a parallel call, the plot function must be call for each object in the returned output (output is a list holding LPJData objects).

It might be interesting to allow passing the entire list to plotLPJData and that the function plots all runs for each output type :

  • in a plot panel and/or
  • in same plot

This will be helpful to quickly compare runs.

Parellelization of grids

Tested and implemented on a local version to run as:

  • Parellelization of grids
  • Parellelization of paremeters
  • Parellelization of grids and parameters

How to implement it in runLPJ?

  1. let user decide what to parallelize or
  2. function figures out what to do depending on input parameters and gridcell file.

For option 1, function still has to figure what to do and check if user defined option was right.

We could set an option parallel with the values:

  • auto (default)
  • grids
  • parameters
  • both

Working with .out files with rLPJGUESS package

Greetings! I am a user of DGVMTools and devtools. I recently discovered rLPJGUESS package. Basically I have files that are in the format of .out files. I want to carry out sensitivity analysis by using these files in this package. My question is that can rLPJGUESS work with files that are in .out format?

P.s. I have files related to different variables of three CMIP5 models (eg lai.out, co2.out) .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.