Python classes

Detector

class sls_detector.Detector(multi_id=0)[source]

Bases: object

Base class used as interface with the slsDetectorSoftware. To control a specific detector use the derived classes such as Eiger and Jungfrau. Functions as an interface to the C++ API and provides a more Pythonic interface

acq()[source]

Blocking command to launch the programmed measurement. Number of frames specified by frames, cycles etc.

api_compatibility
busy

Checks the detector is acquiring. Can also be set but should only be used if the acquire fails and leaves the detector with busy == True

Note

Only works when the measurement is launched using acquire, not with status start!

Returns:True if the detector is acquiring otherwise False
Return type:bool

Examples

d.busy
>> True

#If the detector is stuck reset by:
d.busy = False
clear_errors()[source]

Clear the error mask for the detector. Used to reset after checking.

client_version

str The date of commit for the client API version

Examples

d.client_version
>> '20180327'
client_zmqip

Ip address where the client listens to zmq stream

client_zmqport

zmq port of the client

config_network()[source]

Configures the detector source and destination MAC addresses, IP addresses and UDP ports, and computes the IP header checksum for such parameters

detector_ip

Read detector ip address

detector_mac

Read detector mac address

detector_number

Get all detector numbers as a list. For Eiger the detector numbers correspond to the beb numbers.

Examples

#for beb083 and beb098
detector.detector_number
>> [83, 98]
detector_type

Return either a string or list of strings with the detector type.

  • Eiger
  • Jungfrau
  • etc.

Examples

detector.detector_type
>> 'Eiger'

detector.detector_type
>> ['Eiger',  'Jungfrau']
dynamic_range

Dynamic range of the detector.

dr max counts comments
4 15  
8 255  
16 4095 12 bit internally
32 4294967295 Autosumming of 12 bit frames
Raises:ValueError – If the dynamic range is not available in the detector
Type:int
error_mask

Read the error mask from the slsDetectorSoftware

error_message

Read the error message from the slsDetectorSoftware

exposure_time

double Exposure time in [s] of a single frame.

file_index

int Index for frames and file names

Raises:ValueError – If the user tries to set an index less than zero

Examples

detector.file_index
>> 0

detector.file_index = 10
detector.file_index
>> 10
file_name

Base file name for writing images

Examples

detector.file_name
>> 'run'

detector.file_name = 'myrun'

#For a single acquisition the detector now writes
# myrun_master_0.raw
# myrun_d0_0.raw
# myrun_d1_0.raw
# myrun_d2_0.raw
# myrun_d3_0.raw
Type:str
file_overwrite

bool If true overwrite files on disk

file_padding

Pad files in the receiver bool If true pads partial frames

file_path

Path where images are written

Raises:FileNotFoundError – If path does not exists

Examples

detector.file_path
>> '/path/to/files'

detector.file_path = '/new/path/to/other/files'
Type:str
file_write

bool If True write files to disk

firmware_version

int Firmware version of the detector

flags

Read and set flags. Accepts both single flag as string or list of flags.

Raises:RuntimeError – If flag not recognized

Examples

#Eiger
detector.flags
>> ['storeinram', 'parallel']

detector.flags = 'nonparallel'
detector.flags
>> ['storeinram', 'nonparallel']

detector.flags = ['continous', 'parallel']
flipped_data_x

Flips data on x axis. Set for eiger bottom modules

flipped_data_y

Flips data on y axis.

frame_discard_policy

Decides what the receiver does when packet loss occurs. nodiscard - keep all frames discardempty - discard only empty frames discardpartial - discard partial and empty frames

frame_padding

Padd partial frames in the receiver

frames_caught

Number of frames caught by the receiver. Can be used to check for package loss.

frames_per_file
free_shared_memory()[source]

Free the shared memory that contains the detector settings and reinitialized with 0 detectors so that you can keep using the same object.

high_voltage

High voltage applied to the sensor

hostname

hostnames of all connected detectors

Examples

detector.hostname
>> ['beb059', 'beb058']
Type:list of str
image_size

collections.namedtuple with the image size of the detector Also works setting using a normal tuple

Note

Follows the normal convention in Python of (rows, cols)

Examples

d.image_size = (512, 1024)

d.image_size
>> ImageSize(rows=512, cols=1024)

d.image_size.rows
>> 512

d.image_size.cols
>> 1024
last_client_ip

Returns the ip address of the last client that accessed the detector

Returns:
Return type:str last client ip

Examples

detector.last_client_ip
>> '129.129.202.117'
load_config(fname)[source]

Load detector configuration from a configuration file

Raises:FileNotFoundError – If the file does not exists
load_parameters(fname)[source]

Setup detector by executing commands in a parameters file

Note

If you are relying mainly on the Python API it is probably better to track the settings from Python. This function uses parameters stored in a text file and the command line commands.

Raises:FileNotFoundError – If the file does not exists
load_trimbits(fname, idet=-1)[source]

Load trimbit file or files. Either called with detector number or -1 to try to load detector specific trimbit files

Parameters:
  • fnamestr Filename (including path) to the trimbit files
  • idetint Detector to load trimbits to, -1 for all
#Assuming 500k consisting of beb049 and beb048
# 0 is beb049
# 1 is beb048

#Load name.sn049 to beb049 and name.sn048 to beb048
detector.load_trimbits('/path/to/dir/name')

#Load one file to a specific detector
detector.load_trimbits('/path/to/dir/name.sn049', 0)
lock

Lock the detector to this client

detector.lock = True
lock_receiver

Lock the receivers to this client

detector.lock_receiver = True
module_geometry

namedtuple Geometry(horizontal=nx, vertical=ny) of the detector modules.

Examples

detector.module_geometry
>> Geometry(horizontal=1, vertical=2)

detector.module_geometry.vertical
>> 2

detector.module_geometry[0]
>> 1
n_cycles

Number of cycles for the measurement (exp*n_frames)*n_cycles

n_frames

int Number of frames per acquisition

n_measurements

Number of times to repeat the programmed measurement. This is the outer most part. Real time operation is not guaranteed since this is software controlled.

Examples

detector.n_frames = 1
detector.n_cycles = 1
detector.n_measurements = 3

detector.acq() # 1 frame 3 times

detector.n_frames = 5
detector.n_cycles = 3
detector.n_measurements = 2

detector.acq() # 5x3 frames 2 times total 30 frames
n_modules

int Number of (half)modules in the detector

Examples

detector.n_modules
>> 2
online

Online flag for the detector

Examples

d.online
>> False

d.online = True
period

double Period between start of frames. Set to 0 for the detector to choose the shortest possible

rate_correction

list of double Rate correction for all modules. Set to 0 for disabled

Todo

Should support individual assignments

Raises:ValueError – If the passed list is not of the same length as the number of detectors

Examples

detector.rate_correction
>> [125.0, 155.0]

detector.rate_correction = [125, 155]
readout_clock

Speed of the readout clock relative to the full speed

  • Full Speed
  • Half Speed
  • Quarter Speed
  • Super Slow Speed

Examples

d.readout_clock
>> 'Half Speed'

d.readout_clock = 'Full Speed'
receiver_frame_index
receiver_last_client_ip

Returns the ip of the client last talking to the receiver

receiver_online

Online flag for the receiver. Is set together with detector.online when creating the detector object

Examples

d.receiver_online
>> True

d.receiver_online = False
receiver_version

str Receiver version as a string. [yearmonthday]

Examples

d.receiver_version
>> '20180327'
register

Directly manipulate registers on the readout board

Examples

d.register[0x5d] = 0xf00
reset_frames_caught()[source]

Reset the number of frames caught by the receiver.

Note

Automatically done when using d.acq()

rx_datastream

Zmq datastream from receiver. True if enabled and False otherwise

#Enable data streaming from receiver
detector.rx_datastream = True

#Check data streaming
detector.rx_datastream
>> True
rx_hostname

Receiver hostname

rx_jsonaddheader

UDP buffer size

rx_realudpsocksize

UDP buffer size

rx_tcpport
rx_udpip

Receiver UDP ip

rx_udpmac
rx_udpsocksize

UDP buffer size

rx_zmqip

ip where the receiver streams data

rx_zmqport

Return the receiver zmq ports.

detector.rx_zmqport
>> [30001, 30002]
server_version

int On-board server version of the detector

settings

Detector settings used to control for example calibration or gain switching. For EIGER almost always standard standard.

Warning

For Eiger setting settings should be followed by setting the threshold otherwise reading of the settings will overwrite the set value

settings_path

The path where the slsDetectorSoftware looks for settings/trimbit files

start_detector()[source]

Non blocking command to star acquisition. Needs to be used in combination with receiver start.

start_receiver()[source]
status

idle, running,

Todo

Check possible values

Type:str Status of the detector
stop_detector()[source]

Stop acquisition early or if the detector hangs

stop_receiver()[source]
threaded

Enable parallel execution of commands to the different detector modules

Examples

d.threaded
>> True

d.threaded = False
threshold

Detector threshold in eV

timing_mode

str Timing mode of the detector

  • auto Something
  • trigger Something else
trimbits

Set or read trimbits of the detector.

Examples

#Set all to 32
d.trimbits = 32

d.trimbits
>> 32

#if undefined or different
d.trimbits
>> -1
trimmed_energies

the energies at which the detector was trimmed. This also sets the range for which the calibration of the detector is valid.

detector.trimmed_energies = [5400, 6400, 8000]

detector.trimmed_energies
>> [5400, 6400, 8000]
Type:EIGER
user
vthreshold

Threshold in DAC units for the detector. Sets the individual vcmp of all chips in the detector.

Eiger

class sls_detector.Eiger(id=0)[source]

Bases: sls_detector.detector.Detector

Subclassing Detector to set up correct dacs and detector specific functions.

active

Is the detector active? Can be used to enable or disable a detector module

Examples

d.active
>> active: [True, True]

d.active[1] = False
>> active: [True, False]
add_gappixels

Enable or disable the (virual) pixels between ASICs

Examples

d.add_gappixels = True

d.add_gappixels
>> True
dacs

An instance of DetectorDacs used for accessing the dacs of a single or multi detector.

Examples

d = Eiger()

#Set all vrf to 1500
d.dacs.vrf = 1500

#Check vrf
d.dacs.vrf
>> vrf       :  1500,  1500

#Set a single vtr
d.dacs.vtr[0] = 1800

#Set vrf with multiple values
d.dacs.vrf = [3500,3700]
d.dacs.vrf
>> vrf       :  3500,  3700

#read into a variable
var = d.dacs.vrf[:]

#set multiple with multiple values, mostly used for large systems
d.dacs.vcall[0,1] = [3500,3600]
d.dacs.vcall
>> vcall     :  3500,  3600

d.dacs
>>
========== DACS =========
vsvp      :     0,     0
vtr       :  4000,  4000
vrf       :  1900,  1900
vrs       :  1400,  1400
vsvn      :  4000,  4000
vtgstv    :  2556,  2556
vcmp_ll   :  1500,  1500
vcmp_lr   :  1500,  1500
vcall     :  4000,  4000
vcmp_rl   :  1500,  1500
rxb_rb    :  1100,  1100
rxb_lb    :  1100,  1100
vcmp_rr   :  1500,  1500
vcp       :  1500,  1500
vcn       :  2000,  2000
vis       :  1550,  1550
iodelay   :   660,   660
default_settings()[source]

reset the detector to some type of standard settings mostly used when testing

eiger_matrix_reset

Matrix reset bit for Eiger.

True : Normal operation, the matrix is reset before each acq. False : Matrix reset disabled. Used to not reset before reading out analog test pulses.

flowcontrol_10g

True - Flow control enabled False flow control disabled. Sets for all moduels, if for some reason access to a single module is needed this can be done trough the C++ API.

measured_period
measured_subperiod
pulse_all_pixels(n)[source]

Pulse each pixel of the chip n times using the analog test pulses. The pulse height is set using d.dacs.vcall with 4000 being 0 and 0 being the highest pulse.

#Pulse all pixels ten times
d.pulse_all_pixels(10)

#Avoid resetting before acq
d.eiger_matrix_reset = False

d.acq() #take frame

#Restore normal behaviour
d.eiger_matrix_reset = True
pulse_chip(n)[source]

Advance the counter by toggling enable. Gives 2*n+2 int the counter

pulse_diagonal(n)[source]

Pulse pixels in super colums in a diagonal fashion. Used for calibration of vcall. Saves time compared to pulsing all pixels.

rx_udpport

UDP port for the receiver. Each module has two ports referred to as rx_udpport and rx_udpport2 in the command line interface here they are grouped for each detector

[0:rx_udpport, 0:rx_udpport2, 1:rx_udpport ...]

Examples

d.rx_udpport
>> [50010, 50011, 50004, 50005]

d.rx_udpport = [50010, 50011, 50012, 50013]
rx_zmqport

Return the receiver zmq ports. Note that Eiger has two ports per receiver!

detector.rx_zmqport
>> [30001, 30002, 30003, 30004]
set_delays(delta)[source]
setup500k(hostnames)[source]

Setup the Eiger detector to run on the local machine

sub_deadtime

Deadtime between subexposures. Used to mimize noise by delaying the start of the next subexposure.

sub_exposure_time

Sub frame exposure time in seconds for Eiger in 32bit autosumming mode

d.sub_exposure_time
>> 0.0023

d.sub_exposure_time = 0.002
temp

An instance of DetectorAdcs used to read the temperature of different components

Examples

detector.temp
>>
temp_fpga     :  36.90°C,  45.60°C
temp_fpgaext  :  31.50°C,  32.50°C
temp_10ge     :   0.00°C,   0.00°C
temp_dcdc     :  36.00°C,  36.00°C
temp_sodl     :  33.00°C,  34.50°C
temp_sodr     :  33.50°C,  34.00°C
temp_fpgafl   :  33.81°C,  30.93°C
temp_fpgafr   :  27.88°C,  29.15°C

a = detector.temp.fpga[:]
a
>> [36.568, 45.542]
tengiga

Enable 10Gbit/s data output

Examples

d.tengiga
>> False

d.tengiga = True
tx_delay

Transmission delay of the modules to allow running the detector in a network not supporting the full speed of the detector.

d.tx_delay
>>
Transmission delay [ns]
               left   right   frame
 0:beb048         0   15000       0
 1:beb049       100  190000     100

 d.tx_delay.left = [2000,5000]
vcmp

Convenience function to get and set the individual vcmp of chips Used mainly in the calibration code.

Examples

#Reading
d.vcmp[:]
>> [500, 500, 500, 500, 500, 500, 500, 500]

#Setting
d.vcmp = [500, 500, 500, 500, 500, 500, 500, 500]

Jungfrau

class sls_detector.Jungfrau(multi_id=0)[source]

Bases: sls_detector.detector.Detector

Class used to control a Jungfrau detector. Inherits from the Detector class but a specialized class is needed to provide the correct dacs and unique functions.

dacs

An instance of DetectorDacs used for accessing the dacs of a single or multi detector.

Examples

#Jungfrau
delay

Delay after trigger [s]

detector_ip

Read detector ip address

detector_mac

Read detector mac address

n_gates
n_probes
power_chip

Power on or off the ASICs, True for on False for off

reset_temperature_event()[source]

Reset the temperature_event. After reset temperature_event is False

rx_udpport

UDP port for the receiver. Each module have one port. Note! Eiger has two ports

[0:rx_udpport]

Examples

d.rx_udpport
>> [50010]

d.rx_udpport = [50010]
temp

An instance of DetectorAdcs used to read the temperature of different components

Examples

detector.temp
>>
temp_fpga     :  36.90°C,  45.60°C

a = detector.temp.fpga[:]
a
>> [36.568, 45.542]
temperature_control

Monitor the temperature of the detector and switch off chips if temperature_threshold is crossed

Examples

#activate
detector.temperature_control = True

#deactivate
detector.temperature_control = False
temperature_event

Have the temperature threshold been crossed?

Returns:
  • True if the threshold have been crossed and temperature_control is active
  • otherwise False
temperature_threshold

Threshold for switching of chips