Index: trunk/ippScripts/scripts/camera_exp.pl
===================================================================
--- trunk/ippScripts/scripts/camera_exp.pl	(revision 12079)
+++ trunk/ippScripts/scripts/camera_exp.pl	(revision 12213)
@@ -33,19 +33,21 @@
 use Pod::Usage qw( pod2usage );
 
-my ($exp_tag, $camera, $dbname, $workdir, $no_update, $no_op);
+my ($exp_id, $cam_id, $camera, $dbname, $workdir, $no_update, $no_op);
 GetOptions(
-    'exp_tag|e=s'       => \$exp_tag,
-    'camera|c=s'        => \$camera,
-    'dbname|d=s'        => \$dbname, # Database name
-    'workdir|w=s'       => \$workdir,
-    'no-update'         => \$no_update,
-    'no-op'             => \$no_op,
-) or pod2usage( 2 );
+	   'exp_id=s'          => \$exp_id, # Exposure identifier
+	   'cam_id=s'          => \$cam_id, # Camtool identifier
+	   'camera|c=s'        => \$camera, # Camera
+	   'dbname|d=s'        => \$dbname, # Database name
+	   'workdir|w=s'       => \$workdir, # Working directory
+	   'no-update'         => \$no_update, # Update the database?
+	   'no-op'             => \$no_op, # Don't do any operations?
+	   ) or pod2usage( 2 );
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-    -msg => "Required options: --exp_tag --camera",
+    -msg => "Required options: --exp_id --cam_id --camera",
     -exitval => 3,
-) unless defined $exp_tag
+) unless defined $exp_id
+    and defined $cam_id
     and defined $camera;
 
@@ -75,5 +77,5 @@
 my $files;			# Array of component files
 {
-    my $command = "$camtool -pendingimfile -exp_tag $exp_tag"; # Command to run
+    my $command = "$camtool -pendingimfile -cam_id $cam_id"; # Command to run
     $command .= " -dbname $dbname" if defined $dbname;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -81,10 +83,10 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform camtool: $error_code", $exp_tag, $error_code);
+	&my_die("Unable to perform camtool: $error_code", $cam_id, $error_code);
     }
     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata config doc", $exp_tag, $PS_EXIT_PROG_ERROR);
+	&my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_PROG_ERROR);
     $files = parse_md_list($metadata) or
-	&my_die("Unable to parse metadata list", $exp_tag, $PS_EXIT_PROG_ERROR);
+	&my_die("Unable to parse metadata list", $cam_id, $PS_EXIT_PROG_ERROR);
 }
 
@@ -98,11 +100,11 @@
 #    my @zp;			# Array of photometric zero points
     foreach my $file (@$files) {
-	&my_die("Unable to find class id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{class_id};
+	&my_die("Unable to find class id", $cam_id, $PS_EXIT_SYS_ERROR) unless defined $file->{class_id};
 	my $class_id = $file->{class_id};
-	&my_die("Unable to find bg for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{bg};
-	&my_die("Unable to find bg_mean_stdev for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{bg_mean_stdev};
-#	&my_die("Unable to find sigma_ra for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{sigma_ra};
-#	&my_die("Unable to find sigma_dec for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{sigma_dec};
-#	&my_die("Unable to find zp for class_id=$class_id", $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{zp};
+	&my_die("Unable to find bg for class_id=$class_id", $cam_id, $PS_EXIT_SYS_ERROR) unless defined $file->{bg};
+	&my_die("Unable to find bg_mean_stdev for class_id=$class_id", $cam_id, $PS_EXIT_SYS_ERROR) unless defined $file->{bg_mean_stdev};
+#	&my_die("Unable to find sigma_ra for class_id=$class_id", $cam_id, $PS_EXIT_SYS_ERROR) unless defined $file->{sigma_ra};
+#	&my_die("Unable to find sigma_dec for class_id=$class_id", $cam_id, $PS_EXIT_SYS_ERROR) unless defined $file->{sigma_dec};
+#	&my_die("Unable to find zp for class_id=$class_id", $cam_id, $PS_EXIT_SYS_ERROR) unless defined $file->{zp};
 	push @backgrounds, $file->{bg};
 	push @variances, $file->{bg_stdev}**2;
@@ -129,10 +131,10 @@
     $workdir = $dir;
 }
+
+$workdir = File::Spec->catfile( $workdir, $exp_id );
 system "mkdir -p $workdir" unless -d $workdir;
 
-# make this a function which generates a specific list file for a specific filename
-
 # Generate the file list, and get the statistics
-my $outputFile =  "$exp_tag.cam";
+my $outputFile =  "$exp_id.cam$cam_id";
 my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
 
@@ -182,7 +184,7 @@
 	unless ($success) {
 	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to perform psastro: $error_code", $exp_tag, $error_code);
-	}
-	&my_die("Unable to find expected output file: $fpaObjects", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $fpaObjects;
+	    &my_die("Unable to perform psastro: $error_code", $cam_id, $error_code);
+	}
+	&my_die("Unable to find expected output file: $fpaObjects", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $fpaObjects;
     } else {
 	$fpaObjects = $chipObjects;
@@ -198,5 +200,5 @@
 	unless ($success) {
 	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to perform addstar: $error_code", $exp_tag, $error_code);
+	    &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code);
 	}
     }
@@ -209,7 +211,7 @@
 	unless ($success) {
 	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to perform ppImage: $error_code", $exp_tag, $error_code);
-	}
-	&my_die("Unable to find expected output file: $jpeg1", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $jpeg1;
+	    &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
+	}
+	&my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $jpeg1;
     }
 
@@ -221,7 +223,7 @@
 	unless ($success) {
 	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to perform ppImage: $error_code", $exp_tag, $error_code);
-	}
-	&my_die("Unable to find expected output file: $jpeg2", $exp_tag, $PS_EXIT_PROG_ERROR) unless -f $jpeg2;
+	    &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
+	}
+	&my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $jpeg2;
     }
 }
@@ -232,5 +234,5 @@
 
 unless ($no_update) {
-    my $command = "$camtool -addprocessedexp -exp_tag $exp_tag -uri UNKNOWN " .
+    my $command = "$camtool -addprocessedexp -cam_id $cam_id -uri UNKNOWN " .
 	"-recip " . RECIPE1() . "," . RECIPE2() . " -path_base $outputRoot " .
 	"-bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev " .
@@ -253,10 +255,10 @@
 {
     my $msg = shift; # Warning message on die
-    my $exp_tag = shift; # Exposure tag
+    my $cam_id = shift; # Camtool identifier
     my $exit_code = shift; # Exit code to add
 
     warn($msg);
-    if ($exp_tag and not $no_update) {
-	my $command = "$camtool -addprocessedexp -exp_tag $exp_tag -code $exit_code";
+    if ($cam_id and not $no_update) {
+	my $command = "$camtool -addprocessedexp -cam_id $cam_id -code $exit_code";
 	$command .= " -dbname $dbname" if defined $dbname;
         system ($command);
