mirror of
https://github.com/nqrduck/nqrduck-spectrometer-limenqr.git
synced 2024-11-09 11:10:03 +00:00
Fixed transmitting of multiple pulses.
This commit is contained in:
parent
2777e07df3
commit
ee0aef4011
1 changed files with 17 additions and 23 deletions
|
@ -2,6 +2,7 @@ import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from decimal import Decimal
|
||||||
from nqrduck.module.module_controller import ModuleController
|
from nqrduck.module.module_controller import ModuleController
|
||||||
from nqrduck_spectrometer.base_spectrometer_controller import BaseSpectrometerController
|
from nqrduck_spectrometer.base_spectrometer_controller import BaseSpectrometerController
|
||||||
from nqrduck_spectrometer.measurement import Measurement
|
from nqrduck_spectrometer.measurement import Measurement
|
||||||
|
@ -26,7 +27,7 @@ class LimeNQRController(BaseSpectrometerController):
|
||||||
from .contrib.limr import limr
|
from .contrib.limr import limr
|
||||||
|
|
||||||
self_path = Path(__file__).parent
|
self_path = Path(__file__).parent
|
||||||
driver_path = str(self_path / "contrib/pulseN_test_USB_TX2.cpp")
|
driver_path = str(self_path / "contrib/pulseN_test_USB.cpp")
|
||||||
lime = limr(driver_path)
|
lime = limr(driver_path)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
logger.error("Error while importing limr. %s", e)
|
logger.error("Error while importing limr. %s", e)
|
||||||
|
@ -79,7 +80,7 @@ class LimeNQRController(BaseSpectrometerController):
|
||||||
|
|
||||||
# time domain x and y data
|
# time domain x and y data
|
||||||
tdx = lime.HDF.tdx[evidx] - lime.HDF.tdx[evidx][0]
|
tdx = lime.HDF.tdx[evidx] - lime.HDF.tdx[evidx][0]
|
||||||
tdy = lime.HDF.tdy[evidx] / lime.nav
|
tdy = np.abs(lime.HDF.tdy[evidx] / lime.nav)
|
||||||
|
|
||||||
measurement_data = Measurement(
|
measurement_data = Measurement(
|
||||||
tdx,
|
tdx,
|
||||||
|
@ -211,31 +212,24 @@ class LimeNQRController(BaseSpectrometerController):
|
||||||
# This leads to a default offset of 300 samples for the first pulse
|
# This leads to a default offset of 300 samples for the first pulse
|
||||||
lime.pof = [self.module.model.OFFSET_FIRST_PULSE]
|
lime.pof = [self.module.model.OFFSET_FIRST_PULSE]
|
||||||
lime.pof += [
|
lime.pof += [
|
||||||
int(pulse_shape.resolution * lime.sra)
|
int(pulse_shape.resolution * Decimal(lime.sra))
|
||||||
for i in range(len(pulse_amplitude) -1)
|
for i in range(len(pulse_amplitude) -1)
|
||||||
]
|
]
|
||||||
# Add the TX pulse phase to the pulse phase list (lime.pph) -> not yet implemented
|
# Add the TX pulse phase to the pulse phase list (lime.pph) -> not yet implemented
|
||||||
else:
|
else:
|
||||||
logger.debug("Adding TX pulse to existing pulse sequence")
|
logger.debug("Adding TX pulse to existing pulse sequence")
|
||||||
logger.debug(
|
lime.pfr += [
|
||||||
"Setting if frequency to: %s",
|
|
||||||
self.module.model.if_frequency,
|
|
||||||
)
|
|
||||||
lime.pfr.append(
|
|
||||||
[
|
|
||||||
float(self.module.model.if_frequency)
|
float(self.module.model.if_frequency)
|
||||||
for i in range(len(pulse_amplitude))
|
for i in range(len(pulse_amplitude))
|
||||||
]
|
]
|
||||||
)
|
|
||||||
logger.debug("Setting pulse duration to: %s", event.duration)
|
lime.pdr += [
|
||||||
lime.pdr.append(
|
|
||||||
[
|
|
||||||
float(pulse_shape.resolution)
|
float(pulse_shape.resolution)
|
||||||
for i in range(len(pulse_amplitude))
|
for i in range(len(pulse_amplitude))
|
||||||
]
|
]
|
||||||
)
|
|
||||||
# Setting pulse amplitude
|
# Setting pulse amplitude
|
||||||
lime.pam.append(list(pulse_amplitude))
|
lime.pam += list(pulse_amplitude)
|
||||||
# Get the length of the previous event without a tx pulse
|
# Get the length of the previous event without a tx pulse
|
||||||
blank = []
|
blank = []
|
||||||
previous_events = events[: events.index(event)]
|
previous_events = events[: events.index(event)]
|
||||||
|
@ -247,7 +241,7 @@ class LimeNQRController(BaseSpectrometerController):
|
||||||
prev_event.name,
|
prev_event.name,
|
||||||
prev_event.duration,
|
prev_event.duration,
|
||||||
)
|
)
|
||||||
for parameter in prev_event.parameters:
|
for parameter in prev_event.parameters.values():
|
||||||
if (
|
if (
|
||||||
parameter.name == self.module.model.TX
|
parameter.name == self.module.model.TX
|
||||||
and parameter.get_option_by_name(
|
and parameter.get_option_by_name(
|
||||||
|
@ -273,10 +267,10 @@ class LimeNQRController(BaseSpectrometerController):
|
||||||
prev_duration = lime.pdr[-2] + sum(blank)
|
prev_duration = lime.pdr[-2] + sum(blank)
|
||||||
|
|
||||||
logger.debug("Setting pulse offset to: %s", prev_duration)
|
logger.debug("Setting pulse offset to: %s", prev_duration)
|
||||||
lime.pof.append(np.ceil(prev_duration * lime.sra))
|
lime.pof.append(int(np.ceil(prev_duration * lime.sra)))
|
||||||
lime.pof.append += [
|
lime.pof += [
|
||||||
int(pulse_shape.resolution * lime.sra)
|
int(float(pulse_shape.resolution) * lime.sra)
|
||||||
for i in range(len(pulse_amplitude))
|
for i in range(len(pulse_amplitude) - 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
# The last event is the repetition time event
|
# The last event is the repetition time event
|
||||||
|
@ -323,7 +317,7 @@ class LimeNQRController(BaseSpectrometerController):
|
||||||
|
|
||||||
rx_begin = previous_events_duration + offset + CORRECTION_FACTOR
|
rx_begin = previous_events_duration + offset + CORRECTION_FACTOR
|
||||||
if rx_duration:
|
if rx_duration:
|
||||||
rx_stop = rx_begin + rx_duration
|
rx_stop = rx_begin + float(rx_duration)
|
||||||
return rx_begin * 1e6, rx_stop * 1e6
|
return rx_begin * 1e6, rx_stop * 1e6
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue