Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found

Cible

Sélectionner le projet cible
  • mcrucifix/tseries
1 résultat
Afficher les modifications
Validations sur la source (2)
......@@ -6,18 +6,19 @@ S3method(lines,discreteSpectrum)
S3method(plot,SSAObject)
S3method(plot,discreteSpectrum)
S3method(plot,memObject)
S3method(plot,mmfft)
S3method(plot,periodogram)
S3method(plot,wavelet)
S3method(print,discreteSpectrum)
export(approx_ts)
export(arspec)
export(attributeTones)
export(cis)
export(cwt_morlet)
export(develop)
export(hilbert_extension)
export(mem)
export(mfft)
export(mfft_anova)
export(mfft_complex)
export(mfft_real)
export(mmfft)
......
......@@ -26,6 +26,7 @@ mmfft <- function(xdata, seglength = length(xdata) %/% 16, ...){
}
#' @rdname mmfft
#' @export
plot.mmfft <- function(x){
freqrange <-
c(min(sapply(x, function(xs) min(xs$Freq))),
......@@ -35,7 +36,6 @@ plot.mmfft <- function(x){
c(min(sapply(x, function(xs) min(xs$Amp))),
max(sapply(x, function(xs) max(xs$Amp))))
print(amprange)
amp2lwd <- function(amp){ 3*amp/amprange[2] }
length <- attr(x, "nsections") *
......@@ -48,17 +48,13 @@ plot.mmfft <- function(x){
tstart <- attr(x,"start")
tend <- tstart + nsec * tsec
print(freqrange)
print(c(tstart, tend))
plot(c(tstart, tend), freqrange, type='n', xlab='Time', ylab='Rate')
for (iseq in seq(nsec)){
trange <- tstart + c(iseq-1,iseq)*tsec
obj <- x[[iseq]]
nfreq <- length(obj$Freq)
print(obj$Amp)
lwds <- sapply(obj$Amp, amp2lwd)
print(lwds)
for (j in seq(nfreq)){
lines(trange, rep(obj$Freq[j],2), lwd=lwds[j])
}
......@@ -66,7 +62,3 @@ plot.mmfft <- function(x){
}
......@@ -6,6 +6,7 @@
#' @importFrom RcppAlgos comboGeneral
#' @param omegas: vector of references frequencies, optionally with rownames,
#' @param keepPositives : if TRUE, then only keeps positive combinations of frequencies
#' @param fractions : defaults 1. Set 2 to include double-periods, and 3 triple-periods.
#' @return a vector with combination of tones and explicit rownames, using, if available, the
#' rownames provided in the input vector omega
#' @author Michel Crucifix
......@@ -14,7 +15,24 @@
#' omegas <- c( 0.123, 0.14312, 0.33251, 0.554313)
#' print(toneCombinations(omegas))
toneCombinations <- function(omegas, keepPositives=TRUE){
toneCombinations <- function(omegas, fractions=1, keepPositives=TRUE){
if (fractions == 2){
local({
tmp <- c(as.numeric(omegas), as.numeric(omegas)/2)
names(tmp) <- c(names(omegas), sprintf("%s/2", names(omegas)))
omegas <<- tmp
})
}
if (fractions == 3){
local({
tmp <- c(as.numeric(omegas), as.numeric(omegas)/2, as.numeric(omegas)/3)
names(tmp) <- c(names(omegas), sprintf("%s/2", names(omegas)), sprintf("%s/3", names(omegas)))
omegas <<- tmp
})
}
twoomegas <- c(-omegas,omegas)
indices <- c(-seq(length(omegas)), seq(length(omegas)))
result = rbind(
......@@ -75,6 +93,7 @@ generate_name <- function(invec,char="s", labels = NULL){
#'
#' @param infreq : input frequencies
#' @param omegas : reference frequencies (a numeric vector which may contain explicit row names)
#' @param fractions : 1, 2, or 3 depending on willing to include singe, double or triple periods
#' @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
......@@ -93,9 +112,9 @@ generate_name <- function(invec,char="s", labels = NULL){
#' plot(outfreqs, outamps, type='h')
#' text(outfreqs, outamps+0.1, attributions)
#'
attributeTones <- function(infreq , omegas, tol1 = 1.e-6, tol2 = 1.e-4) {
attributeTones <- function(infreq , omegas, fractions=1, tol1 = 1.e-6, tol2 = 1.e-4) {
attributions <- rep("", length(infreq))
combis <- toneCombinations(omegas)
combis <- toneCombinations(omegas, fractions=fractions)
for (i in seq(infreq)){
deltas <- abs(infreq[i] - combis)
bestSuspect <- which.min(abs(infreq[i] - combis))
......
......@@ -4,13 +4,15 @@
\alias{attributeTones}
\title{Attribution of combination of tones}
\usage{
attributeTones(infreq, omegas, tol1 = 1e-06, tol2 = 1e-04)
attributeTones(infreq, omegas, fractions = 1, tol1 = 1e-06, tol2 = 1e-04)
}
\arguments{
\item{infreq}{: input frequencies}
\item{omegas}{: reference frequencies (a numeric vector which may contain explicit row names)}
\item{fractions}{: 1, 2, or 3 depending on willing to include singe, double or triple periods}
\item{tol1}{: acceptable tolerance for being considered as a certain attribution
(if several frequencies match the criteria, the closest will be taken)}
......
......@@ -4,7 +4,7 @@
\alias{develop}
\title{Develop a spectrum into a time series (generic)}
\usage{
develop(M, times = NULL, start = NULL, end = NULL, deltat = NULL, ...)
develop(M, start = NULL, end = NULL, deltat = NULL, times = NULL, ...)
}
\arguments{
\item{deltat}{: see start.}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mfft_support.R
% Please edit documentation in R/develop.R
\name{develop.discreteSpectrum}
\alias{develop.discreteSpectrum}
\title{MFFT reconstruction}
\title{Discrete spectrum reconstruction}
\usage{
\method{develop}{discreteSpectrum}(M, times = NULL, start = NULL, end = NULL, deltat = NUL, sum = TRUE)
\method{develop}{discreteSpectrum}(
M,
start = NULL,
end = NULL,
deltat = NULL,
times,
dfunction = cos,
sum = TRUE
)
}
\arguments{
\item{M}{: discreteSpectrum object}
\item{deltat}{: see start.}
\item{dfunction}{is the trigonometrical function. Classically one of 'cos', 'sin', or 'cis'}
\item{sum}{: TRUE if user wants to sum components %in% the reconstruction}
\item{times:}{if supplied, times of the decomposition}
......@@ -23,7 +33,7 @@ list of reconstructed components if sum=FALSE, full
reconstructed time series otherwise
}
\description{
MFFT reconstruction
Discrete spectrum reconstruction
}
\note{
if none if times, start and deltat are supplied, will reconstruct based on the attribute `xdata`
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mfft_support.R
\name{mfft_anova}
\alias{mfft_anova}
\alias{as.data.frame.discreteSpectrum}
\alias{plot.discreteSpectrum}
\alias{lines.discreteSpectrum}
\alias{print.discreteSpectrum}
\title{MFFT ANOVA
not ready. do not use.}
\usage{
mfft_anova(M)
\method{as.data.frame}{discreteSpectrum}(x)
\method{plot}{discreteSpectrum}(M, periods = FALSE, labels = NULL, ...)
\method{lines}{discreteSpectrum}(M, ...)
\method{print}{discreteSpectrum}(M, ...)
}
\arguments{
\item{periods}{if TRUE will add a lower axis with period labels}
\item{labels}{to be set above the frequency peaks. Can be the output of `attributeTone`}
\item{a}{`discreteSpectrum` object, typically the output of a `mfft` call.}
}
\description{
MFFT ANOVA
not ready. do not use.
}
......@@ -4,9 +4,11 @@
\alias{toneCombinations}
\title{Generation of combination of tones}
\usage{
toneCombinations(omegas, keepPositives = TRUE)
toneCombinations(omegas, fractions = 1, keepPositives = TRUE)
}
\arguments{
\item{fractions}{: defaults 1. Set 2 to include double-periods, and 3 triple-periods.}
\item{keepPositives}{: if TRUE, then only keeps positive combinations of frequencies}
\item{omegas:}{vector of references frequencies, optionally with rownames,}
......