Scripting Resources for DigitalMicrograph™ |
PyJEM: Beam Shower | |
Function |
A Python script which configures the microscope into a beam showering condition. |
Version |
version:20220921, v1.0 |
Author |
D. R. G. Mitchell |
Acknowledgements |
- |
Comments |
Beam showering (irradiating the specimen with a high dose of electrons/radiation) is a very effective method at reducing or eliminating beam-induced contamination in STEM specimens. This is discussed in the following paper. There are a range of parameters which need to changed to set up a beam showering condition: multiple apertures, magnification, focus, spot size, detectors, screen, scan mode. Setting these takes time, and of course there is always the possibility of making an error and exposing a detector/screen to a high dose, or even forgetting to open the Beam valve. This script automates configuration of the microscope for beam showering, requiring only a single button click. The actual beam shower setup can be configured through a dialog. However, once set, it should then require little further change. The script includes an option to put up reminders about removing EDS detectors, carrying out Lens Relaxation etc, which is useful for inexperienced users. On FEG microscopes the option to close the FEG beam valve after the beam shower is complete is also provided. This allows users to leave the lab during beam showering, safe in the knowledge that if they are delayed getting back, their specimen will not be completely fried and the FEG is safe. The script also creates a fully customisable Ronchigram mode at the click of a button. Typically after beam showering the microscope will need aligning, in terms of centring the Ronchigram, removing astigmatism/coma and positioning the CLA aperture. Thereafter, the original microscope condition can be restored, again at the click of a button. For inexperienced users, this script will greatly speed up their workflow. Time saving is less of an advantage for experienced users, but the major benefit is consistency and avoiding beam showering with the beam valve closed! You can customise the settings which determine the default settings when the dialog launches, should your preferred beam showering recipe differ from the default setup I have created. The settings used can be changed in the dialog as you use it. However, it is nice not to have reconfigure it every time you launch it. After you launch the script (see below), you can leave it running behind the TEM Centre window. Then, whenever you need to use it, just select it from the Windows Task Bar and away you go. |
System Requirements |
Written in Spyder in Anaconda3. Requires a PyJEM-equipped JEOL microscope. The script can be opened in Spyder and run from there. Alternatively, double clicking on the script will run it in Python. If the downloaded script appears as a generic grey file icon it does not have Python set as the default application to open it. Right click on it and set Python to always open it. Python lives in the C://Anaconda3 folder. When you launch the Beam Shower script by double clicking on it, a Console window will also appear. The script will report diagnostic information in that Console. However, you do need to refer to this window during use. You can minimise the Console, but you must not close it. If you encounter any problems, the Console will tell you which operations were the last to be successfully completed before the script stopped. The script MUST be configured to match the hardware you wish to use it with. It was set up on a JEOL F200. However, even if you have this microscope, your actual hardware configuration may differ to mine. For example you may or may not have optional apertures such as the hard x-ray (HXA) or in gap objective lens aperture (OLA - not to be confused with the HCA) present. The script can be configured by setting the various hardware setup parameters at the start of the script - instructions are provided. If the dialog attempts to configure hardware which you do not have - an error will occur. |
Known Issues |
Many microscope operations, such as retracting a detector, lowering the screen, removing an aperture etc take a finite amount of time. If the script makes a call to the microscope while such an operation is still occurring, an error occurs - the microscope beeps and an error message appears in TEM Centre. Such errors are not fatal, but the offending microscope command will be skipped. To avoid this issue a delay parameter called sleeptime is used to pause the script after each microscope operation in order to give it time to complete. If you encounter errors during use, you should increase the value of sleeptime until they go away. Do this for your typical column setup. You may find that for certain atypical setups - eg having the Faraday Cup (optional) inserted, you need an excessively long sleeptime value. This is because to retract the Faraday Cup, or any other slow aperture, takes a very long time (ca 5s). If you used a 5s sleeptime value, the script would be very sluggish. To avoid this, when using atypical column setups, manually configure the really slow things first, then use the script with the typical sleeptime value. This is my second (recent) major Python scripting project. Having become familiar with PyJEM and Python, I focused on writing this correctly, using Classes and Class Methods. This avoid the plethora of global variables which litter my first scripting effort (ApCon). If you are going to write PyJEM scripts of any length, you should do it this way. This script is provided in good faith. The author provides no warranty as to its fitness for purpose. Users of this script do so entirely at their own risk. The author accepts no responsibility for any losses or damages which may arise from its use. Users are advised to consult with their microscope manager before using PyJEM scripts.
Troubleshooting: Minor Errors: The errors mentioned above, caused by asking the microscope to do something while it is busy, are trivial. The microscope beeps, an error message appears in TEM Centre, the offending command is skipped and everything continues to work as normal - no further action is required.
Major Errors: Step 1: I have not encountered any with this script. However, I have seen them in other scripts and they likely arise from untrapped exceptions (the script encounters an error but the error is not caught and Python hangs). Symptoms will include a beep, but no error message popup. In the error log a cryptic error message may appear. Script interaction with TEM Centre stops - TEM Centre continues to work normally. This can be resolved by right clicking on the TEM icon (bottom right of TEM Centre window) to bring up the Emergency panel. This shows LEDs which indicate error states. None will be lit. Click on Stop Alarm in the bottom right of the Emergency window. Normal operation should resume. Step 2: If the above does not work, then in TEM Centre switch from Scanning to TEM mode and then back again. If scripting was blocked, you might find that the script dialog would not appear. Doing the above STEM to TEM to STEM shuffle causes it to reappear, and normal operation is resumed. Step 3: The above two steps have resolved all the major errors I have encountered. However, had they not, then restarting TEM Centre would have been the last thing to try. |
Supported |
Yes |
Included Files |
Main script file. |
Source Code |
zip archive containing the script. |