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

Merge branch 'rep_rate' into 'master'

Adds function repRate()

See merge request SCS/ToolBox!22
parents faa99930 d1f7d1cf
No related branches found
No related tags found
No related merge requests found
...@@ -83,14 +83,37 @@ def pulsePatternInfo(data, plot=False): ...@@ -83,14 +83,37 @@ def pulsePatternInfo(data, plot=False):
print('\n') print('\n')
if plot: if plot:
plt.figure(figsize=(6,3)) plt.figure(figsize=(6,3))
plt.plot(data['npulses_sase3'].trainId, data['npulses_sase3'], 'o-', ms=3, label='SASE 3') plt.plot(data['npulses_sase3'].trainId, data['npulses_sase3'], 'o-',
ms=3, label='SASE 3')
plt.xlabel('trainId') plt.xlabel('trainId')
plt.ylabel('pulses per train') plt.ylabel('pulses per train')
plt.plot(data['npulses_sase1'].trainId, data['npulses_sase1'], '^-', ms=3, color='C2', label='SASE 1') plt.plot(data['npulses_sase1'].trainId, data['npulses_sase1'], '^-',
ms=3, color='C2', label='SASE 1')
plt.legend() plt.legend()
plt.tight_layout() plt.tight_layout()
def repRate(data, sase='sase3'):
''' Calculates the pulse repetition rate in sase according
to the bunch pattern and assuming a minimum pulse
separation of 222e-9 seconds.
Inputs:
data: xarray Dataset containing pulse pattern
sase: sase in which the repetition rate is
calculated (1,2 or 3)
Output:
f: repetition rate in kHz
'''
assert sase in data, 'key "{}" not found in data!'.format(sase)
sase = data[sase].where(data['npulses_{}'.format(sase)]>1,
drop=True).values
if len(sase)==0:
print('Not enough pulses to extract repetition rate')
return 0
f = 1/((sase[0,1] - sase[0,0])*222e-6)
return f
def selectSASEinXGM(data, sase='sase3', xgm='SCS_XGM'): def selectSASEinXGM(data, sase='sase3', xgm='SCS_XGM'):
''' Extract SASE1- or SASE3-only XGM data. ''' Extract SASE1- or SASE3-only XGM data.
There are various cases depending on i) the mode of operation (10 Hz There are various cases depending on i) the mode of operation (10 Hz
......
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