diff --git a/Andor/andorv1.0/andor/__init__.py b/Andor/__init__.py similarity index 100% rename from Andor/andorv1.0/andor/__init__.py rename to Andor/__init__.py diff --git a/Andor/andorv1.0/andor/__pycache__/driver.cpython-37.pyc b/Andor/andorv1.0/andor/__pycache__/driver.cpython-37.pyc deleted file mode 100644 index a6708ab..0000000 Binary files a/Andor/andorv1.0/andor/__pycache__/driver.cpython-37.pyc and /dev/null differ diff --git a/Andor/andorv1.0/andor/__pycache__/driver.cpython-38.pyc b/Andor/andorv1.0/andor/__pycache__/driver.cpython-38.pyc deleted file mode 100644 index e52fc96..0000000 Binary files a/Andor/andorv1.0/andor/__pycache__/driver.cpython-38.pyc and /dev/null differ diff --git a/Andor/andorv1.0/build/lib/andor/__init__.py b/Andor/andorv1/__init__.py similarity index 100% rename from Andor/andorv1.0/build/lib/andor/__init__.py rename to Andor/andorv1/__init__.py diff --git a/Andor/andorv1.0/andor.egg-info/PKG-INFO b/Andor/andorv1/andor.egg-info/PKG-INFO similarity index 100% rename from Andor/andorv1.0/andor.egg-info/PKG-INFO rename to Andor/andorv1/andor.egg-info/PKG-INFO diff --git a/Andor/andorv1.0/andor.egg-info/SOURCES.txt b/Andor/andorv1/andor.egg-info/SOURCES.txt similarity index 100% rename from Andor/andorv1.0/andor.egg-info/SOURCES.txt rename to Andor/andorv1/andor.egg-info/SOURCES.txt diff --git a/Andor/andorv1.0/andor.egg-info/dependency_links.txt b/Andor/andorv1/andor.egg-info/dependency_links.txt similarity index 100% rename from Andor/andorv1.0/andor.egg-info/dependency_links.txt rename to Andor/andorv1/andor.egg-info/dependency_links.txt diff --git a/Andor/andorv1.0/andor.egg-info/entry_points.txt b/Andor/andorv1/andor.egg-info/entry_points.txt similarity index 100% rename from Andor/andorv1.0/andor.egg-info/entry_points.txt rename to Andor/andorv1/andor.egg-info/entry_points.txt diff --git a/Andor/andorv1.0/andor.egg-info/top_level.txt b/Andor/andorv1/andor.egg-info/top_level.txt similarity index 100% rename from Andor/andorv1.0/andor.egg-info/top_level.txt rename to Andor/andorv1/andor.egg-info/top_level.txt diff --git a/Andor/andorv1/andor/__init__.py b/Andor/andorv1/andor/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Andor/andorv1.0/andor/driver.py b/Andor/andorv1/andor/andor_driver.py similarity index 99% rename from Andor/andorv1.0/andor/driver.py rename to Andor/andorv1/andor/andor_driver.py index 8504017..5d89af0 100644 --- a/Andor/andorv1.0/andor/driver.py +++ b/Andor/andorv1/andor/andor_driver.py @@ -1,6 +1,6 @@ from atmcd import * -class andor(): +class andor: def __init__(self): print("Intialising Camera") self.cam = atmcd() #load the atmcd library diff --git a/Andor/andorv1.0/andor/aqctl_andor.py b/Andor/andorv1/andor/aqctl_andor.py similarity index 100% rename from Andor/andorv1.0/andor/aqctl_andor.py rename to Andor/andorv1/andor/aqctl_andor.py diff --git a/Andor/andorv1.0/andor/atmcd.py b/Andor/andorv1/andor/atmcd.py similarity index 100% rename from Andor/andorv1.0/andor/atmcd.py rename to Andor/andorv1/andor/atmcd.py diff --git a/Andor/andorv1/build/lib/andor/__init__.py b/Andor/andorv1/build/lib/andor/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Andor/andorv1.0/build/lib/andor/aqctl_andor.py b/Andor/andorv1/build/lib/andor/aqctl_andor.py similarity index 97% rename from Andor/andorv1.0/build/lib/andor/aqctl_andor.py rename to Andor/andorv1/build/lib/andor/aqctl_andor.py index 4c3a96e..29d9c08 100644 --- a/Andor/andorv1.0/build/lib/andor/aqctl_andor.py +++ b/Andor/andorv1/build/lib/andor/aqctl_andor.py @@ -8,7 +8,7 @@ import os import asyncio -from andor.driver import andor +from andorv1.0.driver import andor from sipyco.pc_rpc import simple_server_loop from sipyco import common_args diff --git a/Andor/andorv1.0/build/lib/andor/atmcd.py b/Andor/andorv1/build/lib/andor/atmcd.py similarity index 100% rename from Andor/andorv1.0/build/lib/andor/atmcd.py rename to Andor/andorv1/build/lib/andor/atmcd.py diff --git a/Andor/andorv1.0/build/lib/andor/driver.py b/Andor/andorv1/build/lib/andor/driver.py similarity index 100% rename from Andor/andorv1.0/build/lib/andor/driver.py rename to Andor/andorv1/build/lib/andor/driver.py diff --git a/Andor/andorv1.0/dist/andor-0.0.0-py3.7.egg b/Andor/andorv1/dist/andor-0.0.0-py3.7.egg similarity index 100% rename from Andor/andorv1.0/dist/andor-0.0.0-py3.7.egg rename to Andor/andorv1/dist/andor-0.0.0-py3.7.egg diff --git a/Andor/andorv1.0/doc/Makefile b/Andor/andorv1/doc/Makefile similarity index 100% rename from Andor/andorv1.0/doc/Makefile rename to Andor/andorv1/doc/Makefile diff --git a/Andor/andorv1.0/doc/conf.py b/Andor/andorv1/doc/conf.py similarity index 100% rename from Andor/andorv1.0/doc/conf.py rename to Andor/andorv1/doc/conf.py diff --git a/Andor/andorv1.0/doc/index.rst b/Andor/andorv1/doc/index.rst similarity index 100% rename from Andor/andorv1.0/doc/index.rst rename to Andor/andorv1/doc/index.rst diff --git a/Andor/andorv1.0/setup.py b/Andor/andorv1/setup.py similarity index 100% rename from Andor/andorv1.0/setup.py rename to Andor/andorv1/setup.py diff --git a/Andor/andorv2/__init__.py b/Andor/andorv2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Andor/andorv2/andor/SingleScan.py b/Andor/andorv2/andor/SingleScan.py new file mode 100644 index 0000000..c6cc50f --- /dev/null +++ b/Andor/andorv2/andor/SingleScan.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +import sys, os + +sys.path.append(r'C:/Users/hoodl/Documents/GitHub/Instruments/Andor/andorv2/andor') + +from atmcd import * +import numpy as np +import matplotlib.pyplot as plt +import time + + +print("Single Scan Example") + +print("Intialising Camera") +sdkObject = atmcd() #load the atmcd library +(ret) = sdkObject.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK +print("Initialize returned",ret) + + + +if atmcd.DRV_SUCCESS==ret: + + (ret, iSerialNumber) = sdkObject.GetCameraSerialNumber() + # print("GetCameraSerialNumber returned:",ret,"Serial No:",iSerialNumber) + + #configure the acquisition + (ret) = sdkObject.CoolerON() + # print("Function CoolerON returned",ret) + + (ret) = sdkObject.SetTemperature(-40) + # print("Function CoolerON returned",ret) + + + (ret) = sdkObject.SetAcquisitionMode(1) + # print("Function SetAcquisitionMode returned",ret,"mode = Single Scan") + + (ret) = sdkObject.SetReadMode(4) + # print("Function SetReadMode returned",ret,"mode = Image") + + (ret) = sdkObject.SetShutter(0,1,50,50) # (0,1,50,50) opens shutter. (0,2,50,50) closes shutter. + + (ret) = sdkObject.SetExposureTime(1) + # print("Function SetExposureTime returned",ret,"time = 0.5s") + + (ret) = sdkObject.SetTriggerMode(0) + # print("Function SetTriggerMode returned",ret,"mode = Internal") + + (ret) = sdkObject.SetVSSpeed(3) + # print(sdkObject.GetAcquiredData()VSSpeed(0,0,0)) + + (ret, xpixels, ypixels) = sdkObject.GetDetector() + # print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels) + + (ret) = sdkObject.SetImage(1, 1, 1, xpixels, 1, ypixels) + # print("Function SetImage returned",ret,"hbin = 1 vbin = 1 hstart = 1 hend =",xpixels,"vstart = 1 vend =",ypixels) + + (ret, fminExposure, fAccumulate, fKinetic) = sdkObject.GetAcquisitionTimings() + # print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic) + + (ret) = sdkObject.PrepareAcquisition() + # print("Function PrepareAcquisition returned",ret) + + #Perform Acquisition + (ret) = sdkObject.StartAcquisition() + # print("Function StartAcquisition returned",ret) + + (ret) = sdkObject.WaitForAcquisition() + # print("Function WaitForAcquisition returned",ret) + + imageSize = xpixels*ypixels + (ret, fullFrameBuffer) = sdkObject.GetMostRecentImage(imageSize) + # print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",imageSize) + + #David's addition + image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array + print(np.sum(image),(np.max(image))) + plt.imshow(image) + + #Clean up + # (ret) = sdkObject.SetShutter(0,2,50,50) + (ret) = sdkObject.ShutDown() + # print("Shutdown returned",ret) + +# else: + # print("Cannot continue, could not initialise camera") + diff --git a/Andor/andorv2/andor/__init__.py b/Andor/andorv2/andor/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Andor/andorv2/andor/andor_driver.py b/Andor/andorv2/andor/andor_driver.py new file mode 100644 index 0000000..6128f81 --- /dev/null +++ b/Andor/andorv2/andor/andor_driver.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python +from atmcd import * +import numpy as np +import matplotlib.pyplot as plt + + + +class ANDOR: + """Driver for ANDOR camera """ + def __init__(self): + self.cam = atmcd() #load the atmcd library + + + (ret) = self.cam.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK + (ret, iSerialNumber) = self.cam.GetCameraSerialNumber() + (ret) = self.cam.CoolerON() + + + (ret) = self.cam.SetTemperature(-40) #David added this + (ret) = self.cam.SetVSSpeed(3.3) #David added this + (ret) = self.cam.SetVSAmplitude(Normal) #David added this + (ret) = self.cam.SetPreAmpGain(3) #David added this + (ret) = self.cam.SetOutputAmplifier(0) # 0 is EMCCD. David added this + (ret) = self.cam.SetEMCCDGain(2) # Max is 300? David added this + #The only setting I have missed is the readout rate which I could not find. might be SetHSSpeed and SetHorizontalSpeed + + (ret) = self.cam.SetAcquisitionMode(1) + (ret) = self.cam.SetReadMode(4) + (ret) = self.cam.SetTriggerMode(0) # 0 is internal, 1 is external, 6 is external start? + (ret, self.xpixels, self.ypixels) = self.cam.GetDetector() + self.imageSize = self.xpixels*self.ypixels + (ret) = self.cam.SetImage(1, 1, 1, self.xpixels, 1, self.ypixels) + (ret) = self.cam.SetExposureTime(0.01) # Set exposure time here! + (ret, self.fminExposure, self.fAccumulate, self.fKinetic) = self.cam.GetAcquisitionTimings() + (ret) = self.cam.PrepareAcquisition() + (ret) = self.cam.StartAcquisition() + + if atmcd.DRV_SUCCESS==ret: + print("_init_() was successful...") + else: + print("_init_() failed...Try restarting Artiq and/or powercycling camera") + + + #Settings we still need: temperature(-40), shift speed (3.3), Vertical Clock Voltage Amplitude (Normal/+0), Readout Rate (17MHz at 16-bit) + # ,Pre-Amp Gain (Gain 3), Output Amplifier (Electron Multiplying), Electron Multiplier (EM) Gain (Enabled->2) + + + def await_trigger(self): + try: + (ret) = self.cam.WaitForAcquisition() + + print("Awaiting trigger...") + + except: + try: + (ret) = self.cam.ShutDown() + except: + pass + print("Error in await_trigger(), try restarting artiq...") + + + + def convert_image(self): + + try: + (ret, fullFrameBuffer) = self.cam.GetMostRecentImage(self.imageSize) # GetImages(somethinghere) might be a better command if we want to do background subtraction + image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array + # plt.imshow(image) + + + # try: + ##Acquire images + # images=[] + # for i in range(num_of_im): + # 1. Get image from buffer (c_long + # 2. Convert c_long to numpy array + # 3. Wipe image from buffer + + # 1. end acquisition + # return images + except: + try: + (ret) = self.cam.ShutDown() + except: + pass + print("Error in convert_image(), try restarting artiq...") + + + + def reset(self): + (ret) = self.cam.ShutDown() + print("Shutdown successful...") diff --git a/Andor/andorv2/andor/aqctl_andor.py b/Andor/andorv2/andor/aqctl_andor.py new file mode 100644 index 0000000..23b4b42 --- /dev/null +++ b/Andor/andorv2/andor/aqctl_andor.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 + +# Written by Joe Britton, 2015 + +import argparse +import logging +import sys +import os +import asyncio + +sys.path.append(r'C:\Users\hoodl\Documents\GitHub\Instruments\andor_repo') + +from andor.andor_driver import ANDOR +from sipyco.pc_rpc import simple_server_loop +from sipyco import common_args + + +logger = logging.getLogger(__name__) + + + + +def get_argparser(): + parser = argparse.ArgumentParser( + description="ARTIQ controller for the ANDOR camera") + common_args.simple_network_args(parser, 3210) + parser.add_argument( + "-d", "--device", default=None, + help="serial port.") + parser.add_argument( + "--softtrig", default=False, action="store_true", + help="Sets trigger to software. Default is hardware") + parser.add_argument( + "--num", default=1, + help="Sets number of images. Default is hardware") + parser.add_argument( + "--simulation", action="store_true", + help="Put the driver in simulation mode, even if --device is used.") + common_args.verbosity_args(parser) + return parser + + +def main(): + args = get_argparser().parse_args() + common_args.init_logger_from_args(args) + if os.name == "nt": + asyncio.set_event_loop(asyncio.ProactorEventLoop()) + # if args.device is None: + # print("Starting in Simulation mode...") + # dev = ANDOR(args.device if not args.simulation else None) + + dev = ANDOR() + #asyncio.get_event_loop().run_until_complete(dev.setup()) + try: + print("ANDOR server startup on port",args.port,"successful...") + simple_server_loop( + {"ANDOR": dev}, common_args.bind_address_from_args(args), args.port) + truthcounter=1 + finally: + print("Closing server...") + #dev.close() + +if __name__ == "__main__": + main() diff --git a/Andor/andorv1.0/andor/__pycache__/atmcd.cpython-38.pyc b/Andor/andorv2/andor/atmcd.py similarity index 77% rename from Andor/andorv1.0/andor/__pycache__/atmcd.cpython-38.pyc rename to Andor/andorv2/andor/atmcd.py index bd4658d..03a3281 100644 Binary files a/Andor/andorv1.0/andor/__pycache__/atmcd.cpython-38.pyc and b/Andor/andorv2/andor/atmcd.py differ diff --git a/Andor/andorv2/doc/Makefile b/Andor/andorv2/doc/Makefile new file mode 100644 index 0000000..298ea9e --- /dev/null +++ b/Andor/andorv2/doc/Makefile @@ -0,0 +1,19 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/Andor/andorv2/doc/conf.py b/Andor/andorv2/doc/conf.py new file mode 100644 index 0000000..f7c5161 --- /dev/null +++ b/Andor/andorv2/doc/conf.py @@ -0,0 +1,176 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + + +import os +import sys +from unittest.mock import Mock + +sys.path.insert(0, os.path.abspath('..')) + +mock_modules = ["asyncserial"] + +for module in mock_modules: + sys.modules[module] = Mock() + +# -- Project information ----------------------------------------------------- + +project = 'Andor' +copyright = '2019, M-Labs' +author = 'M-Labs' + +# The short X.Y version +version = '1.0' +# The full version, including alpha/beta/rc tags +release = '1.0' + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinxarg.ext' +] + +# Add any paths that contain templates here, relative to this directory. +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' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# 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'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = None + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Novatech409Bdoc' + + +# -- 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', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'Novatech409B.tex', 'Novatech409B Documentation', + 'M-Labs', '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, 'novatech409', 'Novatech409B 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, 'Novatech409B', 'Novatech409B Documentation', + author, 'Novatech409B', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] diff --git a/Andor/andorv2/doc/index.rst b/Andor/andorv2/doc/index.rst new file mode 100644 index 0000000..8764c75 --- /dev/null +++ b/Andor/andorv2/doc/index.rst @@ -0,0 +1,24 @@ +Welcome to Novatech409B's documentation! +======================================== + +API +--- + +.. automodule:: novatech409b.driver + :members: + + +ARTIQ controller +---------------- + +.. argparse:: + :ref: novatech409b.aqctl_novatech409b.get_argparser + :prog: aqctl_novatech409b + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/Andor/andorv2/setup.py b/Andor/andorv2/setup.py new file mode 100644 index 0000000..84af854 --- /dev/null +++ b/Andor/andorv2/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup, find_packages + +setup( + name="andor", + install_requires=[],#"sipyco", "asyncserial"], + packages=find_packages(), + entry_points={ + "console_scripts": [ + "aqctl_andor = andor.aqctl_andor:main", + ], + }, +) diff --git a/Andor/sdk's/sdk2/SingleScan.py b/Andor/sdk's/sdk2/SingleScan.py index 0039ede..5026b52 100644 --- a/Andor/sdk's/sdk2/SingleScan.py +++ b/Andor/sdk's/sdk2/SingleScan.py @@ -1,5 +1,7 @@ #!/usr/bin/env python from atmcd import * +import numpy as np +import matplotlib.pyplot as plt print("Single Scan Example") @@ -11,7 +13,7 @@ if atmcd.DRV_SUCCESS==ret: (ret, iSerialNumber) = sdkObject.GetCameraSerialNumber() - print("GetCameraSerialNumber returned:",ret,"Serial No:",iSerialNumber) + print("GetCameraSerialNumb er returned:",ret,"Serial No:",iSerialNumber) #configure the acquisition (ret) = sdkObject.CoolerON() @@ -56,6 +58,10 @@ (ret) = sdkObject.ShutDown() print("Shutdown returned",ret) + #David's addition + image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array + plt.imshow(image) + else: print("Cannot continue, could not initialise camera") diff --git a/andor_repo/andor.egg-info/PKG-INFO b/andor_repo/andor.egg-info/PKG-INFO new file mode 100644 index 0000000..39a60ec --- /dev/null +++ b/andor_repo/andor.egg-info/PKG-INFO @@ -0,0 +1,10 @@ +Metadata-Version: 1.0 +Name: andor +Version: 0.0.0 +Summary: UNKNOWN +Home-page: UNKNOWN +Author: UNKNOWN +Author-email: UNKNOWN +License: UNKNOWN +Description: UNKNOWN +Platform: UNKNOWN diff --git a/andor_repo/andor.egg-info/SOURCES.txt b/andor_repo/andor.egg-info/SOURCES.txt new file mode 100644 index 0000000..4c0acb1 --- /dev/null +++ b/andor_repo/andor.egg-info/SOURCES.txt @@ -0,0 +1,11 @@ +setup.py +andor/SingleScan.py +andor/__init__.py +andor/andor_driver.py +andor/aqctl_andor.py +andor/atmcd.py +andor.egg-info/PKG-INFO +andor.egg-info/SOURCES.txt +andor.egg-info/dependency_links.txt +andor.egg-info/entry_points.txt +andor.egg-info/top_level.txt \ No newline at end of file diff --git a/andor_repo/andor.egg-info/dependency_links.txt b/andor_repo/andor.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/andor_repo/andor.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/andor_repo/andor.egg-info/entry_points.txt b/andor_repo/andor.egg-info/entry_points.txt new file mode 100644 index 0000000..2e14652 --- /dev/null +++ b/andor_repo/andor.egg-info/entry_points.txt @@ -0,0 +1,3 @@ +[console_scripts] +aqctl_andor = andor.aqctl_andor:main + diff --git a/andor_repo/andor.egg-info/top_level.txt b/andor_repo/andor.egg-info/top_level.txt new file mode 100644 index 0000000..fe88de4 --- /dev/null +++ b/andor_repo/andor.egg-info/top_level.txt @@ -0,0 +1 @@ +andor diff --git a/andor_repo/andor/SingleScan.py b/andor_repo/andor/SingleScan.py new file mode 100644 index 0000000..c0ceaf4 --- /dev/null +++ b/andor_repo/andor/SingleScan.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +from atmcd import * +import numpy as np +import matplotlib.pyplot as plt + +print("Single Scan Example") + +print("Intialising Camera") +sdkObject = atmcd() #load the atmcd library +(ret) = sdkObject.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK +print("Initialize returned",ret) + +if atmcd.DRV_SUCCESS==ret: + + (ret, iSerialNumber) = sdkObject.GetCameraSerialNumber() + print("GetCameraSerialNumber returned:",ret,"Serial No:",iSerialNumber) + + #configure the acquisition + (ret) = sdkObject.CoolerON() + print("Function CoolerON returned",ret) + + (ret) = sdkObject.SetAcquisitionMode(1) + print("Function SetAcquisitionMode returned",ret,"mode = Single Scan") + + (ret) = sdkObject.SetReadMode(4) + print("Function SetReadMode returned",ret,"mode = Image") + + (ret) = sdkObject.SetTriggerMode(0) + print("Function SetTriggerMode returned",ret,"mode = Internal") + + (ret, xpixels, ypixels) = sdkObject.GetDetector() + print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels) + + (ret) = sdkObject.SetImage(1, 1, 1, xpixels, 1, ypixels) + print("Function SetImage returned",ret,"hbin = 1 vbin = 1 hstart = 1 hend =",xpixels,"vstart = 1 vend =",ypixels) + + (ret) = sdkObject.SetExposureTime(0.01) + print("Function SetExposureTime returned",ret,"time = 0.01s") + + (ret, fminExposure, fAccumulate, fKinetic) = sdkObject.GetAcquisitionTimings() + print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic) + + (ret) = sdkObject.PrepareAcquisition() + print("Function PrepareAcquisition returned",ret) + + #Perform Acquisition + (ret) = sdkObject.StartAcquisition() + print("Function StartAcquisition returned",ret) + + (ret) = sdkObject.WaitForAcquisition() + print("Function WaitForAcquisition returned",ret) + + imageSize = xpixels*ypixels + (ret, fullFrameBuffer) = sdkObject.GetMostRecentImage(imageSize) + print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",imageSize) + + #Clean up + (ret) = sdkObject.ShutDown() + print("Shutdown returned",ret) + + #David's addition + image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array + plt.imshow(image) + +else: + print("Cannot continue, could not initialise camera") + diff --git a/andor_repo/andor/__init__.py b/andor_repo/andor/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/andor_repo/andor/andor_driver.py b/andor_repo/andor/andor_driver.py new file mode 100644 index 0000000..f78ea5e --- /dev/null +++ b/andor_repo/andor/andor_driver.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python +from andor.atmcd import * +import numpy as np +import matplotlib.pyplot as plt +import time + + +class ANDOR: + """Driver for ANDOR camera """ + def __init__(self): + self.cam = atmcd() #load the atmcd library + # self.reset() + + + (ret) = self.cam.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK + (ret, iSerialNumber) = self.cam.GetCameraSerialNumber() + (ret) = self.cam.CoolerON() + (ret) = self.cam.SetCoolerMode(1) + (ret) = self.cam.SetTemperature(-40) #David added this + (ret) = self.cam.SetHSSpeed(0,0) #David added this + (ret) = self.cam.SetVSSpeed(3)#.3) #David added this + (ret) = self.cam.SetVSAmplitude(0) #David added this + (ret) = self.cam.SetPreAmpGain(3) #David added this + (ret) = self.cam.SetOutputAmplifier(0) # 0 is EMCCD. David added this + (ret) = self.cam.SetEMCCDGain(2) # Max is 300? David added this + #The only setting I have missed is the readout rate which I could not find. might be SetHSSpeed and SetHorizontalSpeed + + (ret) = self.cam.SetShutter(0,1,50,50) # (0,1,50,50) opens shutter. (0,2,50,50) closes shutter. + (ret) = self.cam.SetAcquisitionMode(1) + (ret) = self.cam.SetReadMode(4) + + (ret) = self.cam.SetTriggerMode(1) # 0 is internal, 1 is external, 6 is external start? + (ret, self.xpixels, self.ypixels) = self.cam.GetDetector() + self.imageSize = self.xpixels*self.ypixels + (ret) = self.cam.SetImage(1, 1, 1, self.xpixels, 1, self.ypixels) + (ret) = self.cam.SetExposureTime(.1) # Set exposure time here! + (ret, self.fminExposure, self.fAccumulate, self.fKinetic) = self.cam.GetAcquisitionTimings() + # (ret) = self.cam.PrepareAcquisition() + (ret) = self.cam.StartAcquisition() + + if atmcd.DRV_SUCCESS==ret: + print("Andor Initializiation was successful...") + else: + print("Andor Initializiation failed...Try restarting Artiq and/or powercycling camera") + + + #Settings we still need: temperature(-40), shift speed (3.3), Vertical Clock Voltage Amplitude (Normal/+0), Readout Rate (17MHz at 16-bit) + # ,Pre-Amp Gain (Gain 3), Output Amplifier (Electron Multiplying), Electron Multiplier (EM) Gain (Enabled->2) + + + def await_trigger(self): + # try: + + + + print("Awaiting trigger...") + (ret) = self.cam.WaitForAcquisition()#TimeOut(1000) + # self.cam.WaitForAcquisition(); + print("Taking image...") + # self.cam.CancelWait() + + + + + # except: + # try: + # (ret) = self.cam.ShutDown() + # except: + # pass + # print("Error in await_trigger(), try restarting artiq...") + + + def reset_image(self): + self.cam.CancelWait() + self.cam.AbortAcquisition() + + def start_acq(self): + self.cam.StartAcquisition() + + + def get_last_image(self): + + # try: + (ret, fullFrameBuffer) = self.cam.GetMostRecentImage(self.imageSize) # GetImages(somethinghere) might be a better command if we want to do background subtraction + image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array + + return image + + def plot_image(self,image=None): + if type(image) == type(None): + image = self.last_image() + + plt.imshow(image) + plt.show(block=True) + # plt.pause(3) + # plt.close() + + + # except: + # try: + # (ret) = self.cam.ShutDown() + # except: + # pass + # print("Error in convert_image(), try restarting artiq...") + + + # try: + ##Acquire images + # images=[] + # for i in range(num_of_im): + # 1. Get image from buffer (c_long + # 2. Convert c_long to numpy array + # 3. Wipe image from buffer + + # 1. end acquisition + # return images + + + def take_pic(self): + print("Before T") + self.await_trigger() + print("After T") + self.plot_image() + + # self.CancelWait() + # (0,1,50,50) opens shutter. (0,2,50,50) closes shutter. + + def reset(self): + (ret) = self.cam.SetShutter(0,2,50,50) + (ret) = self.cam.ShutDown() + print("Camera Reset Successful...") diff --git a/andor_repo/andor/aqctl_andor.py b/andor_repo/andor/aqctl_andor.py new file mode 100644 index 0000000..68a57e9 --- /dev/null +++ b/andor_repo/andor/aqctl_andor.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 + +# Written by Joe Britton, 2015 + +import argparse +import logging +import sys +import os +import asyncio + +sys.path.append(r'C:\Users\hoodl\Documents\GitHub\Instruments\andor_repo') + +from andor.andor_driver import ANDOR +from sipyco.pc_rpc import simple_server_loop +from sipyco import common_args + + +logger = logging.getLogger(__name__) + + + + +def get_argparser(): + parser = argparse.ArgumentParser( + description="ARTIQ controller for the ANDOR camera") + common_args.simple_network_args(parser, 3220) + parser.add_argument( + "-d", "--device", default=None, + help="serial port.") + parser.add_argument( + "--softtrig", default=False, action="store_true", + help="Sets trigger to software. Default is hardware") + parser.add_argument( + "--num", default=1, + help="Sets number of images. Default is hardware") + parser.add_argument( + "--simulation", action="store_true", + help="Put the driver in simulation mode, even if --device is used.") + common_args.verbosity_args(parser) + return parser + + +def main(): + args = get_argparser().parse_args() + common_args.init_logger_from_args(args) + if os.name == "nt": + asyncio.set_event_loop(asyncio.ProactorEventLoop()) + # if args.device is None: + # print("Starting in Simulation mode...") + # dev = ANDOR(args.device if not args.simulation else None) + + dev = ANDOR() + #asyncio.get_event_loop().run_until_complete(dev.setup()) + try: + print("ANDOR server startup on port",args.port,"successful...") + simple_server_loop( + {"ANDOR": dev}, common_args.bind_address_from_args(args), args.port) + truthcounter=1 + finally: + print("Closing server...") + #dev.close() + +if __name__ == "__main__": + main() diff --git a/Andor/andorv1.0/andor/__pycache__/atmcd.cpython-37.pyc b/andor_repo/andor/atmcd.py similarity index 77% rename from Andor/andorv1.0/andor/__pycache__/atmcd.cpython-37.pyc rename to andor_repo/andor/atmcd.py index 7b42a64..03a3281 100644 Binary files a/Andor/andorv1.0/andor/__pycache__/atmcd.cpython-37.pyc and b/andor_repo/andor/atmcd.py differ diff --git a/andor_repo/doc/Makefile b/andor_repo/doc/Makefile new file mode 100644 index 0000000..298ea9e --- /dev/null +++ b/andor_repo/doc/Makefile @@ -0,0 +1,19 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/andor_repo/doc/conf.py b/andor_repo/doc/conf.py new file mode 100644 index 0000000..f7c5161 --- /dev/null +++ b/andor_repo/doc/conf.py @@ -0,0 +1,176 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + + +import os +import sys +from unittest.mock import Mock + +sys.path.insert(0, os.path.abspath('..')) + +mock_modules = ["asyncserial"] + +for module in mock_modules: + sys.modules[module] = Mock() + +# -- Project information ----------------------------------------------------- + +project = 'Andor' +copyright = '2019, M-Labs' +author = 'M-Labs' + +# The short X.Y version +version = '1.0' +# The full version, including alpha/beta/rc tags +release = '1.0' + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinxarg.ext' +] + +# Add any paths that contain templates here, relative to this directory. +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' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# 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'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = None + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Novatech409Bdoc' + + +# -- 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', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'Novatech409B.tex', 'Novatech409B Documentation', + 'M-Labs', '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, 'novatech409', 'Novatech409B 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, 'Novatech409B', 'Novatech409B Documentation', + author, 'Novatech409B', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] diff --git a/andor_repo/doc/index.rst b/andor_repo/doc/index.rst new file mode 100644 index 0000000..8764c75 --- /dev/null +++ b/andor_repo/doc/index.rst @@ -0,0 +1,24 @@ +Welcome to Novatech409B's documentation! +======================================== + +API +--- + +.. automodule:: novatech409b.driver + :members: + + +ARTIQ controller +---------------- + +.. argparse:: + :ref: novatech409b.aqctl_novatech409b.get_argparser + :prog: aqctl_novatech409b + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/andor_repo/setup.py b/andor_repo/setup.py new file mode 100644 index 0000000..84af854 --- /dev/null +++ b/andor_repo/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup, find_packages + +setup( + name="andor", + install_requires=[],#"sipyco", "asyncserial"], + packages=find_packages(), + entry_points={ + "console_scripts": [ + "aqctl_andor = andor.aqctl_andor:main", + ], + }, +)