LINTag Jupyter Notebook¶
A small demo to showcase how to remote control the LINTag and LINTag Capture from python.
Load modules¶
This example illustrates, how to use the LINTag from a Jupyter notebook, by remote controlling a running LINTag Capture instance.
For this example, we need the photonscore
module loaded as pe
.
Additionaly, we need numpy
and matplotlib
.
In [9]:
Copied!
import photonscore as pe
import numpy as np
import matplotlib.pyplot as plt
import photonscore as pe
import numpy as np
import matplotlib.pyplot as plt
Initialize the connection to LINTag Capture and the LINTag¶
By creating a device handle called LINTagDevice
, i.e. an instance of the LINTag
class. We can interface with a running instance of LINTag Capture. The default port for this connection is 5556
.
In [10]:
Copied!
LINTagDevice = pe.LINTag("localhost:5556")
LINTagDevice = pe.LINTag("localhost:5556")
Status¶
The Status submodule allows to query the current LINTag Status/Telemetry and its Profile, containing the serial number
Telemetry¶
In [11]:
Copied!
Telemetry = LINTagDevice.status.get_telemetry()
Telemetry
Telemetry = LINTagDevice.status.get_telemetry()
Telemetry
Out[11]:
{'run_id': 'dwkan06y9pjdkytunfztsruf8', 'runtime': 2223, 'up_id': 'aa7c809a-ef12-4c39-ad4b-d0e91bfd05ff', 'uptime': 2226, 'fpga_build_time': {'ticks': '638518269030000000'}, 'fpga_temperature': 45.33212883529663, 'cps': {'0': 0.9999999999999999, '1': 0.0, '7': 0.9999999999999999, '6': 0.0, '4': 0.0, '2': 0.0, '3': 0.0, '5': 0.0}, 'counts_per_ms': {'4': {'values': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, '1': {'values': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, '7': {'values': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}, '6': {'values': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, '0': {'values': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}, '2': {'values': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, '3': {'values': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, '5': {'values': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}, 'clock_failure_message': ''}
Profile¶
In [12]:
Copied!
Profile = LINTagDevice.status.get_profile()
Profile
Profile = LINTagDevice.status.get_profile()
Profile
Out[12]:
{'system_guid': 'tag15slxy6v4wcyc8gkyb8vk6', 'serial_number': 'J811-S303', 'electronics_sn': '08bfb84f44dd', 'number_of_channels': 0, 'taps': {}, 'taps_inverted': {}}
Settings¶
Get current Settings for a specific channel¶
In [13]:
Copied!
Settings = LINTagDevice.settings.get_channel(0)
Settings
Settings = LINTagDevice.settings.get_channel(0)
Settings
Out[13]:
{'nim_nttl': True, 'threshold_v': -0.5, 'rising_edge': True, 'falling_edge': False, 'offset_ps': '0', 'dead_time_ps': 0, 'prolonged_dead_time': False, 'static_calibration': False}
Set new Settings for a specific channel¶
In [14]:
Copied!
LINTagDevice.settings.set_channel(1,
threshold_v=-0.5,
rising_edge=False,
falling_edge=False,
nim_nttl=True,
)
LINTagDevice.settings.set_channel(1,
threshold_v=-0.5,
rising_edge=False,
falling_edge=False,
nim_nttl=True,
)
Set IP-Address in connected LINTag Capture¶
In [15]:
Copied!
LINTagDevice.settings.set_lintag_ip_address("http://192.168.8.31:10032")
LINTagDevice.settings.set_lintag_ip_address("http://192.168.8.31:10032")
Correlator¶
Retrieve Correlator Settings and State¶
In [16]:
Copied!
CorrelatorSettings = LINTagDevice.correlator.get_correlator_settings()
print(CorrelatorSettings)
CorrelatorSettings = LINTagDevice.correlator.get_correlator_settings()
print(CorrelatorSettings)
{'start_channel': 0, 'start_slope': 'RISING', 'stop_channel': 7, 'stop_slope': 'RISING', 'window_ps': 50000, 'correlator_type': 'START_STOP', 'bin_size': 'FIVE_PS', 'is_correlating': True}
Set Correlator Settings¶
In [17]:
Copied!
LINTagDevice.correlator.set_correlator_settings(
correlator_type = "START_STOP",
window_ps = 50000,
start_channel=0,
start_slope="RISING",
stop_channel=7,
bin_size="TEN_PS",
)
LINTagDevice.correlator.set_correlator_settings(
correlator_type = "START_STOP",
window_ps = 50000,
start_channel=0,
start_slope="RISING",
stop_channel=7,
bin_size="TEN_PS",
)
Retrieve Current Histogram¶
In [18]:
Copied!
bins, values = LINTagDevice.correlator.get_histogram()
plt.figure()
plt.plot(bins, values, "o")
plt.show()
bins, values = LINTagDevice.correlator.get_histogram()
plt.figure()
plt.plot(bins, values, "o")
plt.show()
Clear Current Histogram¶
In [19]:
Copied!
LINTagDevice.correlator.clear_histogram()
LINTagDevice.correlator.clear_histogram()
Time scheduled measurements¶
In [20]:
Copied!
# load all the needed packages
import time
import photonscore as pe
import numpy as np
import matplotlib.pyplot as plt
# set up device
LINTagDevice = pe.LINTag("localhost:5556")
LINTagDevice.settings.set_lintag_ip_address("http://192.168.8.31:10032")
# set up channels for measurement
LINTagDevice.settings.set_channel(0, threshold_v=-0.5, nim_nttl=True, rising_edge=True, falling_edge=False)
LINTagDevice.settings.set_channel(7, threshold_v=-0.5, nim_nttl=True, rising_edge=True, falling_edge=False)
# disable all other channels, to not pollute the network interface, important especially for high-throughput measurements
for i in [1,2,3,4,5,6]:
LINTagDevice.settings.set_channel(i, threshold_v=0.0, nim_nttl=True, rising_edge=False, falling_edge=False)
# set up correlator
LINTagDevice.correlator.set_correlator_settings(
window_ps = 50000,
bin_size="FIVE_PS",
correlator_type="START_STOP",
is_correlating=True,
start_channel=0,
start_slope="RISING",
stop_channel=7,
stop_slope="RISING",
)
# do sth. 3 times, change things between
for i in range(3):
# clear the histogram to get startet
LINTagDevice.correlator.clear_histogram()
# let the measurement run for i * 2s + 2s
time.sleep(i*3+1)
# retrieve the histogram
bins, values = LINTagDevice.correlator.get_histogram()
errors = np.sqrt(values)
# plot it
plt.figure()
plt.errorbar(bins, values, yerr=errors, fmt="o-", label="data & error")
plt.title("Plot No. " + str(i+1))
plt.xlim(-0.55, -0.35)
plt.legend(loc="best")
plt.show()
# Do sth. else, e.g. changing LINTag configuration, or changing sth. in your experimental setup
# Setup.Change(i)
# load all the needed packages
import time
import photonscore as pe
import numpy as np
import matplotlib.pyplot as plt
# set up device
LINTagDevice = pe.LINTag("localhost:5556")
LINTagDevice.settings.set_lintag_ip_address("http://192.168.8.31:10032")
# set up channels for measurement
LINTagDevice.settings.set_channel(0, threshold_v=-0.5, nim_nttl=True, rising_edge=True, falling_edge=False)
LINTagDevice.settings.set_channel(7, threshold_v=-0.5, nim_nttl=True, rising_edge=True, falling_edge=False)
# disable all other channels, to not pollute the network interface, important especially for high-throughput measurements
for i in [1,2,3,4,5,6]:
LINTagDevice.settings.set_channel(i, threshold_v=0.0, nim_nttl=True, rising_edge=False, falling_edge=False)
# set up correlator
LINTagDevice.correlator.set_correlator_settings(
window_ps = 50000,
bin_size="FIVE_PS",
correlator_type="START_STOP",
is_correlating=True,
start_channel=0,
start_slope="RISING",
stop_channel=7,
stop_slope="RISING",
)
# do sth. 3 times, change things between
for i in range(3):
# clear the histogram to get startet
LINTagDevice.correlator.clear_histogram()
# let the measurement run for i * 2s + 2s
time.sleep(i*3+1)
# retrieve the histogram
bins, values = LINTagDevice.correlator.get_histogram()
errors = np.sqrt(values)
# plot it
plt.figure()
plt.errorbar(bins, values, yerr=errors, fmt="o-", label="data & error")
plt.title("Plot No. " + str(i+1))
plt.xlim(-0.55, -0.35)
plt.legend(loc="best")
plt.show()
# Do sth. else, e.g. changing LINTag configuration, or changing sth. in your experimental setup
# Setup.Change(i)