Skip to content
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

Option to get run values without timestamps #581

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion extra_data/sourcedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def run_value(self, key, *, allow_multi_run=False):
return val.decode('utf-8', 'surrogateescape')
return val

def run_values(self):
def run_values(self, inc_timestamps=True):
"""Get a dict of all RUN values for this source

This includes keys which are also in CONTROL.
Expand All @@ -461,6 +461,8 @@ def visitor(path, obj):

# Arbitrary file - should be the same across a run
self.files[0].file['RUN'][self.source].visititems(visitor)
if not inc_timestamps:
return {k[:-6]: v for (k, v) in res.items() if k.endswith('.value')}
return res

@property
Expand Down
8 changes: 8 additions & 0 deletions extra_data/tests/test_sourcedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ def test_run_value(mock_spb_raw_run):
value = xgm.run_value('pulseEnergy.conversion.value')
assert isinstance(value, np.float64)

run_dict = xgm.run_values()
assert 'pulseEnergy.conversion.value' in run_dict
assert 'pulseEnergy.conversion.timestamp' in run_dict

values_dict = xgm.run_values(inc_timestamps=False)
assert 'pulseEnergy.conversion' in values_dict
assert 'pulseEnergy.conversion.timestamp' not in values_dict

with pytest.raises(ValueError):
# no run values for instrument sources
am0.run_values()
Expand Down
Loading