From 0e721f39331159e98c6a6f9fea8634cb2645f1bc Mon Sep 17 00:00:00 2001 From: "Hood, Jonathan D" Date: Wed, 26 May 2021 18:01:26 -0400 Subject: [PATCH] Update SimplestScript.py --- Andor/andorv2/andor/SimplestScript.py | 101 +++++++++++++------------- 1 file changed, 52 insertions(+), 49 deletions(-) diff --git a/Andor/andorv2/andor/SimplestScript.py b/Andor/andorv2/andor/SimplestScript.py index a014767..8f85423 100644 --- a/Andor/andorv2/andor/SimplestScript.py +++ b/Andor/andorv2/andor/SimplestScript.py @@ -1,49 +1,52 @@ -#!/usr/bin/env python - -# Library imports - -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 - -cam = atmcd() #load the atmcd library - -# Initializations and settings - -cam.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK -cam.CoolerON() # Turns on TEC -cam.SetTemperature(-40) # TEC temp -cam.SetAcquisitionMode(1) # Single scan -cam.SetReadMode(4) # Image readmode -cam.SetShutter(0,1,50,50) # (0,1,50,50) opens shutter -cam.SetExposureTime(1) # 1 second -cam.SetTriggerMode(1) # External TTL trigger -(ret, xpixels, ypixels) = cam.GetDetector() # Returns detector properties -imagesize = xpixels*ypixels # Set image size -(ret) = cam.SetImage(1, 1, 1, xpixels, 1, ypixels) # Sets ROI? -cam.StartAcquisition() # Starts acquisition cycling - -# Begin acquisition - -print("Before WaitForAcquisition...") -cam.WaitForAcquisition() # Waits for trigger then takes image -print("Trigger received...") - -# Process and plot image - -(ret, fullFrameBuffer) = cam.GetMostRecentImage(imagesize) # Retrieves most recent image -image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array -plt.imshow(image) # Plots image - -#Clean up - -cam.ShutDown() # Shuts down camera - -if ret == 20002: - print("Script ran correctly...") -else: - print("Script failed...") \ No newline at end of file + #!/usr/bin/env python + +### Section 1: Imports ### + + 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 + + cam = atmcd() #load the atmcd library + +### Section 2: Initializations and Settings ### + + cam.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK + cam.CoolerON() # Turns on TEC + cam.SetTemperature(-40) # TEC temp + cam.SetAcquisitionMode(1) # Single scan + cam.SetReadMode(4) # Image readmode + cam.SetShutter(0,1,50,50) # (0,1,50,50) opens shutter + cam.SetExposureTime(1) # 1 second + cam.SetTriggerMode(1) # External TTL trigger + (ret, xpixels, ypixels) = cam.GetDetector() # Returns detector properties + imagesize = xpixels*ypixels # Set image size + cam.SetImage(1, 1, 1, xpixels, 1, ypixels) # Sets ROI? + cam.StartAcquisition() # Starts acquisition cycling + +### Section 3: Acquisition, Processing, and Clean up ### + + # Begin acquisition + + print("Before WaitForAcquisition...") + cam.WaitForAcquisition() # Waits for trigger then takes image + print("Trigger received...") + + # Process and plot image + + (ret, fullFrameBuffer) = cam.GetMostRecentImage(imagesize) # Retrieves most recent image + image = np.reshape(fullFrameBuffer, (512,512)) #Converts c_long 262k array to 512x512 image numpy array + plt.imshow(image) # Plots image + + #Clean up + + cam.CancelWait() # Cancels WaitForAcquisition + cam.AbortAcquisition() # Cancels StartAcquisition + cam.StartAcquisition() # Restarts StartAcquisition + + if ret == 20002: + print("Script ran correctly...") + else: + print("Script failed...") \ No newline at end of file