mirror of
https://github.com/nqrduck/quackseq-limenqr.git
synced 2024-11-18 09:31:01 +00:00
Updated return in case of failed measurement to None.
This commit is contained in:
parent
f2f83a4b5e
commit
72ae23080b
2 changed files with 14 additions and 9 deletions
|
@ -28,17 +28,18 @@ class LimeNQRController(SpectrometerController):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.limenqr = limenqr
|
self.limenqr = limenqr
|
||||||
|
|
||||||
def run_sequence(self, sequence: QuackSequence):
|
def run_sequence(self, sequence: QuackSequence) -> Measurement:
|
||||||
"""Starts the measurement procedure."""
|
"""Starts the measurement procedure."""
|
||||||
lime = self.initialize_lime(sequence)
|
lime = self.initialize_lime(sequence)
|
||||||
if lime is None:
|
if lime is None:
|
||||||
# Emit error message
|
# Emit error message
|
||||||
logger.error("Error initializing Lime driver")
|
logger.error("Error initializing Lime driver")
|
||||||
return -1
|
return None
|
||||||
|
|
||||||
elif lime.Npulses == 0:
|
elif lime.Npulses == 0:
|
||||||
# Emit error message
|
# Emit error message
|
||||||
logger.error("No pulses in the pulse sequence")
|
logger.error("No pulses in the pulse sequence")
|
||||||
return -1
|
return None
|
||||||
|
|
||||||
self.setup_lime_parameters(lime, sequence)
|
self.setup_lime_parameters(lime, sequence)
|
||||||
self.setup_temporary_storage(lime)
|
self.setup_temporary_storage(lime)
|
||||||
|
@ -52,18 +53,22 @@ class LimeNQRController(SpectrometerController):
|
||||||
|
|
||||||
measurement_data = self.process_measurement_results(lime, sequence)
|
measurement_data = self.process_measurement_results(lime, sequence)
|
||||||
|
|
||||||
|
if not measurement_data:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
# Resample the RX data to the dwell time settings
|
# Resample the RX data to the dwell time settings
|
||||||
dwell_time = self.limenqr.model.settings.rx_dwell_time
|
dwell_time = self.limenqr.model.settings.rx_dwell_time
|
||||||
|
|
||||||
dwell_time = UnitConverter.to_float(dwell_time) * 1e6
|
dwell_time = UnitConverter.to_float(dwell_time) * 1e6
|
||||||
logger.debug("Dwell time: %s", dwell_time)
|
logger.debug("Dwell time: %s", dwell_time)
|
||||||
logger.debug(f"Last tdx value: {measurement_data.tdx[-1]}")
|
logger.debug(f"Last tdx value: {measurement_data.tdx[-1][-1]}")
|
||||||
|
|
||||||
if dwell_time:
|
if dwell_time:
|
||||||
n_data_points = int(measurement_data.tdx[-1] / dwell_time)
|
n_data_points = int(measurement_data.tdx[-1][-1] / dwell_time)
|
||||||
logger.debug("Resampling to %s data points", n_data_points)
|
logger.debug("Resampling to %s data points", n_data_points)
|
||||||
tdx = np.linspace(
|
tdx = np.linspace(
|
||||||
0, measurement_data.tdx[-1], n_data_points, endpoint=False
|
0, measurement_data.tdx[-1][-1], n_data_points, endpoint=False
|
||||||
)
|
)
|
||||||
tdy = resample(measurement_data.tdy, n_data_points)
|
tdy = resample(measurement_data.tdy, n_data_points)
|
||||||
name = measurement_data.name
|
name = measurement_data.name
|
||||||
|
|
|
@ -45,9 +45,9 @@ class TestQuackSequence(unittest.TestCase):
|
||||||
|
|
||||||
result = lime.run_sequence(seq)
|
result = lime.run_sequence(seq)
|
||||||
|
|
||||||
plt.plot(result.tdx, result.tdy.imag)
|
plt.plot(result.tdx[-1], result.tdy[-1].imag)
|
||||||
plt.plot(result.tdx, result.tdy.real)
|
plt.plot(result.tdx[-1], result.tdy[-1].real)
|
||||||
plt.plot(result.tdx, np.abs(result.tdy))
|
plt.plot(result.tdx[-1], np.abs(result.tdy[-1]))
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue