Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
T
tseries
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de conteneur
Registre de modèles
Opération
Environnements
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Michel Crucifix
tseries
Validations
184d8c45
Valider
184d8c45
rédigé
Il y a 9 mois
par
Michel Crucifix
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
added tone combination tool
parent
7f0e58fa
Branches
revert-2ae6d755
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
5
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
5 fichiers modifiés
NAMESPACE
+0
-1
0 ajout, 1 suppression
NAMESPACE
R/mfft_complex.R
+1
-1
1 ajout, 1 suppression
R/mfft_complex.R
R/mfft_support.R
+11
-4
11 ajouts, 4 suppressions
R/mfft_support.R
R/toneCombinations.R
+113
-0
113 ajouts, 0 suppression
R/toneCombinations.R
man/mfft_deco.Rd
+10
-1
10 ajouts, 1 suppression
man/mfft_deco.Rd
avec
135 ajouts
et
7 suppressions
NAMESPACE
+
0
−
1
Voir le fichier @
184d8c45
...
@@ -16,7 +16,6 @@ export(mem)
...
@@ -16,7 +16,6 @@ export(mem)
export(mfft_anova)
export(mfft_anova)
export(mfft_complex)
export(mfft_complex)
export(mfft_real)
export(mfft_real)
export(mfft_real_C)
export(periodogram)
export(periodogram)
export(powerspectrum.wavelet)
export(powerspectrum.wavelet)
export(reconstruct_mfft)
export(reconstruct_mfft)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
R/mfft_complex.R
+
1
−
1
Voir le fichier @
184d8c45
...
@@ -113,7 +113,7 @@ mfft_complex <- function(xdata, nfreq=30, minfreq=NULL, maxfreq=NULL, correctio
...
@@ -113,7 +113,7 @@ mfft_complex <- function(xdata, nfreq=30, minfreq=NULL, maxfreq=NULL, correctio
attr
(
OUT
,
"class"
)
<-
"mfft_deco"
attr
(
OUT
,
"class"
)
<-
"mfft_deco"
attr
(
OUT
,
"nfreq"
)
<-
nfreq
attr
(
OUT
,
"nfreq"
)
<-
nfreq
attr
(
OUT
,
"
x
data"
)
<-
xdata
attr
(
OUT
,
"data"
)
<-
xdata
return
(
OUT
)
return
(
OUT
)
}
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
R/mfft_support.R
+
11
−
4
Voir le fichier @
184d8c45
#' MFFT reconstruction
#' MFFT reconstruction
#' @importFrom stats deltat start
#' @rdname mfft_deco
#' @rdname mfft_deco
#' @param M : mfft_deco object
#' @param sum : TRUE if user wants to sum components in the reconstruction
#' @export reconstruct_mfft
#' @export reconstruct_mfft
reconstruct_mfft
<-
function
(
M
){
#' @return list of reconstructed components if sum=FALSE, full
#' reconstructed time series otherwise
reconstruct_mfft
<-
function
(
M
,
sum
=
TRUE
){
if
(
!
(
attr
(
M
,
"class"
)
==
"mfft_deco"
))
stop
(
"object is not a MFFT decomposition"
)
if
(
!
(
attr
(
M
,
"class"
)
==
"mfft_deco"
))
stop
(
"object is not a MFFT decomposition"
)
xdata
<-
attr
(
M
,
"
x
data"
)
xdata
<-
attr
(
M
,
"data"
)
nfreq
<-
attr
(
M
,
"nfreq"
)
nfreq
<-
attr
(
M
,
"nfreq"
)
times
<-
seq
(
length
(
xdata
))
*
dt
(
xdata
)
+
startx
(
xdata
)
times
<-
seq
(
length
(
xdata
))
*
stats
::
deltat
(
xdata
)
+
stats
::
start
(
xdata
)[
1
]
reconstructed
<-
lapply
(
seq
(
nfreq
),
function
(
i
)
M
$
Amp
[
i
]
*
cos
(
M
$
Freq
[
i
]
*
times
+
M
$
Phase
[
i
])
)
reconstructed
<-
lapply
(
seq
(
nfreq
),
function
(
i
)
ts
(
M
$
Amp
[
i
]
*
cos
(
M
$
Freq
[
i
]
*
times
+
M
$
Phase
[
i
]),
start
=
stats
::
start
(
xdata
),
deltat
=
stats
::
deltat
(
xdata
))
)
if
(
sum
)
reconstructed
<-
ts
(
apply
(
simplify2array
(
reconstructed
),
1
,
sum
),
start
=
stats
::
start
(
xdata
),
deltat
=
stats
::
deltat
(
xdata
))
}
}
#' MFFT ANOVA
#' MFFT ANOVA
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
R/toneCombinations.R
0 → 100644
+
113
−
0
Voir le fichier @
184d8c45
#' Generation of combination of tones
#'
#' Generates a vector with combinations of an input vector of frequencies, wih
#' explicit label names, up to order 3 (this could be made more flexible is the future)
#'
#' @importFrom RcppAlgos
#' @param omegas: vector of references frequencies, optionally with rownames,
#' @param keepPositives : if TRUE, then only keeps positive combinations of frequencies
#' @return a vector with combination of tones and explicit rownames, using, if available, the
#' rownames provided in the input vector omega
#' @author Michel Crucifix
#' @examples
# omegas <- c( 0.123, 0.14312, 0.33251, 0.554313)
# outamps <- c(1., 2, 0.2 , 0.5, 0.5)
# outfreqs <- c(1., 1.2432, omegas[1]+omegas[3]+0.00000002, omegas[1]-omegas[4]+0.00004, 0.15)
#
# attributions <- attributeTones(outfreqs, omegas)
#
# cbind(outfreqs, attributions)
#
# plot(outfreqs, outamps, type='h')
# text(outfreqs, outamps+0.1, attributions)
#
toneCombinations
<-
function
(
omegas
,
keepPositives
=
TRUE
){
twoomegas
<-
c
(
-
omegas
,
omegas
)
indices
<-
c
(
-
seq
(
length
(
omegas
)),
seq
(
length
(
omegas
)))
result
=
rbind
(
c
(
0
,
0
,
0
),
cbind
(
RcppAlgos
::
comboGeneral
(
twoomegas
,
m
=
1
,
repetition
=
T
),
0
,
0
),
cbind
(
RcppAlgos
::
comboGeneral
(
twoomegas
,
m
=
2
,
repetition
=
T
)
,
0
),
RcppAlgos
::
comboGeneral
(
twoomegas
,
m
=
3
,
repetition
=
T
))
combos
=
rbind
(
c
(
0
,
0
,
0
),
cbind
(
RcppAlgos
::
comboGeneral
(
indices
,
m
=
1
,
repetition
=
T
),
0
,
0
),
cbind
(
RcppAlgos
::
comboGeneral
(
indices
,
m
=
2
,
repetition
=
T
)
,
0
),
RcppAlgos
::
comboGeneral
(
indices
,
m
=
3
,
repetition
=
T
))
sumre
<-
apply
(
result
,
1
,
sum
)
whichUnique
<-
seq
(
length
(
sumre
))[
!
duplicated
(
sumre
)]
uniqueCombos
<-
combos
[
whichUnique
,
]
uniqueSums
<-
sumre
[
whichUnique
]
# further filtering (?)
if
(
keepPositives
){
tokeep
<-
which
(
uniqueSums
>
0
)
uniqueCombos
<-
uniqueCombos
[
tokeep
,]
uniqueSums
<-
uniqueSums
[
tokeep
]
}
names
(
uniqueSums
)
<-
apply
(
uniqueCombos
,
1
,
function
(
g
)
generate_name
(
g
,
"s"
,
labels
=
names
(
omegas
)))
return
(
cbind
(
uniqueSums
))
}
generate_name
<-
function
(
invec
,
char
=
"s"
,
labels
=
NULL
){
# to do: if labels are supplied, to not produce
tt
<-
as.data.frame
(
table
(
invec
))
flag
<-
FALSE
tmp
<-
sapply
(
seq
(
nrow
(
tt
)),
function
(
i
)
{
indice
<-
as.integer
(
as.character
(
tt
[
i
,][[
1
]]))
if
(
indice
==
0
)
return
(
""
)
else
{
if
(
flag
)
signchar
<-
ifelse
(
sign
(
indice
)
+1
,
" + "
,
" - "
)
else
signchar
<-
ifelse
(
sign
(
indice
)
+1
,
""
,
"-"
)
freq
<-
tt
[
i
,][[
2
]]
freqchar
<-
ifelse
(
freq
==
1
,
""
,
sprintf
(
"%d"
,
freq
))
flag
<<-
TRUE
if
(
is.null
(
labels
))
labelname
<-
sprintf
(
"%s%d"
,
char
,
abs
(
indice
))
else
labelname
<-
labels
[
abs
(
indice
)]
return
(
sprintf
(
"%s%s%s"
,
signchar
,
freqchar
,
labelname
))
}})
# Reduce(function(i) paste (i, sep=""), tmp)
Reduce
(
function
(
i
,
j
)
paste
(
i
,
j
,
sep
=
""
),
tmp
)
}
#' Attribution of combination of tones
#'
#' Based on a vector of frequencies (`infreq`), and a vector of referenc
#' frequencies with row names (it will be input to `toneCombinations`),
#' attribute the `infreq` frequencies with two possible degrees of tolerance
#'
#' @param infreq : input frequencies
#' @param omegas : reference frequencies (a numeric vector which may contain explicit row names)
#' @param tol1 : acceptable tolerance for being considered as a certain attribution
#' (if several frequencies match the criteria, the closest will be taken)
#' @param tol2 : acceptable tolerance for being considered as a likely or plausible
#'
#' @examples
# omegas <- c( 0.123, 0.14312, 0.33251, 0.554313)
# names(omegas) <- c('g1','g2','s1','s2')
# outamps <- c(1., 2, 0.2 , 0.5, 0.5)
# outfreqs <- c(1., 1.2432, omegas[1]+omegas[3]+0.00000002, omegas[1]-omegas[4]+0.00004, 0.15)
#
# attributions <- attributeTones(outfreqs, omegas)
#
# cbind(outfreqs, attributions)
#
# plot(outfreqs, outamps, type='h')
# text(outfreqs, outamps+0.1, attributions)
#
attributeTones
<-
function
(
infreq
,
omegas
,
tol1
=
1
.e
-6
,
tol2
=
1
.e
-4
)
{
attributions
<-
rep
(
""
,
length
(
infreq
))
combis
<-
toneCombinations
(
omegas
)
for
(
i
in
seq
(
infreq
)){
deltas
<-
abs
(
infreq
[
i
]
-
combis
)
bestSuspect
<-
which.min
(
abs
(
infreq
[
i
]
-
combis
))
if
(
deltas
[
bestSuspect
]
<
tol1
)
attributions
[
i
]
<-
rownames
(
combis
)[
bestSuspect
]
else
if
(
deltas
[
bestSuspect
]
<
tol2
)
attributions
[
i
]
<-
paste
(
rownames
(
combis
)[
bestSuspect
],
"?"
)
}
return
(
attributions
)
}
Ce diff est replié.
Cliquez pour l'agrandir.
man/mfft_deco.Rd
+
10
−
1
Voir le fichier @
184d8c45
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
\alias{print.mfft_deco}
\alias{print.mfft_deco}
\title{MFFT reconstruction}
\title{MFFT reconstruction}
\usage{
\usage{
reconstruct_mfft(M)
reconstruct_mfft(M
, sum = TRUE
)
mfft_anova(M)
mfft_anova(M)
...
@@ -21,6 +21,15 @@ mfft_anova(M)
...
@@ -21,6 +21,15 @@ mfft_anova(M)
\method{print}{mfft_deco}(M, ...)
\method{print}{mfft_deco}(M, ...)
}
}
\arguments{
\item{M}{: mfft_deco object}
\item{sum}{: TRUE if user wants to sum components in the reconstruction}
}
\value{
list of reconstructed components if sum=FALSE, full
reconstructed time series otherwise
}
\description{
\description{
MFFT reconstruction
MFFT reconstruction
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter