# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
from slsdet import Detector, currentSrcParameters

s = currentSrcParameters()
s.enable = 1
s.fix= 1
s.normal = 1
s.select = 10


d = Detector()
d.currentsource = s
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
import time
from multiprocessing import Process
from slsdet import Detector, runStatus

d = Detector()

#Create a separate process to run acquire in
p = Process(target=d.acquire)

#Start the thread and short sleep to allow the acq to start
p.start()
time.sleep(0.01)

#Do some other work
while d.status != runStatus.IDLE:
    print("Working")
    time.sleep(0.1)

#Join the process
p.join()
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
# Most settings are represented as enums that can be
# explicitly imported

from slsdet import Detector, fileFormat
d = Detector()
d.fformat = fileFormat.BINARY

# Altough not recommended for convenience all enums
# and some other things can be imported using *

from slsdet import *
d.speed = speedLevel.FULL_SPEED

# To list the available enums, use dir()

import slsdet.enums
for enum in dir(slsdet.enums):
    # filter out special members
    if not enum.startswith('_'):
        print(enum)
Пример #4
0
def setup_somedet():
    os.environ['SLSDETNAME'] = 'erik'
    d = Detector()
    d.config = '~/virtual_one.config'
    return d
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
"""
Example showing how to set and get exposure times
"""

import datetime as dt
from slsdet import Detector
from slsdet.utils import element_if_equal

d = Detector()

# The simplest way is to set the exposure time in
# seconds by using the exptime property
# This sets the exposure time for all modules
d.exptime = 0.5

# exptime also accepts a python datetime.timedelta
# which can be used to set the time in almost any unit
t = dt.timedelta(milliseconds=2.3)
d.exptime = t

# or combination of units
t = dt.timedelta(minutes=3, seconds=1.23)
d.exptime = t

#exptime however always returns the time in seconds
# >>> d.exptime
# 181.23

# To get back the exposure time for each module
Пример #6
0
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
from slsdet import Detector, Eiger, dacIndex

#Using the general detector class and calling with an index
d = Detector()
fpga_temp = d.getTemperature(dacIndex.TEMPERATURE_FPGA)
print(f'fpga_temp: {fpga_temp}\n')

#Using the specialized detector class
e = Eiger()
print("All temperatures for Eiger\n")
print(e.temp)
# >>> e.temp
# temp_fpga      :   54°C   60°C
# temp_fpgaext   :   49°C   52°C
# temp_10ge      :   47°C   45°C
# temp_dcdc      :   52°C   53°C
# temp_sodl      :   51°C   53°C
# temp_sodl      :   51°C   51°C
# temp_fpgafl    :   45°C   49°C
# temp_fpgafr    :   39°C   42°C

# The temperatures can also be returned in a dictionary
t = e.temp.to_dict()
print(t)
# >>> e.temp.to_dict()
# {'fpga': array([55, 60]), 'fpgaext': array([49, 52]),
# 't10ge': array([47, 45]), 'dcdc': array([52, 53]),
# 'sodl': array([51, 53]), 'sodr': array([51, 51]), '
# temp_fpgafl': array([45, 49]),
Пример #7
0
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package


from slsdet import Detector, patternParameters

d = Detector()
pat = patternParameters()

#Access to members of the structure using numpy arrays
pat.patlimits = 0x0, 0xa

d.setPattern(pat)

#Load pattern from file
pat.load("/some/dir/some.pat")
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
import time
from slsdet import Detector, runStatus

n_frames = 10
t_exp = 1

# Set exposure time and number of frames
d = Detector()
d.exptime = t_exp
d.frames = n_frames

# Start the measurement
t0 = time.time()
d.startDetector()
d.startReceiver()

# Wait for the detector to be ready or do other important stuff
time.sleep(t_exp * n_frames)

# check if the detector is ready otherwise wait a bit longer
while d.status != runStatus.IDLE:
    time.sleep(0.1)

# Stop the receiver after we got the frames
# Detector is already idle so we don't need to stop it
d.stopReceiver()

lost = d.rx_framescaught - n_frames
print(
Пример #9
0
#using the specialized class

e = Eiger()
e.dacs
# >>> e.dacs
# ========== DACS =========
# vsvp      :    0    0
# vtrim     : 2480 2480
# vrpreamp  : 3300 3300
# vrshaper  : 1400 1400
# vsvn      : 4000 4000
# vtgstv    : 2556 2556
# vcmp_ll   : 1000 1000
# vcmp_lr   : 1000 1000
# vcal      :    0    0
# vcmp_rl   : 1000 1000
# rxb_rb    : 1100 1100
# rxb_lb    : 1100 1100
# vcmp_rr   : 1000 1000
# vcp       : 1000 1000
# vcn       : 2000 2000
# vishaper  : 1550 1550
# iodelay   :  650  650

# or using the general class and the list
d = Detector()
for dac in d.daclist:
    r = d.getDAC(dac, False)
    print(f'{dac.name:10s} {r}')