Skip to content

Commit c4f4fa8

Browse files
committed
API:
- add White Rabbit support (synchronize clocks between different Harps over fiber optics) - add hardware triggered measurements support - remove unfoldT3Format - add getAbsTime for Unfold measurement class in T3 mode - auto detect library - getDeviceIDs() detects all supported devics Python: - add Demo_TimeTrace_Coincidence.py - add Demo_WR_Configure_Master.py - add Demo_WR_Configure_Slave.py - add Demo_WR_TimeTrace_Master.py - add Demo_WR_TimeTrace_Slave.py - add Demo_HW_Start.py - add Demo_HW_StartGated.py - add Demo_HW_StartStop.py Docu: - add Control Connector
1 parent 70a3032 commit c4f4fa8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3247
-479
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from snAPI.Main import *
2+
3+
if(__name__ == "__main__"):
4+
5+
start = 0
6+
length = 10
7+
8+
sn = snAPI()
9+
sn.getDevice()
10+
11+
# offline processing:
12+
# sn.getFileDevice(r"E:\Data\PicoQuant\G2_T3_sameTTs.ptu")
13+
sn.initDevice(MeasMode.T2)
14+
15+
# set the trigger level
16+
sn.loadIniConfig("config\MH.ini")
17+
18+
#list of channels to build the coincidence from
19+
chans= [1,2]
20+
ciIndex = sn.manipulators.coincidence(chans, 1000, mode = CoincidenceMode.CountOnce,
21+
time = CoincidenceTime.Last,
22+
keepChannels=True) #set keepChannels to false to get the coincidences only
23+
# ciIndex is the 'channel number' where the coincidences are stored
24+
sn.logPrint(f"coincidence index: {ciIndex}")
25+
26+
# block measurement for continuous (acqTime = 0 is until stop) measurement
27+
sn.unfold.startBlock(acqTime=1000, size=1024*1024*1024, savePTU=False)
28+
29+
while(True):
30+
times, channels = sn.unfold.getBlock()
31+
32+
if(len(times) > 9):
33+
sn.logPrint("new data block:")
34+
sn.logPrint(" channel | time tag")
35+
sn.logPrint("--------------------")
36+
37+
# only print the first 10 time tags per block out
38+
# for performance reasons
39+
# but it here should all data be stored to disc
40+
for i in range(10):
41+
sn.logPrint(f"{channels[i]:9} | {times[i]:8}")
42+
43+
44+
# filter the time tags of coincidences
45+
ciTimes = sn.unfold.getTimesByChannel(ciIndex)
46+
sn.logPrint("new coincidence block:")
47+
sn.logPrint("time tag")
48+
sn.logPrint("--------")
49+
if len(ciTimes) > 9:
50+
for i in range(10):
51+
sn.logPrint(f"{ciTimes[i]:8}")
52+
53+
54+
if sn.unfold.finished.contents:
55+
break
56+
57+
# if otherBreakCondition:
58+
sn.unfold.stopMeasure
59+
60+
sn.logPrint("end")

demos/Demo_CorrelationFCS.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
if(__name__ == "__main__"):
99

10-
sn = snAPI(libType=LibType.HH)
10+
sn = snAPI()
1111
sn.getDeviceIDs()
1212
sn.getDevice()
1313
sn.initDevice(MeasMode.T2)
1414

1515
# set the configuration for your device type
16-
sn.loadIniConfig("config\HH.ini")
16+
sn.loadIniConfig("config\MH.ini")
1717

1818
# 1. shift the signals to max correlation max at tau = 0
1919
#sn.device.setInputChannelOffset(1, 1564)
2020

2121
# 2. set windowSize and startTime
22-
sn.correlation.setFCSParameters(1, 2, 1e10, 1e5)
23-
sn.correlation.measure(100,savePTU=True)
22+
sn.correlation.setFCSParameters(1, 2, 1e10, 1e5, 8)
23+
sn.correlation.measure(2000,savePTU=True)
2424

2525
while True:
2626
finished = sn.correlation.isFinished()

demos/Demo_CorrelationG2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77

88
if(__name__ == "__main__"):
99

10-
sn = snAPI(libType=LibType.HH)
10+
sn = snAPI()
1111
sn.getDeviceIDs()
1212
sn.getDevice()
1313
sn.initDevice(MeasMode.T2)
1414

1515
# set the configuration for your device type
16-
sn.loadIniConfig("config\HH.ini")
16+
sn.loadIniConfig("config\MH.ini")
1717

1818
# 1. shift the signals to max correlation max at tau = 0
1919
#sn.device.setInputChannelOffset(1, 1588)
2020

2121
# 2. set windowSize and startTime
22-
sn.correlation.setG2Parameters(1, 2, 100000, 100)
22+
sn.correlation.setG2Parameters(1, 2, 50000, 5)
2323
sn.correlation.measure(1000,savePTU=False)
2424

2525
while True:

demos/Demo_DeviceConfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
if(__name__ == "__main__"):
44

55
# set the library for your device type
6-
sn = snAPI(libType=LibType.HH)
6+
sn = snAPI()
77
sn.getDevice()
88
sn.initDevice()
99

1010
# set the configuration for your device type
11-
sn.loadIniConfig("config\HH.ini")
11+
sn.loadIniConfig("config\MH.ini")
1212

1313
# print complete device config structure
1414
sn.logPrint(json.dumps(sn.deviceConfig, indent=2))

demos/Demo_HW_Start.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from snAPI.Main import *
2+
import matplotlib
3+
matplotlib.use('TkAgg',force=True)
4+
from matplotlib import pyplot as plt
5+
print("Switched to:",matplotlib.get_backend())
6+
7+
8+
if(__name__ == "__main__"):
9+
10+
sn = snAPI()
11+
sn.getDevice()
12+
sn.initDevice(MeasMode.T2)
13+
14+
# a trigger signal on C1 starts the measurement
15+
sn.device.setMeasControl(MeasControl.C1StartCtcStop)
16+
sn.loadIniConfig("config\MH.ini")
17+
18+
# configure timetrace
19+
sn.timeTrace.setNumBins(10000)
20+
sn.timeTrace.setHistorySize(10)
21+
# prepare measurement for triggered start (stop after 10s)
22+
sn.timeTrace.measure(10000, waitFinished=False, savePTU=False)
23+
24+
plt.figure(f'Figure: {sn.deviceConfig["Model"]}')
25+
while True:
26+
finished = sn.timeTrace.isFinished()
27+
counts, times = sn.timeTrace.getData()
28+
plt.clf()
29+
plt.plot(times, counts[0], linewidth=2.0, label='sync')
30+
for c in range(1, 1+sn.deviceConfig["NumChans"]):
31+
plt.plot(times, counts[c], linewidth=2.0, label=f'chan{c}')
32+
33+
plt.xlabel('Time [s]')
34+
plt.ylabel('Counts[Cts/s]')
35+
plt.legend()
36+
plt.title(f'TimeTrace Master {sn.deviceConfig["ID"]}')
37+
plt.pause(0.1)
38+
39+
if finished:
40+
break
41+
42+
plt.show(block=True)

demos/Demo_HW_StartGated.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from snAPI.Main import *
2+
import matplotlib
3+
matplotlib.use('TkAgg',force=True)
4+
from matplotlib import pyplot as plt
5+
print("Switched to:",matplotlib.get_backend())
6+
7+
8+
if(__name__ == "__main__"):
9+
10+
sn = snAPI()
11+
sn.getDevice()
12+
sn.initDevice(MeasMode.T2)
13+
14+
# a trigger signal on C1 starts and holds the measurement
15+
# a low to high slope starts the measurement until the signal on the control connector Pin C1
16+
# is getting low again.
17+
sn.device.setMeasControl(MeasControl.C1Gated, 1, 0)
18+
sn.loadIniConfig("config\MH.ini")
19+
20+
# configure timetrace
21+
sn.timeTrace.setNumBins(10000)
22+
sn.timeTrace.setHistorySize(10)
23+
# prepare measurement for triggered start (stop after 10s)
24+
sn.timeTrace.measure(10000, waitFinished=False, savePTU=False)
25+
26+
plt.figure(f'Figure: {sn.deviceConfig["Model"]}')
27+
while True:
28+
finished = sn.timeTrace.isFinished()
29+
counts, times = sn.timeTrace.getData()
30+
plt.clf()
31+
plt.plot(times, counts[0], linewidth=2.0, label='sync')
32+
for c in range(1, 1+sn.deviceConfig["NumChans"]):
33+
plt.plot(times, counts[c], linewidth=2.0, label=f'chan{c}')
34+
35+
plt.xlabel('Time [s]')
36+
plt.ylabel('Counts[Cts/s]')
37+
plt.legend()
38+
plt.title(f'TimeTrace Master {sn.deviceConfig["ID"]}')
39+
plt.pause(0.1)
40+
41+
if finished:
42+
break
43+
44+
plt.show(block=True)

demos/Demo_HW_StartStop.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from snAPI.Main import *
2+
import matplotlib
3+
matplotlib.use('TkAgg',force=True)
4+
from matplotlib import pyplot as plt
5+
print("Switched to:",matplotlib.get_backend())
6+
7+
if(__name__ == "__main__"):
8+
9+
sn = snAPI()
10+
sn.getDevice()
11+
sn.initDevice(MeasMode.T2)
12+
13+
# a trigger signal on C1 starts and one on C2 stops the measurement
14+
sn.device.setMeasControl(MeasControl.C1StartC2Stop)
15+
sn.loadIniConfig("config\MH.ini")
16+
17+
# configure timetrace
18+
sn.timeTrace.setNumBins(10000)
19+
sn.timeTrace.setHistorySize(10)
20+
# prepare measurement for triggered start and stop
21+
sn.timeTrace.measure(waitFinished=False, savePTU=False)
22+
23+
plt.figure(f'Figure: {sn.deviceConfig["Model"]}')
24+
while True:
25+
finished = sn.timeTrace.isFinished()
26+
counts, times = sn.timeTrace.getData()
27+
plt.clf()
28+
plt.plot(times, counts[0], linewidth=2.0, label='sync')
29+
for c in range(1, 1+sn.deviceConfig["NumChans"]):
30+
plt.plot(times, counts[c], linewidth=2.0, label=f'chan{c}')
31+
32+
plt.xlabel('Time [s]')
33+
plt.ylabel('Counts[Cts/s]')
34+
plt.legend()
35+
plt.title(f'TimeTrace Master {sn.deviceConfig["ID"]}')
36+
plt.pause(0.1)
37+
38+
if finished:
39+
break
40+
41+
plt.show(block=True)

demos/Demo_HeraldedCorrelationG2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
if(__name__ == "__main__"):
99

10-
sn = snAPI(libType=LibType.PH330)
10+
sn = snAPI()
1111
sn.getDeviceIDs()
1212
sn.getDevice()
1313
sn.initDevice(MeasMode.T2)
14-
sn.loadIniConfig("config\PH330_CFD.ini")
14+
sn.loadIniConfig("config\MH.ini")
1515

1616
windowSize = 2000 #ps
1717
# move the histograms of the both channels to the same time after the sync to filter both at once

demos/Demo_HistogramRefresh.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
if(__name__ == "__main__"):
1010

11-
sn = snAPI(libType=LibType.PH330)
11+
sn = snAPI(libType=LibType.TH260)
1212
sn.getDevice()
13-
sn.initDevice(MeasMode.T3)
14-
sn.device.setBinning(2)
13+
sn.initDevice(MeasMode.T2)
1514

1615
# temporarily enable logging of configuration
1716
sn.setLogLevel(LogLevel.Config, True)
1817
# set the configuration for your device type
19-
sn.loadIniConfig("config\PH330_Edge.ini")
18+
sn.loadIniConfig("config\TH.ini")
2019
sn.setLogLevel(LogLevel.Config, False)
2120

2221
# change histogram parameter in T2 mode

demos/Demo_HistogramSimple.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
if(__name__ == "__main__"):
88

9-
# select the device library
10-
sn = snAPI(libType=LibType.HH)
9+
# initialize the API
10+
sn = snAPI()
1111
# get first available device
1212
sn.getDevice()
1313
sn.setLogLevel(logLevel=LogLevel.DataFile, onOff=True)
@@ -16,7 +16,7 @@
1616
sn.initDevice(MeasMode.T2)
1717

1818
# set the configuration for your device type
19-
sn.loadIniConfig("config\HH.ini")
19+
sn.loadIniConfig("config\MH.ini")
2020

2121
# start histogram measurement
2222
sn.histogram.measure(acqTime=1000,savePTU=True)

0 commit comments

Comments
 (0)