diff --git a/.gitignore b/.gitignore index adca393..70c27dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ +# This gitignore file consists of 2 parts: +# * The standard Python .gitignore rules from GitHub +# * custom ignore rules for the labscript suite. +# +# These should be kept separate so that the generic rules can be updated with a +# copy/paste without having to worry about whether we are removing custom rules + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -20,7 +27,6 @@ parts/ sdist/ var/ wheels/ -pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg @@ -50,6 +56,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +cover/ # Translations *.mo @@ -69,11 +76,10 @@ instance/ .scrapy # Sphinx documentation -docs/html/ docs/_build/ -docs/source/_build/ # PyBuilder +.pybuilder/ target/ # Jupyter Notebook @@ -84,6 +90,8 @@ profile_default/ ipython_config.py # pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: .python-version # pipenv @@ -130,9 +138,24 @@ dmypy.json # Pyre type checker .pyre/ +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# +# Custom labscript suite .gitignore rules start below +# + # Editors .vscode/ # conda build results conda_build/ conda_packages/ + +# Sphinx documentation +docs/html/ +docs/source/_build/ +docs/source/components.rst \ No newline at end of file diff --git a/README.md b/README.md index 557a1b1..9963d95 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,21 @@ -# labscript_utils +the labscript suite -Shared modules used by the labscript suite. Includes a graphical exception handler, debug tools, configuration management, cross platform filepath conversions, unit conversions and custom GUI widgets. +# the _labscript suite_ ยป labscript-utils -( -[view on Github](https://github.com/labscript-suite/labscript_utils) -) +### Shared modules used by the _labscript suite_ +[![Actions Status](https://github.com/labscript-suite/labscript-utils/workflows/Build%20and%20Release/badge.svg?branch=maintenance%2F3.0.x)](https://github.com/labscript-suite/labscript-utils/actions) +[![License](https://img.shields.io/pypi/l/labscript-utils.svg)](https://github.com/labscript-suite/labscript-utils/raw/master/LICENSE.txt) +[![Python Version](https://img.shields.io/pypi/pyversions/labscript-utils.svg)](https://python.org) +[![PyPI](https://img.shields.io/pypi/v/labscript-utils.svg)](https://pypi.org/project/labscript-utils) +[![Conda Version](https://img.shields.io/conda/v/labscript-suite/labscript-utils)](https://anaconda.org/labscript-suite/labscript-utils) +[![Google Group](https://img.shields.io/badge/Google%20Group-labscriptsuite-blue.svg)](https://groups.google.com/forum/#!forum/labscriptsuite) + + +Shared modules used by the [*labscript suite*](https://github.com/labscript-suite/labscript-suite). Includes a graphical exception handler, debug tools, configuration management, cross-platform filepath conversions, physical unit conversions and custom GUI widgets. + + +## Installation + +labscript-utils is distributed as a Python package on [PyPI](https://pypi.org/user/labscript-suite) and [Anaconda Cloud](https://anaconda.org/labscript-suite), and should be installed with other components of the _labscript suite_. Please see the [installation guide](https://docs.labscriptsuite.org/en/latest/installation) for details. diff --git a/docs/source/_static/custom.css b/docs/source/_static/custom.css index ad5c1a8..d766bfa 100644 --- a/docs/source/_static/custom.css +++ b/docs/source/_static/custom.css @@ -57,3 +57,7 @@ details { 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12); margin-bottom: 24px; } + +img.labscript-suite-icon { + min-width: 32px; +} \ No newline at end of file diff --git a/docs/source/_templates/components.rst b/docs/source/_templates/components.rst new file mode 100644 index 0000000..f966939 --- /dev/null +++ b/docs/source/_templates/components.rst @@ -0,0 +1,47 @@ +{% if current_project != 'the labscript suite' %} +.. toctree:: + :maxdepth: 2 + :hidden: + + the labscript suite <{{intersphinx_mapping['labscript-suite'][0]}}> + +{% endif %} +*labscript suite* components +============================ + +The *labscript suite* is modular by design, and is comprised of: + +.. list-table:: Python libraries + :widths: 10 90 + :header-rows: 0 + + {% for prog, item in programs.items() if item.type == 'lib' %} + * - .. image:: {{img_path}}/{{item.icon}} + :target: {{intersphinx_mapping['%s' | format(prog)][0]}} + :class: labscript-suite-icon + - |{{prog}}|_ --- {{item.desc}} + {% endfor %} + +.. list-table:: Graphical applications + :widths: 10 90 + :header-rows: 0 + + {% for prog, item in programs.items() if item.type == 'gui' %} + * - .. image:: {{img_path}}/{{item.icon}} + :target: {{intersphinx_mapping['%s' | format(prog)][0]}} + :class: labscript-suite-icon + - |{{prog}}|_ --- {{item.desc}} + {% endfor %} + +.. toctree:: + :maxdepth: 2 + :hidden: + + {% for prog in programs|sort if prog != current_project %} + {{prog}} <{{intersphinx_mapping['%s' | format(prog)][0]}}> + {% endfor %} + +{% for prog in programs %} +.. |{{prog}}| replace:: **{{prog}}** +.. _{{prog}}: {{intersphinx_mapping['%s' | format(prog)][0]}} +{% endfor %} \ No newline at end of file diff --git a/docs/source/api_reference/connections.rst b/docs/source/api/connections.rst similarity index 100% rename from docs/source/api_reference/connections.rst rename to docs/source/api/connections.rst diff --git a/docs/source/api_reference/index.rst b/docs/source/api/index.rst similarity index 100% rename from docs/source/api_reference/index.rst rename to docs/source/api/index.rst diff --git a/docs/source/api_reference/labscript_utils.rst b/docs/source/api/labscript_utils.rst similarity index 100% rename from docs/source/api_reference/labscript_utils.rst rename to docs/source/api/labscript_utils.rst diff --git a/docs/source/conf.py b/docs/source/conf.py index a458123..675d806 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,8 +11,10 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os +from pathlib import Path from m2r import MdInclude from recommonmark.transform import AutoStructify +from jinja2 import FileSystemLoader, Environment # -- Project information (unique to each project) ------------------------------------- @@ -26,8 +28,9 @@ release = version # HTML icons -html_logo = "img/{}.svg".format(project) -html_favicon = "img/{}.ico".format(project) +img_path = 'img' +html_logo = img_path + "/labscript_64x64.svg" +html_favicon = img_path + "/labscript.ico" # -- General configuration (should be identical across all projects) ------------------ @@ -79,38 +82,66 @@ 'matplotlib': ('https://matplotlib.org/', None), 'h5py': ('http://docs.h5py.org/en/stable/', None), 'pydaqmx': ('https://pythonhosted.org/PyDAQmx/', None), - # from https://github.com/MSLNZ/msl-qt/blob/master/docs/create_pyqt_objects.py - # under MIT License 'qt': ( '', 'pyqt5-modified-objects.inv', - ) + ) # from https://github.com/MSLNZ/msl-qt/blob/master/docs/create_pyqt_objects.py + # under MIT License # TODO # desktop-app # spinapi/pynivision/etc } # list of all labscript suite components that have docs -labscript_suite_programs = [ - 'labscript', - 'runmanager', - 'runviewer', - 'blacs', - 'lyse', - 'labscript-utils', - 'labscript-devices', -] -# remove this current repo from the list -if project in labscript_suite_programs: - labscript_suite_programs.remove(project) +labscript_suite_programs = { + 'labscript': { + 'desc': 'Expressive composition of hardware-timed experiments', + 'icon': 'labscript_32nx32n.svg', + 'type': 'lib', + }, + 'labscript-devices': { + 'desc': 'Plugin architecture for controlling experiment hardware', + 'icon': 'labscript_32nx32n.svg', + 'type': 'lib', + }, + 'labscript-utils': { + 'desc': 'Shared modules used by the *labscript suite*', + 'icon': 'labscript_32nx32n.svg', + 'type': 'lib', + }, + 'runmanager': { + 'desc': 'Graphical and remote interface to parameterized experiments', + 'icon': 'runmanager_32nx32n.svg', + 'type': 'gui', + }, + 'blacs': { + 'desc': 'Graphical interface to scientific instruments and experiment supervision', + 'icon': 'blacs_32nx32n.svg', + 'type': 'gui', + }, + 'lyse': { + 'desc': 'Online analysis of live experiment data', + 'icon': 'lyse_32nx32n.svg', + 'type': 'gui', + }, + 'runviewer': { + 'desc': 'Visualize hardware-timed experiment instructions', + 'icon': 'runviewer_32nx32n.svg', + 'type': 'gui', + }, +} # whether to use stable or latest version -labscript_suite_doc_version = 'stable' # 'stable' or 'latest' +labscript_suite_doc_version = os.environ.get('READTHEDOCS_VERSION', 'latest') +if '.' in labscript_suite_doc_version: + labscript_suite_doc_version = 'stable' +elif labscript_suite_doc_version not in ['stable', 'latest']: + labscript_suite_doc_version = 'latest' # add intersphinx references for each component for ls_prog in labscript_suite_programs: intersphinx_mapping[ls_prog] = ( - 'https://docs.labscript_suite.org/projects/{}/en/{}/'.format( + 'https://docs.labscriptsuite.org/projects/{}/en/{}/'.format( ls_prog, labscript_suite_doc_version ), None, @@ -119,7 +150,7 @@ # add intersphinx reference for the metapackage if project != "the labscript suite": intersphinx_mapping['labscript-suite'] = ( - 'https://docs.labscript_suite.org/en/{}/'.format(labscript_suite_doc_version), + 'https://docs.labscriptsuite.org/en/{}/'.format(labscript_suite_doc_version), None, ) @@ -137,6 +168,7 @@ todo_include_todos = False else: todo_include_todos = True + # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -158,7 +190,6 @@ # Customize the html_theme html_theme_options = {'navigation_depth': 3} - # Use m2r only for mdinclude and recommonmark for everything else # https://github.com/readthedocs/recommonmark/issues/191#issuecomment-622369992 def setup(app): @@ -176,4 +207,19 @@ def setup(app): app.add_config_value('m2r_anonymous_references', False, 'env') app.add_config_value('m2r_disable_inline_math', False, 'env') app.add_directive('mdinclude', MdInclude) - app.add_stylesheet('custom.css') + app.add_css_file('custom.css') + + # generate the components.rst file dynamically so it points to stable/latest + # of subprojects correctly + loader = FileSystemLoader(Path(__file__).resolve().parent / templates_path[0]) + env = Environment(loader=loader) + template = env.get_template('components.rst') + with open(Path(__file__).resolve().parent / 'components.rst', 'w') as f: + f.write( + template.render( + intersphinx_mapping=intersphinx_mapping, + programs=labscript_suite_programs, + current_project=project, + img_path=img_path + ) + ) diff --git a/docs/source/img/blacs_32nx32n.svg b/docs/source/img/blacs_32nx32n.svg new file mode 100644 index 0000000..d6a2b0e --- /dev/null +++ b/docs/source/img/blacs_32nx32n.svg @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/docs/source/img/labscript-suite-rectangular-transparent_138nx70n.svg b/docs/source/img/labscript-suite-rectangular-transparent_138nx70n.svg new file mode 100644 index 0000000..828b77e --- /dev/null +++ b/docs/source/img/labscript-suite-rectangular-transparent_138nx70n.svg @@ -0,0 +1,579 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/labscript-utils.svg b/docs/source/img/labscript-utils.svg deleted file mode 100644 index 24d9ee6..0000000 --- a/docs/source/img/labscript-utils.svg +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/source/img/labscript-utils.ico b/docs/source/img/labscript.ico similarity index 100% rename from docs/source/img/labscript-utils.ico rename to docs/source/img/labscript.ico diff --git a/docs/source/img/labscript_32nx32n.svg b/docs/source/img/labscript_32nx32n.svg new file mode 100644 index 0000000..97272af --- /dev/null +++ b/docs/source/img/labscript_32nx32n.svg @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/labscript_64x64.svg b/docs/source/img/labscript_64x64.svg new file mode 100644 index 0000000..987cfe6 --- /dev/null +++ b/docs/source/img/labscript_64x64.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/lyse_32nx32n.svg b/docs/source/img/lyse_32nx32n.svg new file mode 100644 index 0000000..1ddcdcc --- /dev/null +++ b/docs/source/img/lyse_32nx32n.svg @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/runmanager_32nx32n.svg b/docs/source/img/runmanager_32nx32n.svg new file mode 100644 index 0000000..d9df689 --- /dev/null +++ b/docs/source/img/runmanager_32nx32n.svg @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/runviewer_32nx32n.svg b/docs/source/img/runviewer_32nx32n.svg new file mode 100644 index 0000000..ee5aa68 --- /dev/null +++ b/docs/source/img/runviewer_32nx32n.svg @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/source/index.rst b/docs/source/index.rst index 7956870..86f2cab 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -11,6 +11,27 @@ This documentation is primarily for developers who might want to use this common .. toctree:: :maxdepth: 2 + :hidden: + :caption: DOCUMENTATION - api_reference/index + api/index + +.. toctree:: + :maxdepth: 2 + :hidden: + :caption: FURTHER DOCUMENTATION + + components + +.. toctree:: + :maxdepth: 2 + :hidden: + :caption: LINKS + + Home Page + Source Code + PyPI + Anaconda Cloud + BitBucket Archive +.. todolist:: diff --git a/labscript-suite.pth b/labscript-suite.pth index 81cf668..8992fe1 100644 --- a/labscript-suite.pth +++ b/labscript-suite.pth @@ -1,2 +1 @@ -import labscript_profile; labscript_profile.add_userlib_and_pythonlib() -import labscript_profile; labscript_profile.add_development_directories() +import sys; exec("try: import labscript_profile; labscript_profile.add_userlib_and_pythonlib()\nexcept ModuleNotFoundError: pass") diff --git a/labscript_profile/__init__.py b/labscript_profile/__init__.py index d9b2018..a679ff5 100644 --- a/labscript_profile/__init__.py +++ b/labscript_profile/__init__.py @@ -1,3 +1,4 @@ +import site import sys import os from configparser import ConfigParser, NoSectionError, NoOptionError @@ -56,22 +57,4 @@ def add_userlib_and_pythonlib(): except (NoSectionError, NoOptionError): paths = [] for path in paths: - if os.path.exists(path): - sys.path.append(path) - - -def add_development_directories(): - """Prepend directories in /dev to the search path, if they - are listed in the file /dev/enabled (if that file - exists).""" - if LABSCRIPT_SUITE_PROFILE is None: - return - dev_dir = LABSCRIPT_SUITE_PROFILE / 'dev' - enabled_file = dev_dir / 'enabled' - if not os.path.exists(enabled_file): - return - with open(enabled_file) as f: - for line in f: - repository = dev_dir / line.strip() - if os.path.isdir(repository): - sys.path.insert(0, repository) + site.addsitedir(path) diff --git a/labscript_profile/default_profile/labconfig/example.ini b/labscript_profile/default_profile/labconfig/example.ini index f72dca5..63851aa 100644 --- a/labscript_profile/default_profile/labconfig/example.ini +++ b/labscript_profile/default_profile/labconfig/example.ini @@ -10,8 +10,8 @@ app_saved_configs = %(labscript_suite)s\app_saved_configs\%(apparatus_name)s user_devices = user_devices [paths] -connection_table_h5 = %(experiment_shot_storage)s\connectiontable.h5 -connection_table_py = %(labscriptlib)s\connectiontable.py +connection_table_h5 = %(experiment_shot_storage)s\connection_table.h5 +connection_table_py = %(labscriptlib)s\connection_table.py [servers] zlock = localhost diff --git a/labscript_profile/default_profile/userlib/analysislib/example_apparatus/example_IMAQdx_remote.py b/labscript_profile/default_profile/userlib/analysislib/example_apparatus/example_IMAQdx_remote.py new file mode 100644 index 0000000..e4c30b7 --- /dev/null +++ b/labscript_profile/default_profile/userlib/analysislib/example_apparatus/example_IMAQdx_remote.py @@ -0,0 +1,46 @@ +import lyse +from pathlib import Path +import matplotlib.pyplot as plt + +# Is this script being run from within an interactive lyse session? +if lyse.spinning_top: + # If so, use the filepath of the current shot + h5_path = lyse.path +else: + # If not, get the filepath of the last shot of the lyse DataFrame + df = lyse.data() + h5_path = df.filepath.iloc[-1] + +# Instantiate a lyse.Run object for this shot +run = lyse.Run(h5_path) + +# Get a dictionary of the global variables used in this shot +run_globals = run.get_globals() + +# Extract the images 'before' and 'after' generated from camera.expose +before, after = run.get_images('camera', 'comparison', 'before', 'after') + +# Compute the difference of the two images, after casting them to signed integers +# (otherwise negative differences wrap to 2**16 - 1 - diff) +diff = after.astype('int16') - before.astype('int16') + +# Plot the row-wise mean of each image +plt.plot(before.mean(axis=0), label='before') +plt.plot(after.mean(axis=0), label='after') +plt.xlabel('pixel coordinate (column)') +plt.ylabel('counts') + +# Label the plot with a unique string representing the shot +plt.title(Path(run.h5_path).name) + +# Plot adornments +plt.legend(loc='lower left') +plt.grid() + +# Show the plot +plt.show() + +# Compute a result based on the image processing and save it to the 'results' group of +# the shot file +result = diff.std() +run.save_result('foobar', result) diff --git a/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table.py b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table.py new file mode 100644 index 0000000..9a5f5e6 --- /dev/null +++ b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table.py @@ -0,0 +1,27 @@ +from labscript import start, stop, add_time_marker, AnalogOut, DigitalOut +from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock +from labscript_devices.DummyIntermediateDevice import DummyIntermediateDevice + +# Use a virtual, or 'dummy', device for the psuedoclock +DummyPseudoclock(name='pseudoclock') + +# An output of this DummyPseudoclock is its 'clockline' attribute, which we use +# to trigger children devices +DummyIntermediateDevice(name='intermediate_device', parent_device=pseudoclock.clockline) + +# Create an AnalogOut child of the DummyIntermediateDevice +AnalogOut(name='analog_out', parent_device=intermediate_device, connection='ao0') + +# Create a DigitalOut child of the DummyIntermediateDevice +DigitalOut( + name='digital_out', parent_device=intermediate_device, connection='port0/line0' +) + + +if __name__ == '__main__': + # Begin issuing labscript primitives + # start() elicits the commencement of the shot + start() + + # Stop the experiment shot with stop() + stop(1.0) diff --git a/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table_IMAQdx_remote.py b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table_IMAQdx_remote.py new file mode 100644 index 0000000..5bc412f --- /dev/null +++ b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table_IMAQdx_remote.py @@ -0,0 +1,40 @@ +from labscript import start, stop, add_time_marker, Trigger, RemoteBLACS +from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock +from labscript_devices.DummyIntermediateDevice import DummyIntermediateDevice +from labscript_devices.IMAQdxCamera.labscript_devices import IMAQdxCamera + +# Use a virtual ('dummy') device for the psuedoclock +DummyPseudoclock(name='pseudoclock') + +# An output of this DummyPseudoclock is its 'clockline' attribute, which we use +# to trigger children devices +DummyIntermediateDevice(name='intermediate_device', parent_device=pseudoclock.clockline) + +# Instantiate a labscript.Trigger instance used to trigger the camera exposure +# This will be specified as the camera's parent device later +Trigger( + name='camera_trigger', parent_device=intermediate_device, connection='port0/line0' +) + +# On the host specified below, start the RemoteBLACS server by running the following: +# $ python - m labscript_utils.remote +RemoteBLACS(name='test_remote', host='localhost') + +# We then initiate an IMAQdxCamera using this RemoteBLACS instance +# using mock=True to bypass any attempts to commmunicate with an +# actual camera, and generate fake data at the end of the shot +IMAQdxCamera( + name='camera', + parent_device=camera_trigger, + connection='trigger', + serial_number=0xDEADBEEF, + worker=test_remote, + mock=True, +) + +# Begin issuing labscript primitives +# start() elicits the commencement of the shot +start() + +# Stop the experiment shot with stop() +stop(1.0) diff --git a/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_IMAQdx_remote.py b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_IMAQdx_remote.py new file mode 100644 index 0000000..d0a3a61 --- /dev/null +++ b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_IMAQdx_remote.py @@ -0,0 +1,51 @@ +from labscript import start, stop, add_time_marker, Trigger, RemoteBLACS +from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock +from labscript_devices.DummyIntermediateDevice import DummyIntermediateDevice +from labscript_devices.IMAQdxCamera.labscript_devices import IMAQdxCamera + +# Use a virtual ('dummy') device for the psuedoclock +DummyPseudoclock(name='pseudoclock') + +# An output of this DummyPseudoclock is its 'clockline' attribute, which we use +# to trigger children devices +DummyIntermediateDevice(name='intermediate_device', parent_device=pseudoclock.clockline) + +# Instantiate a labscript.Trigger instance used to trigger the camera exposure +# This will be specified as the camera's parent device later +Trigger( + name='camera_trigger', parent_device=intermediate_device, connection='port0/line0' +) + +# On the host specified below, start the RemoteBLACS server by running the following: +# $ python - m labscript_utils.remote +RemoteBLACS(name='test_remote', host='localhost') + +# We then initiate an IMAQdxCamera using this RemoteBLACS instance +# using mock=True to bypass any attempts to commmunicate with an +# actual camera, and generate fake data at the end of the shot +IMAQdxCamera( + name='camera', + parent_device=camera_trigger, + connection='trigger', + serial_number=0xDEADBEEF, + worker=test_remote, + mock=True, +) + +# Begin issuing labscript primitives +# A timing variable t is used for convenience +# start() elicits the commencement of the shot +t = 0 +add_time_marker(t, "Start", verbose=True) +start() + +t += 1 +add_time_marker(t, "Exposure: 'before' image", verbose=True) +camera.expose(t, name='comparison', frametype='before', trigger_duration=0.2) + +t += 0.5 +add_time_marker(t, "Exposure: 'after' image", verbose=True) +camera.expose(t, name='comparison', frametype='after', trigger_duration=0.2) + +t += 0.5 +stop(t) diff --git a/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_experiment.py b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_experiment.py new file mode 100644 index 0000000..1f3c33e --- /dev/null +++ b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_experiment.py @@ -0,0 +1,48 @@ +from labscript import start, stop, add_time_marker, AnalogOut, DigitalOut +from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock +from labscript_devices.DummyIntermediateDevice import DummyIntermediateDevice + +# Use a virtual, or 'dummy', device for the psuedoclock +DummyPseudoclock(name='pseudoclock') + +# An output of this DummyPseudoclock is its 'clockline' attribute, which we use +# to trigger children devices +DummyIntermediateDevice(name='intermediate_device', parent_device=pseudoclock.clockline) + +# Create an AnalogOut child of the DummyIntermediateDevice +AnalogOut(name='analog_out', parent_device=intermediate_device, connection='ao0') + +# Create a DigitalOut child of the DummyIntermediateDevice +DigitalOut( + name='digital_out', parent_device=intermediate_device, connection='port0/line0' +) + +# Begin issuing labscript primitives +# A timing variable t is used for convenience +# start() elicits the commencement of the shot +t = 0 +add_time_marker(t, "Start", verbose=True) +start() + +# Wait for 1 second with all devices in their default state +t += 1 + +# Change the state of digital_out, and denote this using a time marker +add_time_marker(t, "Toggle digital_out (high)", verbose=True) +digital_out.go_high(t) + +# Wait for 0.5 seconds +t += 0.5 + +# Ramp analog_out from 0.0 V to 1.0 V over 0.25 s with a 1 kS/s sample rate +t += analog_out.ramp(t=t, initial=0.0, final=1.0, duration=0.25, samplerate=1e3) + +# Change the state of digital_out, and denote this using a time marker +add_time_marker(t, "Toggle digital_out (low)", verbose=True) +digital_out.go_low(t) + +# Wait for 0.5 seconds +t += 0.5 + +# Stop the experiment shot with stop() +stop(t) diff --git a/labscript_utils/camera_server.py b/labscript_utils/camera_server.py index 3389e66..cf576b5 100644 --- a/labscript_utils/camera_server.py +++ b/labscript_utils/camera_server.py @@ -158,7 +158,7 @@ def transition_to_static(self, h5_filepath): them to the h5 file""" import pyfits start_time = time.time() - with h5py.File(h5_filepath) as f: + with h5py.File(h5_filepath, 'r+') as f: group = f['devices']['camera'] if not 'EXPOSURES' in group: print('no images taken this shot') diff --git a/setup.py b/setup.py index 12b22ca..66a147b 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,24 @@ import os from setuptools import setup +from setuptools.command.develop import develop +from distutils import log + + +class develop_command(develop): + """Custom develop command which installs the .pth file to site-packages for editable + installs.""" + def run(self): + path = os.path.join(self.install_dir, 'labscript-suite.pth') + super().run() + if not self.uninstall: + log.info(f'Copying labscript-suite.pth to {path}') + if not self.dry_run: + self.copy_file('labscript-suite.pth', path) + VERSION_SCHEME = { "version_scheme": os.getenv("SCM_VERSION_SCHEME", "guess-next-dev"), "local_scheme": os.getenv("SCM_LOCAL_SCHEME", "node-and-date"), } -setup(use_scm_version=VERSION_SCHEME) +setup(use_scm_version=VERSION_SCHEME, cmdclass={'develop': develop_command}) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy