Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
artiq_experiments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Nunez Barreto
artiq_experiments
Commits
6cffa368
Commit
6cffa368
authored
May 31, 2021
by
Lucas Giardino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agrego posible applet dehistogramas realtime + ejemplo de prueba
parent
931683cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
0 deletions
+124
-0
histogram.py
artiq_master/repository/histogram.py
+46
-0
pmt_mock_counts_display.py
artiq_master/repository/pmt_mock_counts_display.py
+78
-0
No files found.
artiq_master/repository/histogram.py
0 → 100644
View file @
6cffa368
#!/usr/bin/env python3
import
numpy
as
np
import
PyQt5
# make sure pyqtgraph imports Qt5
import
pyqtgraph
from
artiq.applets.simple
import
TitleApplet
class
MakeHistogramAndPlot
(
pyqtgraph
.
PlotWidget
):
def
__init__
(
self
,
args
):
pyqtgraph
.
PlotWidget
.
__init__
(
self
)
self
.
args
=
args
def
data_changed
(
self
,
data
,
mods
,
title
):
#print(data)
try
:
y
=
data
[
self
.
args
.
y
][
1
]
y
=
y
[
~
np
.
isnan
(
y
)]
#print(self.args.x)
#if len(y[~np.isnan(y)]) > 5: return
if
self
.
args
.
x
is
None
:
x
=
'auto'
else
:
x
=
data
[
self
.
args
.
x
][
1
]
except
KeyError
:
return
# This makes the histogram with the full datasets
# may be slow so it should be run with a reasonable
# --update-delay value
heigs
,
binsides
=
np
.
histogram
(
y
,
bins
=
x
,
density
=
True
)
self
.
clear
()
self
.
plot
(
binsides
,
heigs
,
stepMode
=
True
,
fillLevel
=
0
,
brush
=
(
0
,
0
,
255
,
150
))
self
.
setTitle
(
title
)
def
main
():
applet
=
TitleApplet
(
MakeHistogramAndPlot
)
applet
.
add_dataset
(
"y"
,
"Y values"
)
applet
.
add_dataset
(
"x"
,
"Bin boundaries"
,
required
=
False
)
applet
.
run
()
if
__name__
==
"__main__"
:
main
()
artiq_master/repository/pmt_mock_counts_display.py
0 → 100644
View file @
6cffa368
from
artiq.experiment
import
*
import
time
import
numpy
as
np
from
scipy.stats
import
poisson
class
MockPMT
():
#{{{
def
__init__
(
self
,
mean
=
50
):
self
.
mean
=
mean
def
count
(
self
):
return
poisson
.
rvs
(
self
.
mean
)
def
change_mean
(
self
,
new_mean
):
self
.
mean
=
new_mean
# }}}
class
PMTCountRealtime
(
EnvExperiment
):
"""Realtime PMT counts visualization"""
def
build
(
self
):
self
.
setattr_argument
(
"no_measures"
,
NumberValue
(
10
,
min
=
1
,
ndecimals
=
0
,
step
=
1
))
self
.
setattr_argument
(
"freqs"
,
Scannable
(
default
=
CenterScan
(
200
*
MHz
,
20
*
MHz
,
1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
self
.
setattr_device
(
"ccb"
)
# To issue the applets
self
.
pmt
=
MockPMT
(
mean
=
6
)
def
run
(
self
):
self
.
set_dataset
(
"current_freq"
,
np
.
full
(
1
,
0.
),
broadcast
=
True
,
archive
=
False
)
# Applet creation {{{
self
.
ccb
.
issue
(
"create_applet"
,
"output_frecuency"
,
"${artiq_applet}big_number "
"current_freq"
,
group
=
"realtime_pmt"
)
self
.
ccb
.
issue
(
"create_applet"
,
"ticks_plot"
,
"${artiq_applet}plot_xy "
"ticks"
,
group
=
"realtime_pmt"
)
# Custom histogram plot creator (needs a reasonable --update-delay)
self
.
ccb
.
issue
(
"create_applet"
,
"ticks_histogram"
,
"${artiq_applet}histogram "
"ticks "
"--update-delay 0.5"
,
group
=
"realtime_pmt"
)
# }}}
# # Change freq and read {{{
# # this emulates a change in frequency, then many pmt readings
# # and storing (displaying) the mean
# self.set_dataset("ticks", np.full(len(self.freqs), np.nan),
# broadcast=True, archive=False)
# counts = 0
# for fn, curr_freq in enumerate(self.freqs):
# self.mutate_dataset("current_freq", 0, curr_freq)
# # self.pmt.change_mean(60 + 5*fn)
# counts = 0
# for i in range(self.no_measures):
# counts += self.pmt.count()
# time.sleep(20e-6)
# self.mutate_dataset("ticks", fn, counts/self.no_measures)
# # }}}
# PMT count reading {{{
# This emulates just reading from the PMT: e.g. dark counts distr
self
.
set_dataset
(
"ticks"
,
np
.
full
(
self
.
no_measures
,
np
.
nan
),
broadcast
=
True
,
archive
=
False
)
for
i
in
range
(
self
.
no_measures
):
self
.
mutate_dataset
(
"ticks"
,
i
,
self
.
pmt
.
count
())
time
.
sleep
(
20e-3
)
# }}}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment