Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
maliakal_d 2020-08-20 15:16:36 +02:00
commit 678967bfe1
7 changed files with 158 additions and 8 deletions

View File

@ -145,6 +145,7 @@ Setting and getting times
import datetime as dt
from slsdet import Detector
from slsdet.utils import element_if_equal
d = Detector()
@ -155,7 +156,6 @@ Setting and getting times
# 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
@ -166,3 +166,54 @@ Setting and getting times
# exptime however always returns the time in seconds
>>> d.exptime
181.23
# To get back the exposure time for each module
# it's possible to use getExptime, this also returns
# the values as datetime.timedelta
>>> d.getExptime()
[datetime.timedelta(seconds=181, microseconds=230000), datetime.timedelta(seconds=181, microseconds=230000)]
# In case the values are the same it's possible to use the
# element_if_equal function to reduce the values to a single
# value
>>> t = d.getExptime()
>>> element_if_equal(t)
datetime.timedelta(seconds=1)
--------------
Reading dacs
--------------
::
from slsdet import Detector, Eiger, dacIndex
#using the specialized class
e = Eiger()
>>> 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}')

View File

@ -4,12 +4,10 @@ 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
@ -17,7 +15,6 @@ 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
@ -28,3 +25,18 @@ d.exptime = t
#exptime however always returns the time in seconds
# >>> d.exptime
# 181.23
# To get back the exposure time for each module
# it's possible to use getExptime, this also returns
# the values as datetime.timedelta
# >>> d.getExptime()
# [datetime.timedelta(seconds=181, microseconds=230000), datetime.timedelta(seconds=181, microseconds=230000)]
# In case the values are the same it's possible to use the
# element_if_equal function to reduce the values to a single
# value
# >>> t = d.getExptime()
# >>> element_if_equal(t)
# datetime.timedelta(seconds=1)

View File

@ -0,0 +1,32 @@
from slsdet import Detector, Eiger, dacIndex
#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}')

View File

@ -11,3 +11,35 @@ print(f'fpga_temp: {fpga_temp}\n')
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]),
# 'temp_fpgafr': array([39, 42])}
# or in a numpy array
t = e.temp.to_array()
print(t)
# >>> e.temp.to_array()
# array([[55, 60],
# [49, 52],
# [47, 45],
# [52, 53],
# [51, 53],
# [51, 51],
# [45, 49],
# [40, 43]])

View File

@ -92,6 +92,9 @@ class DetectorDacs:
dac_array[i,:] = _d[:]
return dac_array
def to_array(self):
return self.get_asarray()
def set_from_array(self, dac_array):
"""
Set the dacs from an numpy array with dac values. [ndacs, nmodules]

View File

@ -637,6 +637,18 @@ class Detector(CppDetectorApi):
def reg(self):
return self._register
@property
def daclist(self):
return self.getDacList()
@property
def timinglist(self):
return self.getTimingModeList()
@property
def settingslist(self):
return self.getSettingsList()
@property
def adcreg(self):
"""[Jungfrau][Ctb][Moench][Gotthard] Writes to an adc register

View File

@ -1,5 +1,6 @@
from functools import partial
from collections.abc import Iterable
import numpy as np
class Temperature:
degree_sign = u"\N{DEGREE SIGN}"
@ -39,4 +40,11 @@ class DetectorTemperature:
r_str = '\n'.join([repr(temp) for temp in self])
return r_str
def to_dict(self):
"""Get temperatures as a dictionary with numpy arrays"""
return {attr:np.array(value.get()) for attr, value in self.__dict__.items()}
def to_array(self):
"""Get all temperatures as a numpy array"""
t = self.to_dict()
return np.vstack([value for key, value in t.items()])