#' Get the length of stay of geese in the simulation
#'
#' Read the config file and figure out how many days geese should stay in the
#' simulation. The answer is corrected for the situation where the model exit
#' day is set before the leave date for the goose species in question.
#'
#' @param config character Path to the file to read start and leave date from
#' @param species character The species to the length of stay for
#' @return numeric The length of the stay
#' @export
GetLengthOfStay = function(config = NULL, species = NULL) {
if(tolower(species) == 'greylag'){ sp = 'GL'}
if(tolower(species) == 'pinkfoot'){ sp = 'PF'}
if(tolower(species) == 'barnacle'){ sp = 'BN'}
# Get leavedate
matchstring = paste('GOOSE', sp, 'LEAVINGDATEEND', sep = '_')
leavedate = GetParamValue(param = matchstring, config = config)
# Get startdate
matchstring = paste('GOOSE', sp, 'ARRIVEDATESTART', sep = '_')
startdate = GetParamValue(param = matchstring, config = config)
# Get exitday
exitday = GetParamValue(param = 'MODELEXITDAY', config = config)
exitday = exitday %% 365 # To get day in year
if(leavedate < exitday)
{
lengthofstay = 366-startdate + leavedate
}
if(leavedate >= exitday)
{
lengthofstay = 366-startdate + exitday
}
return(lengthofstay)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.