From 775d6011f12305ade82483c1ec759db80865000b Mon Sep 17 00:00:00 2001 From: jupfi Date: Fri, 26 Apr 2024 14:41:43 +0200 Subject: [PATCH] Moved apodization to measurement. --- src/nqrduck_measurement/controller.py | 2 +- .../signalprocessing_options.py | 37 +------------------ 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/src/nqrduck_measurement/controller.py b/src/nqrduck_measurement/controller.py index 776cbbe..1c61f93 100644 --- a/src/nqrduck_measurement/controller.py +++ b/src/nqrduck_measurement/controller.py @@ -220,7 +220,7 @@ class MeasurementController(ModuleController): logger.debug("Apodization function: %s", function) - apodized_measurement = dialog.apodization(function) + apodized_measurement = measurement.apodization(function) dialog.deleteLater() diff --git a/src/nqrduck_measurement/signalprocessing_options.py b/src/nqrduck_measurement/signalprocessing_options.py index 5746fdb..25efa2b 100644 --- a/src/nqrduck_measurement/signalprocessing_options.py +++ b/src/nqrduck_measurement/signalprocessing_options.py @@ -42,7 +42,7 @@ class Apodization(DuckFormBuilder): CustomFunction(), ] - self.duration = Decimal((measurement.tdx[-1] - measurement.tdx[0]) * 1e-6) + self.duration = (self.measurement.tdx[-1] - self.measurement.tdx[0]) * 1e-6 function_selection_field = DuckFormFunctionSelectionField( False, False, functions, self.duration, parent=parent, default_function=0 @@ -57,37 +57,4 @@ class Apodization(DuckFormBuilder): Function: The selected function. """ return self.get_values()[0] - - def apodization(self, function : Function) -> None: - """Apply the apodization function to the measurement the object has been created to. - - Args: - function (Function): The apodization function. - - Returns: - Measurement: The apodized measurement. - """ - - # Get the y data weights from the function - resolution = ( - self.measurement.tdx[1] - - self.measurement.tdx[0] - ) * 1e-6 - - logger.debug("Resolution: %s", resolution) - logger.debug("Resolution (Dec): %s", Decimal(resolution)) - - y_weight = function.get_pulse_amplitude(self.duration, Decimal(resolution)) - # Append the last value to the end of the array - y_weight = np.append(y_weight, y_weight[-1]) - - tdy_measurement = self.measurement.tdy * y_weight - - apodized_measurement = Measurement( - self.measurement.tdx, - tdy_measurement, - target_frequency=self.measurement.target_frequency, - IF_frequency=self.measurement.IF_frequency, - ) - - return apodized_measurement + \ No newline at end of file