JEOL Scanning Electron Microscopy
This module contains functions for Scanning Electron Microscopy (SEM) data. There are two main functions: sem_base_plot and sem_spectra_peak_labeler.
sem_base_plotis designed to handle JEOL SEM .EMSA files and generate a clean base plot showing counts at each energy level with no labels.sem_spectra_peak_labeleralso handles JEOL SEM .EMSA files, but instead of a clean base plot, it creates a plot with expected element peaks labeled. All other peaks are labeled with possible candidate elements.
get_element_peaks is a helper function that extracts peak data for a given element from a pandas DataFrame. These functions are specifically written for JEOL files and may not work correctly with SEM data from other sources.
SEM Base Plot
The sem_base_plot function takes a JEOL SEM .EMSA file as input, extracts the data, and creates a plot of counts versus energy level, which is saved as a .png file. Here’s an example of how to use the function:
from project_chameleon.jeol_sem_converter import sem_base_plot
sem_base_plot('jeol_sem.EMSA', 'jeol_sem.png', color='blue', label='test_plot')
In this example: - ‘jeol_sem.EMSA’ is the raw JEOL SEM file containing the energy count data. - ‘jeol_sem.png’ is the image file where the plot will be saved. - color=’blue’ is an optional parameter that changes the plot color (defaults to black if not specified). - label=’test_plot’ is an optional title for the plot (defaults to the file name if not provided).
This function does not extract any metadata; it only creates a plot of the data.
SEM Spectra Peak Labeler
The sem_spectra_peak_labeler function also takes a JEOL SEM .EMSA file as input, extracts the data, and creates a plot of counts versus energy level. It then labels expected peaks and identifies possible elements for unexpected peaks. The final labeled plot is saved as a .png file. Here’s how to use the function:
from project_chameleon.jeol_sem_converter import sem_spectra_peak_labeler
sem_spectra_peak_labeler('jeol_sem.EMSA', 'jeol_sem.png', elements_in_plot='H,He,Li')
In this example: - ‘jeol_sem.EMSA’ is the input SEM file. - ‘jeol_sem.png’ is the output plot file. - elements_in_plot=’H,He,Li’ is an optional comma-separated string of expected elements. All listed elements will be labeled in the plot, whether or not a peak is present at those energies. Peaks not matching any of the specified elements will be labeled with possible element candidates.
This function does not extract any metadata; it only creates a labeled plot of the data.
Below is more information on the main functions, as well as some helper functions:
- jeol_sem_converter.get_element_peaks(element, df)
get_element_peaks()is a helper function for the SEM plotting functions. This function extracts the energy values of the peak of the element that was input.- Args:
elementshould be an element from the periodic table.dfshould be a pandas data frame containing periodic elements and their energy peaks.- Returns:
‘’result’’ is the integer values of the energy peaks. ‘’element_name’’ is the name of the element input.
- Exception:
None
- jeol_sem_converter.sem_base_plot(file_name, output_file, color=None, label=None)
sem_base_plot()is a function that converts JEOL SEM .EMSA files into a plot. This plot displays the number of counts at each energy level.- Args:
file_nameshould be a .EMSA file.output_fileshould be a string which will be the name of the output .png file.- Returns:
this function does not return anything. The output is saved as an image file.
- Exception:
file_name must be an .EMSA file. file_name must be a file. output_file must end with ‘.png’.
- jeol_sem_converter.sem_spectra_peak_labeler(input_file, output_file, elements_in_plot='')
sem_spectra_peak_labeler()is a function that converts JEOL SEM .EMSA files into a plot. This plot displays the number of counts at each energy level, and labels the peaks with the expected elements.- Args:
file_nameshould be a .EMSA file.output_fileshould be a string which will be the name of the output .png file.elements_in_plotis a comma separated string containing the elements that are expected to be in the plot.- Returns:
this function does not return anything. The output is saved as an image file.
- Exception:
file_name must be an .EMSA file. file_name must be a file. output_file must end with ‘.png’.