Skip to content
Snippets Groups Projects
Commit e8c6a69b authored by Laurent Mercadier's avatar Laurent Mercadier
Browse files

rename mnemonics to fields

parent 184bee16
No related branches found
No related tags found
1 merge request!263Adds warning if data rate < 95% in load()
...@@ -498,7 +498,7 @@ def concatenateRuns(runs): ...@@ -498,7 +498,7 @@ def concatenateRuns(runs):
return result return result
def check_data_rate(run, mnemonics=None): def check_data_rate(run, fields=None):
""" """
Calculates the fraction of train ids that contain data in a run. Calculates the fraction of train ids that contain data in a run.
...@@ -506,7 +506,7 @@ def check_data_rate(run, mnemonics=None): ...@@ -506,7 +506,7 @@ def check_data_rate(run, mnemonics=None):
---------- ----------
run: extra_data DataCollection run: extra_data DataCollection
the DataCollection associated to the data. the DataCollection associated to the data.
mnemonics: str, list of str or dict fields: str, list of str or dict
mnemonics to check. If None, all mnemonics in the run are checked. mnemonics to check. If None, all mnemonics in the run are checked.
A custom mnemonic can be defined with a dictionnary: {'extra': A custom mnemonic can be defined with a dictionnary: {'extra':
{'source': 'SCS_CDIFFT_MAG/SUPPLY/CURRENT', 'key': {'source': 'SCS_CDIFFT_MAG/SUPPLY/CURRENT', 'key':
...@@ -518,20 +518,20 @@ def check_data_rate(run, mnemonics=None): ...@@ -518,20 +518,20 @@ def check_data_rate(run, mnemonics=None):
that contain data as values. that contain data as values.
""" """
run_mnemonics = mnemonics_for_run(run) run_mnemonics = mnemonics_for_run(run)
if mnemonics is None: if fields is None:
mnemonics = run_mnemonics fields = run_mnemonics
mnemonics = [mnemonics] if isinstance(mnemonics, str) else mnemonics fields = [fields] if isinstance(fields, str) else fields
ret = {} ret = {}
for m in mnemonics: for f in fields:
if isinstance(m, dict): if isinstance(f, dict):
name = list(m.keys())[0] name = list(f.keys())[0]
val = m[name] val = f[name]
m = name f = name
elif m not in run_mnemonics: elif f not in run_mnemonics:
log.warning(f'mnemonic {m} not found. Skipping!') log.warning(f'mnemonic {f} not found. Skipping!')
continue continue
else: else:
val = run_mnemonics[m] val = run_mnemonics[f]
counts = run[val['source']][val['key']].data_counts(False) counts = run[val['source']][val['key']].data_counts(False)
npulses = counts.max() npulses = counts.max()
if npulses == 0: # (only missing data) if npulses == 0: # (only missing data)
...@@ -539,5 +539,5 @@ def check_data_rate(run, mnemonics=None): ...@@ -539,5 +539,5 @@ def check_data_rate(run, mnemonics=None):
else: else:
counts = counts / npulses # to only count trains and not pulses counts = counts / npulses # to only count trains and not pulses
rate = counts.sum() / len(run.train_ids) rate = counts.sum() / len(run.train_ids)
ret[m] = rate ret[f] = rate
return ret return ret
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment