From c4f0052ac996162521738bd6fbde1880d9ef3074 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Thu, 20 Aug 2020 13:46:25 +0200 Subject: [PATCH] WIP --- docs/src/pyexamples.rst | 22 +++++++++++++++++++--- python/examples/exposure_time.py | 22 +++++++++++++++++----- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/docs/src/pyexamples.rst b/docs/src/pyexamples.rst index 5685040e6..158410771 100755 --- a/docs/src/pyexamples.rst +++ b/docs/src/pyexamples.rst @@ -143,8 +143,10 @@ Setting and getting times :: + import datetime as dt from slsdet import Detector + from slsdet.utils import element_if_equal d = Detector() @@ -155,7 +157,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 @@ -163,6 +164,21 @@ Setting and getting times t = dt.timedelta(minutes = 3, seconds = 1.23) d.exptime = t - #exptime however always returns the time in seconds + # exptime however always returns the time in seconds >>> d.exptime - 181.23 \ No newline at end of file + 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) diff --git a/python/examples/exposure_time.py b/python/examples/exposure_time.py index 05ad9b14f..eab8c12f0 100644 --- a/python/examples/exposure_time.py +++ b/python/examples/exposure_time.py @@ -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 @@ -27,4 +24,19 @@ d.exptime = t #exptime however always returns the time in seconds # >>> d.exptime -# 181.23 \ No newline at end of file +# 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) \ No newline at end of file