Skip to content

Commit

Permalink
anomaly correlation yml works!
Browse files Browse the repository at this point in the history
  • Loading branch information
hovey committed Dec 17, 2024
1 parent aea53fe commit 91fb141
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cli/src/xyfigure/xymodel.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# https://www.python.org/dev/peps/pep-0008/#imports
# standard library imports
import os
# import os
import sys

# related third-party imports
import numpy as np
from pathlib import Path
from scipy import signal

# from scipy.integrate import cumtrapz # version 0.14.0, now deprecated
Expand All @@ -14,7 +15,8 @@
# local application/library specific imports
# from xyfigure.xybase import XYBase
# from xyfigure.code.xybase import XYBase
from xyfigure.xybase import XYBase, absolute_path
# from xyfigure.xybase import XYBase, absolute_path
from xyfigure.xybase import XYBase


# Helper functions
Expand Down Expand Up @@ -285,8 +287,10 @@ def correlation(self, value):
print('Error: keyword "file" not found.')
sys.exit("Abnormal termination.")

abs_path = absolute_path(ref_folder)
ref_path_file_input = os.path.join(abs_path, ref_file)
# abs_path = absolute_path(ref_folder)
abs_path = Path(ref_folder).expanduser()
# ref_path_file_input = os.path.join(abs_path, ref_file)
ref_path_file_input = abs_path.joinpath(ref_file)

ref_skip_rows = reference.get("skip_rows", 0)
ref_skip_rows_footer = reference.get("skip_rows_footer", 0)
Expand Down
81 changes: 81 additions & 0 deletions cli/tests/correlation/anomaly_recipe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
signal_a:
class: model
folder: ~/sibl/cli/tests/correlation
file: signal_a.csv
skip_rows: 1
ycolumn: 1
plot_kwargs:
label: reference signal a
color: red
linewidth: 3
linestyle: "--"
marker: D
alpha: 0.9
signal_b:
class: model
folder: ~/sibl/cli/tests/correlation
file: signal_b.csv
skip_rows: 1
ycolumn: 1
plot_kwargs:
label: subject signal b
color: darkcyan
linewidth: 1
linestyle: "-"
marker: o
alpha: 0.8
signal_b_correlated:
class: model
folder: ~/sibl/cli/tests/correlation
file: signal_b.csv
skip_rows: 1
ycolumn: 1
plot_kwargs:
label: subject signal b
color: darkcyan
linewidth: 1
linestyle: "-"
marker: o
alpha: 0.8
signal_process:
process1:
correlation:
reference:
folder: ~/sibl/cli/tests/correlation
file: signal_a.csv
skip_rows: 1
ycolumn: 1
verbose: true
serialize: false
folder: ~/sibl/cli/tests/correlation
file: out_signal_b_correlated.csv
figure_1:
class: view
model_keys: [ signal_a, signal_b ]
folder: ~/sibl/cli/tests/correlation
file: out_anomaly_pre_corr.png
title: Anomaly site example, pre-correlation
xlabel: time (s)
ylabel: position (m)
xlim: [ -1, 22 ]
ylim: [ -1, 5 ]
size: [ 8.0, 6.0 ]
dpi: 100
display: true
details: false
serialize: true
figure_2:
class: view
model_keys: [ signal_a, signal_b_correlated ]
folder: ~/sibl/cli/tests/correlation
file: out_anomaly_post_corr.png
title: Anomaly site example, post-correlation
xlabel: time (s)
ylabel: position (m)
xlim: [ -1, 22 ]
ylim: [ -1, 5 ]
size: [ 8.0, 6.0 ]
dpi: 100
display: true
details: false
serialize: true

0 comments on commit 91fb141

Please sign in to comment.