Index: trunk/ippScripts/scripts/flatcorr_proc.pl
===================================================================
--- trunk/ippScripts/scripts/flatcorr_proc.pl	(revision 20223)
+++ trunk/ippScripts/scripts/flatcorr_proc.pl	(revision 20246)
@@ -42,8 +42,9 @@
 use Pod::Usage qw( pod2usage );
 
-my ($corr_id, $dvodb, $region, $filter, $dbname, $workdir, $verbose, $no_update, $no_op);
+my ($corr_id, $dvodb, $camera, $region, $filter, $dbname, $workdir, $verbose, $no_update, $no_op);
 GetOptions(
     'corr_id|i=s'      => \$corr_id,
     'dvodb|c=s'        => \$dvodb,
+    'camera=s'         => \$camera,
     'region|r=s'       => \$region,
     'filter|f=s'       => \$filter,
@@ -56,8 +57,9 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --corr_id --dvodb --region --filter --workdir",
+pod2usage( -msg => "Required options: --corr_id --dvodb --camera --region --filter --workdir",
            -exitval => 3) unless
     defined $corr_id and
     defined $dvodb and
+    defined $camera and
     defined $region and
     defined $workdir and
@@ -78,8 +80,12 @@
 }
 
+$ipprc->define_camera($camera);
+
 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
 
-my $outgrid = "$workdir/grid.$corr_id";
-my $outcorr = "$workdir/corr.$corr_id";
+# XXX either workdir needs to be non-nebulous here, or addstar / relphot need to handle 
+# nebulous interactions...
+my $outgrid = "$workdir/grid.$camera.$filter.$corr_id";
+my $outcorr = "$workdir/corr.$camera.$filter.$corr_id";
 
 # parse the region (RAs,RAe:DECs,DECe) : item = +/-NNN.NNNN
@@ -90,5 +96,5 @@
 # Run addstar -resort to ensure the db is indexed
 {
-    my $command = "echo $addstar -resort";
+    my $command = "$addstar -resort";
     $command .= " -D CATDIR $dvodb";
     $command .= " -region $RAs $RAe $DECs $DECe";
@@ -104,7 +110,10 @@
 
 # Run relphot (filter) for the specified region (need to clarify the options like imfreeze)
-{
-    my $command = "echo $relphot $filter";
-    $command .= " -D CAMERA $camera";
+# need to convert the camera name to the dvo camera value
+{
+    my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
+
+    my $command = "$relphot $filter";
+    $command .= " -D CAMERA $camdir";
     $command .= " -D CATDIR $dvodb";
     $command .= " -region $RAs $RAe $DECs $DECe";
@@ -133,5 +142,5 @@
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => 0);
     unless ($success) {
         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
@@ -159,5 +168,5 @@
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
+        run(command => $command, verbose => 0);
     unless ($success) {
         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
@@ -179,12 +188,6 @@
 
     my $filelevel = $file->{filelevel};
-    my $camera    = $file->{camera};
     my $telescope = $file->{telescope};
     my $filter    = $file->{filter};
-
-    ## XXX the flat-field correction is only defined for a single
-    ## camera.  we are grabbing the camera here, but we are assuming
-    ## the flatcorrRun was defined for only a single camera.
-    $ipprc->define_camera($camera);
 
     my $command = "$dettool -register_detrend";
@@ -203,5 +206,5 @@
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
+	run(command => $command, verbose => $verbose);
 
     unless ($success) { 
@@ -232,10 +235,10 @@
     }
 
-    my $command = "echo $dvoMakeCorr $outcorr";
+    my $command = "$dvoMakeCorr $outcorr";
     $command .= " -file $outgrid.fits";
     $command .= " -ref $reffile";
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
+	run(command => $command, verbose => $verbose);
 
     unless ($success) { 
@@ -252,5 +255,5 @@
 
     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
+	run(command => $command, verbose => $verbose);
 
     unless ($success) { 
@@ -268,5 +271,5 @@
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => 1);
+        run(command => $command, verbose => $verbose);
 
     unless ($success) {
@@ -287,5 +290,5 @@
 
 	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	    run(command => $command, verbose => 1);
+	    run(command => $command, verbose => $verbose);
 	unless ($success) {
 	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
