WaveletDec#
- class pymultifracs.multiresquantity.WaveletDec#
Bases:
MultiResolutionQuantityBaseWavelet Coefficient Decomposition.
It represents the wavelet coefficients of a signal \(d_X(j, k)\)
Note
Should not be instantiated directly but instead created using the wavelet_analysis function.
- Attributes:
- values
dict[int,ndarray] values[j]contains the coefficients at the scale j. Arrays are of the shape (nj, n_rep)- n_channel
int Number of underlying signals in the wavelet decomposition. May not match the dimensionality of the values arrays in case there are multiple repetitions associated to a single signal.
- gamint
float Fractional integration used in the computation of the MRQ.
- wt_name
str Name of the wavelet used for the decomposition.
- interval_size
int Width of the coef interval over which the MRQ was computed.
- origin_mrq
WaveletDec|None If MRQ is derived from another mrq, refers to the original MRQ.
- bootstrapped_obj
WaveletDec|None Storing the bootstrapped version of the MRQ if bootstraping has been used.
- values
- auto_integrate(scaling_ranges, weighted=None, idx_reject=None)#
Automatically integrates the signal to match the requirements of the multifractal formalism associated to the multi-resolution quantity.
- Parameters:
- scaling_ranges
list[tuple[int,int]] List of pairs of \((j_1, j_2)\) ranges of scales for the analysis.
- weighted
str|None Weighting mode for the linear regressions. Defaults to None, which is no weighting. Possible values are ‘Nj’ which weighs by number of coefficients, and ‘bootstrap’ which weights by bootstrap-derived estimates of variance.
- idx_reject
dict[int,ndarrayof bool] Dictionary associating each scale to a boolean array indicating whether certain coefficients should be removed.
- scaling_ranges
- bootstrap(R, min_scale=1, idx_reject=None)#
Bootstrap the multi-resolution quantity by repeating.
- Parameters:
- R
int Number of repetitions of the bootstrap.
- min_scale
int Minimum scale that will be kept in the bootstrapped MRQ, used to save memory space when analyzing the coarse scales of long time series.
- idx_reject
dict[str,np.ndarray] |None Dictionary of rejected values, by default None which means no rejected values.
- R
- Returns:
WaveletDecMRQ containing the bootstrapped values.
- classmethod bootstrap_multiple(R, min_scale, mrq_list)#
Bootstrap multiple MRQs at once
- check_regularity(scaling_ranges, weighted=None, idx_reject=None, min_j=1)#
Verify that the MRQ has enough regularity for analysis.
- Parameters:
- scaling_ranges
list[tuple[int,int]] List of pairs of (j1, j2) ranges of scales for the analysis.
- weighted
str|None Weighting mode for the linear regressions. Defaults to None, which is no weighting. Possible values are ‘Nj’ which weighs by number of coefficients, and ‘bootstrap’ which weights by bootstrap-derived estimates of variance.
- idx_reject
Dict[int,ndarray] Dictionary associating each scale to a boolean array indicating whether certain coefficients should be removed.
- scaling_ranges
- Returns:
ndarrayEstimate of the minimal Hölder exponent in the MRQ.
- freq2scale(freq, sfreq)#
Get the scales associated to frequencies.
- get_leaders(p_exp, interval_size=3, gamint=None)#
Compute (p-)leaders from the wavelet coefficients
- Parameters:
- p_exp
float|numpy.inf np.inf means wavelet leaders will also be computed, and a float sets the value of the p exponent implying a wavelet p-leader formalism.
- interval_size
int Width of the time shift interval over which the leaders are computed, by default the usual value of 3.
- gamint
int|None Fractional integration coefficient, by default None which means that current integration will be conserved.
- p_exp
- Returns:
WaveletLeaderWavelet (p-)leader derived from the coefficients.
- get_n_bootstrap()#
Returns the number of bootstrapping repetition, or 0 if no bootstrapping
- get_nj_interv(j1=None, j2=None, idx_reject=None)#
Returns nj as an array, for j in [j1,j2]
- get_values(j, idx_reject=None)#
Get the values of the MRQ, applying any finite size effects corrections if necessary (Wavelet p-leaders).
- get_wse(theta=0.5, omega=1, gamint=None)#
Compute weak scaling exponents from the wavelet coefficients
- Parameters:
- theta
float, optional Parameter controlling to which extent the cone reaches in the lower scales. Practically, \((\theta, \omega)\)-leaders computed at scale \(j\) reach down to \(j-j^{\theta}\).
- omega
float, optional Parameter controlling the angle of the cone over which the weak scaling exponents are computed: practically, for computing the \((\theta, \omega)\)-leaders at scale \(j\), the width of the cone at scale \(j\prime\) is \((j-j\prime)^{omega} + 1\).
- gamint
float, optional Fractional integration coefficient, defaults to 0 (no integration).
- theta
- Returns:
WaveletWSEWeak scaling exponent derived from the coefficients.
- integrate(gamint)#
Fractionally integrate the wavelet coefficients.
- Parameters:
- gamint
float Fractional integration coefficient
- gamint
- Returns:
- integrated
WaveletDec
- integrated
- j2_eff()#
Returns the effective maximal scale
- max_scale_bootstrap(idx_reject=None)#
Maximum scale at which bootstrapping can be done
- Parameters:
- idx_reject
dict[str,np.ndarray] |None Dictionary of rejected values, by default None which means no rejected values.
- idx_reject
- Returns:
- Scale
int
- Scale
- plot(j1, j2, ax=None, vmin=None, vmax=None, cbar=True, figsize=(4.5, 1.5), gamma=1, nan_idx=None, signal_idx=0, cbar_kw=None, cmap='magma')#
Plot the multi-resolution quantity.
- Parameters:
- j1
int Initial scale from which to display the values.
- j2
int Maximal scale from which to display the values.
- ax
matplotlib.pyplot.axes|None pyplot axes, defaults to None which creates a new figure.
- vmin
float|None Minimal value of the colorbar, by default None which uses the minimal value in the data.
- vmax
float|None Maximal value of the colorbar, by default None which uses the maximal value in the data.
- cbarbool
Whether to display a colorbar.
- figsize
tuple, optional Size of the figure, used if ax is None.
- gamma
float, optional Exponent of the power-law color normalization, set to 1 for no normalization.
- nan_idx
dict[str,ndarray] |None Index of values to highlight (smart indexing), or boolean mask index of values to highlight as output by robust.get_outliers.
- signal_idx
int, optional Index of the signal to plot, defaults to the first signal.
- cbar_kw
dict|None Arguments to pass to the colorbar function call
- cmap
str Colormap for the plot.
- j1