phenopar_polygon {sephora} | R Documentation |
Phenological parameters estimation in mass
Description
Estimation of phenological parameters from a set of numeric vectors stored in a RData file.
Output is saved as a RData file at the destination specified by dirToSave
Usage
phenopar_polygon(
path = NULL,
product = c("MOD13Q1", "independent"),
data,
frequency = 23,
method = c("OLS", "WLS"),
sigma = NULL,
numFreq,
delta = 0,
distance,
samples,
basis,
corr = NULL,
k,
trace = FALSE,
numCores = 20,
dirToSave,
reportFileBaseName = "phenopar_progress",
outputFileBaseName = "polygon"
)
Arguments
path |
character with full path of RData file containing numeric vectors to analyze. |
product |
character specifying whether dataset is the |
data |
matrix with dataset to analyze. Pertinent when |
frequency |
integer giving number of observations per season. Default, 23. |
method |
character. Should |
sigma |
numeric vector of length equal to |
numFreq |
integer specifying number of frequencies to use in harmonic regression model. |
delta |
numeric. Default, 0. When regression problem is ill-posed, this parameter allows a simple regularization. |
distance |
character indicating what distance to use in hierarchical clustering.
All distances in |
samples |
integer with number of samples to draw from smoothed version of numeric vector to analyze. Used exclusively in Functional Principal Components Analysis (FPCA)-based regression. |
basis |
list giving numeric basis used in FPCA-based regression. See details. |
corr |
Default |
k |
integer, number of principal components used in FPCA-based regression. |
trace |
logical. If |
numCores |
integer. How many processing cores can be used? |
dirToSave |
character. In which directory to save analysis results? |
reportFileBaseName |
character. What base name should be given to a progress report file?
Default, |
outputFileBaseName |
character. What base name should be given to the output file?
Default, |
Value
At the location specified by dirToSave
, a file containing a matrix
with nrow
equal to the number of numeric vectors analyzed and 6 columns, is saved.
The name of this file is:
paste0(tools::file_path_sans_ext(basename(path)), "_phenoparams.RData")
.
See Also
phenopar
, getSpiralPlot
,
tsclust
.
Examples
dirOUTPUT <- system.file("data", package = "sephora")
BASIS <- drbasis(n=100, q=2)
polygon_deciduous <- deciduous_polygon
for(i in 1:nrow(polygon_deciduous)){
polygon_deciduous[i,] <- vecFromData(data=deciduous_polygon, numRow=i)$vec
}
# --- In the following example 'numCores=2' for CRAN
# --- testing purposes only. In a real life example
# --- users are encouraged to set 'numCores' to a number
# --- that reflects the size of their data set as well
# --- as the number of available cores
phenopar_polygon(data=polygon_deciduous,
product="independent",
numFreq = 3, distance = "dtw2",
samples=100, basis=BASIS,
k=3, numCores=2,
dirToSave=dirOUTPUT,
outputFileBaseName = "deciduous")
# --- Auxiliary function to read phenopar_polygon output,
# --- used below to define deciduous_params object
LoadToEnvironment <- function(RData, env = new.env()){
load(RData, env)
return(env)}
# --- colors used in spiralPlot below
cgu <- rgb(173/255,221/255,142/255)
csos <- rgb(120/255,198/255,121/255)
cmat <- rgb(49/255, 163/255,84/255)
csen <- rgb(217/255, 95/255, 14/255)
ceos <- rgb(254/255, 153/255, 41/255)
cdor <- rgb(208/255, 209/255, 230/255)
colores <- c(cgu,csos,cmat,csen,ceos,cdor)
# --- how to get a SpiralPlot
listRDatas <- list.files(path=dirOUTPUT,
pattern=".RData",
full.names=TRUE)
deciduous_params <- LoadToEnvironment(listRDatas[1])
getSpiralPlot(MAT=deciduous_params$output,
LABELS=month.name,
vp_param=list(width=0.5, height=0.7))
vcd::grid_legend(x=1.215, y=0.125, pch=18, col=colores,
frame=FALSE,
labels=c("GU","SoS","Mat","Sen","EoS","Dor"),
title="Params")
# --- cleaning up after work
unlink(paste0(dirOUTPUT, "/deciduous_phenoParams.RData"))
unlink(paste0(dirOUTPUT, "/phenopar_progress.txt"))