From 1f811dfabd562b2993935002f24396bbda29aea2 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Thu, 20 Aug 2020 12:22:49 +0200 Subject: [PATCH] added examples --- python/examples/exposure_time.py | 30 ++++++++++++++++++++++++++ python/examples/reading_temperature.py | 13 +++++++++++ 2 files changed, 43 insertions(+) create mode 100644 python/examples/exposure_time.py create mode 100644 python/examples/reading_temperature.py diff --git a/python/examples/exposure_time.py b/python/examples/exposure_time.py new file mode 100644 index 000000000..05ad9b14f --- /dev/null +++ b/python/examples/exposure_time.py @@ -0,0 +1,30 @@ +""" +Example showing how to set and get exposure times +""" + +import datetime as dt +from slsdet import Detector + + + +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 \ No newline at end of file diff --git a/python/examples/reading_temperature.py b/python/examples/reading_temperature.py new file mode 100644 index 000000000..d3afb32eb --- /dev/null +++ b/python/examples/reading_temperature.py @@ -0,0 +1,13 @@ +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)