Skip to content

Commit

Permalink
public release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoint75 committed Aug 28, 2023
1 parent 5c96609 commit ca24611
Show file tree
Hide file tree
Showing 103 changed files with 4,533 additions and 1,659 deletions.
27 changes: 14 additions & 13 deletions demos/GetCorrelationFCS.py → demos/Demo_CorrelationFCS.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@

if(__name__ == "__main__"):

sn = snAPI()
sn = snAPI(libType=LibType.HH)
sn.getDeviceIDs()
sn.getDevice()
#sn.getFileDevice(r"E:\Data\PicoQuant\CW_Shelved.ptu")
#sn.getFileDevice(r"e:\Data\PicoQuant\cell01_55pct_1.ptu")
#sn.getFileDevice(r"e:\Data\PicoQuant\Correaltion_T3.ptu")
#sn.getFileDevice(r"e:\Data\PicoQuant\OpenCLTest\Atto655+Cy5_diff_FCS+FLCS_Conv.ptu")
sn.initDevice(MeasMode.T3)
#sn.device.setInputDeadTime(-1,1000)
sn.correlation.setFCSparameters(1, 2, 1e4, 5)
sn.correlation.measure(10000,savePTU=True)
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, 1564)

# 2. set windowSize and startTime
sn.correlation.setFCSParameters(1, 2, 1e10, 1e5)
sn.correlation.measure(100,savePTU=True)

while True:
finished = sn.correlation.isFinished()
data, bins = sn.correlation.getFCSdata()
data, bins = sn.correlation.getFCSData()
time.sleep(.3)

plt.clf()
Expand All @@ -34,9 +37,7 @@
plt.legend()
plt.title("FCS")
plt.pause(0.1)

#sn.correlation.clearMeasure()


if finished:
break

Expand Down
41 changes: 41 additions & 0 deletions demos/Demo_CorrelationG2.py
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)
32 changes: 32 additions & 0 deletions demos/Demo_DeviceConfig.py
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")
51 changes: 51 additions & 0 deletions demos/Demo_HistogramRefresh.py
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)
39 changes: 39 additions & 0 deletions demos/Demo_HistogramSimple.py
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)
25 changes: 25 additions & 0 deletions demos/Demo_RecordViewerUF.py
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}")
23 changes: 23 additions & 0 deletions demos/Demo_RecordViewer_Raw.py
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}")
48 changes: 48 additions & 0 deletions demos/Demo_RecordViewer_UF.py
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}")
65 changes: 65 additions & 0 deletions demos/Demo_TimeTrace.py
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)
Loading

0 comments on commit ca24611

Please sign in to comment.