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

Simplified getTIMapd() for case with no change of number of pulses

parent 53021a06
No related branches found
No related tags found
No related merge requests found
......@@ -518,7 +518,7 @@ def mcpPeaks(data, intstart, intstop, bkgstart, bkgstop, mcp=1, t_offset=None, n
pattern and determine the t_offset assuming mininum pulse
separation of 220 ns and digitizer resolution of 2 GHz.
npulses: number of pulses. If None, takes the maximum number of
pulses according to the bunch patter (field 'npulses_sase3')
pulses according to the bunch pattern (field 'npulses_sase3')
Output:
results: DataArray with dims trainId x max(sase3 pulses)
......@@ -592,7 +592,32 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None,
t_offset=t_offset, npulses=npulses)
return tim
#1. case where number of SASE 3 pulses were not changed during the run:
sa3 = data['sase3'].where(data['sase3']>1, drop=True)
sa3 -= sa3[0,0]
idx = np.unique(sa3, axis=0)
npulses_sa3 = data['npulses_sase3']
maxpulses = int(npulses_sa3.max().values)
if npulses is not None:
maxpulses = np.min([npulses, maxpulses])
if len(idx)==1:
if use_apd:
apd = data['MCP{}apd'.format(mcp)]
initialDelay = data.attrs['run'].get_array(
'SCS_UTC1_ADQ/ADC/1', 'board1.apd.channel_0.initialDelay.value')[0].values
upperLimit = data.attrs['run'].get_array(
'SCS_UTC1_ADQ/ADC/1', 'board1.apd.channel_0.upperLimit.value')[0].values
period = upperLimit - initialDelay #period of the apd in number of digitizer samples
idx /= int(period/440) #440 samples correspond to the separation between two pulses at 4.5 MHz
if len(idx)==1:
idx = idx[0].astype(int)
tim = apd.isel(apdId=idx)
return tim
else:
apd = mcpPeaks(data, intstart, intstop, bkgstart, bkgstop, mcp=mcp,
t_offset=t_offset, npulses=maxpulses)
#2. case where the number of SASE 3 pulses varied during the run:
npulses_sa3 = data['npulses_sase3']
maxpulses = int(npulses_sa3.max().values)
if npulses is not None:
......
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