Total Resolution LLC

High Resolution Electron Microscopy Data Analysis and Simulation Software

Scripting Language Module

The scripting language module for Tempas allows you to extend the functionality of the software by controlling the simulation or processing of images in an automated way. This powerful feature enables the creation of new algorithms for testing or implementing new ideas.

The scripting language for Tempas is familiar to those who have experience with C, C++, or the scripting language for Digital Micrograph (copyright Gatan Inc.). It includes built-in functions to run many DM scripts with few or no modifications.

To download the current Script Language Reference Manual, click HERE

 

Syntax Coloring has been added for easier readability and word completion adds to ease of use

 

Examples: Digital Micrograph compatible scripts

Example 1:
Image test = newimage(“test”,512,512)      // Creates a float image  of size 512 by 512
test = exp(-iradius*iradius/100)      // Fills the image with a gaussian with sigma = 10
display(test)      // Displays the image

Example 1: Alternate Syntax - Non DM Compatible
Image test(512,512,exp(-iradius**2/100))     
test.show()       // Displays the image

Example 2:
Image test = newimage(“test”,512,512)      // Creates a float image  of size 512 by 512
test = sin(2*pi()*icol/8)+sin(2*pi()*irow/12)
                              // Fills the image with cross-fringes
                              // of period 8 and 12 pixels in x , y
display(test)      // Displays the image

Example 2: Alternate Syntax - Non DM Compatible
Image test(512,512,sin(2*pi*icol/8)+sin(2*pi*irow/12))     
test.display()       // Displays the image

Example3:

// Precession Tilt series
// This is summing over the power-spectrum of the exit wave function
// by spinning the beam in a circle. The beam tilt is theta (30 mrad).
// The increment in the azimuthal angle is dphi (6 degrees)
// A table of HKL values for different thicknesses is shown
// For illustration purposes, a precession image is also calculated

number theta = 30 // The tilt angle in mrad
number phi = 0 // Tilt angle (degrees) with respect to a-axis
number dphi = 6 // increments in tilt angle (degrees)

simulation sim = getsimulation() // Get the simulation

// We are making sure that everything has been calculated and is current
sim.calculateall()

Image xw = sim.loadexitwave() // Declare and load the exit wave
Image im = sim.loadimage() // Declare and load the image
Image sumim = im ; sumim = 0 ; // Declare the sum for the images and zero
Image sumps = xw ; sumps = 0 ; // Declare the sum for the powerspectrum
// and zero

Openlogwindow()

for(number thickness = 10; thickness <= 100; thickness += 10) {
    sim.setthickness(thickness)
    number i = 0 // declare and  initialize our counter
    for(phi = 0 ; phi < 360; phi += dphi) { // loop over the azimuthal angle
        sim.settilt(theta,phi) // set the tilt of the specimen
        // this is equivalent to the tilting the beam
        sim.calculateexitwave() // Calculate the new exit wave
        sim.calculateimage() // Calculate the new image
        sumim += sim.loadimage() // Add the image to the sum
        xw = sim.loadexitwave() // Load the exit wave
        xw.fft() // Fourier transform to get the frequency
        // complex coefficients
        xw *= conjugate(xw) // Set the complex PowerSpectrum

        // If we had  used xw.ps() to get the
        // power spectrum we would have had a real
        // image in “real” space
        sumps += xw // Add the powerspectrum to the sum
        i++ // Keep track of the count
        print("phi = "+phi) // Just to know where we are in the loop
    }
    sumim /= i // Divide by the number of terms in the sum

     // Create a rectangular image of size 1024 by 1024 of sampling 0.1 Å (default) 
    Image precessionImage = sim.createimage(sumim,1024)

    precessionImage.setname("Image Precession")
    precessionImage.show() // Show the summed images

    sumps /= i // Divide by the number of terms in the sum
    sumps.sqrt() // To compare with the Scattering factors

    // Create a rectangular image of size 1024 by 1024 out to gMax = 4 1/Å
    // with a convergence angle of 0.2 mrad

    Image precessionPS = sim.createfrequencyimage(sumps,1024,0.2,4)
    precessionPS.setname("Power Spectrum Precession Thickness "+ sim.getthickness())

    precessionPS.show() // Show the summed power spectrum
    sumps.setname("thickness " + sim.getthickness())
    sim.createhkltable(sumps)
}


Contact Us

If you have any questions or inquiries, please feel free to contact us.