Moving through a Mesh

The following script demonstrates how the progress can be monitored during a mesh scan. Figure 4.3 is consecutively filled-up with plus signs.

#!/usr/bin/env python
”'
the meshScan class displays the current position in a mesh scan
”'
import Spectra
import time


class scanMesh():
    def __init__( self, startX, stopX, deltaX, startY, stopY, deltaY):
        self.startX = startX
        self.stopX = stopX
        self.deltaX = deltaX
        self.startY = startY
        self.stopY = stopY
        self.deltaY = deltaY

        self.npX = (self.stopX - self.startX)/deltaX + 1
        self.npY = (self.stopY - self.startY)/deltaY + 1

        self.mesh = Spectra.SCAN( name = "mesh", 
                                  start = self.startX, stop = self.stopX,
                                  np = self.npX*self.npY, at = "(1,1,1)",
                                  title = 'Mesh', 
                                  colour = 2, xlabel = 'x', ylabel = 'y', date = True)

        Spectra.gra_command( "set mesh/x_min=%g/x_max=%g/y_min=%g/y_max=%g" % \
                             ( self.startX - self.deltaX, self.stopX + self.deltaX, 
                               self.startY - self.deltaY, self.stopY + self.deltaY))
        Spectra.gra_command( "set mesh/prim=1/type=2")
        Spectra.gra_command( "autoscale/window")

    def setX( self, index, x):
        self.mesh.setX( index, x)
    def setY( self, index, y):
        self.mesh.setY( index, y)
    def display( self):
        self.mesh.display()

def main():
    startX = 0.
    stopX = 1
    deltaX = 0.1
    startY = 0.
    stopY = 2.
    deltaY = 0.1

    o = scanMesh( startX, stopX, deltaX, startY, stopY, deltaY)

    x = startX
    y = startY
    count = 0
    while( y <= stopY):
        while( x <= stopX):
            o.setX( count, x)
            o.setY( count, y)
            o.display()
            count += 1
            x += deltaX
            time.sleep(0.1)
        y += deltaY
        x = startX

    (sts, result) = Spectra.gra_yesno( "Enter Spectra")
    if result == 1:
        Spectra.gra_input()

if __name__ == "__main__":
    main()

Figure 4.2: A Mesh Scan
Image meshScan