knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
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:
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:
[folder]lpjml_run_lsu_00
[file]pft.bin
[file]soilcarbon.bin
[folder]lpjml_run_lsu_01
[folder]lpjml_run_lsu_02
[folder]lpjml_run_lsu_03
[folder]lpjml_run_lsu_04
[folder]lpjml_run_lsu_05
[folder]lpjml_run_lsu_06
[folder]lpjml_run_lsu_07
[file]wet_wet_days.clm
[file]tas_temperature.clm
[file]soil_soil.bin
[file]lwnet_longwave radiation.clm
[file]rsds_shortwave radiation.clm
[file]CO2_CO2 concentration.clm
[file]pr_precipitation.clm
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.
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 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.
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 )
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 )
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.