Skip to content

Commit

Permalink
v1.0.3
Browse files Browse the repository at this point in the history
API:
- count rate manipulator
- fix Memory leak in Unfold Class
- inverted herald parameter
- CoincidenceTime parameter (first, last)
- update PH330 library
- fix SyncDiv (ex SyncDivider)
- update deviceConfig["Resolution"] on setBinnig
- fix MeasMode Histogram
- fix SetStopOverflow

Python:
- fix bins array in T2 histogram with custom bin width
- fix long range bins array in histogram class
  • Loading branch information
tpoint75 committed Jan 24, 2024
1 parent 6c4afc8 commit be90fd1
Show file tree
Hide file tree
Showing 21 changed files with 334 additions and 81 deletions.
33 changes: 24 additions & 9 deletions demos/Demo_HeraldedCorrelationG2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,40 @@

if(__name__ == "__main__"):

sn = snAPI(libType=LibType.MH)
sn = snAPI(libType=LibType.PH330)
sn.getDeviceIDs()
sn.getDevice()
sn.initDevice(MeasMode.T2)
sn.loadIniConfig("config\PH330_CFD.ini")

windowSize = 2000 #ps
# move the histograms of the both channels to the same time after the sync to filter both at once
sn.device.setInputChannelOffset(0,-4000)

# 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)
# measure the count rate before the herald filter
CrInIdx = sn.manipulators.countrate()

# define a gate window after the herald channel 0 (sync) for the detector channels 1 and 2,
# starting at 52000 ps after the herald signal , with a gate length of windowSize (300 ps)
heraldChans = sn.manipulators.herald(0, [1,2], 46000, windowSize, inverted=False, keepChannels=True )

# measure the count rate after the herald filter
CrOutIdx = sn.manipulators.countrate()

# initiate the g2 correlation with the time-gated channels
sn.correlation.setG2Parameters(heraldChans[0],heraldChans[1], 500000, 100)
sn.correlation.measure(100000,savePTU=False)
sn.correlation.setG2Parameters(heraldChans[0], heraldChans[1], windowSize, 1)
sn.correlation.measure(10000,savePTU=False)

while True:
finished = sn.correlation.isFinished()
data, bins = sn.correlation.getG2Data()

CRin = sn.manipulators.getCountrates(CrInIdx)
CRout = sn.manipulators.getCountrates(CrOutIdx)

# print the count rates
sn.logPrint(f"CR in: {CRin[1]}, {CRin[2]} - out: {CRout[heraldChans[0]]}, {CRout[heraldChans[1]]}")

time.sleep(.3)

plt.clf()
Expand Down
8 changes: 4 additions & 4 deletions demos/Demo_HistogramRefresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,23 @@

sn = snAPI(libType=LibType.PH330)
sn.getDevice()
sn.initDevice(MeasMode.T2)
sn.initDevice(MeasMode.T3)
sn.device.setBinning(2)

# temporarily enable logging of configuration
sn.setLogLevel(LogLevel.Config, True)
# set the configuration for your device type
sn.loadIniConfig("config\PH330_CFD.ini")
sn.loadIniConfig("config\PH330_Edge.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)
Expand All @@ -45,6 +44,7 @@
# clear measure data
sn.histogram.clearMeasure()
if finished:
sn.setLogLevel(LogLevel.Manipulators, True)
break

plt.show(block=True)
25 changes: 0 additions & 25 deletions demos/Demo_RecordViewerUF.py

This file was deleted.

7 changes: 4 additions & 3 deletions demos/Demo_TimeTrace_Coincidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

sn = snAPI(libType=LibType.HH)
sn.getDevice()
sn.getFileDevice("C:\Data\PicoQuant\default_109.ptu")

# alternatively read data from file
sn.setLogLevel(LogLevel.DataFile, True)
Expand All @@ -17,8 +18,8 @@
#sn.setLogLevel(logLevel=LogLevel.Config, onOff=True)
sn.loadIniConfig("config\HH.ini")

coincidenceAll = sn.manipulators.coincidence([1,3], windowTime=1e7, mode=CoincidenceMode.CountAll, keepChannels=True)
coincidenceOnce = sn.manipulators.coincidence([1,3], windowTime=1e7, mode=CoincidenceMode.CountOnce, keepChannels=True)
coincidenceAll = sn.manipulators.coincidence([1,2], windowTime=1e7, mode=CoincidenceMode.CountAll, keepChannels=True)
coincidenceOnce = sn.manipulators.coincidence([1,2], windowTime=1e7, mode=CoincidenceMode.CountOnce, keepChannels=True)
# measure 10s
sn.timeTrace.measure(10000, waitFinished=False, savePTU=False)

Expand All @@ -28,7 +29,7 @@
plt.clf()
plt.plot(times, counts[0], linewidth=2.0, label='sync')
plt.plot(times, counts[1], linewidth=2.0, label='chan1')
plt.plot(times, counts[3], linewidth=2.0, label='chan3')
plt.plot(times, counts[2], linewidth=2.0, label='chan2')
plt.plot(times, counts[coincidenceAll], linewidth=2.0, label='coincidenceAll')
plt.plot(times, counts[coincidenceOnce], linewidth=2.0, label='coincidenceOnce')

Expand Down
2 changes: 1 addition & 1 deletion demos/config/PH330_Edge.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
HystCode = 0
SyncDiv = 1
SyncTrigMode = 0
SyncEdgeTrig = -50,0
SyncEdgeTrig = -250,0
SyncChannelOffset = 0
SyncChannelEnable = 1
SyncDeadTime = 0
Expand Down
Binary file removed dist/snAPI-1.0.2.tar.gz
Binary file not shown.
Binary file not shown.
Binary file added dist/snAPI-1.0.3.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions doc_source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ snAPI

::

pip install .\dist\snAPI-x.y.z-cp311-cp311-win_amd64.whl
pip install .\dist\snAPI-<VERSION NUMBER x.y.z>-cp311-cp311-win_amd64.whl

Dependencies
------------
Expand All @@ -70,7 +70,7 @@ Additional Features

Example cutout of a colored log.

2. To get the full power of coding we suggest to use snAPI with VSCode.
2. To get the full power of coding we suggest to use snAPI with Visual Studio Code.

.. image:: _static/VSCode.png
:class: p-2
Expand Down
4 changes: 2 additions & 2 deletions docs/_sources/install.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ snAPI

::

pip install .\dist\snAPI-x.y.z-cp311-cp311-win_amd64.whl
pip install .\dist\snAPI-<VERSION NUMBER x.y.z>-cp311-cp311-win_amd64.whl

Dependencies
------------
Expand All @@ -70,7 +70,7 @@ Additional Features

Example cutout of a colored log.

2. To get the full power of coding we suggest to use snAPI with VSCode.
2. To get the full power of coding we suggest to use snAPI with Visual Studio Code.

.. image:: _static/VSCode.png
:class: p-2
Expand Down
16 changes: 13 additions & 3 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,12 @@ <h2 id="C">C</h2>
<li><a href="snAPI.Main.html#snAPI.Main.snAPI.closeDevice">closeDevice() (snAPI.Main.snAPI method)</a>
</li>
<li><a href="snAPI.Main.html#snAPI.Main.Manipulators.coincidence">coincidence() (snAPI.Main.Manipulators method)</a>
</li>
<li><a href="snAPI.Constants.html#snAPI.Constants.CoincidenceMode">CoincidenceMode (class in snAPI.Constants)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="snAPI.Constants.html#snAPI.Constants.CoincidenceMode">CoincidenceMode (class in snAPI.Constants)</a>
<li><a href="snAPI.Constants.html#snAPI.Constants.CoincidenceTime">CoincidenceTime (class in snAPI.Constants)</a>
</li>
<li><a href="snAPI.Utils.html#snAPI.Utils.Color">Color (class in snAPI.Utils)</a>
</li>
Expand All @@ -454,6 +456,8 @@ <h2 id="C">C</h2>
<li><a href="snAPI.Constants.html#snAPI.Constants.CoincidenceMode.CountAll">CountAll (snAPI.Constants.CoincidenceMode attribute)</a>
</li>
<li><a href="snAPI.Constants.html#snAPI.Constants.CoincidenceMode.CountOnce">CountOnce (snAPI.Constants.CoincidenceMode attribute)</a>
</li>
<li><a href="snAPI.Main.html#snAPI.Main.Manipulators.countrate">countrate() (snAPI.Main.Manipulators method)</a>
</li>
<li><a href="snAPI.Utils.html#snAPI.Utils.Color.Cya">Cya (snAPI.Utils.Color attribute)</a>
</li>
Expand Down Expand Up @@ -527,11 +531,13 @@ <h2 id="F">F</h2>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="snAPI.Constants.html#snAPI.Constants.DeviceType.File">File (snAPI.Constants.DeviceType attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="snAPI.Main.html#snAPI.Main.Filter">Filter (class in snAPI.Main)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="snAPI.Main.html#snAPI.Main.snAPI.filter">filter (snAPI.Main.snAPI attribute)</a>
</li>
<li><a href="snAPI.Constants.html#snAPI.Constants.CoincidenceTime.First">First (snAPI.Constants.CoincidenceTime attribute)</a>
</li>
</ul></td>
</tr></table>
Expand All @@ -548,6 +554,8 @@ <h2 id="G">G</h2>
<li><a href="snAPI.Main.html#snAPI.Main.Unfold.getChannels">getChannels() (snAPI.Main.Unfold method)</a>
</li>
<li><a href="snAPI.Main.html#snAPI.Main.Manipulators.getConfig">getConfig() (snAPI.Main.Manipulators method)</a>
</li>
<li><a href="snAPI.Main.html#snAPI.Main.Manipulators.getCountrates">getCountrates() (snAPI.Main.Manipulators method)</a>
</li>
<li><a href="snAPI.Main.html#snAPI.Main.snAPI.getCountRates">getCountRates() (snAPI.Main.snAPI method)</a>
</li>
Expand Down Expand Up @@ -669,6 +677,8 @@ <h2 id="I">I</h2>
<h2 id="L">L</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="snAPI.Constants.html#snAPI.Constants.CoincidenceTime.Last">Last (snAPI.Constants.CoincidenceTime attribute)</a>
</li>
<li><a href="snAPI.Constants.html#snAPI.Constants.LibType">LibType (class in snAPI.Constants)</a>
</li>
<li><a href="snAPI.Main.html#snAPI.Main.snAPI.loadIniConfig">loadIniConfig() (snAPI.Main.snAPI method)</a>
Expand Down
4 changes: 2 additions & 2 deletions docs/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ <h2>snAPI<a class="headerlink" href="#snapi" title="Permalink to this heading">#
<li><p>Download the latest release from <a class="reference external" href="https://github.com/picoQuant/snapi/releases">github.com/picoQuant/snAPI/releases</a> from the repository: <a class="github reference external" href="https://github.com/picoquant/snapi">picoquant/snapi</a></p></li>
<li><p>Finally, you can unpack the files and install your package using <cite>pip</cite>. Navigate to the directory where your package is located, and type the following command:</p></li>
</ol>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="o">.</span>\<span class="n">dist</span>\<span class="n">snAPI</span><span class="o">-</span><span class="n">x</span><span class="o">.</span><span class="n">y</span><span class="o">.</span><span class="n">z</span><span class="o">-</span><span class="n">cp311</span><span class="o">-</span><span class="n">cp311</span><span class="o">-</span><span class="n">win_amd64</span><span class="o">.</span><span class="n">whl</span>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="o">.</span>\<span class="n">dist</span>\<span class="n">snAPI</span><span class="o">-&lt;</span><span class="n">VERSION</span> <span class="n">NUMBER</span> <span class="n">x</span><span class="o">.</span><span class="n">y</span><span class="o">.</span><span class="n">z</span><span class="o">&gt;-</span><span class="n">cp311</span><span class="o">-</span><span class="n">cp311</span><span class="o">-</span><span class="n">win_amd64</span><span class="o">.</span><span class="n">whl</span>
</pre></div>
</div>
</section>
Expand Down Expand Up @@ -431,7 +431,7 @@ <h2>Additional Features<a class="headerlink" href="#additional-features" title="
<img alt="_images/Log.png" class="p-2" src="_images/Log.png" />
<p>Example cutout of a colored log.</p>
<ol class="arabic simple" start="2">
<li><p>To get the full power of coding we suggest to use snAPI with VSCode.</p></li>
<li><p>To get the full power of coding we suggest to use snAPI with Visual Studio Code.</p></li>
</ol>
<img alt="_images/VSCode.png" class="p-2" src="_images/VSCode.png" />
<p>VSCode will show the documentation on mouse hover.</p>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions docs/snAPI.Constants.html
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,30 @@

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="snAPI_Constants_CoincidenceTime">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">snAPI.Constants.</span></span><span class="sig-name descname"><span class="pre">CoincidenceTime</span></span><a class="headerlink" href="#snAPI_Constants_CoincidenceTime" title="Permalink to this definition">#</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">Enum</span></code></p>
<p>This defines the position of the timetag of the calculated coincidence.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="snAPI_Constants_CoincidenceTime_First">
<span class="sig-name descname"><span class="pre">First</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">0</span></em><a class="headerlink" href="#snAPI_Constants_CoincidenceTime_First" title="Permalink to this definition">#</a></dt>
<dd><p>The coincidence will get the timetag of the first event that build the coincidence.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This makes it is possible to create a herald filter with herald = coincidence and the same window time to filter (removing) the coincidences.
It will work as anti coincidence than.</p>
</div>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="snAPI_Constants_CoincidenceTime_Last">
<span class="sig-name descname"><span class="pre">Last</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">1</span></em><a class="headerlink" href="#snAPI_Constants_CoincidenceTime_Last" title="Permalink to this definition">#</a></dt>
<dd><p>The coincidence will get the timetag of the last event that build the coincidence.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="snAPI_Constants_UnfoldFormat">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">snAPI.Constants.</span></span><span class="sig-name descname"><span class="pre">UnfoldFormat</span></span><a class="headerlink" href="#snAPI_Constants_UnfoldFormat" title="Permalink to this definition">#</a></dt>
Expand Down Expand Up @@ -834,6 +858,11 @@
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#snAPI_Constants_CoincidenceMode_CountOnce"><code class="docutils literal notranslate"><span class="pre">CoincidenceMode.CountOnce</span></code></a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#snAPI_Constants_CoincidenceTime"><code class="docutils literal notranslate"><span class="pre">CoincidenceTime</span></code></a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#snAPI_Constants_CoincidenceTime_First"><code class="docutils literal notranslate"><span class="pre">CoincidenceTime.First</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#snAPI_Constants_CoincidenceTime_Last"><code class="docutils literal notranslate"><span class="pre">CoincidenceTime.Last</span></code></a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#snAPI_Constants_UnfoldFormat"><code class="docutils literal notranslate"><span class="pre">UnfoldFormat</span></code></a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#snAPI_Constants_UnfoldFormat_Nothing"><code class="docutils literal notranslate"><span class="pre">UnfoldFormat.Nothing</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#snAPI_Constants_UnfoldFormat_Absolute"><code class="docutils literal notranslate"><span class="pre">UnfoldFormat.Absolute</span></code></a></li>
Expand Down
Loading

0 comments on commit be90fd1

Please sign in to comment.