From fd52d6bbde9b8f1d03383fecd206667b7d6539e5 Mon Sep 17 00:00:00 2001 From: zerafachris PERSONAL Date: Tue, 28 May 2024 23:17:50 +0200 Subject: [PATCH] scattering: plot_scattering_coefficients_normalisation --- scatcluster/processing/scattering.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scatcluster/processing/scattering.py b/scatcluster/processing/scattering.py index ec9c1a2..a218097 100644 --- a/scatcluster/processing/scattering.py +++ b/scatcluster/processing/scattering.py @@ -621,6 +621,31 @@ def load_scattering_coefficients_xarray(self): self.scattering_coefficients_xarray = scat_coeff_xr return scat_coeff_xr + + def plot_scattering_coefficients_normalisation(self): + """ + Plot the normalization of scattering coefficients. + This function loads the scattering coefficients from an xarray dataset file and plots the normalization of the coefficients. The plot is saved as a PNG file in the specified directory. + + Parameters: + self (object): The instance of the class. + + Returns: + None + """ + scat_vec = self.vectorize_scattering_coefficients_xarray(self.load_scattering_coefficients_xarray()) + _, axs = plt.subplots(1, 1, figsize=(10, 7)) + for col in range(scat_vec.shape[1]): + axs.plot(scat_vec[col], 'b', alpha=0.1) + plt.title(f'{self.data_network}_{self.data_station}_{self.data_location}_{self.network_name}\n' + 'Scattering Coefficients Normalization') + + plt.savefig( + f'{self.data_network}_{self.data_station}_{self.data_location}_{self.network_name}_Scattering_Coefficients_Normalization.png') + + plt.show() + + def preload_times(self): """ Preloads the times data from a numpy file and assigns it to the `data_times` attribute of the class.