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

Copied relevant masks, no need to load euxfel_bunch_pattern package

parent e03ba9c7
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,6 @@ from karabo_data import by_index, RunDirectory
from karabo_data.read_machinery import find_proposal
import xarray as xr
import os
import euxfel_bunch_pattern as bp
mnemonics = {
# Machine
......@@ -377,8 +376,10 @@ mnemonics = {
}
def extractSaseBunchPattern(runDir, sase=3):
''' generate the "saseX" and "npulse_saseX" arrays directly from the bunch pattern table and not using the
MDL device BUNCH_DECODER.
''' generate the "saseX" and "npulse_saseX" arrays directly from the bunch pattern
table and not using the MDL device BUNCH_DECODER. This is inspired from the
euxfel_bunch_pattern project,
https://git.xfel.eu/gitlab/karaboDevices/euxfel_bunch_pattern.git
Inputs:
runDir: run directory obtained by karabo_data.runDirectory()
sase: int, sase number between 1 and 3
......@@ -390,18 +391,23 @@ def extractSaseBunchPattern(runDir, sase=3):
'''
if not (1 <= sase <= 3):
raise ValueError("Invalid SASE value {!r}, expected 1-3")
# define relevant masks, see euxfel_bunch_pattern project for details
DESTINATION_MASK = 0xf << 18
DESTINATION_T4D = 4 << 18 # SASE1/3 dump
DESTINATION_T5D = 2 << 18 # SASE2 dump
PHOTON_LINE_DEFLECTION = 1 << 27 # Soft kick (e.g. SA3)
bp_mnemo = mnemonics['bunchPatternTable']
bp_table = runDir.get_array(bp_mnemo['source'],bp_mnemo['key'],
extra_dims=bp_mnemo['dim'])
destination = bp.DESTINATION_T5D if (sase == 2) else bp.DESTINATION_T4D
matched = (bp_table & bp.DESTINATION_MASK) == destination
destination = DESTINATION_T5D if (sase == 2) else DESTINATION_T4D
matched = (bp_table & DESTINATION_MASK) == destination
if sase == 1:
# Pulses to SASE 1 when soft kick is off
matched &= (bp_table & bp.PHOTON_LINE_DEFLECTION) == 0
matched &= (bp_table & PHOTON_LINE_DEFLECTION) == 0
elif sase == 3:
# Pulses to SASE 3 when soft kick is on
matched &= (bp_table & bp.PHOTON_LINE_DEFLECTION) != 0
matched &= (bp_table & PHOTON_LINE_DEFLECTION) != 0
nz = np.nonzero(matched.values)
dim_pId = matched.shape[1]
......
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