-
Notifications
You must be signed in to change notification settings - Fork 70
Save clock instructions and add runviewer parser for DummyPseudoclock #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
philipstarkey
merged 2 commits into
labscript-suite:master
from
rpanderson:dummy_pseudoclock_updates
Jun 24, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import labscript_utils.h5_lock # noqa: F401 | ||
import h5py | ||
import numpy as np | ||
|
||
|
||
class DummyPseudoclockParser(object): | ||
clock_resolution = 25e-9 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mimics the structure of |
||
trigger_delay = 350e-9 | ||
wait_delay = 2.5e-6 | ||
|
||
def __init__(self, path, device): | ||
self.path = path | ||
self.name = device.name | ||
self.device = device | ||
|
||
def get_traces(self, add_trace, clock=None): | ||
if clock is not None: | ||
times, clock_value = clock[0], clock[1] | ||
clock_indices = np.where((clock_value[1:] - clock_value[:-1]) == 1)[0] + 1 | ||
# If initial clock value is 1, then this counts as a rising edge | ||
# (clock should be 0 before experiment) but this is not picked up | ||
# by the above code. So we insert it! | ||
if clock_value[0] == 1: | ||
clock_indices = np.insert(clock_indices, 0, 0) | ||
clock_ticks = times[clock_indices] | ||
|
||
# get the pulse program | ||
with h5py.File(self.path, 'r') as f: | ||
pulse_program = f[f'devices/{self.name}/PULSE_PROGRAM'][:] | ||
|
||
time = [] | ||
states = [] | ||
trigger_index = 0 | ||
t = 0 if clock is None else clock_ticks[trigger_index] + self.trigger_delay | ||
trigger_index += 1 | ||
|
||
clock_factor = self.clock_resolution / 2.0 | ||
|
||
for row in pulse_program: | ||
if row['period'] == 0: | ||
# special case | ||
if row['reps'] == 1: # WAIT | ||
if clock is not None: | ||
t = clock_ticks[trigger_index] + self.trigger_delay | ||
trigger_index += 1 | ||
else: | ||
t += self.wait_delay | ||
else: | ||
for i in range(row['reps']): | ||
for j in range(1, -1, -1): | ||
time.append(t) | ||
states.append(j) | ||
t += row['period'] * clock_factor | ||
|
||
clock = (np.array(time), np.array(states)) | ||
|
||
clocklines_and_triggers = {} | ||
for pseudoclock_name, pseudoclock in self.device.child_list.items(): | ||
for clock_line_name, clock_line in pseudoclock.child_list.items(): | ||
if clock_line.parent_port == 'internal': | ||
clocklines_and_triggers[clock_line_name] = clock | ||
add_trace(clock_line_name, clock, self.name, clock_line.parent_port) | ||
|
||
return clocklines_and_triggers |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.