Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/source/_static/spectrum.npy
Binary file not shown.
206 changes: 0 additions & 206 deletions examples/20-kalman_filter_simulator.ipynb

This file was deleted.

500 changes: 500 additions & 0 deletions examples/20-wiener_filter_simulator.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion s2generator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

__version__ = "0.0.6"
__version__ = "0.0.7"

__all__ = [
"Node",
Expand Down
3 changes: 0 additions & 3 deletions s2generator/simulator/wiener_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ def transform(
# New sequence = White noise * Wiener filter (convolution)
simulated_series[i, :] = self.invoke(white_noise=white_noise[i, :])

# Remove edge effects after filtering (first filter_order points)
simulated_series = simulated_series[:, self.filter_order :]

# If normalization was performed previously,
# denormalization is now needed to maintain the same mean and variance as the original sequence.
if self.revin:
Expand Down
2 changes: 2 additions & 0 deletions s2generator/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"exponential_smoothing",
"smooth_show_info",
"MovingDecomp",
"plot_time_series",
"plot_series",
"plot_symbol",
"plot_shapiro_wilk",
Expand Down Expand Up @@ -102,6 +103,7 @@

# The Shapiro-Wilk test for normality of the residuals
from .visualization import (
plot_time_series,
plot_series,
plot_symbol,
plot_shapiro_wilk,
Expand Down
29 changes: 27 additions & 2 deletions s2generator/utils/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

__all__ = [
"plot_time_series",
"plot_series",
"plot_symbol",
"plot_shapiro_wilk",
Expand All @@ -25,6 +26,28 @@
from s2generator.utils.print_symbol import symbol_to_markdown


def plot_time_series(
time_series: np.ndarray, figsize: Tuple[int, int] = (12, 3), dpi: int = 256
) -> plt.Figure:
"""
Visualize a single time series.

:param time_series: The time series data to be visualized.
:param figsize: The size of the figure for the generated plot.
:param dpi: Dots per inch (resolution) for the generated plot.

:return: A matplotlib Figure object containing the time series plot.
"""
fig, ax = plt.subplots(figsize=figsize, dpi=dpi)
ax.plot(time_series, color="royalblue")
ax.set_title("Time Series Visualization", fontweight="bold", fontsize=13)
ax.set_xlabel("Time Steps", fontsize=11.5)
ax.set_ylabel("Value", fontsize=11.5)
ax.grid(True)

return fig


def plot_series(x: np.ndarray, y: np.ndarray) -> plt.Figure:
"""
Visualize S2 data
Expand Down Expand Up @@ -307,6 +330,7 @@ def plot_simulator_statistics(
nlags: int = 50,
nperseg: int = 128,
bins: int = 30,
figsize: Tuple[int, int] = None,
) -> plt.Figure:
"""
Compare the statistical properties of the original series and the generated series.
Expand All @@ -320,6 +344,7 @@ def plot_simulator_statistics(
:param nlags: The number of lags to compute for the autocorrelation function.
:param nperseg: The length of each segment for the Welch method in power spectral density estimation.
:param bins: The number of bins to use for the histogram plots.
:param figsize: The size of the figure for the generated plots. If None, it will be automatically determined.

:return: A matplotlib Figure object containing the comparison plots.
"""
Expand All @@ -339,9 +364,9 @@ def plot_simulator_statistics(
# Here we need to determine if the residuals from the model fit have been passed in.
# If residuals are present, a subplot can be added to display their statistical properties.
if residuals is not None:
fig, axes = plt.subplots(3, 2, figsize=(12, 10))
fig, axes = plt.subplots(3, 2, figsize=(12, 10) if figsize is None else figsize)
else:
fig, axes = plt.subplots(2, 2, figsize=(8, 10))
fig, axes = plt.subplots(2, 2, figsize=(12, 7) if figsize is None else figsize)

# Original sequence and generated sequence
axes[0, 0].plot(original_series, label="Original", alpha=0.7, color="royalblue")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setuptools.setup(
name="S2Generator",
packages=setuptools.find_packages(),
version="0.0.6",
version="0.0.7",
description="A series-symbol (S2) dual-modality data generation mechanism, enabling the unrestricted creation of high-quality time series data paired with corresponding symbolic representations.", # 包的简短描述
url="https://github.com/wwhenxuan/S2Generator",
author="whenxuan, johnfan12, changewam",
Expand Down