knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Introduction

This package aims to process LPJml input and output files to create a data frame that is used for training a machine learning model that emulates LPJmL.

The functions in this package are divided into three groups:

Organizing the input folder

For this package to work, a strict organization of input files needs to be followed. The parameter folder that is required by most functions need to point at folder with the following structure, for example:

Each folder should contain the outputs of the simulations with its respective PFT results and soil carbon concentration. The seven lpjml input files should be stored in a parent file.

File naming

Both input and output files will ve identified by string particles in their names, therefore, it important to add/keep string particles that identify those files correctly. As an example, the particles bellow are associated with the input files:

``` temperature = "tas", precipitation = "pr", longwave radiation = "lwnet", shortwave radiation = "rsds", soil = = "soil", number of wetdays = "wet", CO2 atmospheric concentration = "CO2"

``` As output files should be named identically between different simulations, instead of using string particles to identify them, the whole name of the file should be used when required.

Data set info

Data set info is a list of parameters used as input for the lpjm_inputs, lpjml_output and training_warper functions that summarise the information needed to successfully run these two functions. Below you find examples of how to set up dataset_infos to extract both harvest and soil carbon data from LPJmL binaries.

Extracting harvest data

dataset_info = list(

  #file string parts names
  temp ="tas",
  prec ="pr",
  lwnet ="lwnet",
  rsds ="rsds",
  soil ="soil",
  wet ="wet",
  co2 = "CO2",

  #Shared variables
  wyears = seq(1951,2099,10),
  cells = 67420,

  #readLPJ specific variables more information on
  #\code{\link{readLPJ}}

  file_name = "pft_harvest.pft.bin",
  crop ="mgrass",
  water = "rainfed",
  syear = 1951,
  years = 149,
  bands = 32,
  soilcells = FALSE, #True (59199 cells), False (67420 cells)
  monthly = FALSE
)

Extracting soil carbon data

dataset_info = list(

  #file string parts names
  temp ="tas",
  prec ="pr",
  lwnet ="lwnet",
  rsds ="rsds",
  soil ="soil",
  wet ="wet",
  co2 = "CO2",

  #Shared variables
  wyears = seq(1951,2099,10),
  cells = 67420,

  #readLPJ specific variables more information on
  #\code{\link{readLPJ}}

  file_name = "soilc.bin",
  crop =1,
  water =1,
  syear = 1951,
  years = 149,
  bands = 1,
  soilcells = FALSE, #True (59199 cells), False (67420 cells)
  monthly = FALSE
)

Usage Example

library(lpjmule)

dataset_info = list(

  #file string parts names
  temp ="tas",
  prec ="pr",
  lwnet ="lwnet",
  rsds ="rsds",
  soil ="soil",
  wet ="wet",
  co2 = "CO2",

  #Shared variables
  wyears = seq(1951,2099,10),
  cells = 67420,

  #readLPJ specific variables more information on
  #\code{\link{readLPJ}}

  file_name = "pft_harvest.pft.bin",
  crop ="mgrass",
  water = "rainfed",
  syear = 1951,
  years = 149,
  bands = 32,
  soilcells = FALSE, #True (59199 cells), False (67420 cells)
  monthly = FALSE,

  #input levels should equal the levels used for each LPJml
  input_levels = c(seq(0, 2, 0.2), 2.5)
)

setwd()

training_warper("/p/projects/landuse/users/pedrosa/ML_gym/inputs/elevated",dataset_info = dataset_info)


mppalves/lpjmule documentation built on April 1, 2020, 10:28 a.m.