Skip to content

Commit

Permalink
add gif in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hadifawaz1999 committed Jul 21, 2024
1 parent 92f8209 commit 5331639
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 122 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The following parameters can be configured in the `config/config_hydra.yaml` fil
Using DTW on ItalyPowerDemand dataset
- In video format: [dtw-italy](exps/dtw-vis/ItalyPowerDemand/dtw.mp4)
- In video format [download-here](exps/dtw-vis/ItalyPowerDemand/dtw.mp4): ![dtw-italy](exps/dtw-vis/ItalyPowerDemand/dtw.gif)
- In pdf format: [dtw-italy-pdf](exps/dtw-vis/ItalyPowerDemand/dtw.pdf)
## Citation
Expand Down
121 changes: 0 additions & 121 deletions draw_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,127 +189,6 @@ def draw_elastic(
fig.savefig(os.path.join(output_dir, metric + ".pdf"), bbox_inches="tight")


# def draw_elastic(
# x: np.ndarray,
# y: np.ndarray,
# channel_used: int = 0,
# output_dir: str = "./",
# figsize: Tuple[int, int] = None,
# metric: str = "dtw",
# metric_params: dict = None,
# show_warping_connections: bool = False,
# ):

# if int(x.shape[0]) == 1:
# channel_used = 0

# figsize = (10, 10) if figsize is not None else figsize

# reach = metric_params["reach"]

# if metric != "shape_dtw":
# reach = 0

# _x = np.copy(x)
# _y = np.copy(y)

# x = np.pad(x, pad_width=[[0,0],[reach, reach]], mode="edge")
# y = np.pad(y, pad_width=[[0,0],[reach, reach]], mode="edge")

# _cost_matrix = cost_matrix(x=_x, y=_y, metric=metric,**metric_params)
# optimal_path = compute_min_return_path(cost_matrix=_cost_matrix)
# path_dtw_x, path_dtw_y = alignment_path_to_plot(path_dtw=optimal_path)

# fig = plt.figure(figsize=figsize)

# ax_x = fig.add_axes([0.1, 0.1, 0.2, 0.5])
# ax_y = fig.add_axes([0.1 + 0.25, 0.65, 0.5, 0.17])
# ax_matrix = fig.add_axes([0.1 + 0.25, 0.1, 0.5, 0.5])
# ax_cbar = fig.add_axes([0.1 + 0.25 + 0.37, 0.1, 0.2, 0.5])

# ax_x.plot(
# -x[channel_used,reach : len(x[channel_used]) - reach][::-1],
# np.arange(reach, len(x[channel_used]) - reach),
# lw=4,
# color="blue",
# )
# if reach > 0:
# ax_x.plot(-x[channel_used,::-1][channel_used,:reach], np.arange(reach), lw=4, color="green")
# ax_x.plot(
# -x[channel_used,::-1][len(x[channel_used]) - reach :],
# np.arange(len(x[channel_used]) - reach, len(x[channel_used])),
# lw=4,
# color="green",
# )

# ax_y.plot(
# np.arange(reach, len(y[channel_used]) - reach), y[channel_used,reach : len(y[channel_used]) - reach], lw=4, color="red"
# )
# if reach > 0:
# ax_y.plot(np.arange(reach), y[channel_used,:reach], lw=4, color="green")
# ax_y.plot(
# np.arange(len(y[channel_used]) - reach, len(y[channel_used])), y[channel_used,len(y[channel_used]) - reach :], lw=4, color="green"
# )

# ax_x.arrow(
# x=-np.max(x[channel_used]) - 0.5,
# y=len(x[channel_used]) - 1,
# dx=0,
# dy=-len(x[channel_used]) - 1,
# head_width=0.1,
# color="gray",
# )
# ax_x.text(x=-np.max(x[channel_used]) - 0.7, y=0, s="time", rotation="vertical")

# ax_y.arrow(
# x=0, y=np.max(y[channel_used]) + 0.5, dx=len(y[channel_used]) - 1, dy=0, head_width=0.1, color="gray"
# )
# ax_y.text(x=len(y[channel_used]) - 1, y=np.max(y[channel_used]) + 0.7, s="time", rotation="horizontal")

# im = ax_matrix.imshow(_cost_matrix, aspect="equal", cmap="cool", alpha=0.6)
# cbar = ax_cbar.figure.colorbar(im, ax=ax_cbar)
# cbar.set_label(label="Cost Matrix", size=15)

# ax_matrix.plot(path_dtw_y, path_dtw_x, color="black", lw=4)

# if show_warping_connections:
# for pair in optimal_path:

# i, j = pair[0], pair[1]
# i_mid, j_mid = i + reach, j + reach

# con_x = ConnectionPatch(
# (-x[channel_used,::-1][channel_used,len(x[channel_used]) - 1 - i_mid], len(x[channel_used]) - 1 - i_mid),
# (j, i),
# "data",
# "data",
# axesA=ax_x,
# axesB=ax_matrix,
# color="orange",
# linewidth=1,
# )

# con_y = ConnectionPatch(
# (j_mid, y[channel_used,j_mid]),
# (j, i),
# "data",
# "data",
# axesA=ax_y,
# axesB=ax_matrix,
# color="orange",
# linewidth=1,
# )

# ax_matrix.add_artist(con_x)
# ax_matrix.add_artist(con_y)

# ax_x.axis("OFF")
# ax_y.axis("OFF")
# ax_cbar.axis("OFF")

# fig.savefig(os.path.join(output_dir, metric + ".pdf"), bbox_inches="tight")


def draw_elastic_gif(
x: np.ndarray,
y: np.ndarray,
Expand Down
Binary file added exps/dtw-vis/ItalyPowerDemand/dtw.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified exps/dtw-vis/ItalyPowerDemand/dtw.pdf
Binary file not shown.

0 comments on commit 5331639

Please sign in to comment.