From 253d56d8da47b0b304e98b3c58ea0220642e0c93 Mon Sep 17 00:00:00 2001 From: Laurent Mercadier <laurent.mercadier@xfel.eu> Date: Tue, 10 Mar 2020 16:25:14 +0100 Subject: [PATCH] Rename BAM array dimnension to match XGM, TIM... --- bunch_pattern.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bunch_pattern.py b/bunch_pattern.py index b135db4..42f34a6 100644 --- a/bunch_pattern.py +++ b/bunch_pattern.py @@ -187,7 +187,8 @@ def sortBAMdata(data, key='sase3'): corresponds to FLASH busrt length of 800 us @ 9 MHz. The bunchPatternTable only has 2700 values, corresponding to XFEL 600 us burst length @ 4.5 MHz. Hence, we truncate the BAM arrays to 5400 with a stride of 2 and match them - to the bunchPatternTable. + to the bunchPatternTable. If key is one of the sase, the given dimension name + of the bam arrays is 'sa[sase number]_pId', to match other data (XGM, TIM...). Inputs: data: xarray Dataset containing BAM arrays key: str, ['sase1', 'sase2', 'sase3', 'scs_ppl'] @@ -200,11 +201,14 @@ def sortBAMdata(data, key='sase3'): ndata = data dropList = [] mergeList = [] - for key in data: - if 'BAM' in key: - dropList.append(key) - bam = data[key].isel(BAMbunchId=slice(0,5400,2)) + for k in data: + if 'BAM' in k: + dropList.append(k) + bam = data[k].isel(BAMbunchId=slice(0,5400,2)) bam = bam.where(mask, drop=True) + if 'sase' in key: + name = f'sa{key[4]}_pId' + bam = bam.rename({'BAMbunchId':name}) mergeList.append(bam) mergeList.append(data.drop(dropList)) ndata = xr.merge(mergeList, join='inner') -- GitLab