-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
4,533 additions
and
1,659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from snAPI.Main import * | ||
import matplotlib | ||
matplotlib.use('TkAgg',force=True) | ||
from matplotlib import pyplot as plt | ||
print("Switched to:",matplotlib.get_backend()) | ||
import time | ||
|
||
if(__name__ == "__main__"): | ||
|
||
sn = snAPI(libType=LibType.HH) | ||
sn.getDeviceIDs() | ||
sn.getDevice() | ||
sn.initDevice(MeasMode.T2) | ||
|
||
# set the configuration for your device type | ||
sn.loadIniConfig("config\HH.ini") | ||
|
||
# 1. shift the signals to max correlation max at tau = 0 | ||
#sn.device.setInputChannelOffset(1, 1588) | ||
|
||
# 2. set windowSize and startTime | ||
sn.correlation.setG2Parameters(1, 2, 100000, 100) | ||
sn.correlation.measure(1000,savePTU=False) | ||
|
||
while True: | ||
finished = sn.correlation.isFinished() | ||
data, bins = sn.correlation.getG2Data() | ||
time.sleep(.3) | ||
|
||
plt.clf() | ||
plt.plot(bins, data, linewidth=2.0, label='g(2)') | ||
plt.xlabel('Time [s]') | ||
plt.ylabel('g(2)') | ||
plt.legend() | ||
plt.title("g(2)") | ||
plt.pause(0.1) | ||
|
||
if finished: | ||
break | ||
|
||
plt.show(block=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from snAPI.Main import * | ||
|
||
if(__name__ == "__main__"): | ||
|
||
# set the library for your device type | ||
sn = snAPI(libType=LibType.HH) | ||
sn.getDevice() | ||
|
||
sn.initDevice() | ||
|
||
# set the configuration for your device type | ||
sn.loadIniConfig("config\HH.ini") | ||
|
||
# print complete device config structure | ||
sn.logPrint(json.dumps(sn.deviceConfig, indent=2)) | ||
sn.logPrint() | ||
|
||
# device serial number (name) | ||
sn.logPrint("----------------------------------------------") | ||
sn.logPrint("Serial Number:", sn.deviceConfig["ID"]) | ||
|
||
# trigger/ discriminator level of all channels | ||
sn.logPrint("----------------------------------------------") | ||
for channel in sn.deviceConfig["ChansCfg"]: | ||
if channel["TrigMode"] == "Edge": | ||
sn.logPrint("Chan", channel["Index"], "- TrigLvl:", channel["TrigLvl"]) | ||
elif channel["TrigMode"] == "CFD": | ||
sn.logPrint("Chan", channel["Index"], "- DiscrLvl :", channel["DiscrLvl"]) | ||
|
||
# print enable state channel 2 (this is the second channel - the first one has index 0) | ||
sn.logPrint("----------------------------------------------") | ||
sn.logPrint("Chan 2:", "enabled" if sn.deviceConfig["ChansCfg"][1]["ChanEna"] else "disabled") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from snAPI.Main import * | ||
import matplotlib | ||
matplotlib.use('TkAgg',force=True) | ||
from matplotlib import pyplot as plt | ||
print("Switched to:",matplotlib.get_backend()) | ||
from threading import Timer | ||
import time | ||
|
||
if(__name__ == "__main__"): | ||
|
||
sn = snAPI(libType=LibType.HH) | ||
sn.getDevice() | ||
sn.initDevice(MeasMode.T2) | ||
|
||
# temporarily enable logging of configuration | ||
sn.setLogLevel(LogLevel.Config, True) | ||
# set the configuration for your device type | ||
sn.loadIniConfig("config\HH.ini") | ||
sn.setLogLevel(LogLevel.Config, False) | ||
|
||
# change histogram parameter in T2 mode | ||
#sn.histogram.setRefChannel(0) | ||
#sn.histogram.setBinWidth(1) | ||
sn.device.setStopOverflow(int(1e6)) | ||
sn.histogram.measure(acqTime=0, waitFinished=False, savePTU=True) | ||
|
||
while True: | ||
finished = sn.histogram.isFinished() | ||
data, bins = sn.histogram.getData() | ||
sn.logPrint(f"c1max: {max(data[1])}, c2max: {max(data[2])}") | ||
|
||
# 1s refresh time | ||
plt.pause(1) | ||
plt.clf() | ||
plt.plot(bins, data[0], linewidth=2.0, label='sync') | ||
for c in range(1, 1+sn.deviceConfig["NumChans"]): | ||
plt.plot(bins, data[c], linewidth=2.0, label=f'chan{c}') | ||
|
||
plt.yscale('log') | ||
plt.xlabel('Time [ps]') | ||
plt.ylabel('Counts') | ||
plt.legend() | ||
plt.title("Histogram") | ||
|
||
# clear measure data | ||
#sn.histogram.clearMeasure() | ||
if finished: | ||
sn.setLogLevel(LogLevel.Manipulators, True) | ||
break | ||
|
||
plt.show(block=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from snAPI.Main import * | ||
import matplotlib | ||
matplotlib.use('TkAgg',force=True) | ||
from matplotlib import pyplot as plt | ||
print("Switched to:",matplotlib.get_backend()) | ||
|
||
if(__name__ == "__main__"): | ||
|
||
# select the device library | ||
sn = snAPI(libType=LibType.HH) | ||
# get first available device | ||
sn.getDevice() | ||
sn.setLogLevel(logLevel=LogLevel.DataFile, onOff=True) | ||
|
||
#initialize the device | ||
sn.initDevice(MeasMode.T2) | ||
|
||
# set the configuration for your device type | ||
sn.loadIniConfig("config\HH.ini") | ||
|
||
# start histogram measurement | ||
sn.histogram.measure(acqTime=1000,savePTU=True) | ||
|
||
# get the data | ||
data, bins = sn.histogram.getData() | ||
|
||
# plot the histogram | ||
if len(data): | ||
plt.clf() | ||
plt.plot(bins, data[0], linewidth=2.0, label='sync') | ||
for c in range(1, 1+sn.deviceConfig["NumChans"]): | ||
plt.plot(bins, data[c], linewidth=2.0, label=f'chan{c}') | ||
plt.xlabel('Time [ps]') | ||
plt.ylabel('Counts') | ||
plt.legend() | ||
plt.title("Counts / Time") | ||
plt.pause(0.01) | ||
|
||
plt.show(block=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from snAPI.Main import * | ||
|
||
if(__name__ == "__main__"): | ||
|
||
start = 0 | ||
length = 10 | ||
|
||
sn = snAPI(libType=LibType.HH) | ||
sn.getDevice() | ||
|
||
sn.getFileDevice(r"C:\Data\PicoQuant\default_1.ptu") | ||
sn.initDevice(MeasMode.T2) | ||
|
||
# set the configuration for your device type | ||
sn.loadIniConfig("config\HH.ini") | ||
|
||
# 4GB | ||
sn.unfold.measure(size=4*134217728) | ||
times, channels = sn.unfold.getData() | ||
|
||
sn.logPrint("channel | timetag") | ||
sn.logPrint("------------------------") | ||
sn.logPrint(f"{channels[0]:7} | {times[0]:14}") | ||
for i in range(start,start+length): | ||
sn.logPrint(f"{channels[i]:7} | {times[i]:14}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from snAPI.Main import * | ||
|
||
if(__name__ == "__main__"): | ||
|
||
start = 0 | ||
length = 10 | ||
|
||
sn = snAPI(libType=LibType.HH) | ||
sn.getDevice() | ||
|
||
#sn.getFileDevice(r"C:\Data\PicoQuant\default.ptu") | ||
sn.initDevice(MeasMode.T3) | ||
sn.loadIniConfig("config\HH.ini") | ||
|
||
# 1GB | ||
sn.raw.measure(1000, 1024*1024*1024, True, False) | ||
data = sn.raw.getData() | ||
sn.logPrint("from raw data") | ||
sn.logPrint("channel | timetag") | ||
sn.logPrint("-------------------") | ||
|
||
for i in range(start,start+length): | ||
sn.logPrint(f"{sn.raw.channel(data[i]):9} | {sn.raw.dTime_T3(data[i]):7}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from snAPI.Main import * | ||
|
||
if(__name__ == "__main__"): | ||
|
||
start = 0 | ||
length = 10 | ||
|
||
sn = snAPI(libType=LibType.HH) | ||
sn.getDevice() | ||
|
||
sn.getFileDevice(r"C:\Data\PicoQuant\default.ptu") | ||
sn.initDevice(MeasMode.T3) | ||
#sn.setLogLevel(LogLevel.Config, True) | ||
sn.loadIniConfig("config\HH.ini") | ||
|
||
countRates = sn.getCountRates() | ||
|
||
# 1GB | ||
sn.unfold.setT3Format(UnfoldFormat.Absolute) | ||
sn.unfold.measure(acqTime=1000, size=1024*1024*1024, waitFinished=True, savePTU=False) | ||
times, channels = sn.unfold.getData() | ||
sn.logPrint("Unfold Data: UnfoldFormat.Absolute") | ||
sn.logPrint(" channel | absTime") | ||
sn.logPrint("-------------------") | ||
|
||
for i in range(start,start+length): | ||
sn.logPrint(f"{channels[i]:9} | {times[i]:7}") | ||
|
||
sn.unfold.setT3Format(UnfoldFormat.DTimes) | ||
sn.unfold.measure(acqTime=1000, size=1024*1024*1024, waitFinished=True, savePTU=False) | ||
times, channels = sn.unfold.getData() | ||
sn.logPrint("Unfold Data: UnfoldFormat.DTimes") | ||
sn.logPrint(" channel | dTime") | ||
sn.logPrint("-------------------") | ||
|
||
for i in range(start,start+length): | ||
sn.logPrint(f"{channels[i]:9} | {times[i]:7}") | ||
|
||
sn.unfold.setT3Format(UnfoldFormat.DTimesSyncCntr) | ||
sn.unfold.measure(acqTime=1000, size=1024*1024*1024, waitFinished=True, savePTU=False) | ||
times, channels = sn.unfold.getData() | ||
sn.logPrint("Unfold Data: UnfoldFormat.DTimesSyncCntr") | ||
sn.logPrint(" channel | syncCtr | dTime | absTime") | ||
sn.logPrint("-----------------------------------------") | ||
|
||
syncPeriod = 1e12 / countRates[0] # in ps | ||
for i in range(start,start+length): | ||
sn.logPrint(f"{channels[i]:9} | {sn.unfold.nSync_T3(times[i]):7} | {sn.unfold.dTime_T3(times[i]):7} | {(syncPeriod * sn.unfold.nSync_T3(times[i]) + sn.unfold.dTime_T3(times[i])):.1f}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from snAPI.Main import * | ||
import matplotlib | ||
matplotlib.use('TkAgg',force=True) | ||
from matplotlib import pyplot as plt | ||
print("Switched to:",matplotlib.get_backend()) | ||
|
||
if(__name__ == "__main__"): | ||
|
||
sn = snAPI(libType=LibType.HH) | ||
sn.getDevice() | ||
|
||
# alternatively read data from file | ||
sn.setLogLevel(LogLevel.DataFile, True) | ||
sn.initDevice(MeasMode.T2) | ||
|
||
# enable this to get info about loading config | ||
#sn.setLogLevel(logLevel=LogLevel.Config, onOff=True) | ||
sn.loadIniConfig("config\HH.ini") | ||
|
||
numChans = sn.deviceConfig["NumChans"] | ||
triggerMode = TrigMode.Edge if sn.deviceConfig["SyncTrigMode"] == "Edge" else TrigMode.CFD | ||
|
||
if dontUseSettingsFromConfigIni := False: | ||
#set input CFD trigger | ||
if triggerMode == TrigMode.CFD: | ||
#sn.device.setSyncTrigMode(TrigMode.CFD) | ||
sn.device.setInputTrigMode(-1, TrigMode.CFD) | ||
sn.device.setSyncCFD(100, 0) | ||
sn.device.setInputCFD(-1, 100, 0) | ||
|
||
#set input edge trigger | ||
if triggerMode == TrigMode.Edge: | ||
#sn.device.setSyncTrigMode(TrigMode.Edge) | ||
sn.device.setInputTrigMode(-1, TrigMode.Edge) | ||
sn.device.setSyncEdgeTrig(-100, 0) | ||
sn.device.setInputEdgeTrig(-1, -50, 0) | ||
|
||
# configure timetrace | ||
sn.timeTrace.setNumBins(10000) | ||
sn.timeTrace.setHistorySize(10) | ||
|
||
# you can set a custom file name or path | ||
sn.setPTUFilePath(u"MyFileName") | ||
|
||
# measure 10s | ||
sn.timeTrace.measure(10000, waitFinished=False, savePTU=True) | ||
|
||
while True: | ||
finished = sn.timeTrace.isFinished() | ||
counts, times = sn.timeTrace.getData() | ||
plt.clf() | ||
plt.plot(times, counts[0], linewidth=2.0, label='sync') | ||
for c in range(1, 1+sn.deviceConfig["NumChans"]): | ||
plt.plot(times, counts[c], linewidth=2.0, label=f'chan{c}') | ||
|
||
plt.xlabel('Time [s]') | ||
plt.ylabel('Counts[Cts/s]') | ||
plt.legend() | ||
plt.title("TimeTrace") | ||
plt.pause(0.1) | ||
|
||
if finished: | ||
break | ||
|
||
plt.show(block=True) |
Oops, something went wrong.