2-D Scans: many_scans.pl

Now and then the need occurs that a series of scans has to be executed while some experimental parameter is varied. Table 15.8 shows a script that does such a thing.


Table 15.12: Example: 2-D Scans: Many_scans.gra
 
#!/usr/local/bin/perl -w
#
# This Perl script gives an example of a 2D scan.
# The inner loop is a dummy scan which is executed
# at different energies. 
#
use Spectra;
#
#
#
sub print_usage
{
    print "\033[2J\033[5;1f";
    print " Usage: \n";
    print " \n";
    print "   SPECTRA> perl many_scans.pl sname st\n";
    print " \n";
    print "     sname - scan name prefix \n";
    print "     st    - sample time \n";
    print " \n";
    print " \n";
    Wait();
}
my ($sname, $st) = @ARGV;

if( !defined( $st))
{
    print_usage();
    goto finish;
}
#
# the regions and the step widths 
#
my @region = ( 8950, 8970, 8990, 9100);
my @delta =  (    5,    1,   10,    0);
#
# loop over the regions, delta == 0 indicates that we are done
#
for( $i=0; $delta[$i]; $i++)
{
    #
    # loop over the energy inside a region
    #
    for( my $e=$region[$i]; $e < $region[$i+1]; $e += $delta[$i])
    {
	if( !Energy( $e))
	{
	    print "Failed to set the energy to $e \n";
	    Wait();
	    goto finish;
	}
	#
	# the dummy scan
	# 
	if( !Scan( device => "dummy", 
		   start => "0", 
		   stop => "10", 
		   delta => "1", 
		   sample_time => "$st", 
		   scan_name => "${sname}_at_${e}"))
	{
	    print "Failed to execute scan \n";
	    Wait();
	    goto finish;
	}
	#
	# delete GQEs and compress
	#
	Cleanup();
    }
}

finish: