Index: trunk/tools/microtest.pl
===================================================================
--- trunk/tools/microtest.pl	(revision 27438)
+++ trunk/tools/microtest.pl	(revision 27438)
@@ -0,0 +1,61 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+use DBI;
+use constant DB_SOCKET => '/var/run/mysqld/mysqld.sock'; # Socket for mysql
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+use IPC::Cmd 0.36 qw( can_run run );
+use File::Temp qw( tempfile );
+
+my $ppCoord = can_run('ppCoord') or die "Can't find ppCoord";
+
+
+my ($db_host, $db_name, $db_user, $db_pw); # Database details
+my ($label);                               # Label of interest
+my ($verbose);                             # Verbosity?
+
+GetOptions(
+           'dbhost=s' => \$db_host, # Database host name
+           'dbname=s' => \$db_name, # Database name
+           'dbuser=s' => \$db_user, # Database user
+           'dbpass=s' => \$db_pw, # Database p/w
+           'label=s' => \$label, # Label of interest
+           'verbose' => \$verbose, # Verbosity?
+           ) or die "Unable to parse arguments.\n";
+die "Unknown option: @ARGV\n" if @ARGV;
+die "Required options: --dbhost --dbname --dbuser --dbpass --label\n"
+    unless defined $db_host
+    and defined $db_name
+    and defined $db_user
+    and defined $db_pw
+    and defined $label;
+
+# Database connection
+my $db = DBI->connect( "DBI:mysql:database=$db_name;host=$db_host;mysql_socket=" . DB_SOCKET(),
+                       $db_user,
+                       $db_pw,
+                       { RaiseError => 1, AutoCommit => 1 }
+                       ) or die "Unable to connect to database: $DBI::errstr";
+
+# Exposures of interest
+my $exps = $db->selectall_arrayref(
+        "SELECT exp_id, exp_name, magic_id, outroot FROM magicRun JOIN rawExp USING(exp_id) WHERE label = '$label' AND magicRun.state = 'full'",
+        Slice => {}
+        ) or die "Unable to execute SQL: $DBI::errstr";
+
+foreach my $exp (@$exps) {
+    my $id = $exp->{exp_id};    # Exposure identifier
+    my $name = $exp->{exp_name}; # Exposure name
+    my $magic = $exp->{magic_id}; # Magic identifier
+    my $outroot = $exp->{outroot}; # Output root for magic
+
+    my $clusters = "$outroot/$id/$id.mgc.$magic.verify/${id}_clusterPos.txt"; # File with cluster RA,Dec
+    die "Cannot find clusters file $clusters" unless -e $clusters;
+
+    my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.deburned.XXXX",
+                                          UNLINK => !$save_temps, SUFFIX => '.fits' );
+
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => "$ppCoord  , verbose => $verbose);
