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

Adds get_bam_params()

parent e8ef53a0
No related branches found
No related tags found
1 merge request!160Adds get_bam_params()
...@@ -14,9 +14,11 @@ import xarray as xr ...@@ -14,9 +14,11 @@ import xarray as xr
from ..misc.bunch_pattern_external import is_pulse_at from ..misc.bunch_pattern_external import is_pulse_at
from ..mnemonics_machinery import (mnemonics_to_process, from ..mnemonics_machinery import (mnemonics_to_process,
mnemonics_for_run) mnemonics_for_run)
from ..constants import mnemonics as _mnemonics
__all__ = [ __all__ = [
'get_bam', 'get_bam',
'get_bam_params',
] ]
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -32,7 +34,7 @@ def get_bam(run, mnemonics=None, merge_with=None, bunchPattern='sase3'): ...@@ -32,7 +34,7 @@ def get_bam(run, mnemonics=None, merge_with=None, bunchPattern='sase3'):
Parameters Parameters
---------- ----------
run: extra_data.DataCollection run: extra_data.DataCollection
DataCollection containing the digitizer data. DataCollection containing the bam data.
mnemonics: str or list of str mnemonics: str or list of str
mnemonics for BAM, e.g. "BAM1932M" or ["BAM414", "BAM1932M"]. mnemonics for BAM, e.g. "BAM1932M" or ["BAM414", "BAM1932M"].
If None, defaults to "BAM1932M" in case no merge_with dataset If None, defaults to "BAM1932M" in case no merge_with dataset
...@@ -111,3 +113,40 @@ def get_bam(run, mnemonics=None, merge_with=None, bunchPattern='sase3'): ...@@ -111,3 +113,40 @@ def get_bam(run, mnemonics=None, merge_with=None, bunchPattern='sase3'):
ds = mw_ds.merge(ds, join='inner') ds = mw_ds.merge(ds, join='inner')
return ds return ds
def get_bam_params(run, mnemo_or_source='BAM1932S'):
"""
Extract the run values of bamStatus[1-3] and bamError.
Parameters
----------
run: extra_data.DataCollection
DataCollection containing the bam data.
mnemo_or_source: str
mnemonic of the BAM, e.g. 'BAM414', or source name,
e.g. 'SCS_ILH_LAS/DOOCS/BAM_414_B2.
Returns
-------
params: dict
dictionnary containing the extracted parameters.
Note
----
The extracted parameters are run values, they do not reflect any
possible change during the run.
"""
if mnemo_or_source in _mnemonics:
run_mnemonics = mnemonics_for_run(run)
source = run_mnemonics[mnemo_or_source]['source'].split(':')[0]
else:
source = mnemo_or_source
res = {}
res['status1'] = run.get_run_value(source, 'bamStatus1.value')
res['status2'] = run.get_run_value(source, 'bamStatus2.value')
res['status3'] = run.get_run_value(source, 'bamStatus3.value')
res['error'] = run.get_run_value(source, 'bamError.value')
return res
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