-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simulation with modulated output (#390)
* wip: simulation with sample from pulser.sampler.sample() * wip: convert defaultdict to dicts in samples() * wip: determine the basis with empty or zeros samples dicts * wip: update notebook to demonstrate previous fixes * wip: add flag for final zero samples * wip: update Simulation sample extraction * wip: update notebook to showcase changes * Adds sampling with SLM mask and simulation with modulation * Noisy simulations from sampled sequences * Type hinting * Simulation drawing with modulation + bug fixes * Change application of amplitude noise fluctuations * Small fixes to sampling and simulation logic * Updating the unit tests * Updating the tutorials * Incorporating review comments and suggestions Co-authored-by: Louis Vignoli <[email protected]>
- Loading branch information
Showing
12 changed files
with
518 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,44 @@ | ||
"""Defines the main function for sequence sampling.""" | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from pulser.sampler.samples import SequenceSamples | ||
from pulser.sampler.samples import SequenceSamples, _SlmMask | ||
|
||
if TYPE_CHECKING: # pragma: no cover | ||
from pulser import Sequence | ||
|
||
|
||
def sample(seq: Sequence, modulation: bool = False) -> SequenceSamples: | ||
def sample( | ||
seq: Sequence, | ||
modulation: bool = False, | ||
extended_duration: Optional[int] = None, | ||
) -> SequenceSamples: | ||
"""Construct samples of a Sequence. | ||
Args: | ||
seq: The sequence to sample. | ||
modulation: Whether to modulate the samples. | ||
extended_duration: If defined, extends the samples duration to the | ||
desired value. | ||
""" | ||
samples_list = [ | ||
ch_schedule.get_samples(modulated=modulation) | ||
for ch_schedule in seq._schedule.values() | ||
] | ||
if extended_duration: | ||
samples_list = [ | ||
cs.extend_duration(extended_duration) for cs in samples_list | ||
] | ||
optionals = {} | ||
if seq._slm_mask_targets and seq._slm_mask_time: | ||
optionals["_slm_mask"] = _SlmMask( | ||
seq._slm_mask_targets, | ||
seq._slm_mask_time[1], | ||
) | ||
return SequenceSamples( | ||
list(seq.declared_channels.keys()), | ||
[ | ||
ch_schedule.get_samples(modulated=modulation) | ||
for ch_schedule in seq._schedule.values() | ||
], | ||
samples_list, | ||
seq.declared_channels, | ||
**optionals, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.