From d88011cd10e98bbc8677550d38527d443abf15ca Mon Sep 17 00:00:00 2001 From: tensionhead Date: Wed, 17 May 2023 17:24:11 +0200 Subject: [PATCH 1/4] NEW: Batch export individual Fourier estimates to csv - addresses #21 --- pyboat/ui/batch_process.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/pyboat/ui/batch_process.py b/pyboat/ui/batch_process.py index 0775eec..9cb677a 100644 --- a/pyboat/ui/batch_process.py +++ b/pyboat/ui/batch_process.py @@ -85,9 +85,9 @@ def initUI(self, wlet_pars): self.cb_plot_global_spec = QCheckBox("Global Wavelet Spectrum") self.cb_plot_global_spec.setStatusTip("Ensemble averaged Wavelet spectrum") - self.cb_plot_Fourier_dis = QCheckBox("Global Fourier Estimate") + self.cb_plot_Fourier_dis = QCheckBox("Ensemble Fourier Estimate") self.cb_plot_Fourier_dis.setStatusTip( - "Ensemble median and quartiles of the time averaged Wavelet spectra" + "Plots median and quartiles of the ensemble Fourier power spectral distribution" ) self.cb_power_hist = QCheckBox("Ridge Power Histogram") @@ -183,11 +183,17 @@ def initUI(self, wlet_pars): "Saves period, amplitude, power and phase summary statistics to csv files" ) - self.cb_save_Fourier_dis = QCheckBox("Global Fourier Estimate") + self.cb_Fourier_avg = QCheckBox("Fourier Estimates") + self.cb_Fourier_avg.setStatusTip( + "Saves one Fourier power spectral estimate per signal" + ) + + self.cb_save_Fourier_dis = QCheckBox("Ensemble Fourier Estimate") self.cb_save_Fourier_dis.setStatusTip( "Saves median and quartiles of the ensemble Fourier power spectral distribution" ) + export_data = QGroupBox("Export Data") export_data.setStatusTip("Creates csv files") @@ -199,8 +205,9 @@ def initUI(self, wlet_pars): lo.addWidget(self.cb_filtered_sigs, 0, 0) lo.addWidget(self.cb_readout, 1, 0) lo.addWidget(self.cb_sorted_powers, 2, 0) - lo.addWidget(self.cb_save_ensemble_dynamics, 3, 0) + lo.addWidget(self.cb_Fourier_est, 3, 0) lo.addWidget(self.cb_save_Fourier_dis, 4, 0) + lo.addWidget(self.cb_save_ensemble_dynamics, 5, 0) export_data.setLayout(lo) @@ -537,6 +544,7 @@ def do_the_loop(self, norm_vec): # ensemble averaged wavelet spectrum global_modulus = np.zeros((len(periods), len(norm_vec))) + # TODO: parallelize for i, signal_id in enumerate(self.parentDV.df): # log to terminal @@ -671,6 +679,16 @@ def do_the_loop(self, norm_vec): fname, sep=",", float_format=float_format, index=False ) + if self.cb_Fourier_est.isChecked(): + + fname = os.path.join(OutPath, f"{signal_id}_fourier.csv") + if self.debug: + print(f"Saving fourier estimate to {fname}") + + df_fouriers[signal_id].to_csv( + fname, sep=",", float_format=float_format, index=True + ) + self.progress.setValue(i) if EmptyRidge > 0: @@ -816,7 +834,7 @@ def __init__(self, modulus, time_unit, dataset_name="", parent=None): def initUI(self, dataset_name): - self.setWindowTitle(f"Global Wavelet Spectrum - {dataset_name}") + self.setWindowTitle(f"Ensemble Wavelet Spectrum - {dataset_name}") self.setGeometry(410, 360, 700, 500) Canvas = mkGenericCanvas() From d4128baa6cdc063c979e1c2d73953a5ad7405481 Mon Sep 17 00:00:00 2001 From: tensionhead Date: Wed, 17 May 2023 17:32:28 +0200 Subject: [PATCH 2/4] CHG: Colorbar text rotation matplotlib API - apparently works for both mpl < 3.5 and mpl > 3.6 - closes #16 --- pyboat/plotting.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyboat/plotting.py b/pyboat/plotting.py index 977c2d8..27ee2ec 100644 --- a/pyboat/plotting.py +++ b/pyboat/plotting.py @@ -333,8 +333,8 @@ def plot_signal_modulus(axs, time_vector, signal, modulus, periods, p_max=None): ) cb.set_ticks(cb_ticks) cb.ax.set_xticklabels(cb_ticks, fontsize=tick_label_size) - # cb.set_label('$|\mathcal{W}_{\Psi}(t,T)|^2$',rotation = '0',labelpad = 5,fontsize = 15) - cb.set_label("Wavelet Power", rotation="0", labelpad=-12, fontsize=0.9 * label_size) + # cb.set_label('$|\mathcal{W}_{\Psi}(t,T)|^2$', rotation = "horizontal",labelpad = 5,fontsize = 15) + cb.set_label("Wavelet Power", rotation="horizontal", labelpad=-12, fontsize=0.9 * label_size) def plot_modulus(mod_ax, time_vector, modulus, periods, p_max=None): @@ -364,8 +364,8 @@ def plot_modulus(mod_ax, time_vector, modulus, periods, p_max=None): ) cb.set_ticks(cb_ticks) cb.ax.set_xticklabels(cb_ticks, fontsize=tick_label_size) - # cb.set_label('$|\mathcal{W}_{\Psi}(t,T)|^2$',rotation = '0',labelpad = 5,fontsize = 15) - cb.set_label("Wavelet Power", rotation="0", labelpad=-12, fontsize=0.9 * label_size) + # cb.set_label('$|\mathcal{W}_{\Psi}(t,T)|^2$',rotation = 'horizontal',labelpad = 5,fontsize = 15) + cb.set_label("Wavelet Power", rotation="horizontal", labelpad=-12, fontsize=0.9 * label_size) def draw_Wavelet_ridge(ax, ridge_data, marker_size=1.5): From bd6d0ad6a4f0f9a69870f85575fdca4953c5dc8c Mon Sep 17 00:00:00 2001 From: tensionhead Date: Wed, 17 May 2023 17:49:32 +0200 Subject: [PATCH 3/4] CHG: Bump version number --- pyboat/__init__.py | 2 +- pyboat/ui/batch_process.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyboat/__init__.py b/pyboat/__init__.py index 74cdfa2..f99f702 100644 --- a/pyboat/__init__.py +++ b/pyboat/__init__.py @@ -4,7 +4,7 @@ import os import argparse -__version__ = "0.9.11" +__version__ = "0.9.12" # the object oriented API from .api import WAnalyzer diff --git a/pyboat/ui/batch_process.py b/pyboat/ui/batch_process.py index 9cb677a..544c461 100644 --- a/pyboat/ui/batch_process.py +++ b/pyboat/ui/batch_process.py @@ -183,8 +183,8 @@ def initUI(self, wlet_pars): "Saves period, amplitude, power and phase summary statistics to csv files" ) - self.cb_Fourier_avg = QCheckBox("Fourier Estimates") - self.cb_Fourier_avg.setStatusTip( + self.cb_Fourier_est = QCheckBox("Fourier Estimates") + self.cb_Fourier_est.setStatusTip( "Saves one Fourier power spectral estimate per signal" ) From d8defd5c85c42130cf5d8b9a91fde2cdd4ff2ba1 Mon Sep 17 00:00:00 2001 From: tensionhead Date: Mon, 5 Jun 2023 11:50:15 +0200 Subject: [PATCH 4/4] CHG: Save individual Fourier estimates into one file - better solution to #21 --- pyboat/ui/batch_process.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pyboat/ui/batch_process.py b/pyboat/ui/batch_process.py index 544c461..e4a6ea8 100644 --- a/pyboat/ui/batch_process.py +++ b/pyboat/ui/batch_process.py @@ -169,7 +169,7 @@ def initUI(self, wlet_pars): self.cb_readout = QCheckBox("Ridge Readouts") self.cb_readout.setStatusTip( - "Saves one analysis result per signal to disc as csv" + "Saves one ridge analysis result per signal to disc as csv" ) self.cb_readout_plots = QCheckBox("Ridge Readout Plots") @@ -185,15 +185,14 @@ def initUI(self, wlet_pars): self.cb_Fourier_est = QCheckBox("Fourier Estimates") self.cb_Fourier_est.setStatusTip( - "Saves one Fourier power spectral estimate per signal" + "Saves individual Fourier power spectral estimates" ) - self.cb_save_Fourier_dis = QCheckBox("Ensemble Fourier Estimate") + self.cb_save_Fourier_dis = QCheckBox("Global Fourier Estimate") self.cb_save_Fourier_dis.setStatusTip( "Saves median and quartiles of the ensemble Fourier power spectral distribution" ) - export_data = QGroupBox("Export Data") export_data.setStatusTip("Creates csv files") @@ -384,6 +383,16 @@ def run_batch(self): # --- Fourier Distribution Outputs --- + if self.cb_Fourier_est.isChecked(): + + fname = os.path.join(OutPath, f"{dataset_name}_fourier-estimates.csv") + if self.debug: + print(f"Saving fourier estimate to {fname}") + + df_fouriers.to_csv( + fname, sep=",", float_format=float_format, index=True + ) + if self.cb_plot_Fourier_dis.isChecked(): self.fdw = FourierDistributionWindow( @@ -679,16 +688,6 @@ def do_the_loop(self, norm_vec): fname, sep=",", float_format=float_format, index=False ) - if self.cb_Fourier_est.isChecked(): - - fname = os.path.join(OutPath, f"{signal_id}_fourier.csv") - if self.debug: - print(f"Saving fourier estimate to {fname}") - - df_fouriers[signal_id].to_csv( - fname, sep=",", float_format=float_format, index=True - ) - self.progress.setValue(i) if EmptyRidge > 0: