Complete the documentations, and repar the namespaces

This commit is contained in:
hollorol 2017-07-19 16:40:07 +02:00
parent 5883d1b597
commit 7415e2cf88
33 changed files with 483 additions and 169 deletions

View File

@ -1,12 +1,18 @@
Package: RBBGCMuso
Title: What the Package Does (one line, title case)
Version: 0.2.0.0-1
Authors@R: person("Roland", "Hollos", , "hollorol@gmail.com", role = c("aut", "cre"))
Description: What the package does (one paragraph)
Title: An R package for BiomeBGC-MuSo ecosystem modelling
Version: 0.3.0.0-1
Authors@R: person("Roland", "Hollo's", , "hollorol@gmail.com", role = c("aut", "cre"))
Description: What the package does (one paragraph).
License: GPL-2
LazyData: true
NeedsCompilation: no
Packaged: 2016-11-15 13:58:04 UTC; hollorol
Author: First Last [aut, cre]
Maintainer: First Last <first.last@example.com>
Packaged: 2017-07-19 14:00:04 UTC; hollorol
Author: Roland Hollo's [aut, cre]
Imports:
utils,
graphics
Maintainer: Roland Hollo's <hollorol@gmail.com>
RoxygenNote: 6.0.1
Suggests: knitr,
rmarkdown
VignetteBuilder: knitr

View File

@ -1 +1,13 @@
exportPattern("^[^\\.]")
# Generated by roxygen2: do not edit by hand
export(calibMuso)
export(corrigMuso)
export(getyearlycum)
export(getyearlymax)
export(musoDate)
export(plotMuso)
export(rungetMuso)
export(spinupMuso)
export(supportedMuso)
import(graphics)
import(utils)

View File

@ -2,18 +2,21 @@
#'
#' This function changes the epc file and after that runs the BBGC-MuSo model and reads in its outputfile in a very structured way.
#'
#' @author Roland Hollós
#' @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
#' @author Roland Hollos
#' @param 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
#' @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
#' @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 leapyear future feature.
#' @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)
#' @param logfilename If you want to set a specific name for your logfiles you can set this via logfile parameter
#' @param leapYear Should the function do a leapyear correction on the outputdata? If TRUE, then the 31.12 day will be doubled.
#' @return No return, outputs are written to file
#' @usage calibMuso(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL, keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE)
#' @usage calibMuso(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL,
#' keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE)
#' @import utils
#' @export
@ -33,44 +36,6 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf
epc <- settings$epcinput
calibrationpar <- settings$calibrationpar
whereAmI<-getwd()
########################################################
###############################Preparational functions###############
#####################################################
numcut<-function(string){
#This function returns only the starting numbers of a string
unlist(strsplit(grep("^[0-9]",string,value = TRUE),"[aAzZ-]"))[1]
}
numcutall<-function(vector){
#numcall apply numcut for all elements of a string vector
as.numeric(unlist(apply(as.matrix(vector),1,numcut)))
}
stamp<-function(path="./"){
#It gives back a stamp wich is the maximum number of the output numcall
numbers<-numcutall(list.files(path))
if(length(numbers)==0){
return (0)} else {
return(max(numbers))}
}
changemulline <- function(filename,calibrationpar,contents){
#This is the function which is capable change multiple specific lines to other using their row numbers.
#The function uses the previous changspecline function to operate.
##From now changespecline is in the forarcheologist file, because its no longer needed
varnum <- length(calibrationpar)
if(length(contents)!=varnum)
{
cat("Error: number of the values is not the same as the number of the changed parameters")
}
TOT=readLines(filename,-1)
TOT[calibrationpar]<-contents
writeLines(TOT,filename)
}
#############################################################
############################spinup run############################

23
RBBGCMuso/R/changeMuso.R Normal file
View File

@ -0,0 +1,23 @@
#' This is the function which is capable change multiple specific lines to other 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
#'
#' @author Roland Hollos
#' @keywords internal
changemulline <- function(filename,calibrationpar,contents){
#This is the function which is capable change multiple specific lines to other using their row numbers.
#The function uses the previous changspecline function to operate.
##From now changespecline is in the forarcheologist file, because its no longer needed
varnum <- length(calibrationpar)
if(length(contents)!=varnum)
{
cat("Error: number of the values is not the same as the number of the changed parameters")
}
TOT=readLines(filename,-1)
TOT[calibrationpar]<-contents
writeLines(TOT,filename)
}

View File

@ -4,12 +4,8 @@
#'
#'@param year a year
#'@usage isLeapyear(year)
#'@examples
#' isLeapyear(2004)
#' isLeapyear(2000)
#' isLeapyear(2100)
#'@return TRUE, if leapyear, FALSE if dont.
#' @keywords internal
isLeapyear <- function(year){
##This Boolean function tells us whether the given year is leapyear or not
@ -27,12 +23,8 @@ isLeapyear <- function(year){
#'@param year a year
#'@param corrigated Do you want to handle the leapyears, if yes choose TRUE
#'@usage dayOfMonths(year, corrigated=TRUE)
#'@examples
#' dayOfMonths(2004, corrigated=TRUE)
#'
#' dayOfMonths(2004, corrigated=FALSE)
#'
#'@return vector with 12 element. First is January, the last is December. All of the vector element represents the number of the days in that specific month
#' @keywords internal
@ -53,6 +45,12 @@ dayOfMonths <- function(year,corrigated=TRUE){
#' This function tells us how many days are in the given year.
#'
#' This function tells us how many days are in the given year.
#' @author Roland Hollos
#' @keywords internal
dayOfYears <- function(year, corrigated=TRUE){
##This function tells us how many days are in the given year.
@ -68,6 +66,12 @@ dayOfYears <- function(year, corrigated=TRUE){
}
#' How many days are from the given date and given period length(periodlen)?
#'
#'How many days are from the given date and given period length(periodlen)?
#' @author Roland Hollos
#' @keywords internal
sumDaysOfPeriod <- function(year, periodlen, corrigated=TRUE){
##How many days are from the given date and given period length(periodlen)?
@ -85,6 +89,12 @@ sumDaysOfPeriod <- function(year, periodlen, corrigated=TRUE){
}
}
#' Musoleapyear
#'
#' How many days are from the given date and given period length(periodlen)?
#' @author Roland Hollos
#' @keywords internal
musoLeapYears <- function(settings){
days <- 365*settings$numyears
years <- settings$startyear:(settings$startyear+settings$numyears-1)
@ -92,6 +102,19 @@ musoLeapYears <- function(settings){
return(Leapyears)
}
#' It generates BiomeBGC-MuSo dates
#'
#' It generates all of the day-dates which are between the start and endyear of BiomeBGC-MuSo run.
#' How many days are from the given date and given period length(periodlen)?
#' @author Roland Hollos
#' @param timestep timestep, which can be daily ("d"), monthly ("m"), yearly("y")
#' @param settings You have to run the setupMuso function before musoDate. It is its output which contains all of the necessary system variables. It sets the whole environment.
#' @param combined If FALSE the output is a vector of 3 string: day, month year, if true, these strings will be concatenated.
#' @param corrigated If True it counts with leapyears, else dont.
#' @param format This is the format of the date. It can be "en" (dd.mm.yyyy), or "hu" (yyyy.mm.dd)
#' @return The exact date-vectors for the BioBGC-MuSo output. You can use this for labelling purpose for example.
#' @export
musoDate <- function(settings,timestep="d",combined=TRUE, corrigated=TRUE, format="en"){
##purpose: generate date label for muso
@ -122,7 +145,7 @@ musoDate <- function(settings,timestep="d",combined=TRUE, corrigated=TRUE, forma
if(format=="hu"){
dates<-dates[,c(3,2,1)]
} else {
cat("format is coerced to english, because I don't know",format)
cat("format is coerced to english, because I don't know what do you mean by:",format)
}
}

View File

@ -1,9 +1,10 @@
#' getyearlycum
#'
#' Funtion for getting cumulative yearly data from observations
#' @author Roland Hollós
#' @param A vector of the daily observations.
#' @author Roland Hollos
#' @param daily_observations vector of the daily observations.
#' @return A vector of yearly data
#' @export
getyearlycum<-function(daily_observations){
@ -22,10 +23,11 @@ getyearlycum<-function(daily_observations){
#' getyearlymax
#'
#' Function for getting the maximum values of the years, from daily data
#' @author Roland Hollós
#' @author Roland Hollos
#' @param daily_observations vector of the daily observations
#' @return A vector of yearly data
#' @usage getyearlymax(daily_observations)
#' @export
getyearlymax<-function(daily_observations){
number_of_years<-length(daily_observations)/365
@ -43,36 +45,34 @@ getyearlymax<-function(daily_observations){
#' fextension
#'
#' A function for extracting the extension name from the filename string
#' @author Roland Hollós
#' @author Roland Hollos
#' @param filename The string of the filenam
#' @return the extension of the given file
#' @usage fextension(filename)
#' @example
#' fextension(filename="file.csv")
fextension <- function(filename){
#this function gives back the given filenames extension
fextension <- tail(unlist(strsplit(filename,"\\.")),1)
return(fextension)
}
#'supportedMuso
#'
#' A function for getting the list of the output formats which is supported by RBBGCMuso
#' @author Roland Hollós
#' @author Roland Hollos
#' @param type "outputs" or "message", if you choose "outputs", it gives you a simple vector of the formats, if you choose "message", it gives you a full sentence which contains the same information.
#' @return if you choose "outputs", it gives you a simple vector of the formats, if you choose "message", it gives you a full sentence which contains the same information.
#' @usage supportedMuso(type="outputs")
#' @example
#' supportedMuso(type="outputs")
#' @export
supportedMuso <- function(type="outputs"){
supportedFormats <- c("xls","xlsx","odt","csv","txt")
if(x=="outputs"){
if(type=="outputs"){
#If you add new format supports, please expand the lists
return(supportedFormats)
}
if(x=="message"){
if(type=="message"){
return(cat("Supported formats are ",supportedFormats,"If your fileformat is something else, we automaticle coerced it to csv.\n"))
}
}
@ -80,10 +80,11 @@ supportedMuso <- function(type="outputs"){
#' corrigMuso
#'
#' This function leapyear-corrigate the output of the modell
#' @author Roland Hollós
#' @author Roland Hollos
#' @param settings This is the output of the setupMuso() function. It contains all of the RBBGCMuso settings
#' @param data the models outputdata
#' @return It returns the modells leapyear-corrigated output data.
#' @export
#' @usage corrigMuso(settings, data)
corrigMuso <- function(settings, data){

View File

@ -2,7 +2,7 @@
#'
#' This function runs the BBGC-MuSo model and reads in its outputfile in a very structured way, and after that plot the results automaticly
#'
#' @author Roland Hollós
#' @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 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
#' @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
@ -11,31 +11,34 @@
#' @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 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
#' @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
#' @usage rungetMuso(settings, timee="d", debugging=FALSE, logfilename=NULL,
#' keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE)
#' @usage plotMuso(settings, variable,
#' timee="d", silent=TRUE,
#' debugging=FALSE, keepEpc=FALSE,
#' logfilename=NULL, aggressive=FALSE,
#' leapYear=FALSE, export=FALSE)
#' @import graphics
#' @export
plotMuso <- function(settings,
variable,
##compare,
##plotname,
parameters="ECOPHYS",
timee="d",
silent=TRUE,
debugging=FALSE,
keepEpc=FALSE,
logfilename=NULL,
aggressive=FALSE,
leapyear=FALSE,
leapYear=FALSE,
export=FALSE){
musoData <- rungetMuso(settings=settings,
silent=silent,
timee=timee,
parameters=parameters,
debugging=debugging,
keepEpc=keepEpc,
logfilename=logfilename,

View File

@ -2,7 +2,7 @@
#'
#' This function runs the BBGC-MuSo model and reads in its outputfile in a very structured way.
#'
#' @author Roland Hollós
#' @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 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
#' @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
@ -10,10 +10,12 @@
#' @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 leapyear Should the function do a leapyear correction on the outputdata? If TRUE, then the 31.12 day will be doubled.
#' @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
#' @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
#' @usage rungetMuso(settings, timee="d", debugging=FALSE, logfilename=NULL,
#' keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE)
#' @import utils
#' @export
@ -36,29 +38,7 @@ rungetMuso <- function(settings, timee="d", debugging=FALSE, logfilename=NULL, k
epc <- settings$epcinput
calibrationpar <- settings$calibrationpar
whereAmI<-getwd()
########################################################
###############################Preparational functions###############
#####################################################
numcut<-function(string){
#This function returns only the starting numbers of a string
unlist(strsplit(grep("^[0-9]",string,value = TRUE),"[aAzZ-]"))[1]
}
numcutall<-function(vector){
#numcall apply numcut for all elements of a string vector
as.numeric(unlist(apply(as.matrix(vector),1,numcut)))
}
stamp<-function(path="./"){
#It gives back a stamp wich is the maximum number of the output numcall
numbers<-numcutall(list.files(path))
if(length(numbers)==0){
return (0)} else {
return(max(numbers))}
}
#############################################################
############################spinup run############################
##########################################################

View File

@ -2,7 +2,7 @@
#'
#' This funcion is fundamental for the BiomBGC-MuSo modell related functions like spinupMuso, normalMuso, rungetMuso, because it sets the modells environment.
#'
#' @author Roland Hollós
#' @author Roland Hollos
#' @param parallel Do you want to run multiple modell paralelly, if yes, set this variable to TRUE
#' @param executable This parameter stores the place of the modell-executable file. In normal usage, you don't have to be set this, because a RBBgcmuso package contains allways the latest modell executable. In spite of this, if you would like to use this package for modell development or just want to use different models (for example for comparison), you will find it useful
#' @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)
@ -21,10 +21,14 @@
#' @param nitinput Via this parameter, you can tell the modell where are the NO2 data files. As default it reads this from the inifiles.
#' @param ininput Via this parameter, you can tell the modell where are the ini files. As default it reads this from the inifiles.
#' @param epcinput Via this parameter, you can tell the modell where are the epc data files. As default it reads this from the inifiles.
#' @usage setupMuso(executable=NULL, parallel = F, calibrationpar =c(1), outputloc=NULL, inputloc=NULL,
#' metinput=NULL, CO2input=NULL, plantinput=NULL, thininput=NULL,
#' mowinput=NULL, grazinput=NULL, harvinput=NULL, plouginput=NULL, fertinput=NULL,
#' irrinput=NULL, nitinput=NULL, ininput=NULL, epcinput=NULL)
#' @usage setupMuso(executable=NULL, parallel = F, calibrationpar =c(1),
#' outputloc=NULL, inputloc=NULL,
#' metinput=NULL, CO2input=NULL,
#' plantinput=NULL, thininput=NULL,
#' mowinput=NULL, grazinput=NULL,
#' harvinput=NULL, plouginput=NULL,
#' fertinput=NULL, irrinput=NULL,
#' nitinput=NULL, ininput=NULL, epcinput=NULL)
#' @return The output is a the modell setting list wich contains the following elements:
#' executable, calibrationpar, outputloc, outputname, inputloc, ininput, metinput, epcinput,thininput,CO2input, mowinput, grazinput, harvinput, plouginput, fertinput, irrinput, nitinput, inputfiles, numdata, startyear, numyears, outputvars
setupMuso <- function(executable=NULL,

View File

@ -1,63 +1,96 @@
spinupMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL, keepEpc=FALSE, silent=FALSE, aggressive=FALSE){
#' Run the BBGCMuso modell only in spinup phase, and debugging.
#'
#' This function runs the BBGC-MuSo model's in the spinup phase.
#'
#' @author Roland Hollos
#' @param 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.
#' @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 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 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)
#' @param logfilename If you want to set a specific name for your logfiles you can set this via logfile parameter
#' @return No return, outputs are written to file
#' @usage spinupMuso(settings, parameters=NULL, debugging=FALSE,
#' logfilename=NULL, keepEpc=FALSE, silent=FALSE, aggressive=FALSE)
#' @export
spinupMuso <- function(settings, parameters=NULL, debugging=FALSE, logfilename=NULL, keepEpc=FALSE, silent=FALSE, aggressive=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()
##Sometimes a bug occure due to logfiles and controlfiles in the input loc directory
#############################################################
############################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")
}
}
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")}}
##With the aggressive option every unneeded file will deleted
if(aggressive==TRUE){
cleanupMuso()
}
cleanupMuso(location=outputloc)}
##change the epc file if and only if there are given parameters
if(!is.null(parameters)){
changemulline(settings, parameters)
}
changemulline(filename=epc[1], calibrationpar, parameters)}
##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.
whereAmI<-getwd()
## Set the working directory to the inputloc temporary.
setwd(inputloc)
##Run the spinup
system(paste(executable,ininput[1],sep=" "))
logfiles<-list.files(inputloc)[grep("log$",list.files(inputloc))]
perror<-as.numeric(as.vector(lapply(paste(inputloc,logfiles,sep=""),function(x) tail(readLines(x,-1),1))))
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=" "))}
###############################################
#############LOG SECTION#######################
###############################################
logspinup<-list.files(outputloc)[grep("log$",list.files(outputloc))]
spincrash<-tail(readLines(paste(outputloc,logspinup,sep="/"),-1),1)==0
logfiles <- list.files(outputloc)[grep("log$",list.files(outputloc))]
dirName<-paste(inputloc,"/LOG",sep="")
dirERROR<-paste(inputloc,"/ERROR",sep="")
ERROR_EPC<-paste(inputloc,"/ERROR_EPC",sep="")
if(!dir.exists(dirName)){
dir.create(dirName)
}
dir.create(dirName)}
if(!dir.exists(dirERROR)){
dir.create(dirERROR)
}
dir.create(dirERROR)}
if(length(perror)>sum(perror)){
if(spincrash){
errorsign <- 1
} else {
errorsign <- 0
}
errorsign <- 0}
if(keepEpc){#if keepepc option tured on
if(length(unique(dirname(epc)))>1){

33
RBBGCMuso/R/stamplog.R Normal file
View File

@ -0,0 +1,33 @@
#' This function returns only the starting numbers of a string
#'
#' This function returns only the starting numbers of a string
#' @author Roland Hollos
#' @keywords internal
numcut<-function(string){
#This function returns only the starting numbers of a string
unlist(strsplit(grep("^[0-9]",string,value = TRUE),"[aAzZ-]"))[1]
}
#' numcutall
#'
#' apply numcut for all elements of a string vector
#' @author Roland Hollos
#' @keywords internal
numcutall<-function(vector){
#numcall apply numcut for all elements of a string vector
as.numeric(unlist(apply(as.matrix(vector),1,numcut)))
}
#' It gives back a stamp wich is the maximum number of the output numcall
#'
#' It gives back a stamp wich is the maximum number of the output numcall
#' @author Roland Hollos
#' @keywords internal
stamp<-function(path="./"){
#It gives back a stamp wich is the maximum number of the output numcall
numbers<-numcutall(list.files(path))
if(length(numbers)==0){
return (0)} else {
return(max(numbers))}
}

View File

@ -4,10 +4,11 @@
\alias{calibMuso}
\title{calibMuso}
\usage{
calibMuso(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL, keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE)
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 rungetMuso. It is its output which contains all of the necessary system variables. It sets the whole environment}
\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{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)}
@ -15,6 +16,8 @@ calibMuso(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL
\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{logfilename}{If you want to set a specific name for your logfiles you can set this via 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{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.}
@ -23,7 +26,7 @@ calibMuso(settings,parameters=NULL, timee="d", debugging=FALSE, logfilename=NULL
\item{aggressive}{It deletes every possible modell-outputs from the previous modell runs.}
\item{leapyear}{future feature.}
\item{leapYear}{Should the function do a leapyear correction on the outputdata? If TRUE, then the 31.12 day will be doubled.}
}
\value{
No return, outputs are written to file
@ -32,5 +35,5 @@ No return, outputs are written to file
This function changes the epc file and after that runs the BBGC-MuSo model and reads in its outputfile in a very structured way.
}
\author{
Roland Hollós
Roland Hollos
}

View File

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% 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.}
\usage{
changemulline(filename, calibrationpar, contents)
}
\description{
he function uses the previous changspecline function to operate.
}
\author{
Roland Hollos
}
\keyword{internal}

View File

@ -18,5 +18,5 @@ It returns the modells leapyear-corrigated output data.
This function leapyear-corrigate the output of the modell
}
\author{
Roland Hollós
Roland Hollos
}

View File

@ -17,9 +17,4 @@ vector with 12 element. First is January, the last is December. All of the vecto
\description{
This function gives as a vector which contains the number of the days per each month
}
\examples{
dayOfMonths(2004, corrigated=TRUE)
dayOfMonths(2004, corrigated=FALSE)
}
\keyword{internal}

View File

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/musoTime.R
\name{dayOfYears}
\alias{dayOfYears}
\title{This function tells us how many days are in the given year.}
\usage{
dayOfYears(year, corrigated = TRUE)
}
\description{
This function tells us how many days are in the given year.
}
\author{
Roland Hollos
}
\keyword{internal}

View File

@ -16,5 +16,5 @@ the extension of the given file
A function for extracting the extension name from the filename string
}
\author{
Roland Hollós
Roland Hollos
}

View File

@ -7,7 +7,7 @@
getyearlycum(daily_observations)
}
\arguments{
\item{A}{vector of the daily observations.}
\item{daily_observations}{vector of the daily observations.}
}
\value{
A vector of yearly data
@ -16,5 +16,5 @@ A vector of yearly data
Funtion for getting cumulative yearly data from observations
}
\author{
Roland Hollós
Roland Hollos
}

View File

@ -16,5 +16,5 @@ A vector of yearly data
Function for getting the maximum values of the years, from daily data
}
\author{
Roland Hollós
Roland Hollos
}

View File

@ -15,8 +15,4 @@ TRUE, if leapyear, FALSE if dont.
\description{
This function tells us if its argument a leapyear or not.
}
\examples{
isLeapyear(2004)
isLeapyear(2000)
isLeapyear(2100)
}
\keyword{internal}

30
RBBGCMuso/man/musoDate.Rd Normal file
View File

@ -0,0 +1,30 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/musoTime.R
\name{musoDate}
\alias{musoDate}
\title{It generates BiomeBGC-MuSo dates}
\usage{
musoDate(settings, timestep = "d", combined = TRUE, corrigated = TRUE,
format = "en")
}
\arguments{
\item{settings}{You have to run the setupMuso function before musoDate. It is its output which contains all of the necessary system variables. It sets the whole environment.}
\item{timestep}{timestep, which can be daily ("d"), monthly ("m"), yearly("y")}
\item{combined}{If FALSE the output is a vector of 3 string: day, month year, if true, these strings will be concatenated.}
\item{corrigated}{If True it counts with leapyears, else dont.}
\item{format}{This is the format of the date. It can be "en" (dd.mm.yyyy), or "hu" (yyyy.mm.dd)}
}
\value{
The exact date-vectors for the BioBGC-MuSo output. You can use this for labelling purpose for example.
}
\description{
It generates all of the day-dates which are between the start and endyear of BiomeBGC-MuSo run.
How many days are from the given date and given period length(periodlen)?
}
\author{
Roland Hollos
}

View File

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/musoTime.R
\name{musoLeapYears}
\alias{musoLeapYears}
\title{Musoleapyear}
\usage{
musoLeapYears(settings)
}
\description{
How many days are from the given date and given period length(periodlen)?
}
\author{
Roland Hollos
}
\keyword{internal}

15
RBBGCMuso/man/numcut.Rd Normal file
View File

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stamplog.R
\name{numcut}
\alias{numcut}
\title{This function returns only the starting numbers of a string}
\usage{
numcut(string)
}
\description{
This function returns only the starting numbers of a string
}
\author{
Roland Hollos
}
\keyword{internal}

View File

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stamplog.R
\name{numcutall}
\alias{numcutall}
\title{numcutall}
\usage{
numcutall(vector)
}
\description{
apply numcut for all elements of a string vector
}
\author{
Roland Hollos
}
\keyword{internal}

View File

@ -4,8 +4,11 @@
\alias{plotMuso}
\title{plot the BBGCMuso output}
\usage{
rungetMuso(settings, timee="d", debugging=FALSE, logfilename=NULL,
keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE)
plotMuso(settings, variable,
timee="d", silent=TRUE,
debugging=FALSE, keepEpc=FALSE,
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}
@ -20,9 +23,11 @@ keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE)
\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{logfilename}{If you want to set a specific name for your logfiles you can set this via logfile parameter}
\item{aggressive}{It deletes every possible modell-outputs from the previous modell 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 outputdata? If TRUE, then the 31.12 day will be doubled.}
\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.}
}
@ -33,5 +38,5 @@ It depends on the export parameter. The function returns with a matrix with the
This function runs the BBGC-MuSo model and reads in its outputfile in a very structured way, and after that plot the results automaticly
}
\author{
Roland Hollós
Roland Hollos
}

View File

@ -14,6 +14,8 @@ keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE)
\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{logfilename}{If you want to set a specific name for your logfiles you can set this via 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{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.}
@ -22,7 +24,7 @@ keepEpc=FALSE, export=FALSE, silent=FALSE, aggressive=FALSE, leapYear=FALSE)
\item{aggressive}{It deletes every possible modell-outputs from the previous modell 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 outputdata? If TRUE, then the 31.12 day will be doubled.}
}
\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
@ -31,5 +33,5 @@ It depends on the export parameter. The function returns with a matrix with the
This function runs the BBGC-MuSo model and reads in its outputfile in a very structured way.
}
\author{
Roland Hollós
Roland Hollos
}

View File

@ -4,10 +4,14 @@
\alias{setupMuso}
\title{setupMuso}
\usage{
setupMuso(executable=NULL, parallel = F, calibrationpar =c(1), outputloc=NULL, inputloc=NULL,
metinput=NULL, CO2input=NULL, plantinput=NULL, thininput=NULL,
mowinput=NULL, grazinput=NULL, harvinput=NULL, plouginput=NULL, fertinput=NULL,
irrinput=NULL, nitinput=NULL, ininput=NULL, epcinput=NULL)
setupMuso(executable=NULL, parallel = F, calibrationpar =c(1),
outputloc=NULL, inputloc=NULL,
metinput=NULL, CO2input=NULL,
plantinput=NULL, thininput=NULL,
mowinput=NULL, grazinput=NULL,
harvinput=NULL, plouginput=NULL,
fertinput=NULL, irrinput=NULL,
nitinput=NULL, ininput=NULL, epcinput=NULL)
}
\arguments{
\item{executable}{This parameter stores the place of the modell-executable file. In normal usage, you don't have to be set this, because a RBBgcmuso package contains allways the latest modell executable. In spite of this, if you would like to use this package for modell development or just want to use different models (for example for comparison), you will find it useful}
@ -54,5 +58,5 @@ executable, calibrationpar, outputloc, outputname, inputloc, ininput, metinput,
This funcion is fundamental for the BiomBGC-MuSo modell related functions like spinupMuso, normalMuso, rungetMuso, because it sets the modells environment.
}
\author{
Roland Hollós
Roland Hollos
}

View File

@ -0,0 +1,33 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spinupMuso.R
\name{spinupMuso}
\alias{spinupMuso}
\title{Run the BBGCMuso modell only in spinup phase, and debugging.}
\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{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{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{logfilename}{If you want to set a specific name for your logfiles you can set this via 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{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{aggressive}{It deletes every possible modell-outputs from the previous modell runs.}
}
\value{
No return, outputs are written to file
}
\description{
This function runs the BBGC-MuSo model's in the spinup phase.
}
\author{
Roland Hollos
}

15
RBBGCMuso/man/stamp.Rd Normal file
View File

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stamplog.R
\name{stamp}
\alias{stamp}
\title{It gives back a stamp wich is the maximum number of the output numcall}
\usage{
stamp(path = "./")
}
\description{
It gives back a stamp wich is the maximum number of the output numcall
}
\author{
Roland Hollos
}
\keyword{internal}

View File

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/musoTime.R
\name{sumDaysOfPeriod}
\alias{sumDaysOfPeriod}
\title{How many days are from the given date and given period length(periodlen)?}
\usage{
sumDaysOfPeriod(year, periodlen, corrigated = TRUE)
}
\description{
How many days are from the given date and given period length(periodlen)?
}
\author{
Roland Hollos
}
\keyword{internal}

View File

@ -16,5 +16,5 @@ if you choose "outputs", it gives you a simple vector of the formats, if you cho
A function for getting the list of the output formats which is supported by RBBGCMuso
}
\author{
Roland Hollós
Roland Hollos
}

View File

@ -0,0 +1,58 @@
---
title: "Vignette Title"
author: "Vignette Author"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The `html_vignette` output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The `html_vignette` format:
- Never uses retina figures
- Has a smaller default figure size
- Uses a custom CSS stylesheet instead of the default Twitter Bootstrap style
## Vignette Info
Note the various macros within the `vignette` section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the `title` field and the `\VignetteIndexEntry` to match the title of your vignette.
## Styles
The `html_vignette` template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows:
output:
rmarkdown::html_vignette:
css: mystyles.css
## Figures
The figure sizes have been customised so that you can easily put two images side-by-side.
```{r, fig.show='hold'}
plot(1:10)
plot(10:1)
```
You can enable figure captions by `fig_caption: yes` in YAML:
output:
rmarkdown::html_vignette:
fig_caption: yes
Then you can use the chunk option `fig.cap = "Your figure caption."` in **knitr**.
## More Examples
You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using `knitr::kable()`.
```{r, echo=FALSE, results='asis'}
knitr::kable(head(mtcars, 10))
```
Also a quote using `>`:
> "He who gives up [code] safety for [code] speed deserves neither."
([via](https://twitter.com/hadleywickham/status/504368538874703872))

Binary file not shown.