-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
|
||
### Section 1: Imports ### | ||
|
||
import sys, os | ||
#library_path = str(r'C:/Users/hoodl/anaconda3/envs/default/Lib/site-packages/pyAndorSDK2/libs') | ||
#sys.path.append(library_path) | ||
from pyAndorSDK2 import atmcd | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import time | ||
|
||
cam = atmcd(r'C:/Users/hoodl/anaconda3/envs/default/Lib/site-packages/pyAndorSDK2/libs') #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(0) # 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 | ||
plt.savefig("C:/Users/hoodl/Desktop/img.jpeg") | ||
|
||
|
||
# Clean up | ||
|
||
cam.CancelWait() # Cancels WaitForAcquisition | ||
cam.AbortAcquisition() # Cancels StartAcquisition | ||
cam.StartAcquisition() # Restarts StartAcquisition | ||
cam.ShutDown() | ||
|
||
if ret == 20002: | ||
print("Script ran correctly...") | ||
else: | ||
print("Script failed...") |