Skip to content

Commit

Permalink
stupid dot notation
Browse files Browse the repository at this point in the history
  • Loading branch information
patgo25 committed Nov 28, 2023
1 parent d2ab092 commit d170f44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/pygama/evt/build_evt.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ def evaluate_expression(
if mode == "function":
# evaluate expression
func, params = expr.split("(")
params = (
params.replace("dsp.", "dsp_")
.replace("hit.", "hit_")
.replace("evt.", "evt_")
)
params = [f_hit, f_dsp, f_tcm, chns] + [
num_and_pars(e.replace(".", "_"), var_ph) for e in params[:-1].split(",")
num_and_pars(e, var_ph) for e in params[:-1].split(",")
]

# load function dynamically
Expand Down
17 changes: 12 additions & 5 deletions src/pygama/evt/modules/legend_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@
"""
from importlib import import_module

def legend_meta(params:dict) -> list:

def legend_meta(params: dict) -> list:
# only import legend meta data when needed.
# LEGEND collaborators can use the meta keyword
# While for users w/o access to the LEGEND meta data this is still working
lm = import_module("legendmeta")
lmeta = lm.LegendMetadata(path=params["meta_path"])
chmap = lmeta.channelmap(params['time_key'])
chmap = lmeta.channelmap(params["time_key"])
tmp = [
f"ch{e}"
for e in chmap.map("daq.rawid")
if chmap.map("daq.rawid")[e]["system"] == params['system']
if chmap.map("daq.rawid")[e]["system"] == params["system"]
]
if 'usability' not in params.keys(): return tmp
if "usability" not in params.keys():
return tmp
else:
return [e for e in tmp if chmap.map("daq.rawid")[int(e[2:])]["analysis"]["usability"] == params['usability']]
return [
e
for e in tmp
if chmap.map("daq.rawid")[int(e[2:])]["analysis"]["usability"]
== params["usability"]
]

0 comments on commit d170f44

Please sign in to comment.