ProSEM In Action

Scripts - Reference

Summary:

Basics of Scripts, and reference details for the ProSEM classes and functions available in scripts, as well as the common libraries that are included with the ProSEM Python instance.

Included Libraries

In addition to the Python Standard Library,  ProSEM also includes several useful libraries.
(Links open documentation pages for each library in a new browser window.)

Library Name

Description

dateutil

Extended parsing and processing of date and time strings
matplotlib &  mpl_toolkits Draw many types of plots, with extensive controls & options
numpy Numerical processing library
PIL (Python Imaging Library) Image processing library
wx

GUI widgets toolkit, for dialogs for user input in scripts

xlsxwriter For writing Excel format files in the .xlsx format

xlwt

For writing older format Excel files in the .xls file format

Metrology Classes

Measurements must be an instance of one of these classes:  

  • GMetrologyLinesSpaces
  • GMetrologyCircle
  • GMetrologyEllipse
  • GMetrologyRectangle
  • GMetrologyTriangle
  • GMetrologyShape
  • GMetrologySingleEdge
  • GMetrologyMultiEdge

The Python isinstanceof(object,type) function can be used to test for an object type.  Example:

Example to test if item is a Lines&Spaces measurement:    if (isinstance(item,GMetrologyLinesSpaces)):

 

Accessing Measurement Data, Properties and Functions

When writing scripts for ProSEM, context is key; specifically, all measurement data in ProSEM is stored in a hierarchy, and thus must be accessed within that hierarchy.

ProSEM Project  -->  Image(s)   -->   Group(s)  -->  Measurement(s)

Data Hierarchy Diagram

Items can be accessed by index, starting from 0.  Some examples:

prosem[0]    the first image in a project
prosem[2][1]    the second group in the third image in the project
prosem[1][0][4]   the fifth measurement in the first group in the second image

so any attribute of an item is available:

prosem.base    C:\Users\me\Documents\

prosem[0].file     C:\Users\me\Documents\AB0223.tif         full path of the first image in the project
prosem[0].label    AB0223                                                    the label of the first image in ProSEM (filename modified as needed so that it can be used as a property name.

prosem[1][2].label    Rectangles           the name of the third group in the second image in this project

 

If it is necessary to find the index of an object by a property value, this code is useful:

imageName = 'PhotXtal_1'    # find the index of the image with this name
context = prosem            # by looking in the project
index = next((i for i, item in enumerate(context) if item.label == imageName),ValueError)
if (index == ValueError):
    print('Error: item label not found in project.')
else:
    ...
 

Or to find the index of the group named 'Circles & Ellipses' in an image:

context = prosem[2]                   # search in the third image in the project
groupName = 'Circles & Ellipses'      # for the index of the group of Circles & Ellipses
index = next((i for i, item in enumerate(context) if item.label == groupName),ValueError)

 
print(prosem[2][index][0].MajorDiameter)
251.548

Note that in both examples, it is important to check that the index is valid, that is, that the item sought actually exists, by checking that the return is not ValueError.

Project Properties, Functions, and Methods

Examples here assume a ProSEM project, ie a GProSEM object is instanced with the name prosem

Name Kind Description Example
Example Result
Notes
len Function Count of images in the project

len(prosem)

3

There are three images in this project

file Attribute Full path of the ProSEM project file

prosem.file

C:\Users\me\Documents\Example.iab

The full path of the project file.  Within a script called from interactive ProSEM, this is the temporary project passed to ProSEM, not the project open in the interactive ProSEM instance.
base Attribute The directory where the currently loaded project resides

prosem.base

C:\Users\me\Documents\

Similar to file (above), but only the path, without the project filename,
MeasurementUnit Attribute User units of the current project, either 'nm' or 'um'

prosem.MeasurementUnit

nm

Possible values are:
nm (nanometers)
um (microns) (note this is a u character, not a Greek mu character)

version

Attribute Version number of ProSEM

prosem.version

v2.8.3

 

load_project(path)

Method Loads a project from a file

prosem.load_project("/home/dir/name.iab")

Loads this project into the ProSEM scripting environment

This replaces an existing project in the scripting environment without warning. If, at script conclusion, this is passed back to the interactive ProSEM session, then the project that was open in the interactive session prior to the script call will be replaced as well.

save_project(path=None)

Method Save the project to a file

prosem.save_project()

Saves the project in the ProSEM scripting environment to the specified file,

If no filepath/filename is given, the saved project is updates the project file that was loaded into the ProSEM scripting environment

add_image(path)

Method Add an image file to the current project, or create a new project containing just one image.

prosem.add_image("/home/dir/file.tif")

Loads this iamge into the project in the ProSEM scripting environment

 

add_folder(path)

Method Add a folder of images to the current project, or create a new project containing images from a folder.

prosem.add_folder("/home/dir/subdir/")

Load images in the specified folder into the project in the ProSEM scripting environment

 

load_recipe(path)

Method Load a recipe from a file.

prosem.load_recipe("/home/dir/example.mpr")

Loads the recipe into the project in the ProSEM scripting environment

 

save_recipe(path)

Method Save the current recipe to a file.

prosem.save_recipe("/home/dir/another.mpr")

Saves the recipe currently in the ProSEM scripting environment to the specified file.

Silently overwrites an existing file with the same path/name

selection

Attribute Object selected in the project Images Panel

type(prosem.selection)

ProSEMpy.GImage object

prosem.selection.label

'MyFilename_21'

The object that was selected at the time the script was called. Could get an Image, a Group, or a stored Measurement

result_table_names

Attribute A list of all Result Tables in the project

prosem.result_table_names

['Lines & Spaces', 'Shapes', 'Triangles']

Result Tables only exist in a project if there are stored objects of that feature type

group_table_names

Attribute A list of all Group Tables in the project

prosem.group_table_names

['Lines & Spaces', 'Circles & Ellipses']

Group Tables only exist in a project if there are Gratings or Arrays of object of a specified data type.  In this example, the project has both Line/Space Gratings and array of Circles/Ellipses

summary_table_names

Attribute A list of all Summary Tables in a project

prosem.summary_table_names

['My Example Summary']

Summary Tables only exist if they have been created in a project

result_table(name)

Attribute The full contents of the specified Result Table

prosem.result_table("Circles & Ellipses")


[['Image', 'Group ID', 'Measurement ID', 'Validation', 'Center X[nm]', 'Center Y[nm]', 'Major Axis Direction[deg]', 'Major Diameter[nm]', ... ], ['Q3__Array_Hex', 'Group_1', 'M_1', 'Success', '495.7', '217.7', '0.00', '256.3',  ... ]]

Returns a list of lists, where each subordinate list has the contents of each row in the Result Table, with the first list being the data column headers for that table.

group_table(name)

Attribute The full contents of the specified Group Table

prosem.group_table("Circles & Ellipses")

[['Image', 'Group ID', 'Col Vector X[nm]', 'Col Vector Y[nm]', 'Row Vector X[nm]', 'Row Vector Y[nm]', 'Radial Jitter[nm]', 'Col Jitter[nm]', 'Row Jitter[nm]', ... ], ['Q3__Array_Hex', 'Group_1', '452.9', '-2.8', '218.5', '390.0', '1.8', '1.5', '1.5', '6', ...]]

Returns a list of lists, where each subordinate list has the contents of each row in the Group Table, with the first list being the data column headers for that table.

summary_table(name)

Attribute The full contents of the specified Summary Table


prosem.summary_table(prosem.summary_table_names[0])

[['Image', 'N', 'Mean of CD Mean[nm]', 'StdDev of CD Mean[nm]'], ['A__Metal_Lines', '3', '239.9', '192.5'], ['C__Negative_Resist_Nanoscale', '3', '40.7', '0.5'], ['F__Grating_Etched_In_InP_238nm_period', '12', '112.0', '2.3']]

 

Returns a list of lists, where each subordinate list has the contents of each row in the Summary Table, with the first list being the data column headers for that table.

 

 

Image Properties, Functions, and Methods

Examples assume: prosem is a GProSEM object, and image is a GImage object within that project.

Name Kind Description Example
Example Result
Notes
len Function Count of Groups in the image

len(prosem[0])  or len(image)

1

The image has one group of measurements.

CountX
CountY
Attribute Number of pixels in the image in X or Y

prosem[0].CountX  or image.CountY

1280.0

Return value is type float
PixelSize Writable Attribute The pixel size of the image, in user units

prosem[0].PixelSize  or image.PixelSize

1.325

prosem[1].PixelSize=3.14159

The pixel size of the second image in the project is set to 3.14159 user units

The MeasurementUnit is a property of the project, described above.

This is a writable attribute, so the pixel size of an image can be changed by assignment.

Rotation Attribute Rotation of the image

prosem[0].Rotation

7.0

Normally 0; is otherwise if the image has been rotated using the rotate method

SizeX
SizeY

Attribute The dimensions of the SEM image, in user units.  

prosem[0].SizeY  or image.SizeX

3996.875

This is computed for the total image, if a portion of the image is a data bar or border, that space will be included in this value, so the actual displayed image area may be less that this Size

label

Attribute The Name of the image file in ProSEM

prosem[0].label

My_Image_Name

This is set to the filename of the image, but with Python special characters replaced with underscores, so that this can be used as a property name.  This label can also be changed in ProSEM Images panel, so it is not necessarily the name of the image file.

file Attribute The full file path and filename of the image file

prosem[1].file   or  image.file

"/home/direc/imageFileName.tif"

Functions in the standard python OS.path library can be very helpful to parse this, for example to extract the filename and extension:
name,ext = os.path.splitext(os.path.split(image.file)[1])

length

Attribute Count of the number of groups in the image

prosem[0].length  or   image.length

2.0

This property is a float type

metadata Attribute A Python dictionary holding SEM metadata for the image, if it exists

len(image.metadata)

33

image.metadata.keys()

['MODE','SCALE','MAG','STAGEX','STAGEY']

image.metadata['MAG']

'100000'

Metadata stored in or with SEM images depends completely on the SEM tool vendor and model.

The first example uses the len() function to return how many metadata items have been read from the image.

The second example uses the keys() method to return a list of the names of the metadata items available for this image.

The third example returns the value of the metadata item named "MAG".

rotate(angle, copy)

Method Rotates image by the given angle

image.rotate(45,copy=0)

Rotates the image by 45 degrees, modifying the image in-place in ProSEM, not creating a copy.

The modified image is only within ProSEM; the image file is not modified by ProSEM.
Angle is in degrees.

export_item(item, path, width, height, scale)

Method Saves the measured image to a file, with overlays as displayed on the screen.

prosem.export_item("/home/dir/mimage.png")

Silently overwrites an existing file with the same path/name.
Optional parameters: a single named parameter: "width=..." or "height=..." or "scale=...".  If none, exported image is same resolution as original file.

 

Group Properties, Functions, and Methods

Examples assume: prosem is a GProSEM object, image is a GImage object within that project, and group is a GGroup object within that image.

The properties available depend on the type of group, a generic group of measurements, a grating (a group of adjacent line/space measurements), or an array (a group of 2-dimensional objects in a 2-dimensional layout).

Generic Groups

Name Kind Description Example
Example Result
Notes
len Function Count of measurements in the group

len(prosem[0][1])  or len(group)

4

The group has four measurements.  Return value is an integer

GroupID

or

label

Attribute The name of the group

prosem[1][1].label
'Lines & Spaces'

image[0].GroupID
'Group_1'

Return value is a string.
The two attributes return the same answer.

IsArray Attribute Is this group an Array?

prosem[1][1].IsArray == True
False

group.IsArray == True
True

Test if the objects in this group have an array fit. If True, array fit parameters are available; see below.

IsGrating Attribute Is this group a Grating?

prosem[1][1].IsGrating == True
True

group.IsGrating == True
False

Test if the objects in this group have a grating fit. If True, grating fit parameters are available; see below.

EdgeProfileFitQuality

Attribute The average of the Edge Fit Quality score for measurements in this group

group1.EdgeProfileFitQuality

0.8794

The return value is a float between 0 and 1.0

FeatureFitQuality

Attribute The average of the Feature Fit Quality score for measurements in this group

prosem[3][1].FeatureFitQuality

0.8998

The return value is a float between 0 and 1.0

image Attribute The GImage object which is the parent of this group

type(group1.image)
<class 'ProSEMpy.GImage'>

group2.image.label
'X2_Grat_0293'

 

length

Attribute Count of the number of measurements in this group

prosem[0][1].length  or   group.length

8.0

This property is a float type

export_image(path, width, height, scale)

Method Saves the measured image to a file, with overlays as displayed on the screen.

prosem[1][3].export_image
("/home/dir/expimg.png")

 

Silently overwrites an existing file with the same path/name.
Optional parameters define width and height or scale factor from original

 

Grating Groups

Name Kind Description Example
Example Result
Notes
GratingPitchMean
GratingPitchStdDev
GratingPitchMin
GratingPitchMax
Attribute Statistics for Pitch measurements

group1.GratingPitchMean
221.6272

group1.GratingPitchStdDev
4.2867

Grating pitch is measured from each rising edge to the adjacent rising edge, and each falling edge to the adjacent falling edge

GratingLineMean
GratingLineStdDev
GratingLineMin
GratingLineMax

Attribute Statistics for Line measurements

group1.GratingLineMin
108.6492

group1.GratingLineMax
124.6146

 

GratingTrenchMean
GratingTrenchStdDev
GratingTrenchMin
GratingTrenchMax

Attribute Statistics for Line measurements

prosem[0][1].length  or   group.length

8.0

This property is a float type

 

Array Groups

Name Kind Description Example
Example Result
Notes

ColVectorX
ColVectorY
RowVectorX
RowVectorY

Attribute Vector Dimensions of a unit cell of the fitted array

prosem[2][0].ColVectorX
468.3544

group3.ColVectorY
-0.1692

Grating pitch is measured from each rising edge to the adjacent rising edge, and each falling edge to the adjacent falling edge

ColJitter
RowJitter
RadialJitter

Attribute Mean Jitter for elements in the group

group1.GratingLineMin
108.6492

group1.GratingLineMax
124.6146

Jitter is the distance of the object center from the fitted array point, given as components along the row and column vectors, as well as the radial distance from the fitted array point

MeanofArea
StdDevofArea
MeanofFittedArea
StdDevofFittedArea

Attribute Statistics for the enclosed area and fitted area for the shapes in the array

group.MeanofFittedArea
80024.7877
group2.StdDevofFittedArea
995.9376

 

MeanofBBoxHeight
MeanofBBoxWidth

Attribute Average dimensions of the measurement bounding box (extreme points)

group.MeanofBBoxHeight
323.2241

The shape BBox encloses all edge points in the measured shape, so these dimensions reveal the most outlying points in each dimension

MissingFeatures

 

   

 

 

MeanofMajorDiameter
StdDevofMajorDiameter
MeanofMinorDiameter
StdDevofMinorDiameter
MeanofAspectRatio
StdDevofAspectRatio
MeanofMajorAxisDirection
StdDevofMajorAxisDirection

Attribute

Arrays of Circles and Ellipses Only

Statistics for measured circles and ellipses in the array

prosem[2][0].MeanofMajorDiameter
324.5167

group.StdDevofMinorDiameter
2.3179

 

MeanofHeight
StdDevofHeight
MeanofWidth
StdDevofWidth
MeanofRotation
StdDevofRotation

Attribute

Arrays of Rectangles Only

Statistics for fitted rectangles in the array

group.MeanofHeight
85.3946

 

MeanofEdgeAngle1 MeanofEdgeAngle2 MeanofEdgeAngle3 MeanofEdgeLength1 MeanofEdgeLength2 MeanofEdgeLength3 MeanofInteriorAngle1 MeanofInteriorAngle2 MeanofInteriorAngle3 StdDevofEdgeAngle1 StdDevofEdgeAngle2 StdDevofEdgeAngle3 StdDevofEdgeLength1 StdDevofEdgeLength2 StdDevofEdgeLength3 StdDevofInteriorAngle1 StdDevofInteriorAngle2 StdDevofInteriorAngle3

Attribute

Arrays of Triangles Only

Statistics for fitted triangles in the array

group.MeanofEdgeAngle2
120.748

group.MeanofEdgeLength1
127.5192

 

 

Measurement Properties, Functions, and Methods

Examples assume: prosem is a GProSEM object, image is a GImage object within that project, group is a GGroup object within that image, and meas is a stored measurement object within that group of one of the GMetrology... classes. (list above.)

The properties available depend on the object type of measurement.

Generic Measurement Properties & Methods

These properties and methods apply to all of the individual Feature Types described below.

Name Kind Description Example
Example Result
Notes

group

Attribute The group object this measurement belongs to

prosem[0][0][0].group
<ProSEMpy.GGroup object at 0x0001C10>

prosem[0][0][0].group.label
'Lines & Spaces'

Return value is a GGroup object.

image Attribute The image object this measurement belongs to

prosem[1][1].IsArray == True
False

group.IsArray == True
True

Test if the objects in this group have an array fit. If True, array fit parameters are available; see below.

validationstate Writable Attribute Validation Status, one of: <br> Validated, Success, Uncertain, OutOfSpec, Failure

prosem[0][0][0].validationstate
'Validated'

meas.validationstate = 'OutOfSpec'

meas.validationstate = 's'

Return value is a string.  When setting a value, the assignment is permissive; not case sensitive and can be shortened to the least ambiguous string, for example 's' --> 'Success'.

outline

Method Access to all edge points in the measurement

len(prosem[0][1][0].outline)
565

meas.outline(0)[53]
GPoint(x=20893.8461, y=28906.2499)

meas.outline(0)[30][0]
20912.0801

For Line/Space measurements, a required parameter specifies which edge, 0 or 1.  The Outline object can be subscripted to access an individual edge point, indexed from 0 to len-1. The Point object can be subscripted to access the X or Y coordinates, indexed 0 or 1, respectively.

label

Attribute The name of the measurement ProSEM

prosem[0][3][3].label

'M_12'

 

export_image(path, width, height, scale)

Method Saves an image of the measurement ROI to a file, with overlays as displayed on the screen.

prosem.export_image("/home/dir/another.mpr")

 

Silently overwrites an existing file with the same path/name.
Optional parameters specify size or scaling factor; otherwise defaults to the size of the ROI

distance_fitted_feature(a,b)

Method Compute the shortest distance between the fitted features of two measurements.

meas.distance_fitted_feature(meas1,meas2)
8697.2506

Returns the nearest distance (in user units) between the fittted features of the two measurements given.

distance_nearest_points(a,b)

Method Compute the distance between the closest points detected in two measurements.

meas.distance_nearest_points(line1,prosem[0][4][0])
26911.3008

Returns the nearest distance (in user units) between the closest measurement points of the two measurements given.

compute_cd(a, b, output)

 

Method Compute the distance between two line measurements by averaging over line to point distances.

 

Optional 'output' argument determines the statistical property to return: "mean" (the default), "median", "min", "max", "range", "stddev", or "rms".

Input Parameters    

 

 

LLX LLY

URX URY

Attribute Extents of the ROI containing this measurement.

meas1.LLX
15805.8011

prosem[0][2][1].URX
27667.9224

X and Y coordinates of the Lower Left (LL) and Upper Right (UR) corners of the Region of Interest

AutoContrast Attribute Now obsolete

 

If autocontrast

FilterType
GaussX
GaussY
Attribute Image Pre-processing Filter Used, and parameters

Filter Type values include: No Filter, Gaussian, Nagao-Matsuyama, Sym-Nearest-Neighbor, Median.

The GaussX and GaussY properties only apply when the FilterType=Gaussian; for other types, the value is 'N.A.'

LineScanAvg Attribute Number of scan lines averaged during image preprocessing

Default is 0

 

EdgeMode Attribute Edge Finding method applied for this measurement

All Feature Types: Automatic, Canny, and Slope Analysis

Circle, Line/Space: Manual

2-D Shapes: Correlation

 

FineMode
CdPos
Attribute The edge fitting method used and the signal location on the edge used to define the edge point

The available values for fit mode depend on the chosen edge position.

Top: Sigmoidal Fit, Parabolic Peak

Mid: Sigmoidal Fit, Max Slope

Bottom: Sigmoidal Fit, Regression To Baseline

When Position is set to Custom Signal Level, the CdPos property as the signal level percentage

FineMode = Threshold also used the defined CdPos value for the threshold

 

TwoPassMeasurement Attribute  

 

 

 

Feature Type: Line/Space

       

CDMean
CDMax
CDMin
CDMedian

CDSampleCount
CDStdDev

CD Measurement results    

CenterX
CenterY

E0Angle
E0CenterX
E0CenterY
E1Angle
E1CenterX
E1CenterY

Geometric data about each edge in the Line/Trench feature    

EdgeProfileFitQuality
E0EdgeProfileFitQuality
E1EdgeProfileFitQuality

Edge fitting metrics, for the feature, and for each edge    

FeatureFitQuality
E0FeatureFitQuality
E1FeatureFitQuality

E0FitErrorMean
E0FitErrorStdDev
E1FitErrorMean
E1FitErrorStdDev

Feature (Line) fitting metrics, for the feature, and for each edge    

E0LER3StdDev
E0LERCorrelationLengthXi
E0LERRoughnessExponentAlpha

E1LER3StdDev
E1LERCorrelationLengthXi
E1LERRoughnessExponentAlpha

Line Edge Roughness metrics for each edge in the Line/Trench feature    
LWR3StdDev
LWRCorrelationLengthXi
LWRRoughnessExponentAlpha
Line Width Roughness metrics for the Line/Trench    

FilterType
LineScanAvg
GaussX
GaussY

Image Preprocessing Parameters    

CdPos
EdgeMode
FineMode
TwoPassMeasurement

Feature Fit Parameters    

 

Feature Type: Circle/Ellipse

       

Major Diameter
Minor Diameter

Major Axis Direction

AspectRatio

Circle/Ellipse Measurement results

For a circle type, the Major and Minor axes are always equal

   

Area

Fitted Area

The area bounded by the traced shape, and by the fitted circle or ellipse shape    

CenterX
CenterY

Center of the fitted circle/ellipse, in user units (nm or um), with the origin at the image lower-left corner    

EdgeProfileFitQuality

Edge fitting metric    

FeatureFitQuality

Feature (Circle/Ellipse) fitting metrics    

FilterType
LineScanAvg
GaussX
GaussY

Image Preprocessing Parameters    

CdPos
EdgeMode
FineMode
TwoPassMeasurement

Feature Fit Parameters    

 

Feature Type: Rectangle

       

Height
Width
Rotation

AspectRatio

Rectangle Measurement results

   

Area

Fitted Area

The area bounded by the traced shape, and by the fitted rectangle    

CenterX
CenterY

Center of the fitted rectangle, in user units (nm or um), with the origin at the image lower-left corner    

EdgeProfileFitQuality

Edge fitting metric    

FeatureFitQuality

Feature (Circle/Ellipse) fitting metrics    

FilterType
LineScanAvg
GaussX
GaussY

Image Preprocessing Parameters    

CdPos
EdgeMode
FineMode
TwoPassMeasurement

Feature Fit Parameters    

 

Feature Type: Triangle

       

EdgeLength1
EdgeLength2
EdgeLength3

Triangle Measurement results:
The edge of the each of the three sides of the fitted triangle

   

InteriorAngle1
InteriorAngle2
InteriorAngle3

Triangle Measurement results:
The interior angle of the each of the three sides of the fitted triangle, in degrees
   

EdgeAngle1
EdgeAngle2
EdgeAngle3

Triangle Measurement results:
The angle of each of the three sides of the fitted triangle, with respect to the horizontal axis of the image frame
   

Area

Fitted Area

The area bounded by the traced shape, and by the fitted triangle    

CenterX
CenterY

Center of the fitted triangle, in user units (nm or um), with the origin at the image lower-left corner    

EdgeProfileFitQuality

Edge fitting metric    

FeatureFitQuality

Feature (Circle/Ellipse) fitting metrics    

FilterType
LineScanAvg
GaussX
GaussY

Image Preprocessing Parameters    

CdPos
EdgeMode
FineMode
TwoPassMeasurement

Feature Fit Parameters    

 

Feature Type: Single Edge

       

Angle

The angle of the fitted line of the Single Edge,    

CenterX
CenterY

Center of the fitted single-line, in user units (nm or um), with the origin at the image lower-left corner    
LER3StdDev
LERCorrelationLengthXi
LERRoughnessExponentAlpha
The Line Edge Roughness measurement results for the single edge    

EdgeProfileFitQuality

Edge fitting metric    

FeatureFitQuality

Feature (Single Line) fitting metrics    

FilterType
LineScanAvg
GaussX
GaussY

Image Preprocessing Parameters    

CdPos
EdgeMode
FineMode
TwoPassMeasurement

Feature Fit Parameters