R/LBLE_to_BE.R

Defines functions LBLE_to_BE

Documented in LBLE_to_BE

#' LBLE_to_BE transforms a set of parameters from LengthB LengthE to Begin End.
#' @title Transform a set of parameters from LengthB LengthE to Begin End.
#' @author Marc Girondot
#' @return Return a set of modified parameters
#' @param parameters Set of current parameters
#' @param help If TRUE, an help is displayed
#' @description This function is used to transform a set of parameters 
#' that uses LengthB, Peak and LengthE to a set of parameters 
#' that uses Begin, Peak and End.
#' @family Phenology model
#' @examples 
#' # Read a file with data
#' data(Gratiot)
#' # Generate a formatted list nammed data_Gratiot
#' refdate <- as.Date("2001-01-01")
#' data_Gratiot<-add_phenology(Gratiot, name="Complete", reference=refdate, format="%d/%m/%Y")
#' # Generate initial points for the optimisation
#' parg<-par_init(data_Gratiot, fixed.parameters=NULL)
#' # Change the parameters to Begin End format
#' parg1<-LBLE_to_BE(parameters=parg)
#' # And change back to LengthB LengthE
#' parg2<-BE_to_LBLE(parameters=parg1)
#' @export


LBLE_to_BE <-
function(parameters=NULL, help=FALSE) {
if(help) {
	cat("This function is used to transform a set of parameters\n")
	cat("that uses LengthB, Peak and LengthE to a set of parameters\n")
	cat("that uses Begin, Peak and End.\n")

} else {

if (!is.null(parameters)) {
	pk<-parameters["Peak"]
	lb<-parameters["LengthB"]
	le<-parameters["LengthE"]

	bg<-pk-lb
	en<-pk+le
	
	parameters[names(parameters)=="LengthB"]<-bg
	names(parameters)[names(parameters)=="LengthB"]<-"Begin"
	
	parameters[names(parameters)=="LengthE"]<-en
	names(parameters)[names(parameters)=="LengthE"]<-"End"
	
	return(parameters)
	
}
}
}

Try the phenology package in your browser

Any scripts or data that you put into this service are public.

phenology documentation built on Oct. 16, 2023, 9:06 a.m.