Created
February 16, 2016 15:04
-
-
Save habi/ad03e1d48605ef03c759 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
GetCurrentImage.py | David Haberthür <david.haberthuer@psi.ch> | |
Minimal script to get current camera image from EPICS and display it | |
""" | |
# Import necessary modules | |
from epicsPV import epicsPV | |
import numpy | |
import matplotlib.pyplot as plt | |
# Initialize EPICS channels. The channel names have been found in | |
# /import/work/sls/java/ImageJ/plugins/EPICS_ccdconnection/EPICS_CC_Viewer.java | |
chImage = epicsPV('X02DA-CCDCAM:FPICTURE') | |
chImageWidth = epicsPV('X02DA-CCDCAM:WIDTH') | |
chImageHeight = epicsPV('X02DA-CCDCAM:HEIGHT') | |
# Read image size and put the values into a list | |
ImageSize = [int(chImageHeight.getw()), int(chImageWidth.getw())] | |
# Read the EPICS image channel. This is a stream of numbers, which we put into | |
# an array and reshape this array to the image size. The image values should | |
# then be unsigned integers (0 to 65535), we thus convert the array to 'uint16' | |
Image = numpy.asarray(chImage.getw()).reshape(ImageSize).astype('uint16') | |
plt.imshow(Image, cmap='gray', interpolation='nearest') | |
plt.show() |
@simon: I absolutely agree. My pep8
only complains about "W292 no newline at end of file" in this case...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a side mark, when coding python you should try to somehow stick with https://www.python.org/dev/peps/pep-0008/