-
Notifications
You must be signed in to change notification settings - Fork 8
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
channelmap updates #78
base: main
Are you sure you want to change the base?
Changes from all commits
9931e74
2499ef9
136e2a7
54d1f58
b051873
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,6 +17,7 @@ | |||||||||||||
|
||||||||||||||
import logging | ||||||||||||||
import os | ||||||||||||||
import re | ||||||||||||||
from datetime import datetime | ||||||||||||||
from getpass import getuser | ||||||||||||||
from pathlib import Path | ||||||||||||||
|
@@ -103,7 +104,7 @@ def reset(self) -> None: | |||||||||||||
self._repo.git.checkout(self._default_git_ref) | ||||||||||||||
|
||||||||||||||
def channelmap( | ||||||||||||||
self, on: str | datetime | None = None, system: str = "all" | ||||||||||||||
self, on: str | datetime | None = None, system: str | None = None | ||||||||||||||
) -> AttrsDict: | ||||||||||||||
"""Get a LEGEND channel map. | ||||||||||||||
|
||||||||||||||
|
@@ -116,9 +117,11 @@ def channelmap( | |||||||||||||
---------- | ||||||||||||||
on | ||||||||||||||
a :class:`~datetime.datetime` object or a string matching the | ||||||||||||||
pattern ``YYYYmmddTHHMMSSZ``. | ||||||||||||||
pattern ``YYYYmmddTHHMMSSZ``, or ``p# r#``, which are period and | ||||||||||||||
run numbers. | ||||||||||||||
system: 'all', 'phy', 'cal', 'lar', ... | ||||||||||||||
query only a data taking "system". | ||||||||||||||
query only a data taking "system". If on is None, default to | ||||||||||||||
'all', otherwise this must be provided | ||||||||||||||
|
||||||||||||||
Warning | ||||||||||||||
------- | ||||||||||||||
|
@@ -136,12 +139,35 @@ def channelmap( | |||||||||||||
>>> channel.analysis.usability | ||||||||||||||
'on' | ||||||||||||||
|
||||||||||||||
>>> channel = lmeta.channelmap(on=datetime.now(), system='cal').V05267B | ||||||||||||||
|
||||||||||||||
>>> channel = lmeta.channelmap('p08 r005', system='cal').V05267B | ||||||||||||||
|
||||||||||||||
See Also | ||||||||||||||
-------- | ||||||||||||||
.textdb.TextDB.on | ||||||||||||||
""" | ||||||||||||||
if on is None: | ||||||||||||||
on = datetime.now() | ||||||||||||||
if system is None: | ||||||||||||||
system = "all" | ||||||||||||||
|
||||||||||||||
if system is None: | ||||||||||||||
msg = "Use of channelmap with an on arg but no system arg is deprecated and will raise an error in the future. Provide a value (e.g. 'all', 'cal', 'phy', etc.)" | ||||||||||||||
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.
Suggested change
|
||||||||||||||
log.warning(msg) | ||||||||||||||
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.
Suggested change
|
||||||||||||||
# msg = "System cannot be None. Provide a value (e.g. 'all', 'cal', 'phy', etc.)" | ||||||||||||||
# raise ValueError(msg) | ||||||||||||||
|
||||||||||||||
try: | ||||||||||||||
pd, run = re.fullmatch("([pP][0-9]+)\\s*([rR][0-9]+)", on).group(1, 2) | ||||||||||||||
runinfo = self.dataprod.runinfo[pd][run] | ||||||||||||||
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. Will this generate an understandable error message if the string does not match? |
||||||||||||||
if system == "all": | ||||||||||||||
on = next(iter(runinfo.values())).start_key | ||||||||||||||
else: | ||||||||||||||
on = runinfo[system].start_key | ||||||||||||||
except (AttributeError, TypeError): | ||||||||||||||
# on is not a period/run | ||||||||||||||
pass | ||||||||||||||
|
||||||||||||||
chmap = self.hardware.configuration.channelmaps.on( | ||||||||||||||
on, pattern=None, system=system | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.