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

raise TypeError if npulses missing when no pulse pattern info is available

parent 0ae0897c
No related branches found
No related tags found
1 merge request!24No pulse pattern info case
......@@ -126,7 +126,7 @@ def selectSASEinXGM(data, sase='sase3', xgm='SCS_XGM', sase3First=True, npulses=
sase: key of sase to select: {'sase1', 'sase3'}
xgm: key of xgm to select: {'SA3_XGM', 'SCS_XGM'}
sase3First: bool, optional. Used in case no bunch pattern was recorded
npulses: int, optional. Used in case no bunch pattern was recorded.
npulses: int, optional. Required in case no bunch pattern was recorded.
Output:
DataArray that has all trainIds that contain a lasing
......@@ -135,10 +135,13 @@ def selectSASEinXGM(data, sase='sase3', xgm='SCS_XGM', sase3First=True, npulses=
are filled with NaNs.
'''
if sase not in data:
print('Missing bunch pattern info!\n'
+'Retrieving {} SASE {} pulses assuming that '.format(npulses, sase[4])
print('Missing bunch pattern info!')
if npulses is None:
raise TypeError('npulses argument is required when bunch pattern ' +
'info is missing.')
print('Retrieving {} SASE {} pulses assuming that '.format(npulses, sase[4])
+'SASE {} pulses come first.'.format('3' if sase3First else '1'))
#in older version of DAQ, non data numbers were filled with 0.0.
#in older version of DAQ, non-data numbers were filled with 0.0.
xgmData = data[xgm].where(data[xgm]!=0.0, drop=True)
xgmData = xgmData.fillna(0.0).where(xgmData!=1.0, drop=True)
if (sase3First and sase=='sase3') or (not sase3First and sase=='sase1'):
......@@ -449,7 +452,7 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None,
bkgstop: trace index of background stop
t_offset: index separation between two pulses
mcp: MCP channel number
npulses: int, optional. Number of pulses to compute. Needed if
npulses: int, optional. Number of pulses to compute. Required if
no bunch pattern info is available.
stride: int, optional. Used to select pulses in the APD array if
no bunch pattern info is available.
......@@ -458,9 +461,12 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None,
with N=max(number of pulses per train)
'''
if 'sase3' not in data:
print('Missing bunch pattern info!\n'
+'Retrieving {} SASE 3 pulses assuming that '.format(npulses)
+'SASE 3 pulses come first.')
print('Missing bunch pattern info!\n')
if npulses is None:
raise TypeError('npulses argument is required when bunch pattern ' +
'info is missing.')
print('Retrieving {} SASE 3 pulses assuming that '.format(npulses) +
'SASE 3 pulses come first.')
if use_apd:
tim = data['MCP{}apd'.format(mcp)][:,:npulses:stride]
else:
......@@ -800,7 +806,7 @@ def matchXgmTimPulseId(data, use_apd=True, intstart=None, intstop=None,
bkgstart: trace index of background start
bkgstop: trace index of background stop
t_offset: index separation between two pulses
npulses: number of pulses to compute. Needed if no bunch
npulses: number of pulses to compute. Required if no bunch
pattern info is available
sase3First: bool, needed if bunch pattern is missing.
stride: int, used to select pulses in the TIM APD array if
......
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