Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
fa74d0ef
Commit
fa74d0ef
authored
May 07, 2021
by
Valentin Valls
Browse files
Add poissonian filter
parent
3af4dd59
Changes
1
Hide whitespace changes
Inline
Side-by-side
bliss/controllers/simulation_counter.py
View file @
fa74d0ef
...
...
@@ -402,7 +402,13 @@ class SimulationCounter(Counter):
class
_Signal
:
"""Helper to provide a set of predefined signals"""
"""Helper to provide a set of predefined 1D signals
Arguments:
name: Name of the shape of the signal. See `SIGNALS`.
npoints: Number of points generated for this signal
poissonian: If true the signal is randomized with poissonian filter
"""
@
staticmethod
def
_missing_edge_of_gaussian_left
(
npoints
,
frac_missing
):
...
...
@@ -476,14 +482,20 @@ class _Signal:
"linear_up"
:
lambda
npoints
:
numpy
.
linspace
(
0
,
1
,
num
=
npoints
),
}
def
__init__
(
self
,
name
:
str
=
"sawtooth"
,
npoints
:
int
=
50
):
def
__init__
(
self
,
name
:
str
=
"sawtooth"
,
npoints
:
int
=
50
,
poissonian
:
bool
=
False
):
if
name
not
in
self
.
SIGNALS
:
raise
RuntimeError
(
f
"Signal name '
{
name
}
' undefined"
)
self
.
name
=
name
self
.
npoints
=
npoints
self
.
poissonian
=
poissonian
def
compute
(
self
)
->
numpy
.
ndarray
:
return
self
.
SIGNALS
[
self
.
name
](
self
.
npoints
)
signal
=
self
.
SIGNALS
[
self
.
name
](
self
.
npoints
)
if
self
.
poissonian
:
signal
=
numpy
.
random
.
poisson
(
signal
)
return
signal
class
FixedShapeCounter
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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