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

added function to match XGM and TIM pulse Id

parent fcd1612e
No related branches found
No related tags found
No related merge requests found
...@@ -395,6 +395,7 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None, ...@@ -395,6 +395,7 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None,
The missing values, in case of change of number of pulses, are filled The missing values, in case of change of number of pulses, are filled
with NaNs. with NaNs.
Inputs:
data: xarray Dataset containing MCP raw traces (e.g. 'MCP1raw') data: xarray Dataset containing MCP raw traces (e.g. 'MCP1raw')
intstart: trace index of integration start intstart: trace index of integration start
intstop: trace index of integration stop intstop: trace index of integration stop
...@@ -721,4 +722,44 @@ def checkTimApdWindow(data, mcp=1, use_apd=True, intstart=None, intstop=None): ...@@ -721,4 +722,44 @@ def checkTimApdWindow(data, mcp=1, use_apd=True, intstart=None, intstop=None):
ax2.legend(lines + lines2, labels + labels2, loc=0) ax2.legend(lines + lines2, labels + labels2, loc=0)
else: else:
ax.legend(loc='lower left') ax.legend(loc='lower left')
plt.tight_layout() plt.tight_layout()
\ No newline at end of file
def matchXgmTimPulseId(data, use_apd=True, intstart=None, intstop=None,
bkgstart=None, bkgstop=None, t_offset=None,
npulses=None):
''' Function to match XGM pulse Id with TIM pulse Id.
Inputs:
data: xarray Dataset containing XGM and TIM data
use_apd: bool. If True, uses the digitizer APD ('MCP[1,2,3,4]apd').
If False, peak integration is performed from raw traces.
All following parameters are needed in this case.
intstart: trace index of integration start
intstop: trace index of integration stop
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
Output:
xr DataSet containing XGM and TIM signals with the share
dimension 'pId'. Raw traces, raw XGM and raw APD are dropped.
'''
res = tb.selectSASEinXGM(data, xgm='SCS_XGM').rename({'XGMbunchId':'pId'})
res2 = tb.selectSASEinXGM(data, xgm='SA3_XGM').rename({'XGMbunchId':'pId'})
dropList = ['SCS_XGM','SA3_XGM']
mergeList = [res, res2]
for mcp in range(1,5):
if 'MCP{}apd'.format(mcp) in data or 'MCP{}raw'.format(mcp) in data:
MCPapd = tb.getTIMapd(data, mcp=mcp, use_apd=use_apd, intstart=intstart, intstop=intstop,
bkgstart=bkgstart, bkgstop=bkgstop, t_offset=t_offset,
npulses=npulses).rename('MCP{}apd'.format(mcp))
if use_apd:
MCPapd = MCPapd.rename({'apdId':'pId'})
else:
MCPapd = MCPapd.rename({'MCP{}fromRaw'.format(mcp):'pId'})
dropList.append('MCP{}raw'.format(mcp))
mergeList.append(MCPapd)
dropList.append('MCP{}apd'.format(mcp))
mergeList.append(data.drop(dropList))
subset = xr.merge(mergeList, join='inner')
return subset
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