diff --git a/cli/src/xyfigure/xymodel.py b/cli/src/xyfigure/xymodel.py index 04f8745..ded1ac1 100644 --- a/cli/src/xyfigure/xymodel.py +++ b/cli/src/xyfigure/xymodel.py @@ -46,12 +46,8 @@ def cross_correlation(reference, subject, verbose=False): print( f" Reference [t_min, t_max] by dt (s): [{ref_t_min}, {ref_t_max}] by {ref_delta_t}" ) - print( - f" Subject [t_min, t_max] by dt (s): [{t_min}, {t_max}] by {dt}" - ) - print( - f" Globalized [t_min, t_max] by dt (s): [{T_MIN}, {T_MAX}] by {DT}" - ) + print(f" Subject [t_min, t_max] by dt (s): [{t_min}, {t_max}] by {dt}") + print(f" Globalized [t_min, t_max] by dt (s): [{T_MIN}, {T_MAX}] by {DT}") print(f" Globalized times: {t_span}") print(f" Length of globalized times: {len(t_span)}") @@ -59,9 +55,7 @@ def cross_correlation(reference, subject, verbose=False): t_span, reference[:, 0], reference[:, 1], left=0.0, right=0.0 ) - y_span = np.interp( - t_span, subject[:, 0], subject[:, 1], left=0.0, right=0.0 - ) + y_span = np.interp(t_span, subject[:, 0], subject[:, 1], left=0.0, right=0.0) cross_corr = np.correlate(ref_y_span, y_span, mode="full") cross_corr_max = np.max(cross_corr) @@ -72,9 +66,7 @@ def cross_correlation(reference, subject, verbose=False): mode="full", ) - ref_self_corr = np.correlate(ref_y_span, ref_y_span)[ - 0 - ] # self correlated reference + ref_self_corr = np.correlate(ref_y_span, ref_y_span)[0] # self correlated reference rel_corr_error = 0.0 if ref_self_corr > 0: @@ -90,12 +82,8 @@ def cross_correlation(reference, subject, verbose=False): T_MIN_CORR = np.minimum(ref_t_min, t_shift[0]) T_MAX_CORR = np.maximum(ref_t_max, t_shift[-1]) - n_samples_corr = ( - int((T_MAX_CORR - T_MIN_CORR) / DT) + 1 - ) # DT unchanged pre-shift - t_span_corr = np.linspace( - T_MIN_CORR, T_MAX_CORR, n_samples_corr, endpoint=True - ) + n_samples_corr = int((T_MAX_CORR - T_MIN_CORR) / DT) + 1 # DT unchanged pre-shift + t_span_corr = np.linspace(T_MIN_CORR, T_MAX_CORR, n_samples_corr, endpoint=True) ref_y_span_corr = np.interp( t_span_corr, reference[:, 0], reference[:, 1], left=0.0, right=0.0 @@ -111,9 +99,7 @@ def cross_correlation(reference, subject, verbose=False): print("\nCorrelation...") print(f" Sliding dot product (cross-correlation): {cross_corr}") print(f" Length of the sliding dot product: {len(cross_corr)}") - print( - f" Max sliding dot product (cross-correlation): {cross_corr_max}" - ) + print(f" Max sliding dot product (cross-correlation): {cross_corr_max}") print( f" Sliding dot product of normalized signals (cross-correlation): {cross_corr_unit}" ) @@ -316,8 +302,8 @@ def correlation(self, value): usecols=(ref_xcolumn, ref_ycolumn), ) - tcorrelated, ycorrelated, cc_relative_error, L2_error = ( - cross_correlation(ref_data, self._data, verbose=verbosity) + tcorrelated, ycorrelated, cc_relative_error, L2_error = cross_correlation( + ref_data, self._data, verbose=verbosity ) self._data = np.transpose([tcorrelated, ycorrelated]) # overwrite @@ -350,9 +336,7 @@ def gradient(self, value): # https://docs.scipy.org/doc/numpy/reference/generated/numpy.gradient.html # for k in range(value): for k in range(gradient_order): - ydot = np.gradient( - self._data[:, 1], self._data[:, 0], edge_order=2 - ) + ydot = np.gradient(self._data[:, 1], self._data[:, 0], edge_order=2) self._data[:, 1] = ydot # overwrite if self._verbose: print(f" Derivative {k+1} completed.") @@ -404,9 +388,7 @@ def integration(self, value): # + ics[k] # ) inty = ( - cumulative_trapezoid( - self._data[:, 1], self._data[:, 0], initial=0 - ) + cumulative_trapezoid(self._data[:, 1], self._data[:, 0], initial=0) + ics[k] ) @@ -522,18 +504,10 @@ def __init__(self, guid, **kwargs): } self._plot_kwargs = kwargs.get("plot_kwargs", _default) self._alpha = self._plot_kwargs.get("alpha", _default["alpha"]) - self._edgecolor = self._plot_kwargs.get( - "edgecolor", _default["edgecolor"] - ) - self._facecolor = self._plot_kwargs.get( - "facecolor", _default["facecolor"] - ) - self._linestyle = self._plot_kwargs.get( - "linestyle", _default["linestyle"] - ) - self._linewidth = self._plot_kwargs.get( - "linewidth", _default["linewidth"] - ) + self._edgecolor = self._plot_kwargs.get("edgecolor", _default["edgecolor"]) + self._facecolor = self._plot_kwargs.get("facecolor", _default["facecolor"]) + self._linestyle = self._plot_kwargs.get("linestyle", _default["linestyle"]) + self._linewidth = self._plot_kwargs.get("linewidth", _default["linewidth"]) """