From 0df2e6d2d8bd2c56398045ec62f5a85a61947061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 10:19:07 +0100 Subject: [PATCH 01/37] Update musoRand.R --- RBBGCMuso/R/musoRand.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RBBGCMuso/R/musoRand.R b/RBBGCMuso/R/musoRand.R index e527ef8..fbf8672 100644 --- a/RBBGCMuso/R/musoRand.R +++ b/RBBGCMuso/R/musoRand.R @@ -1,10 +1,10 @@ #' musoRand #' -#' This funtion samples uniformly from the chosen parameters of the Biome-BGCMuSo model, where the parameters are constrained by the model logic. -#' @author Roland Hollos -#' @param parameters This is a dataframe (heterogeneous data-matrix), where first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the input-file, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized. -#' @param constrains This is a matrics wich specify the constrain rules for the sampling. Further informations coming son. -#' @param iteration The number of samples. We propose to use at least 3000 iteration, because it is generally fast and it can be subsampled later at any time. +#' This funtion uses the Monte Carlo technique to uniformly sample the parameter space from user defined parameters of the Biome-BGCMuSo model. The sampling algorithm ensures that the parameters are constrained by the model logic which means that parameter dependencies are fully taken into account (parameter dependency means that e.g leaf C:N ratio must be smaller than C:N ratio of litter; more complicated rules apply to the allocation parameters where the allocation fractions to different plant compartments must sum up 1). This function implements a mathematically correct solution to provide uniform distriution for all selected parameters. +#' @author Roland HOLLOS +#' @param parameters This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization. +#' @param constrains This is a matrix wich specify the constrain rules for the sampling. PArameter dependencies are described in the Biome-BGCMuSo User's Guide. Further informations is coming soon. +#' @param iteration The number of samples for the Monte-Carlo experiment. We propose to use at least 3000 iteration because it is generally fast and it can be subsampled later at any time. #' @importFrom limSolve xsample #' @export From 1070f73fdb1096215b058804e79c430bf7b2ed4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 10:22:57 +0100 Subject: [PATCH 02/37] Update musoRand.R --- RBBGCMuso/R/musoRand.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RBBGCMuso/R/musoRand.R b/RBBGCMuso/R/musoRand.R index fbf8672..ea38e40 100644 --- a/RBBGCMuso/R/musoRand.R +++ b/RBBGCMuso/R/musoRand.R @@ -3,7 +3,7 @@ #' This funtion uses the Monte Carlo technique to uniformly sample the parameter space from user defined parameters of the Biome-BGCMuSo model. The sampling algorithm ensures that the parameters are constrained by the model logic which means that parameter dependencies are fully taken into account (parameter dependency means that e.g leaf C:N ratio must be smaller than C:N ratio of litter; more complicated rules apply to the allocation parameters where the allocation fractions to different plant compartments must sum up 1). This function implements a mathematically correct solution to provide uniform distriution for all selected parameters. #' @author Roland HOLLOS #' @param parameters This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization. -#' @param constrains This is a matrix wich specify the constrain rules for the sampling. PArameter dependencies are described in the Biome-BGCMuSo User's Guide. Further informations is coming soon. +#' @param constrains This is a matrix wich specify the constrain rules for the sampling. Parameter dependencies are described in the Biome-BGCMuSo User's Guide. Further informations is coming soon. #' @param iteration The number of samples for the Monte-Carlo experiment. We propose to use at least 3000 iteration because it is generally fast and it can be subsampled later at any time. #' @importFrom limSolve xsample #' @export From 3d05b24f997b0ca1f351bfe8f2bc31b58a2fd7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 11:02:40 +0100 Subject: [PATCH 03/37] Update musoMonte.R --- RBBGCMuso/R/musoMonte.R | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/RBBGCMuso/R/musoMonte.R b/RBBGCMuso/R/musoMonte.R index b10d030..550240c 100644 --- a/RBBGCMuso/R/musoMonte.R +++ b/RBBGCMuso/R/musoMonte.R @@ -1,18 +1,18 @@ #' musoMonte #' -#' This function does monteCarlo on BiomeBGC-MuSo. It samples specified modell variables in given rangge from conditional multivariate uniform distribution, and runs the modell for each run. -#' @author Roland Hollos -#' @param settings A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically. -#' @param parameters This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized. -#' @param calibrationPar You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8) -#' @param inputDir The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file. -#' @param iterations number of the monteCarlo run. -#' @param preTag It will be the name of the output files. For example preTag-1.csv, pretag-2csv... -#' @param outputType This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet. -#' @param fun If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need. -#' @param varIndex This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3. -#' @param debugging If you set this parameter, you can save every logfile, and RBBGCMuso will select those which contains errors. -#' @param keepEpc if you set keepEpc also true, it will save every selected epc file, and put the wrong ones in the WRONGEPC directory. +#' This function executes the Monte Carlo experiment with Biome-BGCMuSo (musoRand is called by this function). It samples the selected model parameters within user defined ranges from conditional multivariate uniform distribution, and then runs the model for each run. +#' @author Roland HOLLOS +#' @param settings A list of environmental variables for the Monte Carlo experiment. These settings are generated by the setupMuso function. By default the settings parameter is generated automatically. +#' @param parameters This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization. +#' @param calibrationPar You might want to change some parameters in your EPC file before you run the modell. You have to select the appropirate model parameters here. You can refer to the parameters by the number of the line in the EPC file where the variables are defined. The indexing of the lines starts at 1, and each line matters (like in any simple text file). You should use a vector for this selection like c(1,5,8) +#' @param inputDir The location of the input directory for the Biome-BGCMuSo model. This directory must contain a viable pack of all input files and the model executable file. +#' @param iterations Number of the monteCarlo simulations. +#' @param preTag This defines the name of the output files. This tag will be re-used so that the results will be like preTag-1.csv, preTag-2csv... +#' @param outputType This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is chosen the function creates one large csv file for all of the runs. If "moreCsv" is chosen, every model output goes to separate files. If netCDF is selected the output will be stored in a netCDF file. The default value of the outputTypes is "moreCsv". Note that netCDF is not implemented yet. +#' @param fun If you select a variable from the possible outputs (by using the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your needs. +#' @param varIndex This parameter specifies which parameter will be used for the Monte Carlo experimnt from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3. +#' @param debugging If you set this parameter, you can save every logfile, and RBBGCMuso will select those which contains errors. This is useful to study why the model crashes with a given parameter set. +#' @param keepEpc If you set keepEpc as TRUE, it will save every selected EPC file, and move the wrong ones into the WRONGEPC directory. #' @export musoMonte <- function(settings=NULL, From a32feeda6d25f8268af6e5c7f2600c2ab959119b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 11:30:30 +0100 Subject: [PATCH 04/37] Update musoSensi.R --- RBBGCMuso/R/musoSensi.R | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/RBBGCMuso/R/musoSensi.R b/RBBGCMuso/R/musoSensi.R index 9e2a7d9..3f3d291 100644 --- a/RBBGCMuso/R/musoSensi.R +++ b/RBBGCMuso/R/musoSensi.R @@ -1,20 +1,20 @@ #' musoSensi #' -#' This function does regression based sensitivity analysis based on the output of musoMonte. -#' @author Roland Hollos -#' @param monteCarloFile If you run musoMonte function previously, you did not have to rerun the monteCarlo, just provide the preservedEpc.csv file with its path. If you do not set this parameter, musoSensi will fun the musoMonte function to get all of the information. -#' @param outputFile The filename in which the output of musoSensi function will be saved. It's default value is: "sensitivity.csv" -#' @param plotName The name of the output barplot. It's default value is: "sensitivity.jpg" -#' @param settings A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically. -#' @param parameters This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized. -#' @param calibrationPar You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8) -#' @param inputDir The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file. -#' @param iterations number of the monteCarlo run. -#' @param preTag It will be the name of the output files. For example preTag-1.csv, pretag-2csv... -#' @param outputType This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet. -#' @param fun If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need. -#' @param varIndex This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3. -#' @param skipSpinup With this parameter, you can turn of the spinup phase after the first spinup. I will decrease the time significantly. +#' This function performs multiple liear regression based global sensitivity analysis based on the output of musoMonte. First the user has to select the parameters of interest with possible minimum and maximum values. After execution musoSensi will then assign weights to the predefined parameters which means that the importance of the parameters will be ranked. The sensitivity analysis calculates the effect of input variability on the output variability in Monte Carlo framework. The result will largely depend on the selected output variable (GPP, evapotranspiration, LAI, soil water content), and on the parameter ranges. Other factors like climate, management and site specific conditions might affect the results. +#' @author Roland HOLLOS +#' @param monteCarloFile If you run the musoMonte function previously, you do not have to re-run the monteCarlo experiment, simply provide the preservedEpc.csv file to musoSensi with its path. If you do not set this parameter, musoSensi will run the musoMonte function to get all necessary information. +#' @param outputFile The filename in which the output of the musoSensi function will be saved. By default it is "sensitivity.csv" +#' @param plotName The name of the output barplot. It's default value is "sensitivity.jpg" +#' @param settings A list of environmental variables for the Monte Carlo experiment. These settings are generated by the setupMuso function. By default the settings parameter is generated automatically. +#' @param parameters This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization. +#' @param calibrationPar You might want to change some parameters in your EPC file before you run the modell. You have to select the appropirate model parameters here. You can refer to the parameters by the number of the line in the EPC file where the variables are defined. The indexing of the lines starts at 1, and each line matters (like in any simple text file). You should use a vector for this selection like c(1,5,8) +#' @param inputDir The location of the input directory for the Biome-BGCMuSo model. This directory must contain a viable pack of all input files and the model executable file. +#' @param iterations Number of the Monte Carlo simulations. +#' @param preTag This defines the name of the output files. This tag will be re-used so that the results will be like preTag-1.csv, preTag-2csv... +#' @param outputType This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is chosen the function creates one large csv file for all of the runs. If "moreCsv" is chosen, every model output goes to separate files. If netCDF is selected the output will be stored in a netCDF file. The default value of the outputTypes is "moreCsv". Note that netCDF is not implemented yet. +#' @param fun If you select a variable from the possible outputs (by using the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your needs. +#' @param varIndex This parameter specifies which parameter will be used for the Monte Carlo experiment from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3. +#' @param skipSpinup With this parameter you can turn off the spinup phase after the first spinup was successfully executed (endpoint file is available). This option can dramatically decrease the time needed for the sensitivity analysis. Note that in case of natural vegetation this option might not be feasible. For croplands this is more feasible. #' @importFrom ggplot2 geom_bar ggplot aes theme element_text xlab ylab ggtitle ggsave scale_y_continuous #' @importFrom scales percent #' @export From 6ed0f05edc5cc3721e4b868fbe45cbdcf912ac07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 11:31:25 +0100 Subject: [PATCH 05/37] Update musoMonte.R --- RBBGCMuso/R/musoMonte.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RBBGCMuso/R/musoMonte.R b/RBBGCMuso/R/musoMonte.R index 550240c..ba9ad0c 100644 --- a/RBBGCMuso/R/musoMonte.R +++ b/RBBGCMuso/R/musoMonte.R @@ -6,11 +6,11 @@ #' @param parameters This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization. #' @param calibrationPar You might want to change some parameters in your EPC file before you run the modell. You have to select the appropirate model parameters here. You can refer to the parameters by the number of the line in the EPC file where the variables are defined. The indexing of the lines starts at 1, and each line matters (like in any simple text file). You should use a vector for this selection like c(1,5,8) #' @param inputDir The location of the input directory for the Biome-BGCMuSo model. This directory must contain a viable pack of all input files and the model executable file. -#' @param iterations Number of the monteCarlo simulations. +#' @param iterations Number of the Monte Carlo simulations. #' @param preTag This defines the name of the output files. This tag will be re-used so that the results will be like preTag-1.csv, preTag-2csv... #' @param outputType This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is chosen the function creates one large csv file for all of the runs. If "moreCsv" is chosen, every model output goes to separate files. If netCDF is selected the output will be stored in a netCDF file. The default value of the outputTypes is "moreCsv". Note that netCDF is not implemented yet. #' @param fun If you select a variable from the possible outputs (by using the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your needs. -#' @param varIndex This parameter specifies which parameter will be used for the Monte Carlo experimnt from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3. +#' @param varIndex This parameter specifies which parameter will be used for the Monte Carlo experiment from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3. #' @param debugging If you set this parameter, you can save every logfile, and RBBGCMuso will select those which contains errors. This is useful to study why the model crashes with a given parameter set. #' @param keepEpc If you set keepEpc as TRUE, it will save every selected EPC file, and move the wrong ones into the WRONGEPC directory. #' @export From bacd952684dcd7a878f2733bdca1bbb08e4d3c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 11:38:51 +0100 Subject: [PATCH 06/37] Update spinupMuso.R --- RBBGCMuso/R/spinupMuso.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RBBGCMuso/R/spinupMuso.R b/RBBGCMuso/R/spinupMuso.R index ec48ee4..3392c97 100644 --- a/RBBGCMuso/R/spinupMuso.R +++ b/RBBGCMuso/R/spinupMuso.R @@ -3,7 +3,7 @@ #' This function runs the Biome-BGCMuSo model in spinup phase. #' #' @author Roland HOLLOS -#' @param settings IRBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option. +#' @param settings RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option. #' @param debugging If debugging is set to TRUE, after model execution the function copies the Biome-BGCMuSo log file into a LOG directory to stores it for further processing. If debugging is set to STAMPLOG instead of TRUE, it concatenates a number before the logfile, which is one plus the maximum of those present in the LOG directory. In each case the log files will be saved. #' @param keepEpc If keepEpc is set to TRUE, the function keeps the EPC file and stamps it, and then copies it to the EPCS directory. If debugging is set to TRUE, it copies the wrong EPC files to the wrong epc directory. #' @param silent If you set the silent parameter to TRUE, all of the model's output normally written to the screen will be suppressed. This option can be useful to increase the speed of the model execution. From 8b9cf87d67f2b6e9adc01346dd379c6b1022f39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 11:40:51 +0100 Subject: [PATCH 07/37] Update normalMuso.R --- RBBGCMuso/R/normalMuso.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RBBGCMuso/R/normalMuso.R b/RBBGCMuso/R/normalMuso.R index 33e5dfa..db9e53c 100644 --- a/RBBGCMuso/R/normalMuso.R +++ b/RBBGCMuso/R/normalMuso.R @@ -5,7 +5,7 @@ #' @author Roland HOLLOS #' @param settings RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option. #' @param timee The required timesteps in the model output. It can be "d", if it is daily, "m", if it is monthly, "y" if it is yearly. It is recommended to use daily data, as the yearly and monthly data is not well-tested yet. -#' @param debugging If debugging is set to TRUE, after model execution the function copies the Biome-BGCMuSo log file into a LOG directory to stores it for further processing. If debugging is set to STAMPLOG instead of TRUE, it concatenates a number before the logfile, which is one plus the maximum of those present in the LOG directory. In each case the log files will be saved. +#' @param debugging If debugging is set to TRUE, after model execution the function copies the Biome-BGCMuSo log file into a LOG directory and stores it for further processing. If debugging is set to STAMPLOG instead of TRUE, it concatenates a number before the logfile, which is one plus the maximum of those present in the LOG directory. In each case the log files will be saved. #' @param keepEpc If keepEpc is set to TRUE, the function keeps the EPC file and stamps it, and then copies it to the EPCS directory. If debugging is set to TRUE, it copies the wrong EPC files to the wrong epc directory. #' @param export If it is set to YES or you define a filename here, the function converts the output to the specific file format. For example, if you set export to "example.csv", it converts the output to "csv". If you set it to "example.xls" it converts the output to example.xls with the xlsx package. If the Excel converter package is not installed it gives back a warning message and converts the results to csv. #' @param silent If you set the silent parameter to TRUE, all of the model's output normally written to the screen will be suppressed. This option can be useful to increase the speed of the model execution. From 8a680f973de989c2a70f91ba4b2d1eda432ebec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 11:53:38 +0100 Subject: [PATCH 08/37] Update plotMuso.R --- RBBGCMuso/R/plotMuso.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RBBGCMuso/R/plotMuso.R b/RBBGCMuso/R/plotMuso.R index f132a57..0b03c47 100644 --- a/RBBGCMuso/R/plotMuso.R +++ b/RBBGCMuso/R/plotMuso.R @@ -1,10 +1,10 @@ #'plot the BBGCMuso output #' -#' This function runs the BBGC-MuSo model and reads in its outputfile in a very structured way, and after that plot the results automaticly +#' This function runs the Biome-BGCMuSo model and reads its output file in a well structured way, and after that it plots the results automatically. plotMuso is a convenient and quick method to create nice graphs from Biome-BGCMuSo output which is quite painful in other environments. #' -#' @author Roland Hollos, Dora Hidy -#' @param settings You have to run the setupMuso function before rungetMuso. It is its output which contains all of the necessary system variables. It sets the whole environment -#' @param timee The required timesteps in the modell output. It can be "d", if it is daily, "m", if it's monthly, "y", it it is yearly +#' @author Roland HOLLOS, Dora HIDY +#' @param settings RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option. +#' @param timee The required timesteps in the model output. It can be "d", if it is daily, "m", if it is monthly, "y" if it is yearly. It is recommended to use daily data, as the yearly and monthly data is not well-tested yet. #' @param debugging If it is TRUE, it copies the log file to a Log directory to store it, if it is stamplog it contatenate a number before the logfile, which is one more than the maximum of the represented ones in the LOG directory. If it is true or stamplog it collects the "wrong" logfiles #' @param keepEpc If TRUE, it keeps the epc file and stamp it, after these copies it to the EPCS directory. If debugging True or false, it copies the wrong epc files to the wrong epc directory. #' @param export if it is yes or you give a filename here, it converts the output to the specific extension. For example, if you set export to "example.csv", it converts the output to "csv", if you set it to "example.xls" it converts to example.xls with the xlsx package. If it is not installed it gives back a warning message and converts it to csv. From cae854b7e39d58359a0ab897cab564f5d42eecb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 14:02:03 +0100 Subject: [PATCH 09/37] Update plotMuso.R --- RBBGCMuso/R/plotMuso.R | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/RBBGCMuso/R/plotMuso.R b/RBBGCMuso/R/plotMuso.R index 0b03c47..dfaa167 100644 --- a/RBBGCMuso/R/plotMuso.R +++ b/RBBGCMuso/R/plotMuso.R @@ -1,21 +1,21 @@ -#'plot the BBGCMuso output +#'plot the Biome-BGCMuSo output #' #' This function runs the Biome-BGCMuSo model and reads its output file in a well structured way, and after that it plots the results automatically. plotMuso is a convenient and quick method to create nice graphs from Biome-BGCMuSo output which is quite painful in other environments. #' #' @author Roland HOLLOS, Dora HIDY #' @param settings RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option. #' @param timee The required timesteps in the model output. It can be "d", if it is daily, "m", if it is monthly, "y" if it is yearly. It is recommended to use daily data, as the yearly and monthly data is not well-tested yet. -#' @param debugging If it is TRUE, it copies the log file to a Log directory to store it, if it is stamplog it contatenate a number before the logfile, which is one more than the maximum of the represented ones in the LOG directory. If it is true or stamplog it collects the "wrong" logfiles -#' @param keepEpc If TRUE, it keeps the epc file and stamp it, after these copies it to the EPCS directory. If debugging True or false, it copies the wrong epc files to the wrong epc directory. -#' @param export if it is yes or you give a filename here, it converts the output to the specific extension. For example, if you set export to "example.csv", it converts the output to "csv", if you set it to "example.xls" it converts to example.xls with the xlsx package. If it is not installed it gives back a warning message and converts it to csv. -#' @param silent If you set it TRUE all off the modells output to the screen will be suppressed. It can be usefull, because it increases the model-speed. -#' @param aggressive It deletes every possible modell-outputs from the previous modell runs. -#' @param variable column number of the variable which should be plottedor "all" if you have less than 10 variables. In this case it will plot everything in a matrix layout -#' @param leapYear Should the function do a leapyear correction on the outputdata? If TRUE, then the 31.12 day will be doubled. -#' @param logfilename If you want to set a specific name for your logfiles you can set this via logfile parameter -#' @param plotType There are two options now: continious time series("cts") or disctrete time series("dts") -#' @param skipSpinup If TRUE, calibMuso wont do spinup simulation -#' @return It depends on the export parameter. The function returns with a matrix with the modell output, or writes this in a file, which is given previously +#' @param debugging If debugging is set to TRUE, after model execution the function copies the Biome-BGCMuSo log file into a LOG directory and stores it for further processing. If debugging is set to STAMPLOG instead of TRUE, it concatenates a number before the logfile, which is one plus the maximum of those present in the LOG directory. In each case the log files will be saved. +#' @param keepEpc If keepEpc is set to TRUE, the function keeps the EPC file and stamps it, and then copies it to the EPCS directory. If debugging is set to TRUE, it copies the wrong EPC files to the wrong epc directory. +#' @param export If it is set to YES or you define a filename here, the function converts the output to the specific file format. For example, if you set export to "example.csv", it converts the output to "csv". If you set it to "example.xls" it converts the output to example.xls with the xlsx package. If the Excel converter package is not installed it gives back a warning message and converts the results to csv. +#' @param silent If you set the silent parameter to TRUE, all of the model's output normally written to the screen will be suppressed. This option can be useful to increase the speed of the model execution. +#' @param aggressive It deletes all previous model-outputs from previous model runs. +#' @param variable Column number of the output variable which should be plotted, or "all" if you have less than 10 variables. In this case the function will plot everything in a matrix layout. +#' @param leapYear Should the function do a leapyear correction on the output data? If TRUE, then the result for 31 December will be doubled in leap years which means that the results for the leap year will cover all 366 days. See the model's User's Guide for notes on leap years. +#' @param logfilename If you would like to set a specific name for your logfiles you can set this via the logfile parameter. +#' @param plotType There are two options implemented by now: continuous time series ("cts") or disctrete time series ("dts") +#' @param skipSpinup If TRUE, the function won't perform the spinup simulation. In this case the endpoint file must exist that provides initial conditions for the run. +#' @return It depends on the export parameter. The function returns with a matrix with the model output, or writes this into a file, which is defined previously #' @usage plotMuso(settings, variable, #' timee="d", silent=TRUE, #' debugging=FALSE, keepEpc=FALSE, From 8d674ce5f9517360badc4caf1a2cef687abee912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 14:09:58 +0100 Subject: [PATCH 10/37] Update changeMuso.R --- RBBGCMuso/R/changeMuso.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RBBGCMuso/R/changeMuso.R b/RBBGCMuso/R/changeMuso.R index aafd8a0..6e3e1f5 100644 --- a/RBBGCMuso/R/changeMuso.R +++ b/RBBGCMuso/R/changeMuso.R @@ -1,7 +1,7 @@ -#' This is the function which is capable change multiple specific lines to other using their row numbers. +#' This is the function which is capable to change multiple specific lines to others using their row numbers. #' -#' he function uses the previous changspecline function to operate. - ##From now changespecline is in the forarcheologist file, because its no longer needed +#' The function uses the previous changspecline function to operate. + ##From now changespecline is in the forarcheologist file, because itis no longer needed #' #' @author Roland Hollos #' @keywords internal From edeb068c140a9f6e8a64354582cad44ff1804241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 14:10:58 +0100 Subject: [PATCH 11/37] Update debugMuso.R --- RBBGCMuso/R/debugMuso.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RBBGCMuso/R/debugMuso.R b/RBBGCMuso/R/debugMuso.R index 312d5ad..0d6c473 100644 --- a/RBBGCMuso/R/debugMuso.R +++ b/RBBGCMuso/R/debugMuso.R @@ -1,6 +1,6 @@ #'rungetMuso #' -#' This function runs the BBGC-MuSo model and reads in its outputfile in a very structured way. +#' This function runs the Biome-BGCMuSo model and reads its outputfile in a well structured way. #' #' @author Roland Hollos #' @keywords internal From 0444a76c1a47dbdf926f64e380c0f9c97e630043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 15:44:44 +0100 Subject: [PATCH 12/37] Update README.org --- README.org | 1 + 1 file changed, 1 insertion(+) diff --git a/README.org b/README.org index 9adb0d1..7279d31 100644 --- a/README.org +++ b/README.org @@ -4,6 +4,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA +*Current version: 0.6.1* RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. ** Installation From fc059d3a25e886aae32cf5b42291cc2fc41e5eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 15:45:40 +0100 Subject: [PATCH 13/37] Update README.org --- README.org | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.org b/README.org index 9adb0d1..aa43f5e 100644 --- a/README.org +++ b/README.org @@ -4,6 +4,8 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA +*Current version: 0.6.1* + RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. ** Installation From 5238c7131b138171aa6aced5e0b4021aba726822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 16:01:27 +0100 Subject: [PATCH 14/37] Update plotMuso.R --- RBBGCMuso/R/plotMuso.R | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/RBBGCMuso/R/plotMuso.R b/RBBGCMuso/R/plotMuso.R index dfaa167..db4de22 100644 --- a/RBBGCMuso/R/plotMuso.R +++ b/RBBGCMuso/R/plotMuso.R @@ -239,19 +239,19 @@ plotMuso <- function(settings=NULL, plotName = plotName) } -#'plot the BBGCMuso output with data +#'plot the Biome-BGCMuSo model output with observation data #' -#' This function runs the BBGC-MuSo model and reads in its outputfile in a very structured way, and after that plot the results automaticly along with a given measurement +#' This function runs the Biome-BGCMuSo model and reads its output file in a well structured way, and after that it plots the results automatically along with a given measurement dataset provided by the user. plotMusoWithData is a convenient and quick method to create nice graphs from Biome-BGCMuSo output which is quite painful in other environments. #' -#' @author Roland Hollos, Dora Hidy -#' @param settings You have to run the setupMuso function before rungetMuso. It is its output which contains all of the necessary system variables. It sets the whole environment -#' @param sep This is the separator used in the measurement file -#' @param savePlot It it is specified, the plot will be saved in a format specified with the immanent extension +#' @author Roland HOLLOS, Dora HIDY +#' @param settings RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option. +#' @param sep This is the separator symbol used in the measurement file (that is supposed to be a delimited text file) +#' @param savePlot It it is specified, the plot will be saved in a graphical format specified by the immanent extension. For example, it the savePlot is set to image01.png then a PNG graphics file will be created. #' @param variable The name of the output variable to plot #' @param NACHAR This is not implemented yet -#' @param csvFile The file of the measurement. It must contain a header. -#' @param calibrationPar documentation in setupMuso() -#' @param parameters documentation in calibMuso() +#' @param csvFile This specifies the filename of the measurements. It must contain a header. Typically this is a CSV file. +#' @param calibrationPar You might want to change some parameters in your EPC file before running the model. The function offers possibility for this without editing the EPC file. In this situation you have to select the appropirate model parameters first. You can refer to these parameters with the number of the line in the EPC file. Indexing of lines start from one. You should use a vector for this referencing like c(1,5,8) +#' @param parameters Using the function it is possible to change some of the EPC parameters prior to model execution. This can be achieved with this option. In the parameters variable you have set the row indices of the variables that you wish to change. In this parameters you can give an exact value for them in a vector form like c(1,2,3,4). #' @usage plotMuso(settings, variable, #' timee="d", silent=TRUE, #' debugging=FALSE, keepEpc=FALSE, @@ -300,14 +300,14 @@ plotMusoWithData <- function(csvFile, variable, NACHAR=NA, settings=NULL, sep=", #' compareMuso #' -#' This function runs the modell, change one of it's input, and plot both in one plot. +#' This function runs the model, then changes one of its input data, runs it again, and plots both results in one graph. #' -#' @author Roland Hollos -#' @param settings You have to run the setupMuso function before rungetMuso. It is its output which contains all of the necessary system variables. It sets the whole environment -#' @param parameters In the settings variable you have set the row indexes of the variables, you wish to change. In this parameter you can give an exact value for them in a vector like: c(1,2,3,4) +#' @author Roland HOLLOS +#' @param settings RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option. +#' @param parameters Using this function it is possible to change some of the EPC parameters prior to model execution. This can be achieved with this option. In the parameters variable you have set the row indices of the variables that you wish to change. In this parameters you can give an exact value for them in a vector form like c(1,2,3,4). #' @param variable The name of the output variable to plot -#' @param calibrationPar in the help of setupMuso function. -#' @param fileToChange You can change any line of the epc or the ini file, you just have to specify with this variable which file you van a change. Two options possible: "epc", "ini", "both" +#' @param calibrationPar You might want to change some parameters in your EPC file before running the model. This function offers possibility for this without editing the EPC file. In this situation you have to select the appropirate model parameters first. You can refer to these parameters with the number of the line in the EPC file. Indexing of lines start from one. You should use a vector for this referencing like c(1,5,8) +#' @param fileToChange You can change any line of the EPC or the INI file. Please choose "EPC", "INI" or "BOTH". This file will be used for the analysis, and the original parameter values will be changed according to the choice of the user. #' @import ggplot2 #' @export compareMuso <- function(settings=NULL,parameters, variable=1, calibrationPar=NULL, fileToChange="epc", skipSpinup=TRUE, timeFrame="day"){ From 286acf41f5bf708813142c6a20c667aa377a2eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Tue, 29 Jan 2019 16:02:44 +0100 Subject: [PATCH 15/37] Update README.org --- README.org | 1 + 1 file changed, 1 insertion(+) diff --git a/README.org b/README.org index 7279d31..aa43f5e 100644 --- a/README.org +++ b/README.org @@ -5,6 +5,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA *Current version: 0.6.1* + RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. ** Installation From 5888dd51804835d8cdb8007e2ef28949a75e03fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 29 Jan 2019 16:22:22 +0100 Subject: [PATCH 16/37] Update current version info --- README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.org b/README.org index aa43f5e..2b0ed0d 100644 --- a/README.org +++ b/README.org @@ -4,7 +4,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA -*Current version: 0.6.1* +*Current version: 0.6.3* RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. From 0b389ca2176a3e0e45dfe76088d5908fb5562131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 29 Jan 2019 16:23:19 +0100 Subject: [PATCH 17/37] fix version information --- README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.org b/README.org index 2b0ed0d..bf2c800 100644 --- a/README.org +++ b/README.org @@ -4,7 +4,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA -*Current version: 0.6.3* +*Current version: 0.6.1.3* RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. From dc3a72141d2585a6e0435eab4cde2f107b70a408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 29 Jan 2019 17:10:44 +0100 Subject: [PATCH 18/37] fixing merge conflicts from Documentation branch --- README.org | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.org b/README.org index 8e67c17..bf2c800 100644 --- a/README.org +++ b/README.org @@ -4,11 +4,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA -<<<<<<< HEAD *Current version: 0.6.1.3* -======= -*Current version: 0.6.1* ->>>>>>> Documentation RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. From 120d397c5edd86edf322a592fdd57adcbff2f82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Wed, 30 Jan 2019 13:43:36 +0100 Subject: [PATCH 19/37] Update outputMapping.R --- RBBGCMuso/R/outputMapping.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RBBGCMuso/R/outputMapping.R b/RBBGCMuso/R/outputMapping.R index bb148b7..6fd5df1 100644 --- a/RBBGCMuso/R/outputMapping.R +++ b/RBBGCMuso/R/outputMapping.R @@ -1,8 +1,8 @@ #' updateMusoMapping #' -#' This function updates the muso output code-variable matrix. Within Biome-BGCMuSo the state variables and fluxes are marked by integer numbers. In order to provide meaningful variable names (e.g. 3009 means Gross Primary Production) a conversion table is needed which is handled by this function. +#' This function updates the Biome-BGCMuSo output code-variable matrix. Within Biome-BGCMuSo the state variables and fluxes are marked by integer numbers. In order to provide meaningful variable names (e.g. 3009 means Gross Primary Production in Biome-BGCMuSo v5) a conversion table is needed which is handled by this function. #' @author Roland HOLLOS -#' @param output_map_init The output code-variable bindings are described in output_map_init.c file that is part of the current Biome-BGCMuSo source code. Using this function the user can read the output_map_init.c file and pass it to RBBGCMuso for further work. +#' @param output_map_init The output code-variable bindings are described in output_map_init.c file that is part of the Biome-BGCMuSo source code. Using this function the user can read the output_map_init.c file and pass it to RBBGCMuso for further work. #' @return The output code-variable matrix, and also the function changes the global variable #' @export #' @usage updateMusoMapping(output_map_init="output_map_init.c") From 5ebc187adbb6bcd9a6a21c91a81d137ca3d16f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Wed, 30 Jan 2019 13:48:21 +0100 Subject: [PATCH 20/37] Update assistantFunctions.R --- RBBGCMuso/R/assistantFunctions.R | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/RBBGCMuso/R/assistantFunctions.R b/RBBGCMuso/R/assistantFunctions.R index cfdd16c..d198b84 100644 --- a/RBBGCMuso/R/assistantFunctions.R +++ b/RBBGCMuso/R/assistantFunctions.R @@ -1,9 +1,9 @@ #' getLogs #' -#'This function gives us the muso logfiles with their paths +#'This function gives us the muso logfiles with their path #' #'@param outputLoc This is the location of the output files. -#'@param outputNames These are the prefixis of the logfiles +#'@param outputNames These are the prefixes of the logfiles #'@return Logfiles with paths #'@keywords internal @@ -18,10 +18,10 @@ getLogs <- function(outputLoc, outputNames, type = "spinup"){ #' readErrors #' -#'This function reads the spinup and the normal logfiles and gives back the last line which indicates weather there are any errors. +#'This function reads the spinup and the normal logfiles and gives back the last line which indicates weather there are any errors during the model execution or not. #' -#'@param outputLoc This is the location of the output files. -#'@param logfiles These are the names of the logfiles +#'@param outputLoc This is the location of the output file. +#'@param logfiles These are the names of the logfiles. #'@return vector with 0 and 1 values, 1, if succed, 0 if not. The first is the spinup run, the second is the normal. #'@keywords internal @@ -61,8 +61,8 @@ readErrors <- function(outputLoc, logfiles, type = "both"){ #'This function gives us the muso output files with their paths #' #'@param outputLoc This is the location of the output files. -#'@param outputNames These are the prefixis of the logfiles -#'@return Output files with their paths +#'@param outputNames These are the prefixes of the logfiles. +#'@return Output files with their paths. #'@keywords internal @@ -73,10 +73,10 @@ getOutFiles <- function(outputLoc, outputNames){ #' stampAndCopy #' -#'This function gives us the muso output files with their paths +#'This function gives us the model output files with their paths #' #'@param outputLoc This is the location of the output files. -#'@param outputNames These are the prefixis of the logfiles +#'@param outputNames These are the prefixes of the logfiles #'@return Output files with their paths #'@keywords internal From 4e9e94d3b7953a06f7511417f9ec520ee7b9ce7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Wed, 30 Jan 2019 13:49:43 +0100 Subject: [PATCH 21/37] Update cleanup.R --- RBBGCMuso/R/cleanup.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RBBGCMuso/R/cleanup.R b/RBBGCMuso/R/cleanup.R index 0c9bd27..b34edbf 100644 --- a/RBBGCMuso/R/cleanup.R +++ b/RBBGCMuso/R/cleanup.R @@ -2,9 +2,9 @@ #' #' cleanupMuso can erase all of the unnecessary log and output files. #' -#' @author Roland Hollos -#' @param location It is the place where your output files are. -#' @param simplicity TRUE or FALSE. If true cleanupMuso will erase only the log files from only the location +#' @author Roland HOLLOS +#' @param location This is the place (directory) where your output files are located. +#' @param simplicity TRUE or FALSE. If TRUE cleanupMuso will erase only the log files from the location #' @param deep If it is TRUE, it will delete every files from the subdirectories also #' @usage cleanupMuso(location=NULL, simplicity=TRUE,deep=FALSE) #' @export From 1bbb3065e68d65a99b3905d2405c6dba44245451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 5 Feb 2019 19:20:14 +0100 Subject: [PATCH 22/37] cleaning up... --- RBBGCMuso/R/musoMont.R | 205 -------------------------------- RBBGCMuso/R/musoSensi.R | 6 +- RBBGCMuso/R/runModell.R | 21 ---- RBBGCMuso/R/rungettanul.R | 240 -------------------------------------- RBBGCMuso/R/soilCalib.R | 1 - 5 files changed, 4 insertions(+), 469 deletions(-) delete mode 100644 RBBGCMuso/R/musoMont.R delete mode 100644 RBBGCMuso/R/runModell.R delete mode 100644 RBBGCMuso/R/rungettanul.R delete mode 100644 RBBGCMuso/R/soilCalib.R diff --git a/RBBGCMuso/R/musoMont.R b/RBBGCMuso/R/musoMont.R deleted file mode 100644 index 3185794..0000000 --- a/RBBGCMuso/R/musoMont.R +++ /dev/null @@ -1,205 +0,0 @@ -#' musoMont -#' -#' This function does monteCarlo on BiomeBGC-MuSo. It samples specified modell variables in given rangge from conditional multivariate uniform distribution, and runs the modell for each run. -#' @author Roland Hollos -#' @param settings A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically. -#' @param parameters This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized. -#' @param calibrationPar You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8) -#' @param inputDir The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file. -#' @param iterations number of the monteCarlo run. -#' @param preTag It will be the name of the output files. For example preTag-1.csv, pretag-2csv... -#' @param outputType This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet. -#' @param fun If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need. -#' @param varIndex This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3. -#' @param debugging If you set this parameter, you can save every logfile, and RBBGCMuso will select those which contains errors. -#' @param keepEpc if you set keepEpc also true, it will save every selected epc file, and put the wrong ones in the WRONGEPC directory. -#' @export - -musoMonte <- function(settings=NULL, - parameters=NULL, - inputDir = "./", - outLoc = "./calib", - iterations = 10, - preTag = "mont-", - outputType = "moreCsv", - fun=mean, - varIndex = 1, - silent = TRUE, - skipSpinup = FALSE, - debugging = FALSE, - keepEpc = FALSE, - ...){ - - getEpcValue <- function(epc, linum){ - numcord <- numeric(3) - numcord[1] <- as.integer(linNum) - linNum <- as.integer(round(linNum * 100)) - numcord[3] <-linNum %% 10 +1 - numcord[2] <- (linNum %/% 10) %% 10 + 1 - numcord - } - - - if(is.null(parameters)){ - parameters <- tryCatch(read.csv("parameters.csv"), error = function (e) { - stop("You need to specify a path for the parameters.csv, or a matrix.") - }) - } else { - if((!is.list(parameters)) & (!is.matrix(parameters))){ - parameters <- tryCatch(read.csv(parameters), error = function (e){ - stop("Cannot find neither parameters file neither the parameters matrix") - }) - }} - - outLocPlain <- basename(outLoc) #Where to put the csv outputs - currDir <- getwd() # just to go back, It is unlikely to be used - inputDir <- normalizePath(inputDir) # Where are the model files. - - if(!dir.exists(outLoc)){ - dir.create(outLoc) - warning(paste(outLoc," is not exists, so it was created")) - } - - outLoc <- normalizePath(outLoc) - - - if(is.null(settings)){ - settings <- setupMuso() - } - - parameterNames <- parameters[,1] - parReal <- parameters[,-1] - Otable <- OtableMaker(parReal) - A <- as.matrix(Otable[[1]][,c(2,4,5,6)]) - B <- as.matrix(Otable[[2]]) - settings$calibrationPar <- A[,1] - pretag <- file.path(outLoc,preTag) - npar <- length(settings$calibrationPar) - - ##reading the original epc file at the specified - ## row numbers - - origEpcFile <- readLines(settings$epcInput[2]) - - origEpc <- unlist(lapply(settings$calibrationPar, function (x) { - as.numeric(unlist(strsplit(origEpcFile[x],split="[\t ]"))[1]) - })) - - ## Prepare the preservedEpc matrix for the faster - ## run. - preservedEpc <- matrix(nrow = (iterations +1 ), ncol = npar) - preservedEpc[1,] <- origEpc - Otable[[1]][,1] <- (as.character(Otable[[1]][,1])) - for(i in parameters[,2]){ - Otable[[1]][Otable[[1]][,2]==i,1] <- as.character(parameters[parameters[,2]==i,1]) - } - - colnames(preservedEpc) <- Otable[[1]][,1] - preservedEpc <- cbind(preservedEpc,rep(NA,(iterations+1))) - colnames(preservedEpc)[(npar+1)] <- "y" - ## Save the backupEpc, while change the settings - ## variable and set the output. - file.copy(settings$epc[2],"savedEpc",overwrite = TRUE) # do I need this? - pretag <- file.path(outLoc,preTag) - - ## Creating function for generating separate - ## csv files for each run - - progBar <- txtProgressBar(1,iterations,style=3) - - modelRun <- function(settings, debugging, parameters, keepEpc, silent, skipSpinup){ - if(!skipSpinup){ - calibMuso(settings, debugging = debugging, parameters = parameters, keepEpc = keepEpc, silent = silent) - } else { - normalMuso(settings, debugging = debugging, parameters = parameters, keepEpc = keepEpc, silent = silent) - } - - } - - moreCsv <- function(){ - - if(skipSpinup){#skipSpinup is boolean - spinupMuso(settings = settings , silent = silent) - } - a <- numeric(iterations+1) - tempData <- modelRun(settings=settings, - debugging = debugging, - parameters = origEpc, - keepEpc = keepEpc, - silent = silent, - skipSpinup = skipSpinup) - ## tempData <- calibMuso(settings, debugging = "stamplog", parameters = origEpc,keepEpc = TRUE,silent = silent) - a[1] <- tryCatch(fun(tempData[,varIndex]),error=function(e){return(NA)}) - preservedEpc[1,(npar+1)] <- a[1] - write.table(t(preservedEpc[1,]),row.names = FALSE,"preservedEpc.csv",sep=",") - write.csv(x=tempData, file=paste0(preTag,1,".csv")) - for(i in 1:iterations){ - parVar <- musoRandomizer(A,B)[,2] - preservedEpc[(i+1),] <- c(parVar,NA) - exportName <- paste0(preTag,(i+1),".csv") - tempData <- modelRun(settings = settings, - debugging = debugging, - parameters = parVar, - keepEpc = keepEpc, - silent=silent, - skipSpinup =skipSpinup) - write.csv(x=tempData,file=exportName) - - preservedEpc[(i+1),(npar+1)] <- a[i+1]<- tryCatch(fun(tempData[,varIndex]),error=function(e){return(NA)}) - write.table(t(preservedEpc[(i+1),]),file="preservedEpc.csv",row.names=FALSE,col.names=FALSE, append=TRUE,sep=",") - setTxtProgressBar(progBar,i) - } - cat("\n") - return(preservedEpc) - } - - ## Creating function for generating one - ## csv files for each run - - oneCsv <- function () { - numDays <- settings$numdata[1] - if(!onDisk){ - for(i in 1:iterations){ - - parVar <- apply(parameters,1,function (x) { - runif(1, as.numeric(x[3]), as.numeric(x[4]))}) - - preservedEpc[(i+1),] <- parVar - exportName <- paste0(preTag,".csv") - write.csv(parvar,"preservedEpc.csv",append=TRUE) - calibMuso(settings,debugging = "stamplog", - parameters = parVar,keepEpc = TRUE) %>% - {mutate(.,iD = i)} %>% - {write.csv(.,file=exportName,append=TRUE)} - } - - return(preservedEpc) - } else { - - } - } - - netCDF <- function () { - stop("This function is not inplemented yet") - } - - ## Call one function according to the outputType - switch(outputType, - "oneCsv" = (a <- oneCsv()), - "moreCsv" = (a <- moreCsv()), - "netCDF" = (a <- netCDF())) - - ## Change back the epc file to the original - for(i in file.path("./",grep(outLocPlain, list.files(inputDir), invert = TRUE, value = TRUE))){ - file.remove(i,recursive=TRUE) - } - for(i in list.files()){ - file.copy(i,outLoc,recursive=TRUE,overwrite = TRUE) - } - - unlink(tmp,recursive = TRUE) - setwd(currDir) - file.copy("savedEpc",settings$epc[2],overwrite = TRUE) - return(a) -} - diff --git a/RBBGCMuso/R/musoSensi.R b/RBBGCMuso/R/musoSensi.R index 3f3d291..a84790f 100644 --- a/RBBGCMuso/R/musoSensi.R +++ b/RBBGCMuso/R/musoSensi.R @@ -16,7 +16,6 @@ #' @param varIndex This parameter specifies which parameter will be used for the Monte Carlo experiment from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3. #' @param skipSpinup With this parameter you can turn off the spinup phase after the first spinup was successfully executed (endpoint file is available). This option can dramatically decrease the time needed for the sensitivity analysis. Note that in case of natural vegetation this option might not be feasible. For croplands this is more feasible. #' @importFrom ggplot2 geom_bar ggplot aes theme element_text xlab ylab ggtitle ggsave scale_y_continuous -#' @importFrom scales percent #' @export musoSensi <- function(monteCarloFile = NULL, @@ -74,7 +73,7 @@ musoSensi <- function(monteCarloFile = NULL, xlab(NULL)+ ylab(NULL)+ ggtitle("Sensitivity")+ - scale_y_continuous(labels = percent,limits=c(0,1)) + scale_y_continuous(labels = scales::percent,limits=c(0,1)) print(sensiPlot) ggsave(plotName,dpi=dpi) return(S) @@ -110,3 +109,6 @@ musoSensi <- function(monteCarloFile = NULL, return(doSensi(M)) } } + + + diff --git a/RBBGCMuso/R/runModell.R b/RBBGCMuso/R/runModell.R deleted file mode 100644 index 4e0ac8a..0000000 --- a/RBBGCMuso/R/runModell.R +++ /dev/null @@ -1,21 +0,0 @@ -## runModell <- function(executable,) -## { - - -## if(silent){#silenc mode -## if(Linuxp){ -## #In this case, in linux machines -## tryCatch(system(paste(executable,iniInput[1],"> /dev/null",sep=" ")), -## error= function (e){stop("Cannot run the modell-check the executable!")}) -## } else { -## #In windows machines there is a show.output.on.console option -## tryCatch(system(paste(executable,iniInput[1],sep=" "),show.output.on.console = FALSE), -## error= function (e){stop("Cannot run the modell-check the executable!")}) -## } - -## } else { -## system(paste(executable,iniInput[1],sep=" ")) -## } - - -## } diff --git a/RBBGCMuso/R/rungettanul.R b/RBBGCMuso/R/rungettanul.R deleted file mode 100644 index ff38c2d..0000000 --- a/RBBGCMuso/R/rungettanul.R +++ /dev/null @@ -1,240 +0,0 @@ -## rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE){ - - - - -## ########################################################################## -## ###########################Set local variables######################## -## ######################################################################## - -## Linuxp <-(Sys.info()[1]=="Linux") -## ##Copy the variables from settings -## inputloc <- settings$inputloc -## outputloc <- settings$outputloc -## executable <- settings$executable -## ininput <- settings$ininput -## epc <- settings$epcinput -## calibrationPar <- settings$calibrationPar -## whereAmI<-getwd() - -## ############################################################# -## ############################spinup run############################ -## ########################################################## - - -## ##Sometimes a bug occure due to logfiles and controlfiles in the input loc directory - - -## if(silent!=TRUE){ -## if(length(grep("(dayout$)|(log$)",list.files(inputloc)))>0){ -## cat(" \n \n WARMING: there is a log or dayout file nearby the ini files, that may cause problemes. \n \n If you want to avoid that possible problemes, please copy the log or dayout files into a save place, and after do a cleanupMuso(), or delete these manually, or run the rungetMuso(), with the agressive=TRUE parameter \n \n") - -## } - -## } - -## if(aggressive==TRUE){ -## cleanupMuso(location=outputloc) -## } - -## ##We change the working directory becase of the model, but we want to avoid sideeffects, so we save the current location and after that we will change everything to it. - -## ## Set the working directory to the inputloc temporary. -## setwd(inputloc) - - -## ##Run the model for the spinup run. - -## if(silent){#silenc mode -## if(Linuxp){ -## #In this case, in linux machines -## system(paste(executable,ininput[1],"> /dev/null",sep=" ")) -## } else { -## #In windows machines there is a show.output.on.console option -## system(paste(executable,ininput[1],sep=" "),show.output.on.console = FALSE) -## } - -## } else { -## system(paste(executable,ininput[1],sep=" ")) -## } - - - -## logspinup<-list.files(outputloc)[grep("log$",list.files(outputloc))]#load the logfiles -## if(length(logspinup)==0){ -## return("Modell Failure")#in that case the modell did not create even a logfile -## } - -## spincrash<-tail(readLines(paste(outputloc,logspinup,sep="/"),-1),1)==0 #If the last line in the logfile is 0 There are mistakes so the spinup crashes - -## if(!spincrash){##If spinup did not crashed, run the normal run. - -## ##################################################################### -## ###########################normal run######################### -## ################################################################# - -## ##for the sake of safe we set the location again -## setwd(inputloc) - -## if(silent){ -## if(Linuxp){ -## system(paste(executable,ininput[2],"> /dev/null",sep=" ")) -## } else { -## system(paste(executable,ininput[2],sep=" "),show.output.on.console = FALSE) -## } - -## } else { -## system(paste(executable,ininput[2],sep=" ")) -## } - - -## ##read the output - -## switch(timee, -## "d"=(Reva<-getdailyout(settings)), -## "m"=(Reva<-getmonthlyout(settings)), -## "y"=(Reva<-getyearlyout(settings)) -## ) -## } - - -## logfiles <- list.files(outputloc)[grep("log$",list.files(outputloc))]#creating a vector for logfilenames - -## ############################################### -## #############LOG SECTION####################### -## ############################################### - -## perror<-as.numeric(as.vector(lapply(paste(outputloc,logfiles,sep="/"),function(x) tail(readLines(x,-1),1)))) #vector of spinup and normalrun error - -## if((debugging=="stamplog")|(debugging==TRUE)){#If debugging option turned on -## ##If log or ERROR directory does not exists create it! -## dirName<-paste(inputloc,"LOG",sep="") -## dirERROR<-paste(inputloc,"ERROR",sep="") - -## if(!dir.exists(dirName)){ -## dir.create(dirName) -## } - -## if(!dir.exists(dirERROR)){ -## dir.create(dirERROR) -## } -## } - -## ##if errorsign is 1 there is error, if it is 0 everything ok -## if(length(perror)>sum(perror)){ -## errorsign <- 1 -## } else { -## errorsign <- 0 -## } - - -## if(keepEpc){#if keepepc option tured on - -## if(length(unique(dirname(epc)))>1){ -## print("Why are you playing with my nervs? Seriously? You hold your epc-s in different folders?") -## } else { -## epcdir <- dirname(epc[1]) - -## WRONGEPC<-paste(inputloc,"WRONGEPC",sep="") -## EPCS<-paste(inputloc,"EPCS",sep="") - -## if(!dir.exists(WRONGEPC)){ -## dir.create(WRONGEPC) -## } - -## if(!dir.exists(EPCS)){ -## dir.create(EPCS) -## } - -## epcfiles <- list.files(epcdir)[grep("epc$",list.files(epcdir))] -## stampnum<-stamp(EPCS) -## lapply(epcfiles,function (x) file.copy(from = paste(epcdir,"/",x,sep=""),to=paste(EPCS,"/",(stampnum+1),"-",x,sep=""))) -## if(errorsign==1){ -## lapply(epcfiles,function (x) file.copy(from = paste(EPCS,"/",(stampnum+1),"-",x,sep=""), to=WRONGEPC)) -## } - -## } -## } - - - - - -## if(debugging=="stamplog"){ -## stampnum<-stamp(dirName) -## if(inputloc==outputloc){ -## lapply( logfiles, function (x) file.rename(from=paste(outputloc,x, sep=""), to=paste(dirName, "/",(stampnum+1),"-",x,sep=""))) - -## } else { -## lapply( logfiles, function (x) file.rename(from=paste(outputloc,x, sep="/"), to=paste(dirName, "/",(stampnum+1),"-",x,sep=""))) -## } - -## if(errorsign==1){ -## lapply( logfiles, function (x) file.copy(from=paste(dirName, "/",(stampnum+1),"-",x,sep=""), to=dirERROR ))} - -## } else { if(debugging){ -## if(is.null(logfilename)){ - -## if(inputloc==outputloc){ -## lapply( logfiles, function (x) file.rename(from=paste(outputloc,x, sep=""), to=paste(dirName,"/", x, sep=""))) -## } else { -## lapply( logfiles, function (x) file.rename(from=paste(outputloc,x, sep="/"), to=paste(dirName,"/", x, sep=""))) -## } - -## if(errorsign==1){ -## lapply( logfiles, function (x) file.rename(from=paste(dirName,"/", x, sep=""), to=dirERROR)) -## } - -## } else { - -## if(inputloc==outputloc){#These are very ugly solutions for a string problem: inputloc: "./", if outputloc equalent of inputloc, it ends with "/", the string manipulation can not handle this. The better solution is easy, but I dont have enough time(Roland Hollo's) -## lapply( logfiles, function (x) file.rename(from=paste(outputloc,x, sep=""), to=paste(dirName, "/",logfilename,"-",x,sep=""))) -## } else { -## lapply( logfiles, function (x) file.rename(from=paste(outputloc,x, sep="/"), to=paste(dirName, "/",logfilename,"-",x,sep=""))) -## } - -## if(errorsign==1){ -## lapply( logfiles, function (x) file.rename(from=paste(dirName, "/",logfilename,"-",x,sep=""), to=dirERROR)) -## } -## } - -## }} - -## cleanupMuso(location=outputloc) -## if(errorsign==1){ -## return("Modell Failure") -## } - -## if(timee=="d"){ -## colnames(Reva) <- unlist(settings$outputvars[[1]]) -## } else { -## if(timee=="y") -## colnames(Reva) <- unlist(settings$outputvars[[2]]) -## } - -## if(leapYear){ -## Reva <- corrigMuso(settings,Reva) -## rownames(Reva) <- musoDate(settings) -## } else { -## rownames(Reva) <- musoDate(settings, corrigated=FALSE) -## } - -## if(export!=FALSE){ -## setwd(whereAmI) - -## ## switch(fextension(export), -## ## "csv"=(write.csv(Reva,export)), -## ## "xlsx"=(), -## ## "odt"= - - -## ## ) -## write.csv(Reva,export) - -## } else{ -## setwd(whereAmI) -## return(Reva)} -## } - - - diff --git a/RBBGCMuso/R/soilCalib.R b/RBBGCMuso/R/soilCalib.R deleted file mode 100644 index 053d7ba..0000000 --- a/RBBGCMuso/R/soilCalib.R +++ /dev/null @@ -1 +0,0 @@ -#soilMatrix <- function(numberOfLayers=) From 9d582aebf80c8e755a91160da396ee97d20f6965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 5 Feb 2019 19:47:20 +0100 Subject: [PATCH 23/37] solving tmp bug in musoMonte --- RBBGCMuso/R/musoMonte.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RBBGCMuso/R/musoMonte.R b/RBBGCMuso/R/musoMonte.R index ba9ad0c..0bb315a 100644 --- a/RBBGCMuso/R/musoMonte.R +++ b/RBBGCMuso/R/musoMonte.R @@ -13,6 +13,7 @@ #' @param varIndex This parameter specifies which parameter will be used for the Monte Carlo experiment from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3. #' @param debugging If you set this parameter, you can save every logfile, and RBBGCMuso will select those which contains errors. This is useful to study why the model crashes with a given parameter set. #' @param keepEpc If you set keepEpc as TRUE, it will save every selected EPC file, and move the wrong ones into the WRONGEPC directory. +#' @importFrom magrittr '%>%' #' @export musoMonte <- function(settings=NULL, @@ -112,12 +113,15 @@ musoMonte <- function(settings=NULL, moreCsv <- function(){ + settings$iniInput[2] %>% + (function(x) paste0(dirname(x),"/",tools::file_path_sans_ext(basename(x)),"-tmp.",tools::file_ext(x))) %>% + unlink randValues <- randVals[[2]] settings$calibrationPar <- randVals[[1]] ## randValues <- randValues[,randVals[[1]] %in% parameters[,2]][,rank(parameters[,2])] modellOut <- matrix(ncol = numVars, nrow = iterations + 1) - origModellOut <- calibMuso(silent=TRUE) + origModellOut <- calibMuso(settings=settings,silent=TRUE) write.csv(x=origModellOut, file=paste0(pretag,1,".csv")) if(!is.list(fun)){ From 09945ba2858905ad1421434204c1046ed41bc193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 5 Feb 2019 19:53:36 +0100 Subject: [PATCH 24/37] version number change --- RBBGCMuso/DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RBBGCMuso/DESCRIPTION b/RBBGCMuso/DESCRIPTION index af0433f..13a2679 100644 --- a/RBBGCMuso/DESCRIPTION +++ b/RBBGCMuso/DESCRIPTION @@ -1,6 +1,6 @@ Package: RBBGCMuso Title: An R package for BiomeBGC-MuSo ecosystem modelling -Version: 0.6.1.3 +Version: 0.6.1.4 Authors@R: person("Roland", "Hollo's", , "hollorol@gmail.com", role = c("aut", "cre")) Description: What the package does (one paragraph). Depends: R (>= 3.3.2) From 01cbb3a657acec77e76f00b88e72d0b4603d8340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 5 Feb 2019 19:55:30 +0100 Subject: [PATCH 25/37] version update to 0.6.1.4 --- README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.org b/README.org index bf2c800..76c38ad 100644 --- a/README.org +++ b/README.org @@ -4,7 +4,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA -*Current version: 0.6.1.3* +*Current version: 0.6.1.4* RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. From 41d66da7a7608d8b3c29d28512900aef1c4ec567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 5 Feb 2019 21:29:44 +0100 Subject: [PATCH 26/37] new feature: randEpc version: 0.6.2.0 --- RBBGCMuso/DESCRIPTION | 2 +- RBBGCMuso/NAMESPACE | 3 +- RBBGCMuso/R/genEpc.R | 35 +++++++++++++++++ RBBGCMuso/man/changemulline.Rd | 4 +- RBBGCMuso/man/cleanupMuso.Rd | 6 +-- RBBGCMuso/man/compareMuso.Rd | 12 +++--- RBBGCMuso/man/dynRound.Rd | 22 +++++++++++ RBBGCMuso/man/getLogs.Rd | 4 +- RBBGCMuso/man/getOutFiles.Rd | 4 +- RBBGCMuso/man/musoMapping.Rd | 6 +-- RBBGCMuso/man/musoMappingFind.Rd | 8 ++-- RBBGCMuso/man/musoMonte.Rd | 62 ++++++++---------------------- RBBGCMuso/man/musoQuickEffect.Rd | 16 ++++---- RBBGCMuso/man/musoRand.Rd | 10 ++--- RBBGCMuso/man/musoSensi.Rd | 30 +++++++-------- RBBGCMuso/man/normalMuso.Rd | 32 +++++++-------- RBBGCMuso/man/plotMuso.Rd | 32 +++++++-------- RBBGCMuso/man/plotMusoWithData.Rd | 18 ++++----- RBBGCMuso/man/randEpc.Rd | 24 ++++++++++++ RBBGCMuso/man/readErrors.Rd | 6 +-- RBBGCMuso/man/runMuso.Rd | 34 ++++++++-------- RBBGCMuso/man/spinupMuso.Rd | 20 +++++----- RBBGCMuso/man/stampAndDir.Rd | 4 +- RBBGCMuso/man/updateMusoMapping.Rd | 8 ++-- 24 files changed, 226 insertions(+), 176 deletions(-) create mode 100644 RBBGCMuso/R/genEpc.R create mode 100644 RBBGCMuso/man/dynRound.Rd create mode 100644 RBBGCMuso/man/randEpc.Rd diff --git a/RBBGCMuso/DESCRIPTION b/RBBGCMuso/DESCRIPTION index 13a2679..a0268eb 100644 --- a/RBBGCMuso/DESCRIPTION +++ b/RBBGCMuso/DESCRIPTION @@ -1,6 +1,6 @@ Package: RBBGCMuso Title: An R package for BiomeBGC-MuSo ecosystem modelling -Version: 0.6.1.4 +Version: 0.6.2.0 Authors@R: person("Roland", "Hollo's", , "hollorol@gmail.com", role = c("aut", "cre")) Description: What the package does (one paragraph). Depends: R (>= 3.3.2) diff --git a/RBBGCMuso/NAMESPACE b/RBBGCMuso/NAMESPACE index 4002067..e128bf0 100644 --- a/RBBGCMuso/NAMESPACE +++ b/RBBGCMuso/NAMESPACE @@ -21,6 +21,7 @@ export(normalMuso) export(paramSweep) export(plotMuso) export(plotMusoWithData) +export(randEpc) export(runMuso) export(rungetMuso) export(setupMuso) @@ -56,9 +57,9 @@ importFrom(ggplot2,xlab) importFrom(ggplot2,ylab) importFrom(limSolve,xsample) importFrom(magrittr,'%<>%') +importFrom(magrittr,'%>%') importFrom(rmarkdown,pandoc_version) importFrom(rmarkdown,render) -importFrom(scales,percent) importFrom(tcltk,tk_choose.files) importFrom(tibble,rownames_to_column) importFrom(tidyr,gather) diff --git a/RBBGCMuso/R/genEpc.R b/RBBGCMuso/R/genEpc.R new file mode 100644 index 0000000..0543f8e --- /dev/null +++ b/RBBGCMuso/R/genEpc.R @@ -0,0 +1,35 @@ +#' randEpc +#' +#' randEpc is a random epc creator based on musoMonte +#' @author Roland HOLLOS +#' @param parameterFile parameters.csv file location +#' @param location output location directory +#' @param sourceEpc the original epc file-the template +#' @param iteration the number of iterations +#' @export + +randEpc <- function(parameterFile = "parameters.csv", location = "./epcDir", + sourceEpc = "maize.epc", iterations = 1000, constrains = NULL){ + + if(!dir.exists(location)){ + dir.create(location) + } + sourceEpc <- normalizePath(sourceEpc) + currDir <- getwd() + parameters <- read.csv(parameterFile) + + if(iterations < 3000){ + randVals <- musoRand(parameters = parameters,constrains = constrains, iterations = 3000) + randVals[[2]]<- randVals[[2]][sample(1:3000,iterations),] + } else { + randVals <- musoRand(parameters = parameters,constrains = constrains, iterations = iterations) + } + file.copy(sourceEpc,location,overwrite = TRUE) + setwd(location) + for(i in seq(iterations)){ + epcOut <- gsub("\\.",paste0("-",i,"."),basename(sourceEpc)) + changemulline(filePaths = basename(sourceEpc), calibrationPar = randVals[[1]], + contents = randVals[[2]][i,],fileOut = epcOut, fileToChange = "epc") + } + setwd(currDir) +} diff --git a/RBBGCMuso/man/changemulline.Rd b/RBBGCMuso/man/changemulline.Rd index 601fcb7..7acf438 100644 --- a/RBBGCMuso/man/changemulline.Rd +++ b/RBBGCMuso/man/changemulline.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/changeMuso.R \name{changemulline} \alias{changemulline} -\title{This is the function which is capable change multiple specific lines to other using their row numbers.} +\title{This is the function which is capable to change multiple specific lines to others using their row numbers.} \usage{ changemulline(filePaths, calibrationPar, contents, fileOut, fileToChange, modifyOriginal = FALSE) } \description{ -he function uses the previous changspecline function to operate. +The function uses the previous changspecline function to operate. } \author{ Roland Hollos diff --git a/RBBGCMuso/man/cleanupMuso.Rd b/RBBGCMuso/man/cleanupMuso.Rd index ffa0f25..7f830d6 100644 --- a/RBBGCMuso/man/cleanupMuso.Rd +++ b/RBBGCMuso/man/cleanupMuso.Rd @@ -7,9 +7,9 @@ cleanupMuso(location=NULL, simplicity=TRUE,deep=FALSE) } \arguments{ -\item{location}{It is the place where your output files are.} +\item{location}{This is the place (directory) where your output files are located.} -\item{simplicity}{TRUE or FALSE. If true cleanupMuso will erase only the log files from only the location} +\item{simplicity}{TRUE or FALSE. If TRUE cleanupMuso will erase only the log files from the location} \item{deep}{If it is TRUE, it will delete every files from the subdirectories also} } @@ -17,5 +17,5 @@ cleanupMuso(location=NULL, simplicity=TRUE,deep=FALSE) cleanupMuso can erase all of the unnecessary log and output files. } \author{ -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/compareMuso.Rd b/RBBGCMuso/man/compareMuso.Rd index e1ba0e0..4890945 100644 --- a/RBBGCMuso/man/compareMuso.Rd +++ b/RBBGCMuso/man/compareMuso.Rd @@ -9,19 +9,19 @@ compareMuso(settings = NULL, parameters, variable = 1, timeFrame = "day") } \arguments{ -\item{settings}{You have to run the setupMuso function before rungetMuso. It is its output which contains all of the necessary system variables. It sets the whole environment} +\item{settings}{RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option.} -\item{parameters}{In the settings variable you have set the row indexes of the variables, you wish to change. In this parameter you can give an exact value for them in a vector like: c(1,2,3,4)} +\item{parameters}{Using this function it is possible to change some of the EPC parameters prior to model execution. This can be achieved with this option. In the parameters variable you have set the row indices of the variables that you wish to change. In this parameters you can give an exact value for them in a vector form like c(1,2,3,4).} \item{variable}{The name of the output variable to plot} -\item{calibrationPar}{in the help of setupMuso function.} +\item{calibrationPar}{You might want to change some parameters in your EPC file before running the model. This function offers possibility for this without editing the EPC file. In this situation you have to select the appropirate model parameters first. You can refer to these parameters with the number of the line in the EPC file. Indexing of lines start from one. You should use a vector for this referencing like c(1,5,8)} -\item{fileToChange}{You can change any line of the epc or the ini file, you just have to specify with this variable which file you van a change. Two options possible: "epc", "ini", "both"} +\item{fileToChange}{You can change any line of the EPC or the INI file. Please choose "EPC", "INI" or "BOTH". This file will be used for the analysis, and the original parameter values will be changed according to the choice of the user.} } \description{ -This function runs the modell, change one of it's input, and plot both in one plot. +This function runs the model, then changes one of its input data, runs it again, and plots both results in one graph. } \author{ -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/dynRound.Rd b/RBBGCMuso/man/dynRound.Rd new file mode 100644 index 0000000..6c5c541 --- /dev/null +++ b/RBBGCMuso/man/dynRound.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/assistantFunctions.R +\name{dynRound} +\alias{dynRound} +\title{dynRound} +\usage{ +dynRound(x, y, seqLen) +} +\arguments{ +\item{x}{The lower end of the sequence} + +\item{y}{The higher end of the sequence} + +\item{seqLen}{The length of the sequence} +} +\value{ +rounded sequence +} +\description{ +This function rounds a sequence (definded by its endpoints and the length) optimally +} +\keyword{internal} diff --git a/RBBGCMuso/man/getLogs.Rd b/RBBGCMuso/man/getLogs.Rd index b0a4621..8b0057b 100644 --- a/RBBGCMuso/man/getLogs.Rd +++ b/RBBGCMuso/man/getLogs.Rd @@ -9,12 +9,12 @@ getLogs(outputLoc, outputNames, type = "spinup") \arguments{ \item{outputLoc}{This is the location of the output files.} -\item{outputNames}{These are the prefixis of the logfiles} +\item{outputNames}{These are the prefixes of the logfiles} } \value{ Logfiles with paths } \description{ -This function gives us the muso logfiles with their paths +This function gives us the muso logfiles with their path } \keyword{internal} diff --git a/RBBGCMuso/man/getOutFiles.Rd b/RBBGCMuso/man/getOutFiles.Rd index 437bda0..2183a46 100644 --- a/RBBGCMuso/man/getOutFiles.Rd +++ b/RBBGCMuso/man/getOutFiles.Rd @@ -9,10 +9,10 @@ getOutFiles(outputLoc, outputNames) \arguments{ \item{outputLoc}{This is the location of the output files.} -\item{outputNames}{These are the prefixis of the logfiles} +\item{outputNames}{These are the prefixes of the logfiles.} } \value{ -Output files with their paths +Output files with their paths. } \description{ This function gives us the muso output files with their paths diff --git a/RBBGCMuso/man/musoMapping.Rd b/RBBGCMuso/man/musoMapping.Rd index 7db1c42..d8e2b9f 100644 --- a/RBBGCMuso/man/musoMapping.Rd +++ b/RBBGCMuso/man/musoMapping.Rd @@ -12,11 +12,11 @@ musoMapping(code, mapData=NULL) \item{mapData}{updateMusomapping generated matrix} } \value{ -The name of the MuSo outputcode +The name of the Biome-BGCMuSo output code (e.g. if code is 3009 this function should return GPP to the user) } \description{ -musoMapping can give us the name of a muso outputcode +musoMapping can provide the user the name of a Biome-BGCMuSo output code. Within Biome-BGCMuSo the state variables and fluxes are marked by integer numbers. In order to provide meaningful variable names (e.g. 3009 means Gross Primary Production) a conversion table is needed which is utilized by this function. This function converts variable codes into names musoMappingFind does the opposite. } \author{ -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/musoMappingFind.Rd b/RBBGCMuso/man/musoMappingFind.Rd index b50cc79..22710a6 100644 --- a/RBBGCMuso/man/musoMappingFind.Rd +++ b/RBBGCMuso/man/musoMappingFind.Rd @@ -7,14 +7,14 @@ musoMapping(code, mapData=NULL) } \arguments{ -\item{variable}{If null return the whole mapping, else search a variable code} +\item{variable}{If this is null, return the whole mapping table. In other cases search for the variable code} } \value{ -The code of th specific name +The code of the specific output variable name } \description{ -musoMapping can give us the name of a muso outputcode +musoMappingFind can provide us the code of the Biome-BGCMuSo output variable name. Within Biome-BGCMuSo the state variables and fluxes are marked by integer numbers. In order to provide meaningful variable names (e.g. 3009 means Gross Primary Production) a conversion table is needed which is utilized by this function. This function converts variable names into codes. musoMapping does the opposite. } \author{ -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/musoMonte.Rd b/RBBGCMuso/man/musoMonte.Rd index ec88557..e7b37cf 100644 --- a/RBBGCMuso/man/musoMonte.Rd +++ b/RBBGCMuso/man/musoMonte.Rd @@ -1,15 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/musoMont.R, R/musoMonte.R +% Please edit documentation in R/musoMonte.R \name{musoMonte} \alias{musoMonte} -\title{musoMont} +\title{musoMonte} \usage{ -musoMonte(settings = NULL, parameters = NULL, inputDir = "./", - outLoc = "./calib", iterations = 10, preTag = "mont-", - outputType = "moreCsv", fun = mean, varIndex = 1, outVars = NULL, - silent = TRUE, skipSpinup = TRUE, debugging = FALSE, - keepEpc = FALSE, constrains = NULL, ...) - musoMonte(settings = NULL, parameters = NULL, inputDir = "./", outLoc = "./calib", iterations = 10, preTag = "mont-", outputType = "moreCsv", fun = mean, varIndex = 1, outVars = NULL, @@ -17,57 +11,31 @@ musoMonte(settings = NULL, parameters = NULL, inputDir = "./", keepEpc = FALSE, constrains = NULL, ...) } \arguments{ -\item{settings}{A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically.} +\item{settings}{A list of environmental variables for the Monte Carlo experiment. These settings are generated by the setupMuso function. By default the settings parameter is generated automatically.} -\item{parameters}{This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized.} +\item{parameters}{This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization.} -\item{inputDir}{The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file.} +\item{inputDir}{The location of the input directory for the Biome-BGCMuSo model. This directory must contain a viable pack of all input files and the model executable file.} -\item{iterations}{number of the monteCarlo run.} +\item{iterations}{Number of the Monte Carlo simulations.} -\item{preTag}{It will be the name of the output files. For example preTag-1.csv, pretag-2csv...} +\item{preTag}{This defines the name of the output files. This tag will be re-used so that the results will be like preTag-1.csv, preTag-2csv...} -\item{outputType}{This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet.} +\item{outputType}{This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is chosen the function creates one large csv file for all of the runs. If "moreCsv" is chosen, every model output goes to separate files. If netCDF is selected the output will be stored in a netCDF file. The default value of the outputTypes is "moreCsv". Note that netCDF is not implemented yet.} -\item{fun}{If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need.} +\item{fun}{If you select a variable from the possible outputs (by using the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your needs.} -\item{varIndex}{This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3.} +\item{varIndex}{This parameter specifies which parameter will be used for the Monte Carlo experiment from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3.} -\item{debugging}{If you set this parameter, you can save every logfile, and RBBGCMuso will select those which contains errors.} +\item{debugging}{If you set this parameter, you can save every logfile, and RBBGCMuso will select those which contains errors. This is useful to study why the model crashes with a given parameter set.} -\item{keepEpc}{if you set keepEpc also true, it will save every selected epc file, and put the wrong ones in the WRONGEPC directory.} +\item{keepEpc}{If you set keepEpc as TRUE, it will save every selected EPC file, and move the wrong ones into the WRONGEPC directory.} -\item{calibrationPar}{You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8)} - -\item{settings}{A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically.} - -\item{parameters}{This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized.} - -\item{calibrationPar}{You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8)} - -\item{inputDir}{The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file.} - -\item{iterations}{number of the monteCarlo run.} - -\item{preTag}{It will be the name of the output files. For example preTag-1.csv, pretag-2csv...} - -\item{outputType}{This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet.} - -\item{fun}{If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need.} - -\item{varIndex}{This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3.} - -\item{debugging}{If you set this parameter, you can save every logfile, and RBBGCMuso will select those which contains errors.} - -\item{keepEpc}{if you set keepEpc also true, it will save every selected epc file, and put the wrong ones in the WRONGEPC directory.} +\item{calibrationPar}{You might want to change some parameters in your EPC file before you run the modell. You have to select the appropirate model parameters here. You can refer to the parameters by the number of the line in the EPC file where the variables are defined. The indexing of the lines starts at 1, and each line matters (like in any simple text file). You should use a vector for this selection like c(1,5,8)} } \description{ -This function does monteCarlo on BiomeBGC-MuSo. It samples specified modell variables in given rangge from conditional multivariate uniform distribution, and runs the modell for each run. - -This function does monteCarlo on BiomeBGC-MuSo. It samples specified modell variables in given rangge from conditional multivariate uniform distribution, and runs the modell for each run. +This function executes the Monte Carlo experiment with Biome-BGCMuSo (musoRand is called by this function). It samples the selected model parameters within user defined ranges from conditional multivariate uniform distribution, and then runs the model for each run. } \author{ -Roland Hollos - -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/musoQuickEffect.Rd b/RBBGCMuso/man/musoQuickEffect.Rd index 65d15d1..1676a4e 100644 --- a/RBBGCMuso/man/musoQuickEffect.Rd +++ b/RBBGCMuso/man/musoQuickEffect.Rd @@ -9,22 +9,22 @@ musoQuickEffect(settings = NULL, calibrationPar = NULL, startVal, parName = "parVal") } \arguments{ -\item{settings}{The settings from setupMuso output} +\item{settings}{RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option.} -\item{startVal}{The oroginal parameterValue} +\item{startVal}{The initial value of the given parameter.} -\item{endVal}{The goal value while the function pass} +\item{endVal}{The maximum of the given parameter.} -\item{nSteps}{How many steps 'till you reach the endVal} +\item{nSteps}{Number of steps from startVal to endVal. It equals the number of simulations, and number of curves on the final plot.} -\item{fileTochange}{Please choose "epc" "ini" or "both". This is the place of the orininal variable.} +\item{fileTochange}{Please choose "EPC", "INI" or "BOTH". This file will be used for the analysis, and the original parameter values will be changed according to the choice of the user.} } \value{ -An effect plot +Graph showing the runs with the selected parameters with color coding. The graph will show data from the last simulation year. } \description{ -This function changes a choosen parameter, and visualize the effect of the change on a chosen variable. +This function changes a chosen parameter from the INI or from the ecophysiological constants file (EPC) within a predefined range (defined by the user), and visualizes the effect of the change on the selected output variable. The user has to specify the parameter, the interval for the parameter effect test, and the number of steps. This function focuses only on one parameter. The so-called paramSweep function can manipulate multiple INI/EPC parameters and visualize the results. } \author{ -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/musoRand.Rd b/RBBGCMuso/man/musoRand.Rd index 928ccb8..ebb2d78 100644 --- a/RBBGCMuso/man/musoRand.Rd +++ b/RBBGCMuso/man/musoRand.Rd @@ -7,15 +7,15 @@ musoRand(parameters, constrains = NULL, iterations = 3000) } \arguments{ -\item{parameters}{This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the input-file, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized.} +\item{parameters}{This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization.} -\item{constrains}{This is a matrics wich specify the constrain rules for the sampling. Further informations coming son.} +\item{constrains}{This is a matrix wich specify the constrain rules for the sampling. Parameter dependencies are described in the Biome-BGCMuSo User's Guide. Further informations is coming soon.} -\item{iteration}{The number of sample-s. It is adviced to use at least 3000 iteration, because it is generally fast and it can be subsampled later at any time.} +\item{iteration}{The number of samples for the Monte-Carlo experiment. We propose to use at least 3000 iteration because it is generally fast and it can be subsampled later at any time.} } \description{ -This funtion samples uniformly from the choosen parameters of the BiomeBGC-Muso model, which parameters are constrained by the model logic. +This funtion uses the Monte Carlo technique to uniformly sample the parameter space from user defined parameters of the Biome-BGCMuSo model. The sampling algorithm ensures that the parameters are constrained by the model logic which means that parameter dependencies are fully taken into account (parameter dependency means that e.g leaf C:N ratio must be smaller than C:N ratio of litter; more complicated rules apply to the allocation parameters where the allocation fractions to different plant compartments must sum up 1). This function implements a mathematically correct solution to provide uniform distriution for all selected parameters. } \author{ -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/musoSensi.Rd b/RBBGCMuso/man/musoSensi.Rd index e5836b1..af86c7e 100644 --- a/RBBGCMuso/man/musoSensi.Rd +++ b/RBBGCMuso/man/musoSensi.Rd @@ -12,35 +12,35 @@ musoSensi(monteCarloFile = NULL, parameters = NULL, settings = NULL, skipSpinup = TRUE, dpi = 300) } \arguments{ -\item{monteCarloFile}{If you run musoMonte function previously, you did not have to rerun the monteCarlo, just provide the preservedEpc.csv file with its path. If you do not set this parameter, musoSensi will fun the musoMonte function to get all of the information.} +\item{monteCarloFile}{If you run the musoMonte function previously, you do not have to re-run the monteCarlo experiment, simply provide the preservedEpc.csv file to musoSensi with its path. If you do not set this parameter, musoSensi will run the musoMonte function to get all necessary information.} -\item{parameters}{This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized.} +\item{parameters}{This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization.} -\item{settings}{A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically.} +\item{settings}{A list of environmental variables for the Monte Carlo experiment. These settings are generated by the setupMuso function. By default the settings parameter is generated automatically.} -\item{inputDir}{The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file.} +\item{inputDir}{The location of the input directory for the Biome-BGCMuSo model. This directory must contain a viable pack of all input files and the model executable file.} -\item{iterations}{number of the monteCarlo run.} +\item{iterations}{Number of the Monte Carlo simulations.} -\item{preTag}{It will be the name of the output files. For example preTag-1.csv, pretag-2csv...} +\item{preTag}{This defines the name of the output files. This tag will be re-used so that the results will be like preTag-1.csv, preTag-2csv...} -\item{outputType}{This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet.} +\item{outputType}{This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is chosen the function creates one large csv file for all of the runs. If "moreCsv" is chosen, every model output goes to separate files. If netCDF is selected the output will be stored in a netCDF file. The default value of the outputTypes is "moreCsv". Note that netCDF is not implemented yet.} -\item{fun}{If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need.} +\item{fun}{If you select a variable from the possible outputs (by using the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your needs.} -\item{varIndex}{This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3.} +\item{varIndex}{This parameter specifies which parameter will be used for the Monte Carlo experiment from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3.} -\item{outputFile}{The filename in which the output of musoSensi function will be saved. It's default value is: "sensitivity.csv"} +\item{outputFile}{The filename in which the output of the musoSensi function will be saved. By default it is "sensitivity.csv"} -\item{plotName}{The name of the output barplot. It's default value is: "sensitivity.jpg"} +\item{plotName}{The name of the output barplot. It's default value is "sensitivity.jpg"} -\item{skipSpinup}{With this parameter, you can turn of the spinup phase after the first spinup. I will decrease the time significantly.} +\item{skipSpinup}{With this parameter you can turn off the spinup phase after the first spinup was successfully executed (endpoint file is available). This option can dramatically decrease the time needed for the sensitivity analysis. Note that in case of natural vegetation this option might not be feasible. For croplands this is more feasible.} -\item{calibrationPar}{You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8)} +\item{calibrationPar}{You might want to change some parameters in your EPC file before you run the modell. You have to select the appropirate model parameters here. You can refer to the parameters by the number of the line in the EPC file where the variables are defined. The indexing of the lines starts at 1, and each line matters (like in any simple text file). You should use a vector for this selection like c(1,5,8)} } \description{ -This function does regression based sensitivity analysis based on the output of musoMonte. +This function performs multiple liear regression based global sensitivity analysis based on the output of musoMonte. First the user has to select the parameters of interest with possible minimum and maximum values. After execution musoSensi will then assign weights to the predefined parameters which means that the importance of the parameters will be ranked. The sensitivity analysis calculates the effect of input variability on the output variability in Monte Carlo framework. The result will largely depend on the selected output variable (GPP, evapotranspiration, LAI, soil water content), and on the parameter ranges. Other factors like climate, management and site specific conditions might affect the results. } \author{ -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/normalMuso.Rd b/RBBGCMuso/man/normalMuso.Rd index 9098bcd..972f667 100644 --- a/RBBGCMuso/man/normalMuso.Rd +++ b/RBBGCMuso/man/normalMuso.Rd @@ -8,38 +8,38 @@ normalMuso(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NUL keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE) } \arguments{ -\item{settings}{You have to run the setupMuso function before calibMuso. It is its output which contains all of the necessary system variables. It sets the whole running environment} +\item{settings}{RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option.} -\item{parameters}{In the settings variable you have set the row indexes of the variables, you wish to change. In this parameter you can give an exact value for them in a vector like: c(1,2,3,4)} +\item{parameters}{Using normalMuso it is possible to change some of the EPC parameters prior to model execution. This can be achieved with this option. In the parameters variable you have set the row indices of the variables that you wish to change. In this parameters you can give an exact value for them in a vector form like c(1,2,3,4).} -\item{timee}{The required timesteps in the modell output. It can be "d", if it is daily, "m", if it's monthly, "y", it it is yearly. I recommend to use daily data, the yearly and monthly data is not well-tested yet.} +\item{timee}{The required timesteps in the model output. It can be "d", if it is daily, "m", if it is monthly, "y" if it is yearly. It is recommended to use daily data, as the yearly and monthly data is not well-tested yet.} -\item{debugging}{If it is TRUE, it copies the log file to a Log directory to store it, if it is stamplog it contatenate a number before the logfile, which is one more than the maximum of the represented ones in the LOG directory. If it is true or stamplog it collects the "wrong" logfiles} +\item{debugging}{If debugging is set to TRUE, after model execution the function copies the Biome-BGCMuSo log file into a LOG directory and stores it for further processing. If debugging is set to STAMPLOG instead of TRUE, it concatenates a number before the logfile, which is one plus the maximum of those present in the LOG directory. In each case the log files will be saved.} -\item{logfilename}{If you want to set a specific name for your logfiles you can set this via logfile parameter} +\item{logfilename}{If you would like to set a specific name for your logfiles you can set this via the logfile parameter.} -\item{keepEpc}{If TRUE, it keeps the epc file and stamp it, after these copies it to the EPCS directory. If debugging True or false, it copies the wrong epc files to the wrong epc directory.} +\item{keepEpc}{If keepEpc is set to TRUE, the function keeps the EPC file and stamps it, and then copies it to the EPCS directory. If debugging is set to TRUE, it copies the wrong EPC files to the wrong epc directory.} -\item{export}{if it is yes or you give a filename here, it converts the ouxtput to the specific extension. For example, if you set export to "example.csv", it converts the output to "csv", if you set it to "example.xls" it converts to example.xls with the xlsx package. If it is not installed it gives back a warning message and converts it to csv.} +\item{export}{If it is set to YES or you define a filename here, the function converts the output to the specific file format. For example, if you set export to "example.csv", it converts the output to "csv". If you set it to "example.xls" it converts the output to example.xls with the xlsx package. If the Excel converter package is not installed it gives back a warning message and converts the results to csv.} -\item{silent}{If you set it TRUE all off the modells output to the screen will be suppressed. It can be usefull, because it increases the model-speed.} +\item{silent}{If you set the silent parameter to TRUE, all of the model's output normally written to the screen will be suppressed. This option can be useful to increase the speed of the model execution.} -\item{aggressive}{It deletes every possible modell-outputs from the previous modell runs.} +\item{aggressive}{It deletes all previous model-outputs from previous model runs.} -\item{leapYear}{Should the function do a leapyear correction on the outputdata? If TRUE, then the 31.12 day will be doubled.} +\item{leapYear}{Should the function do a leapyear correction on the output data? If TRUE, then the result for 31 December will be doubled in leap years which means that the results for the leap year will cover all 366 days. See the model's User's Guide for notes on leap years.} -\item{binaryPlace}{The place of the binary output files.} +\item{binaryPlace}{The directory for the binary output files (see the keepBinary parameter).} -\item{fileToChange}{You can change any line of the epc or the ini file, you just have to specify with this variable which file you van a change. Two options possible: "epc", "ini"} +\item{fileToChange}{You can change any line of the EPC or the INI file prior to model execution. All you need to do is to specify with this variable which file you want to change. Two options possible: "EPC" or "INI"} -\item{keepBinary}{In default RBBGCMuso to keep working area as clean as possible, deletes all the regular output files. The results are directly printed to the standard output, but you can redirect it, and save it to a variable, or you can export your results to the desired destination in a desired format. Whith this variable you can enable to keep the binary output files. If you want to set the location of the binary output, please take a look at the binaryPlace argument.} +\item{keepBinary}{By default RBBGCMuso keeps the working environment as clean as possible, thus deletes all the regular output files. The results are directly written to the standard output (e.g. to the screen), but you can redirect it and save them to a variable. Alternatively, you can export your results to the desired destination in a desired format. Through the keepBinary parameter you can set RBBGCMuso to keep the binary output files. If you would like to set the location of the binary output, please take a look at the binaryPlace argument.} } \value{ -The simunation output matrix, where the columns are the choosen variables and each row is a day/month/year data. +The simulation output matrix, where the columns are the chosen variables and each row is a daily/monthly/annual data. } \description{ -This function changes the epc file and after that runs the BBGC-MuSo model in normal phase and reads in its outputfile in a well-structured way. +This function optionally changes the EPC file and runs the Biome-BGCMuSo model in normal phase and reads its output file in a well-structured way with debugging features. (Execution of spinup phase is possible with spinupMuso.) Prerequisite of normalMuso is the existence of the endpoint file (which is the result of the spinup phase and contains initial conditions for the simulation). } \author{ -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/plotMuso.Rd b/RBBGCMuso/man/plotMuso.Rd index 5c26ebe..0e33757 100644 --- a/RBBGCMuso/man/plotMuso.Rd +++ b/RBBGCMuso/man/plotMuso.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/plotMuso.R \name{plotMuso} \alias{plotMuso} -\title{plot the BBGCMuso output} +\title{plot the Biome-BGCMuSo output} \usage{ plotMuso(settings, variable, timee="d", silent=TRUE, @@ -11,36 +11,36 @@ logfilename=NULL, aggressive=FALSE, leapYear=FALSE, export=FALSE) } \arguments{ -\item{settings}{You have to run the setupMuso function before rungetMuso. It is its output which contains all of the necessary system variables. It sets the whole environment} +\item{settings}{RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option.} -\item{variable}{column number of the variable which should be plottedor "all" if you have less than 10 variables. In this case it will plot everything in a matrix layout} +\item{variable}{Column number of the output variable which should be plotted, or "all" if you have less than 10 variables. In this case the function will plot everything in a matrix layout.} -\item{timee}{The required timesteps in the modell output. It can be "d", if it is daily, "m", if it's monthly, "y", it it is yearly} +\item{timee}{The required timesteps in the model output. It can be "d", if it is daily, "m", if it is monthly, "y" if it is yearly. It is recommended to use daily data, as the yearly and monthly data is not well-tested yet.} -\item{silent}{If you set it TRUE all off the modells output to the screen will be suppressed. It can be usefull, because it increases the model-speed.} +\item{silent}{If you set the silent parameter to TRUE, all of the model's output normally written to the screen will be suppressed. This option can be useful to increase the speed of the model execution.} -\item{debugging}{If it is TRUE, it copies the log file to a Log directory to store it, if it is stamplog it contatenate a number before the logfile, which is one more than the maximum of the represented ones in the LOG directory. If it is true or stamplog it collects the "wrong" logfiles} +\item{debugging}{If debugging is set to TRUE, after model execution the function copies the Biome-BGCMuSo log file into a LOG directory and stores it for further processing. If debugging is set to STAMPLOG instead of TRUE, it concatenates a number before the logfile, which is one plus the maximum of those present in the LOG directory. In each case the log files will be saved.} -\item{keepEpc}{If TRUE, it keeps the epc file and stamp it, after these copies it to the EPCS directory. If debugging True or false, it copies the wrong epc files to the wrong epc directory.} +\item{keepEpc}{If keepEpc is set to TRUE, the function keeps the EPC file and stamps it, and then copies it to the EPCS directory. If debugging is set to TRUE, it copies the wrong EPC files to the wrong epc directory.} -\item{logfilename}{If you want to set a specific name for your logfiles you can set this via logfile parameter} +\item{logfilename}{If you would like to set a specific name for your logfiles you can set this via the logfile parameter.} -\item{aggressive}{It deletes every possible modell-outputs from the previous modell runs.} +\item{aggressive}{It deletes all previous model-outputs from previous model runs.} -\item{leapYear}{Should the function do a leapyear correction on the outputdata? If TRUE, then the 31.12 day will be doubled.} +\item{leapYear}{Should the function do a leapyear correction on the output data? If TRUE, then the result for 31 December will be doubled in leap years which means that the results for the leap year will cover all 366 days. See the model's User's Guide for notes on leap years.} -\item{plotType}{There are two options now: continious time series("cts") or disctrete time series("dts")} +\item{plotType}{There are two options implemented by now: continuous time series ("cts") or disctrete time series ("dts")} -\item{skipSpinup}{If TRUE, calibMuso wont do spinup simulation} +\item{skipSpinup}{If TRUE, the function won't perform the spinup simulation. In this case the endpoint file must exist that provides initial conditions for the run.} -\item{export}{if it is yes or you give a filename here, it converts the output to the specific extension. For example, if you set export to "example.csv", it converts the output to "csv", if you set it to "example.xls" it converts to example.xls with the xlsx package. If it is not installed it gives back a warning message and converts it to csv.} +\item{export}{If it is set to YES or you define a filename here, the function converts the output to the specific file format. For example, if you set export to "example.csv", it converts the output to "csv". If you set it to "example.xls" it converts the output to example.xls with the xlsx package. If the Excel converter package is not installed it gives back a warning message and converts the results to csv.} } \value{ -It depends on the export parameter. The function returns with a matrix with the modell output, or writes this in a file, which is given previously +It depends on the export parameter. The function returns with a matrix with the model output, or writes this into a file, which is defined previously } \description{ -This function runs the BBGC-MuSo model and reads in its outputfile in a very structured way, and after that plot the results automaticly +This function runs the Biome-BGCMuSo model and reads its output file in a well structured way, and after that it plots the results automatically. plotMuso is a convenient and quick method to create nice graphs from Biome-BGCMuSo output which is quite painful in other environments. } \author{ -Roland Hollos, Dora Hidy +Roland HOLLOS, Dora HIDY } diff --git a/RBBGCMuso/man/plotMusoWithData.Rd b/RBBGCMuso/man/plotMusoWithData.Rd index ca6ef62..6bdaa42 100644 --- a/RBBGCMuso/man/plotMusoWithData.Rd +++ b/RBBGCMuso/man/plotMusoWithData.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/plotMuso.R \name{plotMusoWithData} \alias{plotMusoWithData} -\title{plot the BBGCMuso output with data} +\title{plot the Biome-BGCMuSo model output with observation data} \usage{ plotMuso(settings, variable, timee="d", silent=TRUE, @@ -11,25 +11,25 @@ logfilename=NULL, aggressive=FALSE, leapYear=FALSE, export=FALSE) } \arguments{ -\item{csvFile}{The file of the measurement. It must contain a header.} +\item{csvFile}{This specifies the filename of the measurements. It must contain a header. Typically this is a CSV file.} \item{variable}{The name of the output variable to plot} \item{NACHAR}{This is not implemented yet} -\item{settings}{You have to run the setupMuso function before rungetMuso. It is its output which contains all of the necessary system variables. It sets the whole environment} +\item{settings}{RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option.} -\item{sep}{This is the separator used in the measurement file} +\item{sep}{This is the separator symbol used in the measurement file (that is supposed to be a delimited text file)} -\item{savePlot}{It it is specified, the plot will be saved in a format specified with the immanent extension} +\item{savePlot}{It it is specified, the plot will be saved in a graphical format specified by the immanent extension. For example, it the savePlot is set to image01.png then a PNG graphics file will be created.} -\item{calibrationPar}{documentation in setupMuso()} +\item{calibrationPar}{You might want to change some parameters in your EPC file before running the model. The function offers possibility for this without editing the EPC file. In this situation you have to select the appropirate model parameters first. You can refer to these parameters with the number of the line in the EPC file. Indexing of lines start from one. You should use a vector for this referencing like c(1,5,8)} -\item{parameters}{documentation in calibMuso()} +\item{parameters}{Using the function it is possible to change some of the EPC parameters prior to model execution. This can be achieved with this option. In the parameters variable you have set the row indices of the variables that you wish to change. In this parameters you can give an exact value for them in a vector form like c(1,2,3,4).} } \description{ -This function runs the BBGC-MuSo model and reads in its outputfile in a very structured way, and after that plot the results automaticly along with a given measurement +This function runs the Biome-BGCMuSo model and reads its output file in a well structured way, and after that it plots the results automatically along with a given measurement dataset provided by the user. plotMusoWithData is a convenient and quick method to create nice graphs from Biome-BGCMuSo output which is quite painful in other environments. } \author{ -Roland Hollos, Dora Hidy +Roland HOLLOS, Dora HIDY } diff --git a/RBBGCMuso/man/randEpc.Rd b/RBBGCMuso/man/randEpc.Rd new file mode 100644 index 0000000..6087be7 --- /dev/null +++ b/RBBGCMuso/man/randEpc.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/genEpc.R +\name{randEpc} +\alias{randEpc} +\title{randEpc} +\usage{ +randEpc(parameterFile = "parameters.csv", location = "./epcDir", + sourceEpc = "maize.epc", iterations = 1000, constrains = NULL) +} +\arguments{ +\item{parameterFile}{parameters.csv file location} + +\item{location}{output location directory} + +\item{sourceEpc}{the original epc file-the template} + +\item{iteration}{the number of iterations} +} +\description{ +randEpc is a random epc creator based on musoMonte +} +\author{ +Roland HOLLOS +} diff --git a/RBBGCMuso/man/readErrors.Rd b/RBBGCMuso/man/readErrors.Rd index ff77bbe..a5723da 100644 --- a/RBBGCMuso/man/readErrors.Rd +++ b/RBBGCMuso/man/readErrors.Rd @@ -7,14 +7,14 @@ readErrors(outputLoc, logfiles, type = "both") } \arguments{ -\item{outputLoc}{This is the location of the output files.} +\item{outputLoc}{This is the location of the output file.} -\item{logfiles}{These are the names of the logfiles} +\item{logfiles}{These are the names of the logfiles.} } \value{ vector with 0 and 1 values, 1, if succed, 0 if not. The first is the spinup run, the second is the normal. } \description{ -This function reads the spinup and the normal logfiles and gives back the last line which indicates weather there are any errors. +This function reads the spinup and the normal logfiles and gives back the last line which indicates weather there are any errors during the model execution or not. } \keyword{internal} diff --git a/RBBGCMuso/man/runMuso.Rd b/RBBGCMuso/man/runMuso.Rd index dd0aa7c..0f3e716 100644 --- a/RBBGCMuso/man/runMuso.Rd +++ b/RBBGCMuso/man/runMuso.Rd @@ -8,42 +8,42 @@ calibMuso(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE) } \arguments{ -\item{settings}{You have to run the setupMuso function before calibMuso. It is its output which contains all of the necessary system variables. It sets the whole running environment} +\item{settings}{RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option.} -\item{parameters}{In the settings variable you have set the row indexes of the variables, you wish to change. In this parameter you can give an exact value for them in a vector like: c(1,2,3,4)} +\item{parameters}{Using normalMuso it is possible to change some of the EPC parameters prior to model execution. This can be achieved with this option. In the parameters variable you have set the row indices of the variables that you wish to change. In this parameters you can give an exact value for them in a vector form like c(1,2,3,4).} -\item{timee}{The required timesteps in the modell output. It can be "d", if it is daily, "m", if it's monthly, "y", it it is yearly. I recommend to use daily data, the yearly and monthly data is not well-tested yet.} +\item{timee}{The required timesteps in the model output. It can be "d", if it is daily, "m", if it is monthly, "y" if it is yearly. It is recommended to use daily data, as the yearly and monthly data is not well-tested yet.} -\item{debugging}{If it is TRUE, it copies the log file to a Log directory to store it, if it is stamplog it contatenate a number before the logfile, which is one more than the maximum of the represented ones in the LOG directory. If it is true or stamplog it collects the "wrong" logfiles} +\item{debugging}{If debugging is set to TRUE, after model execution the function copies the Biome-BGCMuSo log file into a LOG directory to stores it for further processing. If debugging is set to STAMPLOG instead of TRUE, it concatenates a number before the logfile, which is one plus the maximum of those present in the LOG directory. In each case the log files will be saved.} -\item{logfilename}{If you want to set a specific name for your logfiles you can set this via logfile parameter} +\item{logfilename}{If you would like to set a specific name for your logfiles you can set this via the logfile parameter.} -\item{keepEpc}{If TRUE, it keeps the epc file and stamp it, after these copies it to the EPCS directory. If debugging True or false, it copies the wrong epc files to the wrong epc directory.} +\item{keepEpc}{If keepEpc is set to TRUE, the function keeps the EPC file and stamps it, and then copies it to the EPCS directory. If debugging is set to TRUE, it copies the wrong EPC files to the wrong epc directory.} -\item{export}{if it is yes or you give a filename here, it converts the ouxtput to the specific extension. For example, if you set export to "example.csv", it converts the output to "csv", if you set it to "example.xls" it converts to example.xls with the xlsx package. If it is not installed it gives back a warning message and converts it to csv.} +\item{export}{If it is set to YES or you define a filename here, the function converts the output to the specific file format. For example, if you set export to "example.csv", it converts the output to "csv". If you set it to "example.xls" it converts the output to example.xls with the xlsx package. If the Excel converter package is not installed it gives back a warning message and converts the results to csv.} -\item{silent}{If you set it TRUE all off the modells output to the screen will be suppressed. It can be usefull, because it increases the model-speed.} +\item{silent}{IIf you set the silent parameter to TRUE, all of the model's output normally written to the screen will be suppressed. This option can be useful to increase the speed of the model execution.} -\item{aggressive}{It deletes every possible modell-outputs from the previous modell runs.} +\item{aggressive}{It deletes all previous model-outputs from previous model runs.} -\item{leapYear}{Should the function do a leapyear correction on the outputdata? If TRUE, then the 31.12 day will be doubled.} +\item{leapYear}{Should the function do a leapyear correction on the output data? If TRUE, then the result for 31 December will be doubled in leap years which means that the results for the leap year will cover all 366 days. See the model's User's Guide for notes on leap years.} -\item{keepBinary}{In default RBBGCMuso to keep working area as clean as possible, deletes all the regular output files. The results are directly printed to the standard output, but you can redirect it, and save it to a variable, or you can export your results to the desired destination in a desired format. Whith this variable you can enable to keep the binary output files. If you want to set the location of the binary output, please take a look at the binaryPlace argument.} +\item{keepBinary}{By default RBBGCMuso keeps the working environment as clean as possible, thus deletes all the regular output files. The results are directly written to the standard output (e.g. to the screen), but you can redirect it and save them to a variable. Alternatively, you can export your results to the desired destination in a desired format. Through the keepBinary parameter you can set RBBGCMuso to keep the binary output files. If you would like to set the location of the binary output, please take a look at the binaryPlace argument.} -\item{binaryPlace}{The place of the binary output files.} +\item{binaryPlace}{The directory for the binary output files (see the keepBinary parameter).} -\item{fileToChange}{You can change any line of the epc or the ini file, you just have to specify with this variable which file you van a change. Two options possible: "epc", "ini"} +\item{fileToChange}{You can change any line of the EPC or the INI file prior to model execution. All you need to do is to specify with this variable which file you want to change. Two options possible: "EPC" or "INI"} -\item{skipSpinup}{If TRUE, calibMuso wont do spinup simulation} +\item{skipSpinup}{If this is set to TRUE, runMuso will not perform the spinup simulation. This is of course means that the endpoint file (initial conditions) must be available for the normal INI file. This option might be extremely useful to speed up multiple model execution. In cropland related simulations due to site history the EPC file used in the normal phase might differ from the one used in the spinup phase, which means that the spinup is the same even if we change the parameterization for the normal phase. In this situation skipSpinup is really useful.} -\item{prettyOut}{date ad Date type, separate year, month, day vectors} +\item{prettyOut}{If this parameter is to TRUE then date will provided as the R-style Date type, and separate year, month and day vectors. In typical cases the user should use this option.} } \value{ No return, outputs are written to file } \description{ -This function changes the epc file and after that runs the BBGC-MuSo model and reads in its outputfile in a well-structured way. +This function runs the Biome-BGCMuSo model (with option to change the EPC file), then it reads its output file in a well-structured way. As the result is passed to R, the results can be easily post-processed in R environment. } \author{ -Roland Holl\'{o}s +Roland HOLL\'{O}S } diff --git a/RBBGCMuso/man/spinupMuso.Rd b/RBBGCMuso/man/spinupMuso.Rd index 28cd02a..6f31f41 100644 --- a/RBBGCMuso/man/spinupMuso.Rd +++ b/RBBGCMuso/man/spinupMuso.Rd @@ -2,32 +2,32 @@ % Please edit documentation in R/spinupMuso.R \name{spinupMuso} \alias{spinupMuso} -\title{Run the BBGCMuso modell only in spinup phase, and debugging.} +\title{Runs the Biome-BGCMuSo model in spinup phase (execution of normal phase is possible with normalMuso) with debugging features.} \usage{ spinupMuso(settings, parameters=NULL, debugging=FALSE, logfilename=NULL, keepEpc=FALSE, silent=FALSE, aggressive=FALSE) } \arguments{ -\item{settings}{You have to run the setupMuso function before spinupMuso. It is its output which contains all of the necessary system variables. It sets the whole running environment.} +\item{settings}{RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option.} -\item{parameters}{In the settings variable you have set the row indexes of the variables, you wish to change. In this parameter you can give an exact value for them in a vector like: c(1,2,3,4)} +\item{parameters}{|||| In the parameters variable you have set the row indices of the variables that you wish to change. In this parameter you can provide an exact value for them in a vector form like c(1,2,3,4)} -\item{debugging}{If it is TRUE, it copies the log file to a Log directory to store it, if it is stamplog it contatenate a number before the logfile, which is one more than the maximum of the represented ones in the LOG directory. If it is true or stamplog it collects the "wrong" logfiles} +\item{debugging}{If debugging is set to TRUE, after model execution the function copies the Biome-BGCMuSo log file into a LOG directory to stores it for further processing. If debugging is set to STAMPLOG instead of TRUE, it concatenates a number before the logfile, which is one plus the maximum of those present in the LOG directory. In each case the log files will be saved.} -\item{logfilename}{If you want to set a specific name for your logfiles you can set this via logfile parameter} +\item{logfilename}{If you would like to set a specific name for the logfiles you can set this via the logfilename parameter} -\item{keepEpc}{If TRUE, it keeps the epc file and stamp it, after these copies it to the EPCS directory. If debugging True or false, it copies the wrong epc files to the wrong epc directory.} +\item{keepEpc}{If keepEpc is set to TRUE, the function keeps the EPC file and stamps it, and then copies it to the EPCS directory. If debugging is set to TRUE, it copies the wrong EPC files to the wrong epc directory.} -\item{silent}{If you set it TRUE all off the modells output to the screen will be suppressed. It can be usefull, because it increases the model-speed.} +\item{silent}{If you set the silent parameter to TRUE, all of the model's output normally written to the screen will be suppressed. This option can be useful to increase the speed of the model execution.} -\item{aggressive}{It deletes every possible modell-outputs from the previous modell runs.} +\item{aggressive}{It deletes all previous model-outputs from previous model runs.} } \value{ No return, outputs are written to file } \description{ -This function runs the BBGC-MuSo model's in the spinup phase. +This function runs the Biome-BGCMuSo model in spinup phase. } \author{ -Roland Hollos +Roland HOLLOS } diff --git a/RBBGCMuso/man/stampAndDir.Rd b/RBBGCMuso/man/stampAndDir.Rd index 61ab743..c1d2843 100644 --- a/RBBGCMuso/man/stampAndDir.Rd +++ b/RBBGCMuso/man/stampAndDir.Rd @@ -10,12 +10,12 @@ stampAndDir(outputLoc, names, stampDir, wrongDir, type = "output", \arguments{ \item{outputLoc}{This is the location of the output files.} -\item{outputNames}{These are the prefixis of the logfiles} +\item{outputNames}{These are the prefixes of the logfiles} } \value{ Output files with their paths } \description{ -This function gives us the muso output files with their paths +This function gives us the model output files with their paths } \keyword{internal} diff --git a/RBBGCMuso/man/updateMusoMapping.Rd b/RBBGCMuso/man/updateMusoMapping.Rd index 83aef85..9a2752e 100644 --- a/RBBGCMuso/man/updateMusoMapping.Rd +++ b/RBBGCMuso/man/updateMusoMapping.Rd @@ -7,14 +7,14 @@ updateMusoMapping(output_map_init="output_map_init.c") } \arguments{ -\item{output_map_init}{The outputcode-variable bindings is described in output_map_init.c file, via this parameter, you can give it the the function} +\item{output_map_init}{The output code-variable bindings are described in output_map_init.c file that is part of the Biome-BGCMuSo source code. Using this function the user can read the output_map_init.c file and pass it to RBBGCMuso for further work.} } \value{ -The outputcode-variable matrix, and also change the global variable +The output code-variable matrix, and also the function changes the global variable } \description{ -This function update the the muso outputcode-variable matrix +This function updates the Biome-BGCMuSo output code-variable matrix. Within Biome-BGCMuSo the state variables and fluxes are marked by integer numbers. In order to provide meaningful variable names (e.g. 3009 means Gross Primary Production in Biome-BGCMuSo v5) a conversion table is needed which is handled by this function. } \author{ -Roland Hollos +Roland HOLLOS } From d95809e0eddcf3c5b0ab6a6e203eab5b436f12d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 5 Feb 2019 21:35:20 +0100 Subject: [PATCH 27/37] version update --- README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.org b/README.org index 76c38ad..d72f737 100644 --- a/README.org +++ b/README.org @@ -4,7 +4,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA -*Current version: 0.6.1.4* +*Current version: 0.6.1.5* RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. From 17924ab7eba666f32c8238f524a7bba3c81dc770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Tue, 5 Feb 2019 21:36:57 +0100 Subject: [PATCH 28/37] version update fix --- README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.org b/README.org index d72f737..0d9754a 100644 --- a/README.org +++ b/README.org @@ -4,7 +4,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA -*Current version: 0.6.1.5* +*Current version: 0.6.2.0* RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. From 13e2b0e8c589d35689ab2b48dbbf694224f8f203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20BARCZA?= Date: Wed, 6 Feb 2019 21:40:47 +0100 Subject: [PATCH 29/37] Update musoSensi.R --- RBBGCMuso/R/musoSensi.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RBBGCMuso/R/musoSensi.R b/RBBGCMuso/R/musoSensi.R index a84790f..c583f91 100644 --- a/RBBGCMuso/R/musoSensi.R +++ b/RBBGCMuso/R/musoSensi.R @@ -1,6 +1,6 @@ #' musoSensi #' -#' This function performs multiple liear regression based global sensitivity analysis based on the output of musoMonte. First the user has to select the parameters of interest with possible minimum and maximum values. After execution musoSensi will then assign weights to the predefined parameters which means that the importance of the parameters will be ranked. The sensitivity analysis calculates the effect of input variability on the output variability in Monte Carlo framework. The result will largely depend on the selected output variable (GPP, evapotranspiration, LAI, soil water content), and on the parameter ranges. Other factors like climate, management and site specific conditions might affect the results. +#' This function performs multiple linear regression based global sensitivity analysis using on the output of musoMonte. The algorithm implements the method proposed by Verbeeck et al. 2006 (Tree Physiology 26, 807–817). First the user has to select the parameters of interest with possible minimum and maximum values. After execution musoSensi will then assign weights to the predefined parameters which means that the importance of the parameters will be ranked. The sensitivity analysis calculates the effect of input variability on the output variability in Monte Carlo framework. The result will largely depend on the selected output variable (GPP, evapotranspiration, LAI, soil water content), and on the parameter ranges. Other factors like climate, management and site specific conditions might affect the results. #' @author Roland HOLLOS #' @param monteCarloFile If you run the musoMonte function previously, you do not have to re-run the monteCarlo experiment, simply provide the preservedEpc.csv file to musoSensi with its path. If you do not set this parameter, musoSensi will run the musoMonte function to get all necessary information. #' @param outputFile The filename in which the output of the musoSensi function will be saved. By default it is "sensitivity.csv" From d1e31b60b204df445cc97e4537153fec46b2145b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Thu, 7 Feb 2019 12:39:39 +0100 Subject: [PATCH 30/37] adding dailyVarCodes as output --- RBBGCMuso/R/setupMuso.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RBBGCMuso/R/setupMuso.R b/RBBGCMuso/R/setupMuso.R index a933536..e4a4b0c 100644 --- a/RBBGCMuso/R/setupMuso.R +++ b/RBBGCMuso/R/setupMuso.R @@ -267,7 +267,8 @@ setupMuso <- function(executable=NULL, numData=numData, startYear=startYear, numYears=numYears, - outputVars=outputVars + outputVars=outputVars, + dailyVarCodes= gsub("\\s.*","",dailyVarCodes) ) if(writep!=nrow(grepHelper)){ From 6ef8f32a729614806bf20f7b1d1d7898702e268c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Fri, 8 Feb 2019 14:12:47 +0100 Subject: [PATCH 31/37] Fixing depTableMaker ordering bug --- RBBGCMuso/R/musoRand.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/RBBGCMuso/R/musoRand.R b/RBBGCMuso/R/musoRand.R index ea38e40..477bd17 100644 --- a/RBBGCMuso/R/musoRand.R +++ b/RBBGCMuso/R/musoRand.R @@ -18,11 +18,13 @@ musoRand <- function(parameters, constrains = NULL, iterations=3000){ constMatrix <- constMatrix[,-1] depTableMaker <- function(constMatrix,parameters){ - parameters <- parameters[order(parameters[,1]),] - constMatrix[constMatrix[,"INDEX"] %in% parameters[,1],c(5,6)]<-parameters[,c(2,3)] + ## parameters <- parameters[order(parameters[,1]),] ## BUG!!! + selectedRows <- constMatrix[,"INDEX"] %in% parameters[,1] + rankList <- rank(constMatrix[selectedRows,2]) + constMatrix[selectedRows,c(5,6)] <- parameters[rankList,c(2,3)] logiConstrain <- (constMatrix[,"GROUP"] %in% constMatrix[constMatrix[,"INDEX"] %in% parameters[,1],"GROUP"] & (constMatrix[,"GROUP"]!=0)) | ((constMatrix[,"INDEX"] %in% parameters[,1]) & (constMatrix[,"GROUP"] == 0)) - constMatrix<-constMatrix[logiConstrain,] + constMatrix <- constMatrix[logiConstrain,] constMatrix <- constMatrix[order(apply(constMatrix[,7:8],1,function(x){x[1]/10+abs(x[2])})),] constMatrix } From f3fa17d2209f46d70dfe823a4277ea32c10dc223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Fri, 8 Feb 2019 16:57:44 +0100 Subject: [PATCH 32/37] Solving musoRand bug finally. --- RBBGCMuso/R/musoRand.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RBBGCMuso/R/musoRand.R b/RBBGCMuso/R/musoRand.R index 477bd17..bb995cc 100644 --- a/RBBGCMuso/R/musoRand.R +++ b/RBBGCMuso/R/musoRand.R @@ -18,7 +18,7 @@ musoRand <- function(parameters, constrains = NULL, iterations=3000){ constMatrix <- constMatrix[,-1] depTableMaker <- function(constMatrix,parameters){ - ## parameters <- parameters[order(parameters[,1]),] ## BUG!!! + parameters <- parameters[order(parameters[,1]),] ## BUG!!! selectedRows <- constMatrix[,"INDEX"] %in% parameters[,1] rankList <- rank(constMatrix[selectedRows,2]) constMatrix[selectedRows,c(5,6)] <- parameters[rankList,c(2,3)] From 232f2f40e3aefbc210969bf92db2a06215782f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Fri, 8 Feb 2019 16:59:30 +0100 Subject: [PATCH 33/37] Patch version --- RBBGCMuso/DESCRIPTION | 2 +- README.org | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RBBGCMuso/DESCRIPTION b/RBBGCMuso/DESCRIPTION index a0268eb..45d6e6c 100644 --- a/RBBGCMuso/DESCRIPTION +++ b/RBBGCMuso/DESCRIPTION @@ -1,6 +1,6 @@ Package: RBBGCMuso Title: An R package for BiomeBGC-MuSo ecosystem modelling -Version: 0.6.2.0 +Version: 0.6.2.1 Authors@R: person("Roland", "Hollo's", , "hollorol@gmail.com", role = c("aut", "cre")) Description: What the package does (one paragraph). Depends: R (>= 3.3.2) diff --git a/README.org b/README.org index 0d9754a..7581656 100644 --- a/README.org +++ b/README.org @@ -4,7 +4,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA -*Current version: 0.6.2.0* +*Current version: 0.6.2.1* RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. From ddb5934b3e8da6b6dd36c7a52a48cff62440f76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Sat, 9 Feb 2019 00:43:32 +0100 Subject: [PATCH 34/37] New feature: saveAllMusoPlots --- RBBGCMuso/DESCRIPTION | 2 +- RBBGCMuso/NAMESPACE | 3 + RBBGCMuso/R/getOutput.R | 14 ++-- RBBGCMuso/R/musoSensi.R | 27 ++++---- RBBGCMuso/R/plotMuso.R | 107 +++++++++++++++++++----------- RBBGCMuso/R/setupMuso.R | 3 +- RBBGCMuso/man/musoSensi.Rd | 31 +++------ RBBGCMuso/man/saveAllMusoPlots.Rd | 24 +++++++ README.org | 2 +- 9 files changed, 133 insertions(+), 80 deletions(-) create mode 100644 RBBGCMuso/man/saveAllMusoPlots.Rd diff --git a/RBBGCMuso/DESCRIPTION b/RBBGCMuso/DESCRIPTION index a0268eb..b51225f 100644 --- a/RBBGCMuso/DESCRIPTION +++ b/RBBGCMuso/DESCRIPTION @@ -1,6 +1,6 @@ Package: RBBGCMuso Title: An R package for BiomeBGC-MuSo ecosystem modelling -Version: 0.6.2.0 +Version: 0.6.3.0 Authors@R: person("Roland", "Hollo's", , "hollorol@gmail.com", role = c("aut", "cre")) Description: What the package does (one paragraph). Depends: R (>= 3.3.2) diff --git a/RBBGCMuso/NAMESPACE b/RBBGCMuso/NAMESPACE index e128bf0..a11b3e9 100644 --- a/RBBGCMuso/NAMESPACE +++ b/RBBGCMuso/NAMESPACE @@ -24,6 +24,7 @@ export(plotMusoWithData) export(randEpc) export(runMuso) export(rungetMuso) +export(saveAllMusoPlots) export(setupMuso) export(spinupMuso) export(supportedMuso) @@ -53,6 +54,7 @@ importFrom(ggplot2,ggtitle) importFrom(ggplot2,labs) importFrom(ggplot2,scale_y_continuous) importFrom(ggplot2,theme) +importFrom(ggplot2,theme_classic) importFrom(ggplot2,xlab) importFrom(ggplot2,ylab) importFrom(limSolve,xsample) @@ -60,6 +62,7 @@ importFrom(magrittr,'%<>%') importFrom(magrittr,'%>%') importFrom(rmarkdown,pandoc_version) importFrom(rmarkdown,render) +importFrom(scales,percent) importFrom(tcltk,tk_choose.files) importFrom(tibble,rownames_to_column) importFrom(tidyr,gather) diff --git a/RBBGCMuso/R/getOutput.R b/RBBGCMuso/R/getOutput.R index 1f4d196..ee24515 100644 --- a/RBBGCMuso/R/getOutput.R +++ b/RBBGCMuso/R/getOutput.R @@ -29,12 +29,16 @@ getmonthlyout<-function(settings){ } getyearlyout<-function(settings){ - binaryname<-paste(settings$inputloc,settings$outputname,".annout",sep="") - d<-file(binaryname,"rb") - yearoutput<-matrix(readBin(d,"double",size=4,n=(settings$numdata[3])),(settings$numyears),byrow=TRUE) - close(d) - return(yearoutput) + binaryname<-paste0(settings$inputLoc,"/",settings$outputName[2],".annout") + ## d<-file(binaryname,"rb") + ## yearoutput<-matrix(readBin(d,"double",size=4,n=(settings$numData[3])),(settings$numYears),byrow=TRUE) + ## close(d) + ## return(yearoutput) + outPut <- read.table(binaryname,skip = 1) + colnames(outPut) <- c("year", paste0("var_",settings$annualVarCodes)) + outPut } + diff --git a/RBBGCMuso/R/musoSensi.R b/RBBGCMuso/R/musoSensi.R index c583f91..20e7607 100644 --- a/RBBGCMuso/R/musoSensi.R +++ b/RBBGCMuso/R/musoSensi.R @@ -1,21 +1,18 @@ #' musoSensi #' -#' This function performs multiple linear regression based global sensitivity analysis using on the output of musoMonte. The algorithm implements the method proposed by Verbeeck et al. 2006 (Tree Physiology 26, 807–817). First the user has to select the parameters of interest with possible minimum and maximum values. After execution musoSensi will then assign weights to the predefined parameters which means that the importance of the parameters will be ranked. The sensitivity analysis calculates the effect of input variability on the output variability in Monte Carlo framework. The result will largely depend on the selected output variable (GPP, evapotranspiration, LAI, soil water content), and on the parameter ranges. Other factors like climate, management and site specific conditions might affect the results. -#' @author Roland HOLLOS -#' @param monteCarloFile If you run the musoMonte function previously, you do not have to re-run the monteCarlo experiment, simply provide the preservedEpc.csv file to musoSensi with its path. If you do not set this parameter, musoSensi will run the musoMonte function to get all necessary information. -#' @param outputFile The filename in which the output of the musoSensi function will be saved. By default it is "sensitivity.csv" -#' @param plotName The name of the output barplot. It's default value is "sensitivity.jpg" -#' @param settings A list of environmental variables for the Monte Carlo experiment. These settings are generated by the setupMuso function. By default the settings parameter is generated automatically. -#' @param parameters This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization. -#' @param calibrationPar You might want to change some parameters in your EPC file before you run the modell. You have to select the appropirate model parameters here. You can refer to the parameters by the number of the line in the EPC file where the variables are defined. The indexing of the lines starts at 1, and each line matters (like in any simple text file). You should use a vector for this selection like c(1,5,8) -#' @param inputDir The location of the input directory for the Biome-BGCMuSo model. This directory must contain a viable pack of all input files and the model executable file. -#' @param iterations Number of the Monte Carlo simulations. -#' @param preTag This defines the name of the output files. This tag will be re-used so that the results will be like preTag-1.csv, preTag-2csv... -#' @param outputType This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is chosen the function creates one large csv file for all of the runs. If "moreCsv" is chosen, every model output goes to separate files. If netCDF is selected the output will be stored in a netCDF file. The default value of the outputTypes is "moreCsv". Note that netCDF is not implemented yet. -#' @param fun If you select a variable from the possible outputs (by using the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your needs. -#' @param varIndex This parameter specifies which parameter will be used for the Monte Carlo experiment from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3. -#' @param skipSpinup With this parameter you can turn off the spinup phase after the first spinup was successfully executed (endpoint file is available). This option can dramatically decrease the time needed for the sensitivity analysis. Note that in case of natural vegetation this option might not be feasible. For croplands this is more feasible. +#' This function does regression based sensitivity analysis based on the output of musoMonte. +#' @param settings A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically. +#' @param parameters This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized. +#' @param calibrationPar You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8) +#' @param inputDir The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file. +#' @param iterations number of the monteCarlo run. +#' @param preTag It will be the name of the output files. For example preTag-1.csv, pretag-2csv... +#' @param outputType This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet. +#' @param fun If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need. +#' @param varIndex This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3. +#' @param skipSpinup With this parameter, you can turn of the spinup phase after the first spinup. I will decrease the time significantly. #' @importFrom ggplot2 geom_bar ggplot aes theme element_text xlab ylab ggtitle ggsave scale_y_continuous +#' @importFrom scales percent #' @export musoSensi <- function(monteCarloFile = NULL, diff --git a/RBBGCMuso/R/plotMuso.R b/RBBGCMuso/R/plotMuso.R index db4de22..d54f2da 100644 --- a/RBBGCMuso/R/plotMuso.R +++ b/RBBGCMuso/R/plotMuso.R @@ -27,30 +27,18 @@ #' @importFrom tidyr separate gather #' @export -plotMuso <- function(settings=NULL, - variable=1, - ##compare, - ##plotname, - timee="d", - silent=TRUE, - calibrationPar=NULL, - parameters=NULL, - debugging=FALSE, - keepEpc=FALSE, - fileToChange="epc", - logfilename=NULL, - aggressive=FALSE, - leapYear=FALSE, - plotName=NULL, - plotType="cts", - layerPlot=FALSE, - colour="blue", - skipSpinup=TRUE, - fromData=FALSE, - timeFrame="day", - selectYear=NULL, - groupFun=mean, - dpi=300){ +plotMuso <- function(settings = NULL, variable = 1, + ##compare, ##plotname, + timee = "d", silent = TRUE, + calibrationPar = NULL, parameters = NULL, + debugging = FALSE, keepEpc = FALSE, + fileToChange = "epc", logfilename = NULL, + aggressive = FALSE, leapYear = FALSE, + plotName = NULL, plotType = "cts", + layerPlot = FALSE, colour = "blue", + skipSpinup = TRUE, fromData = FALSE, + timeFrame = "day", selectYear = NULL, + groupFun = mean, separateFile = FALSE, dpi=300){ if( plotType!="cts" && plotType != "dts"){ warning(paste0("The plotType ", plotType," is not implemented, plotType is set to cts")) @@ -63,6 +51,7 @@ plotMuso <- function(settings=NULL, numberOfYears <- settings$numYears startYear <- settings$startYear + dailyVarCodes <- settings$dailyVarCodes ## musoData <- rungetMuso(settings=settings, ## silent=silent, ## timee=timee, @@ -164,20 +153,21 @@ plotMuso <- function(settings=NULL, } p } else{ - p <- musoData %>% - select(c("date",variableName))%>% - gather(., key= outputs, value = bla,variableName) %>% + p <- musoData %>% + select(c("date",variableName))%>% + gather(., key= outputs, value = bla,variableName) %>% # head %>% - ggplot(aes(x=date,y=bla))+ - facet_wrap(~ outputs, scales = "free_y",ncol=1) + - geom_line(colour=colour)+ - theme( - axis.title.y = element_blank() - ) - if(!is.null(plotName)){ - ggsave(as.character(plotName),p) - } - p + ggplot(aes(x=date,y=bla))+ + facet_wrap(~ outputs, scales = "free_y",ncol=1) + + geom_line(colour=colour)+ + theme( + axis.title.y = element_blank() + ) + if(!is.null(plotName)){ + ggsave(as.character(plotName),p) + } + p + } } } else { @@ -323,4 +313,47 @@ compareMuso <- function(settings=NULL,parameters, variable=1, calibrationPar=NUL } +#' saveAllMusoPlots +#' +#' This simple function takes the parameters from the ini files and generates graphics for all output variable. +#' +#' @author Roland HOLLOS +#' @param settings RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option. +#' @param plotName The basename for the output plots +#' @param destination The destination for the output plots, it not exits the function will create it. +#' @param silent if true do not suspect for printfs... +#' @importFrom ggplot2 theme_classic ggplot geom_line geom_point theme element_blank geom_bar labs aes_string aes ggsave +#' @export + +saveAllMusoPlots <- function(settings=NULL, plotName = ".png", + silent = TRUE, type = "line", + colour = NULL, skipSpinup = FALSE){ + + if(is.null(settings)){ + settings <- setupMuso() + } + + dailyVarCodes <- settings$dailyVarCodes + annualVarCodes <-settings$annualVarCodes + outputVars <- unlist(settings$outputVars[[1]]) + musoData <- calibMuso(settings = settings, prettyOut = TRUE, silent = silent, skipSpinup = skipSpinup) + for(i in seq_along(dailyVarCodes)){ + bases <- ggplot(data = musoData, mapping = aes_string(x = "date", y = outputVars[i])) + object <-ifelse(type == "line",paste0("geom_line(colour = '",colour,"')"), + ifelse(type == "point",paste0("geom_line(colour = ",colour,")"), + stop("The"))) + outPlot <- bases + eval(parse(text = object)) + theme_classic() + theme(axis.title.x=element_blank()) + ggsave(paste0("daily-",dailyVarCodes[i],plotName),outPlot) + } + + musoYData <- getyearlyout(settings) + + for(i in seq_along(annualVarCodes)){ + outPlot <- ggplot(data = musoYData, mapping = aes_string(x = "year", y = paste0("var_",annualVarCodes[i])))+ + geom_bar(stat = "identity")+ labs(y = musoMapping(annualVarCodes[i])) + theme_classic() + + theme(axis.title.x=element_blank()) + ggsave(paste0("annual-",annualVarCodes[i],plotName),outPlot) + } + +} diff --git a/RBBGCMuso/R/setupMuso.R b/RBBGCMuso/R/setupMuso.R index e4a4b0c..40a1b55 100644 --- a/RBBGCMuso/R/setupMuso.R +++ b/RBBGCMuso/R/setupMuso.R @@ -268,7 +268,8 @@ setupMuso <- function(executable=NULL, startYear=startYear, numYears=numYears, outputVars=outputVars, - dailyVarCodes= gsub("\\s.*","",dailyVarCodes) + dailyVarCodes= gsub("\\s.*","",dailyVarCodes), + annualVarCodes = gsub("\\s.*","",annualVarCodes) ) if(writep!=nrow(grepHelper)){ diff --git a/RBBGCMuso/man/musoSensi.Rd b/RBBGCMuso/man/musoSensi.Rd index af86c7e..4086151 100644 --- a/RBBGCMuso/man/musoSensi.Rd +++ b/RBBGCMuso/man/musoSensi.Rd @@ -12,35 +12,26 @@ musoSensi(monteCarloFile = NULL, parameters = NULL, settings = NULL, skipSpinup = TRUE, dpi = 300) } \arguments{ -\item{monteCarloFile}{If you run the musoMonte function previously, you do not have to re-run the monteCarlo experiment, simply provide the preservedEpc.csv file to musoSensi with its path. If you do not set this parameter, musoSensi will run the musoMonte function to get all necessary information.} +\item{parameters}{This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized.} -\item{parameters}{This is a dataframe (heterogeneous data-matrix), where the first column is the name of the parameter, the second is a numeric vector of the rownumbers of the given variable in the input EPC file, and the last two columns describe the minimum and the maximum of the parameter (i.e. the parameter ranges), defining the interval for the randomization.} +\item{settings}{A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically.} -\item{settings}{A list of environmental variables for the Monte Carlo experiment. These settings are generated by the setupMuso function. By default the settings parameter is generated automatically.} +\item{inputDir}{The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file.} -\item{inputDir}{The location of the input directory for the Biome-BGCMuSo model. This directory must contain a viable pack of all input files and the model executable file.} +\item{iterations}{number of the monteCarlo run.} -\item{iterations}{Number of the Monte Carlo simulations.} +\item{preTag}{It will be the name of the output files. For example preTag-1.csv, pretag-2csv...} -\item{preTag}{This defines the name of the output files. This tag will be re-used so that the results will be like preTag-1.csv, preTag-2csv...} +\item{outputType}{This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet.} -\item{outputType}{This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is chosen the function creates one large csv file for all of the runs. If "moreCsv" is chosen, every model output goes to separate files. If netCDF is selected the output will be stored in a netCDF file. The default value of the outputTypes is "moreCsv". Note that netCDF is not implemented yet.} +\item{fun}{If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need.} -\item{fun}{If you select a variable from the possible outputs (by using the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your needs.} +\item{varIndex}{This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3.} -\item{varIndex}{This parameter specifies which parameter will be used for the Monte Carlo experiment from the output list of Biome-BGCMuSo (defined by the INI file). You can extract this information from the INI files. At the output parameter specifications, the parameter order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926 for the experiment, you should specify varIndex as 3.} +\item{skipSpinup}{With this parameter, you can turn of the spinup phase after the first spinup. I will decrease the time significantly.} -\item{outputFile}{The filename in which the output of the musoSensi function will be saved. By default it is "sensitivity.csv"} - -\item{plotName}{The name of the output barplot. It's default value is "sensitivity.jpg"} - -\item{skipSpinup}{With this parameter you can turn off the spinup phase after the first spinup was successfully executed (endpoint file is available). This option can dramatically decrease the time needed for the sensitivity analysis. Note that in case of natural vegetation this option might not be feasible. For croplands this is more feasible.} - -\item{calibrationPar}{You might want to change some parameters in your EPC file before you run the modell. You have to select the appropirate model parameters here. You can refer to the parameters by the number of the line in the EPC file where the variables are defined. The indexing of the lines starts at 1, and each line matters (like in any simple text file). You should use a vector for this selection like c(1,5,8)} +\item{calibrationPar}{You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8)} } \description{ -This function performs multiple liear regression based global sensitivity analysis based on the output of musoMonte. First the user has to select the parameters of interest with possible minimum and maximum values. After execution musoSensi will then assign weights to the predefined parameters which means that the importance of the parameters will be ranked. The sensitivity analysis calculates the effect of input variability on the output variability in Monte Carlo framework. The result will largely depend on the selected output variable (GPP, evapotranspiration, LAI, soil water content), and on the parameter ranges. Other factors like climate, management and site specific conditions might affect the results. -} -\author{ -Roland HOLLOS +This function does regression based sensitivity analysis based on the output of musoMonte. } diff --git a/RBBGCMuso/man/saveAllMusoPlots.Rd b/RBBGCMuso/man/saveAllMusoPlots.Rd new file mode 100644 index 0000000..6132d6a --- /dev/null +++ b/RBBGCMuso/man/saveAllMusoPlots.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plotMuso.R +\name{saveAllMusoPlots} +\alias{saveAllMusoPlots} +\title{saveAllMusoPlots} +\usage{ +saveAllMusoPlots(settings = NULL, plotName = ".png", silent = TRUE, + type = "line", colour = NULL, skipSpinup = FALSE) +} +\arguments{ +\item{settings}{RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option.} + +\item{plotName}{The basename for the output plots} + +\item{silent}{if true do not suspect for printfs...} + +\item{destination}{The destination for the output plots, it not exits the function will create it.} +} +\description{ +This simple function takes the parameters from the ini files and generates graphics for all output variable. +} +\author{ +Roland HOLLOS +} diff --git a/README.org b/README.org index 0d9754a..befb200 100644 --- a/README.org +++ b/README.org @@ -4,7 +4,7 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA -*Current version: 0.6.2.0* +*Current version: 0.6.3.0* RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. From 3195d76bcb16d31e183c6b1b7b8f3469f4b968bb Mon Sep 17 00:00:00 2001 From: hollorol Date: Sat, 9 Feb 2019 02:08:47 +0100 Subject: [PATCH 35/37] Fix merge conflict --- README.org | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.org b/README.org index 20de0d1..352ecd9 100644 --- a/README.org +++ b/README.org @@ -4,11 +4,8 @@ * The RBBGCMuso Package #+AUTHOR: Roland HOLLÓS, Dóra HIDY, Zoltán BARCZA -<<<<<<< HEAD -*Current version: 0.6.2.1* -======= + *Current version: 0.6.3.0* ->>>>>>> feature/multiplot RBBGCMuso is an R package which supports the easy but powerful application of the [[http://agromo.agrar.mta.hu/bbgc/][Biome-BGCMuSo]] biogeochemical model in R environment. It also provides some additional tools for the model such as Biome-BGCMuSo optimized Monte-Carlo simulation and global sensitivity analysis. If you would like to use the framework, please read the following description. @@ -183,4 +180,4 @@ E-mail: hollorol@gmail.com ** Acknowledgements -The research was funded by the Széchenyi 2020 programme, the European Regional Development Fund and the Hungarian Government (GINOP-2.3.2-15-2016-00028). + The research was funded by the Széchenyi 2020 programme, the European Regional Development Fund and the Hungarian Government (GINOP-2.3.2-15-2016-00028). From dcddaee7f58415c0c60708087ec35a1cbb374611 Mon Sep 17 00:00:00 2001 From: hollorol Date: Sun, 10 Feb 2019 09:39:38 +0100 Subject: [PATCH 36/37] Adding csv functionality to saveAllmusoPlots --- RBBGCMuso/R/plotMuso.R | 4 ++-- RBBGCMuso/man/saveAllMusoPlots.Rd | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/RBBGCMuso/R/plotMuso.R b/RBBGCMuso/R/plotMuso.R index d54f2da..36d7fac 100644 --- a/RBBGCMuso/R/plotMuso.R +++ b/RBBGCMuso/R/plotMuso.R @@ -327,7 +327,7 @@ compareMuso <- function(settings=NULL,parameters, variable=1, calibrationPar=NUL saveAllMusoPlots <- function(settings=NULL, plotName = ".png", - silent = TRUE, type = "line", + silent = TRUE, type = "line", outFile = "annual.csv", colour = NULL, skipSpinup = FALSE){ if(is.null(settings)){ @@ -348,7 +348,7 @@ saveAllMusoPlots <- function(settings=NULL, plotName = ".png", } musoYData <- getyearlyout(settings) - + write.csv(musoYData,paste0(settings$outputNames[[2]],outFile)) for(i in seq_along(annualVarCodes)){ outPlot <- ggplot(data = musoYData, mapping = aes_string(x = "year", y = paste0("var_",annualVarCodes[i])))+ geom_bar(stat = "identity")+ labs(y = musoMapping(annualVarCodes[i])) + theme_classic() + diff --git a/RBBGCMuso/man/saveAllMusoPlots.Rd b/RBBGCMuso/man/saveAllMusoPlots.Rd index 6132d6a..79b184b 100644 --- a/RBBGCMuso/man/saveAllMusoPlots.Rd +++ b/RBBGCMuso/man/saveAllMusoPlots.Rd @@ -5,7 +5,8 @@ \title{saveAllMusoPlots} \usage{ saveAllMusoPlots(settings = NULL, plotName = ".png", silent = TRUE, - type = "line", colour = NULL, skipSpinup = FALSE) + type = "line", outFile = "annual.csv", colour = NULL, + skipSpinup = FALSE) } \arguments{ \item{settings}{RBBGCMuso uses variables that define the entire simulation environment. Those environment variables include the name of the INI files, the name of the meteorology files, the path to the model executable and its file name, the entire output list, the entire output variable matrix, the dependency rules for the EPC parameters etc. Using the runMuso function RBBGCMuso can automatically create those environment variables by inspecting the files in the working directory (this happens through the setupMuso function). It means that by default model setup is performed automatically in the background and the user has nothing to do. With this settings parameter we can force runMuso to skip automatic environment setup as we provide the environment settings to runMuso. In a typical situation the user can skip this option.} From 3188c8d2d47eed99574c4a501ea48f426247a4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Holl=C3=B3s?= Date: Mon, 11 Feb 2019 14:47:42 +0100 Subject: [PATCH 37/37] Adding new functionality to BBGCDB --- RBBGCMuso/R/setupMuso.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/RBBGCMuso/R/setupMuso.R b/RBBGCMuso/R/setupMuso.R index 40a1b55..42882df 100644 --- a/RBBGCMuso/R/setupMuso.R +++ b/RBBGCMuso/R/setupMuso.R @@ -55,7 +55,8 @@ setupMuso <- function(executable=NULL, epcInput=NULL, mapData=NULL, leapYear=FALSE, - version=5 + version=5, + doCopy=TRUE ){ Linuxp <-(Sys.info()[1]=="Linux") @@ -188,8 +189,11 @@ setupMuso <- function(executable=NULL, } else { executable<-file.path(inputLoc,"muso.exe") } - } else { - file.copy(executable,inputLoc) + } else { + if(doCopy){ + file.copy(executable,inputLoc) + } + } outputName <- character(2) outputName[1] <- basename(unlist(strsplit(iniFiles[[1]][grep("OUTPUT_CONTROL",iniFiles[[1]])+1],"[\ \t]"))[1])