Moved apodization to measurement.

This commit is contained in:
jupfi 2024-04-26 14:41:43 +02:00
parent c9e3dd1f44
commit 775d6011f1
2 changed files with 3 additions and 36 deletions

View file

@ -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()

View file

@ -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