Skip to content

Commit

Permalink
routine
Browse files Browse the repository at this point in the history
  • Loading branch information
dpeana committed May 26, 2021
1 parent b6f91bc commit 8fcd3f2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 15 deletions.
49 changes: 49 additions & 0 deletions Andor/andorv2/andor/SimplestScript.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/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...")
28 changes: 14 additions & 14 deletions Andor/andorv2/andor/SingleScan.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,51 +25,51 @@

#configure the acquisition
(ret) = sdkObject.CoolerON()
# print("Function CoolerON returned",ret)
print("Function CoolerON returned",ret)

(ret) = sdkObject.SetTemperature(-40)
# print("Function CoolerON returned",ret)
print("Function CoolerON returned",ret)


(ret) = sdkObject.SetAcquisitionMode(1)
# print("Function SetAcquisitionMode returned",ret,"mode = Single Scan")
print("Function SetAcquisitionMode returned",ret,"mode = Single Scan")

(ret) = sdkObject.SetReadMode(4)
# print("Function SetReadMode returned",ret,"mode = Image")
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")
print("Function SetExposureTime returned",ret,"time = 0.5s")

(ret) = sdkObject.SetTriggerMode(0)
# print("Function SetTriggerMode returned",ret,"mode = Internal")
print("Function SetTriggerMode returned",ret,"mode = Internal")

(ret) = sdkObject.SetVSSpeed(3)
# print(sdkObject.GetAcquiredData()VSSpeed(0,0,0))
# print(sdkObject.GetAcquiredData(VSSpeed(0,0,0)))

(ret, xpixels, ypixels) = sdkObject.GetDetector()
# print("Function GetDetector returned",ret,"xpixels =",xpixels,"ypixels =",ypixels)
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)
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)
print("Function GetAcquisitionTimings returned",ret,"exposure =",fminExposure,"accumulate =",fAccumulate,"kinetic =",fKinetic)

(ret) = sdkObject.PrepareAcquisition()
# print("Function PrepareAcquisition returned",ret)
print("Function PrepareAcquisition returned",ret)

#Perform Acquisition
(ret) = sdkObject.StartAcquisition()
# print("Function StartAcquisition returned",ret)
print("Function StartAcquisition returned",ret)

(ret) = sdkObject.WaitForAcquisition()
# print("Function WaitForAcquisition returned",ret)
print("Function WaitForAcquisition returned",ret)

imageSize = xpixels*ypixels
(ret, fullFrameBuffer) = sdkObject.GetMostRecentImage(imageSize)
# print("Function GetMostRecentImage returned",ret,"first pixel =",fullFrameBuffer[0],"size =",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
Expand Down
2 changes: 1 addition & 1 deletion andor_repo/andor/andor_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_last_image(self):

def plot_image(self,image=None):
if type(image) == type(None):
image = self.last_image()
image = self.get_last_image()

plt.imshow(image)
plt.show(block=True)
Expand Down

0 comments on commit 8fcd3f2

Please sign in to comment.