Skip to content

Commit

Permalink
API:
Browse files Browse the repository at this point in the history
- bump :v1.0.2
- add warnings if parameters exceed their limits on device functions
- change snAPI init for ipython
- fix parseBool in read OpenFileDevice
- fix a possible crash in TimeTrace if a channel number higher than possible number of channels
- improve forcedStop
- fixed Times for Marker with T3 Formats != Absolute
- fix some uncategorized log entries
- fix PH330 PQ_TAGID_TTRESULTFORMAT_TTTRRECTYPE
- add library warnings on measure start
Docu:
- fix description of Unfold.dTime_T3()
- fixed misleading correlation figure
Python:
- fix init snAPI for older python versions
- fix returning array size for getCountRates()
- improve Tool_PlotCountRateByTriggerLevel.py to plot all channels
- fix dTimes in Demo_RecordViewer_UF
- fixed isMarker() in Raw measure class
- add Demo_HeraldedCorrelationG2.py
  • Loading branch information
tpoint75 committed Nov 22, 2023
1 parent 544a9d1 commit 595cc56
Show file tree
Hide file tree
Showing 21 changed files with 114 additions and 66 deletions.
42 changes: 42 additions & 0 deletions demos/Demo_HeraldedCorrelationG2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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.MH)
sn.getDeviceIDs()
sn.getDevice()
sn.initDevice(MeasMode.T2)

# define the path for the T2 file
sn.getFileDevice("E:\Data\PicoQuant\CW_Shelved.ptu")

# define a gate window after the herald channel (1) for the detector channels (2 and 3),
# starting at 100000 ps after the herald signal, with a gate length of 200000 ps
heraldChans = sn.manipulators.herald(1, [2, 3], 100000, 200000)

# initiate the g2 correlation with the time-gated channels
sn.correlation.setG2Parameters(heraldChans[0],heraldChans[1], 500000, 100)
sn.correlation.measure(100000,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)
23 changes: 13 additions & 10 deletions demos/Demo_RecordViewer_UF.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sn = snAPI(libType=LibType.HH)
sn.getDevice()

sn.getFileDevice(r"C:\Data\PicoQuant\default.ptu")
sn.getFileDevice(r"E:\Data\PicoQuant\G2_T3_sameTTs.ptu")
sn.initDevice(MeasMode.T3)
#sn.setLogLevel(LogLevel.Config, True)
sn.loadIniConfig("config\HH.ini")
Expand All @@ -20,29 +20,32 @@
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("-------------------")
sn.logPrint(" channel | absTime")
sn.logPrint("--------------------")

for i in range(start,start+length):
sn.logPrint(f"{channels[i]:9} | {times[i]:7}")
sn.logPrint(f"{channels[i]:9} | {times[i]:8}")

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("-------------------")
sn.logPrint(" channel | dTime")
sn.logPrint("--------------------")

resolution = sn.deviceConfig['Resolution']
for i in range(start,start+length):
sn.logPrint(f"{channels[i]:9} | {times[i]:7}")
sn.logPrint(f"{channels[i]:9} | {(resolution * times[i]):8}")

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("-----------------------------------------")
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}")
sn.logPrint(f"{channels[i]:9} | {sn.unfold.nSync_T3(times[i]):7} | {(resolution * sn.unfold.dTime_T3(times[i])):8} | {(syncPeriod * sn.unfold.nSync_T3(times[i]) + (resolution * sn.unfold.dTime_T3(times[i]))):.1f}")

print("end")
7 changes: 1 addition & 6 deletions demos/config/PH330_Edge.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,4 @@ TrigMode = 0
ChanOffs = 0
ChanEna = 1
DeadTime = 0

[Channel_0]
EdgeTrig = 0,0

[Channel_1]
EdgeTrig = -120,0
EdgeTrig = -50,0
Binary file removed dist/snAPI-1.0.1.tar.gz
Binary file not shown.
Binary file not shown.
Binary file added dist/snAPI-1.0.2.tar.gz
Binary file not shown.
Binary file modified docs/_images/03_Correlation_Bunching.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/03_Correlation_Bunching_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/03_Correlation_Antibunching.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/03_Correlation_Antibunching_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/03_Correlation_Bunching.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/03_Correlation_Bunching_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/snAPI.Constants.html
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@

<dl class="py attribute">
<dt class="sig sig-object py" id="snAPI_Constants_LibType_TH260">
<span class="sig-name descname"><span class="pre">TH260</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">3</span></em><a class="headerlink" href="#snAPI_Constants_LibType_TH260" title="Permalink to this definition">#</a></dt>
<span class="sig-name descname"><span class="pre">TH260</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">2</span></em><a class="headerlink" href="#snAPI_Constants_LibType_TH260" title="Permalink to this definition">#</a></dt>
<dd><p>This selects the library for the
<a class="reference external" href="https://www.picoquant.com/products/category/tcspc-and-time-tagging-modules/timeharp-260-tcspc-and-mcs-board-with-pcie-interface">TimeHarp 260</a>
(TH260) devices.
Expand All @@ -428,7 +428,7 @@

<dl class="py attribute">
<dt class="sig sig-object py" id="snAPI_Constants_LibType_PH330">
<span class="sig-name descname"><span class="pre">PH330</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">4</span></em><a class="headerlink" href="#snAPI_Constants_LibType_PH330" title="Permalink to this definition">#</a></dt>
<span class="sig-name descname"><span class="pre">PH330</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">3</span></em><a class="headerlink" href="#snAPI_Constants_LibType_PH330" title="Permalink to this definition">#</a></dt>
<dd><p>This selects the library for the
<a class="reference external" href="https://www.picoquant.com/products/category/tcspc-and-time-tagging-modules/picoharp_330_precise_and_versatile_event_timer_and_tcspc_unit">PicoHarp 330</a>
(PH330) devices.</p>
Expand Down
38 changes: 21 additions & 17 deletions docs/snAPI.Main.html
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,7 @@
<div class="line">MH150/160, PH330: [1: 2*br, 2: 4*br, .., 24: 16777216*br]</div>
<div class="line">HH400: [1: 2*br, 2: 4*br, .., 26: 67108864*br]</div>
<div class="line">TH260: [1: 2*br, 2: 4*br, .., 22: 4194304*br]</div>
<div class="line">this means: n*br = 2^binning</div>
<div class="line">(br stands for base resolution)</div>
</div>
</p>
Expand Down Expand Up @@ -3449,7 +3450,8 @@
<dl class="py method">
<dt class="sig sig-object py" id="snAPI_Main_Unfold_dTime_T3">
<span class="sig-name descname"><span class="pre">dTime_T3</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">times</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#snAPI_Main_Unfold_dTime_T3" title="Permalink to this definition">#</a></dt>
<dd><p>This function takes a T3 <cite>Unfold</cite> data record and returns the differential time.</p>
<dd><p>This function takes a T3 <cite>Unfold</cite> data record and returns the differential time slot. For the differential time
it has to be multiplied by the Resolution.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Use this function with the T3 <cite>Unfold</cite> data record. with <a class="reference internal" href="snAPI.Constants.html#snAPI_Constants_UnfoldFormat_DTimesSyncCntr" title="snAPI.Constants.UnfoldFormat.DTimesSyncCntr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">UnfoldFormat.DTimesSyncCntr</span></code></a>.
Expand All @@ -3472,7 +3474,7 @@
</dl>
<p class="rubric">Example</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># prints out the differential time of a T3 `Unfold` data record</span>
<span class="n">sn</span><span class="o">.</span><span class="n">print</span><span class="p">(</span><span class="n">sn</span><span class="o">.</span><span class="n">unfold</span><span class="o">.</span><span class="n">dTime_T3</span><span class="p">(</span><span class="n">times</span><span class="p">[</span><span class="n">i</span><span class="p">]))</span>
<span class="n">sn</span><span class="o">.</span><span class="n">print</span><span class="p">(</span><span class="n">sn</span><span class="o">.</span><span class="n">deviceConfig</span><span class="p">[</span><span class="s1">&#39;Resolution&#39;</span><span class="p">]</span> <span class="o">*</span> <span class="n">sn</span><span class="o">.</span><span class="n">unfold</span><span class="o">.</span><span class="n">dTime_T3</span><span class="p">(</span><span class="n">times</span><span class="p">[</span><span class="n">i</span><span class="p">]))</span>
</pre></div>
</div>
</dd></dl>
Expand Down Expand Up @@ -3902,19 +3904,19 @@
</dd>
</dl>
<p class="rubric">Example</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># runs a while loop until the measurement is finished</span>
<span class="k">while</span> <span class="n">sn</span><span class="o">.</span><span class="n">timetrace</span><span class="o">.</span><span class="n">isFinished</span><span class="p">():</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">sn</span><span class="o">.</span><span class="n">timetrace</span><span class="o">.</span><span class="n">getData</span><span class="p">()</span>
<span class="o">...</span>

<span class="c1"># break a while loop if the measurement is finished and reads the last data</span>
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
<span class="n">finished</span> <span class="o">=</span> <span class="n">sn</span><span class="o">.</span><span class="n">timetrace</span><span class="o">.</span><span class="n">isFinished</span><span class="p">()</span>
<span class="n">counts</span><span class="p">,</span> <span class="n">times</span> <span class="o">=</span> <span class="n">sn</span><span class="o">.</span><span class="n">timetrace</span><span class="o">.</span><span class="n">getData</span><span class="p">()</span>
<span class="o">...</span>

<span class="k">if</span> <span class="n">finished</span><span class="p">:</span>
<span class="k">break</span>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span># runs a while loop until the measurement is finished
while !sn.timetrace.isFinished():
data = sn.timetrace.getData()
...

# break a while loop if the measurement is finished and reads the last data
while True:
finished = sn.timetrace.isFinished()
counts, times = sn.timetrace.getData()
...

if finished:
break
</pre></div>
</div>
</dd></dl>
Expand Down Expand Up @@ -4001,7 +4003,7 @@

<dl class="py method">
<dt class="sig sig-object py" id="snAPI_Main_Correlation_setFCSParameters">
<span class="sig-name descname"><span class="pre">setFCSParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">startChannel</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stopChannel</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">windowSize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000000000000.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">startTime</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#snAPI_Main_Correlation_setFCSParameters" title="Permalink to this definition">#</a></dt>
<span class="sig-name descname"><span class="pre">setFCSParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">startChannel</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stopChannel</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">windowSize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000000000000.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">startTime</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">intervalLength</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">8</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#snAPI_Main_Correlation_setFCSParameters" title="Permalink to this definition">#</a></dt>
<dd><p>This function sets the the parameters for the FCS correlation. If the <cite>startChannel</cite> is the same as the
<cite>stopChannel</cite> an autocorrelation is calculated and if the channels are different a
cross calculation is calculated.</p>
Expand All @@ -4024,8 +4026,10 @@
<dd class="field-odd"><ul class="simple">
<li><p><strong>startChannel</strong> (<em>int</em><em> (</em><em>0 is sync channel</em><em>)</em>) – start channel</p></li>
<li><p><strong>stopChannel</strong> (<em>int</em><em> (</em><em>0 is sync channel</em><em>)</em>) – click channel</p></li>
<li><p><strong>windowSize</strong> (<em>int</em><em> [</em><em>ps</em><em>]</em>) – size of the correlation window</p></li>
<li><p><strong>windowSize</strong> (<em>float</em><em> [</em><em>ps</em><em>]</em>) – size of the correlation window</p></li>
<li><p><strong>startTime</strong> (<em>int</em><em> [</em><em>ps</em><em>]</em>) – minimum tau, the left border of the correlation (Default: None - T2: BaseResolution, T3: Resolution)</p></li>
<li><p><strong>startTime</strong> – number of sub elements, that the multiple tau algorithm uses to create (Default: None - T2: BaseResolution, T3: Resolution)</p></li>
<li><p><strong>intervalLength</strong> (<em>int</em><em> | </em><em>None</em>) – </p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
Expand Down
4 changes: 2 additions & 2 deletions snAPI/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LibType(Enum):
(HH400) devices.
"""
TH260 = 3
TH260 = 2
"""
This selects the library for the
`TimeHarp 260 <https://www.picoquant.com/products/category/tcspc-and-time-tagging-modules/timeharp-260-tcspc-and-mcs-board-with-pcie-interface>`_
Expand All @@ -40,7 +40,7 @@ class LibType(Enum):
with a deadtime below 2 ns.
"""
PH330 = 4
PH330 = 3
"""
This selects the library for the
`PicoHarp 330 <https://www.picoquant.com/products/category/tcspc-and-time-tagging-modules/picoharp_330_precise_and_versatile_event_timer_and_tcspc_unit>`_
Expand Down
Loading

0 comments on commit 595cc56

Please sign in to comment.