Sample code (detector)¶
This page presents a simple sample code using the detector package.
The functions to be introduced are as follows
Get a list of detectors that can be controlled
Get or set a detector information
Image capturing
Prerequisites
TEMCenter is running (in the case of online)
PyJEM version is 1.3.0 (Operation check environment)
0. import¶
[2]:
# Ver.1.3.0
from PyJEM import detector
# from PyJEM.offline import detector ## offline
1. Get usable detector/camera name¶
Gets a list of detector names that can be controlled from detector package.
[2]:
detector.get_attached_detector()
[2]:
['camera', 'STEM Image']
2. Get camera information¶
Enter the camera name for which you want to get information in the argument of detector.Detector().
The camera name can be obtained with 1. Get usable detector/camera name
2.2 Get camera information.¶
[5]:
cam.get_detectorsetting()
[5]:
{'AreaModeImagingArea': {'Height': 256, 'Left': 128, 'Top': 128, 'Width': 256},
'AreaModeImagingAreaMaximum': '2048, 2048',
'AreaModeImagingAreaMinimum': '4, 2',
'CanBinning': False,
'CanGain': True,
'CanOffset': True,
'ExposureTime': [],
'ExposureTimeIndex': 0,
'ExposureTimeIndexMaximum': 4094,
'ExposureTimeIndexMinimum': 0,
'ExposureTimeString': '0.17',
'ExposureTimeValue': 0.16666666666666666,
'FrameRate': [],
'GainIndex': 0,
'GainIndexMaximum': 4095,
'GainIndexMinimum': 0,
'HorizontalLineNo': 1,
'ImagingArea': {'Height': 512, 'Width': 512, 'X': 0, 'Y': 0},
'ImagingAreaMaximum': '1280, 1024',
'ImagingAreaMinimum': '4, 2',
'OffsetIndex': 0,
'OffsetIndexMaximum': 4095,
'OffsetIndexMinimum': 0,
'OutputImageInformation': {'DataBits': 16,
'EffectBits': 16,
'ImageSize': {'Height': 512, 'Width': 512},
'PixelsPerMeter': {'Horizontal': 3401, 'Vertical': 3401}},
'ScanRotation': 0.0,
'SpotPosition': {'X': 0, 'Y': 0},
'SyncMode': 1,
'Version': '1.00',
'frameIntegration': 20,
'frameIntegrationMaximum': 255,
'frameIntegrationMinimum': 1,
'horizontalLineNoMaximum': 512,
'horizontalLineNoMinimum': 1,
'scanMode': 0,
'scanRotationMaximum': 360.0,
'scanRotationMinimum': 0.0,
'scanRotationStep': 0.1,
'spotPositionMaximum': '2047, 2047',
'spotPositionMinimum': '0, 0'}
3. Change gain value.¶
Change the gain value of the camera.
The input value is a decimal number.
You can change other setting information as well.
[5]:
cam.set_gainindex(1234)
[5]:
{'GainIndex': 1234}
4. Capture image with selected camera¶
[8]:
%matplotlib inline
cam.snapshot("jpg",save=True, show=True)