Skip to content

Commit

Permalink
Adds FrameCounter to smurf file emulator (#347)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
jlashner and pre-commit-ci[bot] authored Aug 31, 2022
1 parent 9835771 commit e3300f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ ENV/

# vscode
*.code-workspace
.vscode

# Custom
.crossbar/
Expand Down
18 changes: 12 additions & 6 deletions agents/smurf_file_emulator/smurf_file_emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ def get_smurf_status():
SUBBANDS_PER_BAND = 512
CHANS_PER_BAND = 512

primary_names = [
'UnixTime', 'FluxRampIncrement', 'FluxRampOffset', 'Counter0',
'Counter1', 'Counter2', 'AveragingResetBits', 'FrameCounter',
'TESRelaySetting'
]
primary_idxs = {name: idx for idx, name in enumerate(primary_names)}


class Tune:
"""
Expand Down Expand Up @@ -145,6 +152,7 @@ class G3FrameGenerator:
def __init__(self, stream_id, sample_rate, tune,
action=None, action_time=None):
self.frame_num = 0
self.sample_num = 0
self.session_id = int(time.time())
self.tune = tune
self.nchans = np.sum(tune.channels != -1)
Expand Down Expand Up @@ -202,6 +210,8 @@ def get_data_frame(self, start, stop):

times = np.arange(start, stop, 1. / self.sample_rate)
nsamps = len(times)
frame_counter = np.arange(self.sample_num, self.sample_num + nsamps, dtype=int)
self.sample_num += nsamps
chans = np.arange(self.nchans)
names = [f'r{ch:0>4}' for ch in chans]

Expand All @@ -216,13 +226,9 @@ def get_data_frame(self, start, stop):
g3times = core.G3VectorTime(times * core.G3Units.s)
fr['data'] = so3g.G3SuperTimestream(names, g3times, data)

primary_names = [
'UnixTime', 'FluxRampIncrement', 'FluxRampOffset', 'Counter0',
'Counter1', 'Counter2', 'AveragingResetBits', 'FrameCounter',
'TESRelaySetting'
]
primary_data = np.zeros((len(primary_names), nsamps), dtype=np.int64)
primary_data[0, :] = (times * 1e9).astype(int)
primary_data[primary_idxs['UnixTime'], :] = (times * 1e9).astype(int)
primary_data[primary_idxs['FrameCounter'], :] = frame_counter
fr['primary'] = so3g.G3SuperTimestream(primary_names, g3times, primary_data)

tes_bias_names = [f'bias{bg:0>2}' for bg in range(NBIASLINES)]
Expand Down

0 comments on commit e3300f6

Please sign in to comment.