Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 40 additions & 31 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
import os
import sys

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))

# -- Project information -----------------------------------------------------

project = 'oxart-devices'
copyright = '2017-2021, Ion Trap Quantum Computing group'
author = 'Ion Trap Quantum Computing group'
project = "oxart-devices"
copyright = "2017-2021, Ion Trap Quantum Computing group"
author = "Ion Trap Quantum Computing group"

# The short X.Y version
version = ''
version = ""
# The full version, including alpha/beta/rc tags
release = ''
release = ""

# -- General configuration ---------------------------------------------------

Expand All @@ -38,23 +38,23 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -66,25 +66,25 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None

# -- Options for HTML output -------------------------------------------------

html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

html_theme_options = {
'canonical_url': 'https://oxfordiontrapgroup.github.io/oxart-devices/',
"canonical_url": "https://oxfordiontrapgroup.github.io/oxart-devices/",
}

html_context = {
'display_github': True,
'github_user': 'OxfordIonTrapGroup',
'github_repo': 'oxart-devices',
'github_version': 'master',
'conf_py_path': '/docs/'
"display_github": True,
"github_user": "OxfordIonTrapGroup",
"github_repo": "oxart-devices",
"github_version": "master",
"conf_py_path": "/docs/",
}

# Add any paths that contain custom static files (such as style sheets) here,
Expand All @@ -105,23 +105,20 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'oxartdevicesdoc'
htmlhelp_basename = "oxartdevicesdoc"

# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -131,24 +128,36 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'oxart-devices.tex', 'oxart-devices Documentation',
'Oxford Ion Trap Quantum Computing group', 'manual'),
(
master_doc,
"oxart-devices.tex",
"oxart-devices Documentation",
"Oxford Ion Trap Quantum Computing group",
"manual",
),
]

# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, 'oxart-devices', 'oxart-devices Documentation', [author], 1)]
man_pages = [(master_doc, "oxart-devices", "oxart-devices Documentation", [author], 1)]

# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'oxart-devices', 'oxart-devices Documentation', author,
'oxart-devices', 'One line description of project.', 'Miscellaneous'),
(
master_doc,
"oxart-devices",
"oxart-devices Documentation",
author,
"oxart-devices",
"One line description of project.",
"Miscellaneous",
),
]

# -- Options for Epub output -------------------------------------------------
Expand All @@ -166,7 +175,7 @@
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]

# -- Extension configuration -------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion oxart/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
49 changes: 26 additions & 23 deletions oxart/devices/andor_camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class CameraSetup(EnvExperiment):
"""Set camera parameters."""

_camera_name = "camera"

def build(self):
Expand All @@ -15,8 +16,9 @@ def build(self):
self.en_em_gain = self.get_argument("EM enabled", BooleanValue(default=False))
self.em_gain = self.get_argument("EM Gain", NumberValue(default=300))

self.roi_mode = self.get_argument("Image size",
EnumerationValue(["Full", "ROI"]))
self.roi_mode = self.get_argument(
"Image size", EnumerationValue(["Full", "ROI"])
)
self.run_acq = self.get_argument("Start acquisition", BooleanValue())

self.set_default_scheduling(pipeline_name="camera")
Expand All @@ -36,13 +38,13 @@ def run(self):
self.camera.set_exposure_time(self.t_exp)

if self.en_em_gain:
self.camera.set_horizontal_shift_parameters(17,
em_gain=True,
adc_bit_depth=16)
self.camera.set_horizontal_shift_parameters(
17, em_gain=True, adc_bit_depth=16
)
else:
self.camera.set_horizontal_shift_parameters(3,
em_gain=False,
adc_bit_depth=16)
self.camera.set_horizontal_shift_parameters(
3, em_gain=False, adc_bit_depth=16
)
self.camera.set_vertical_shift_speed(3.3)
self.camera.set_em_gain(self.em_gain)

Expand All @@ -53,12 +55,14 @@ def issue_applets(self):
ddb = self.get_device_db()
dev = ddb[self._camera_name]

self.ccb.issue("create_applet",
"Camera",
"${python} -m oxart.applets.camera_viewer "
"--server " + dev["host"] + " "
"--serial " + dev["target_name"],
group="monitor")
self.ccb.issue(
"create_applet",
"Camera",
"${python} -m oxart.applets.camera_viewer "
"--server " + dev["host"] + " "
"--serial " + dev["target_name"],
group="monitor",
)


class ChooseROI(EnvExperiment):
Expand All @@ -68,13 +72,12 @@ def build(self):
self.setattr_device("core")
self.setattr_device("camera")

self.roi_length = \
self.get_argument("ROI length", NumberValue(50, ndecimals=0))
self.roi_width = \
self.get_argument("ROI width", NumberValue(50, ndecimals=0))
self.roi_length = self.get_argument("ROI length", NumberValue(50, ndecimals=0))
self.roi_width = self.get_argument("ROI width", NumberValue(50, ndecimals=0))

self.ion_signal_width = \
self.get_argument("Ion signal width", NumberValue(30, ndecimals=0))
self.ion_signal_width = self.get_argument(
"Ion signal width", NumberValue(30, ndecimals=0)
)

self.set_default_scheduling(pipeline_name="camera")

Expand All @@ -93,9 +96,9 @@ def run(self):
break
time.sleep(10 * ms)

im, sub_region = trim_image(im_full,
n_width=int(self.roi_width),
n_length=int(self.roi_length))
im, sub_region = trim_image(
im_full, n_width=int(self.roi_width), n_length=int(self.roi_length)
)

roi = [*sub_region[0], *sub_region[1]]

Expand Down
18 changes: 9 additions & 9 deletions oxart/devices/arduino_dac/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, serial_name, n_channels=16, v_min=-10, v_max=10):

def _send_command(self, command):
try:
self.port.write((command + '\n').encode())
self.port.write((command + "\n").encode())
except serial.SerialTimeoutException:
logger.exception("Serial write timeout: Force exit")
# This is hacky but makes the server exit
Expand All @@ -44,11 +44,11 @@ def _read_line(self):

Returns '' on timeout
"""
s = ''
while len(s) == 0 or s[-1] != '\n':
s = ""
while len(s) == 0 or s[-1] != "\n":
c = self.port.read().decode()
if c == '': # Timeout
raise Exception('Serial read timeout')
if c == "": # Timeout
raise Exception("Serial read timeout")
s += c
return s

Expand Down Expand Up @@ -81,19 +81,19 @@ def set_voltage(self, channel, voltage, update=True):
should be updated on execution of this command, or later with 'update'
"""
if update:
command = 'VU'
command = "VU"
else:
command = 'V'
command = "V"

if not self._validate_channel_index(channel):
raise Exception("Bad channel index: {}".format(channel))

command += ' {}'.format(channel)
command += " {}".format(channel)

if not self._validate_voltage(voltage):
raise Exception("Bad voltage: {}".format(voltage))

command += ' {:.4f}\n'.format(voltage)
command += " {:.4f}\n".format(voltage)

self._send_command(command)

Expand Down
47 changes: 28 additions & 19 deletions oxart/devices/arduino_dds/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ def __eq__(self, value):
return False

if not isinstance(value, ProfileDescriptor):
raise ValueError("Bad value type in ProfileDescriptor equality: "
"{}".format(type(value)))

if self.freq_word == value.freq_word and\
self.amp_word == value.amp_word and\
self.phase_word == value.phase_word:
raise ValueError(
"Bad value type in ProfileDescriptor equality: "
"{}".format(type(value))
)

if (
self.freq_word == value.freq_word
and self.amp_word == value.amp_word
and self.phase_word == value.phase_word
):
return True
else:
return False
Expand Down Expand Up @@ -82,8 +86,10 @@ def set_profile(self, profile, freq, phase=0.0, amp=1.0):

# Check if this profile is already present
if self.current_profiles[profile] == new_profile:
logger.debug("Not setting profile {} with {}, already set"
"".format(profile, new_profile))
logger.debug(
"Not setting profile {} with {}, already set"
"".format(profile, new_profile)
)
else:
# If it is not present, set it and log it
self._set_profile_lsb(profile, freq_word, phase_word, amp_word)
Expand All @@ -94,17 +100,20 @@ def _set_profile_lsb(self, profile, freq, phase, amp):
"""Freq, phase, amp are all in units of lsb."""
if profile < 0 or profile > 7 or not isinstance(profile, int):
raise ValueError("DDS profile should be an integer between 0 and 7")
if amp > 0x3fff or amp < 0 or not isinstance(amp, int):
raise ValueError("DDS amplitude word should be an integer "
"between 0 and 0x3fff")
if phase > 0xffff or phase < 0 or not isinstance(phase, int):
raise ValueError("DDS phase word should be an integer between "
"0 and 0xffff")
if freq < 0 or freq > 0xffffffff or not isinstance(freq, int):
raise ValueError("DDS frequency word should be an integer "
"between 0 and 0xffffffff")

self.send('PLSB {} {} {} {}\n'.format(profile, amp, phase, freq))
if amp > 0x3FFF or amp < 0 or not isinstance(amp, int):
raise ValueError(
"DDS amplitude word should be an integer " "between 0 and 0x3fff"
)
if phase > 0xFFFF or phase < 0 or not isinstance(phase, int):
raise ValueError(
"DDS phase word should be an integer between " "0 and 0xffff"
)
if freq < 0 or freq > 0xFFFFFFFF or not isinstance(freq, int):
raise ValueError(
"DDS frequency word should be an integer " "between 0 and 0xffffffff"
)

self.send("PLSB {} {} {} {}\n".format(profile, amp, phase, freq))
time.sleep(0.01)

def reset(self):
Expand Down
Loading