Index: /trunk/ippScripts/scripts/publish_file.pl
===================================================================
--- /trunk/ippScripts/scripts/publish_file.pl	(revision 25071)
+++ /trunk/ippScripts/scripts/publish_file.pl	(revision 25072)
@@ -39,10 +39,9 @@
 
 # Parse the command-line arguments
-my ( $pub_id, $exp_id, $camera, $stage, $stage_id, $format, $product, $workdir );
+my ( $pub_id, $camera, $stage, $stage_id, $format, $product, $workdir );
 my ( $dbname, $verbose, $no_update, $save_temps, $redirect );
 
 GetOptions(
     'pub_id=s'          => \$pub_id, # Publish identifier
-    'exp_id=s'          => \$exp_id, # Exposure identifier
     'camera=s'          => \$camera, # Camera name
     'stage=s'           => \$stage,       # Stage of interest
@@ -58,8 +57,7 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --pub_id --exp_id --camera --stage --stage_id --product --workdir",
+pod2usage( -msg => "Required options: --pub_id --camera --stage --stage_id --product --workdir",
            -exitval => $PS_EXIT_CONFIG_ERROR) unless
     defined $pub_id and
-    defined $exp_id and
     defined $camera and
     defined $product and
@@ -68,5 +66,5 @@
     defined $workdir;
 
-my $outroot = "$workdir/$product.$pub_id.$exp_id"; # Output root name
+my $outroot = "$workdir/$product.$pub_id"; # Output root name
 
 my $ipprc = PS::IPP::Config->new( $camera ) or
@@ -83,4 +81,5 @@
 my %files;                      # Input filenames
 my %zp;                         # Zero points
+my %exp_id;                     # Exposure identifiers
 {
     my $command;                # Command to run
@@ -119,8 +118,11 @@
             $zp{"$skycell_id.pos"} = $zp;
             $zp{"$skycell_id.neg"} = $zp if defined $comp->{bothways} and $comp->{bothways};
+            $exp_id{"$skycell_id.pos"} = $comp->{exp1};
+            $exp_id{"$skycell_id.neg"} = $comp->{exp2} if defined $comp->{bothways} and $comp->{bothways};
         } elsif ($stage eq 'camera') {
             my $cam_id = $comp->{cam_id};
             $files{$cam_id} = $ipprc->filename( "PSASTRO.OUTPUT", $path_base );
             $zp{$cam_id} = $zp;
+            $exp_id{$cam_id} = $comp->{exp_id};
         }
     }
@@ -137,4 +139,5 @@
 
     my $zp = $zp{$comp};
+    my $exp_id = $exp_id{$comp};
     if ($product eq "IPP-MOPS") {
         my $outuri = "$outroot.$comp.fits";
@@ -142,5 +145,5 @@
             &my_die( "Unable to resolve output file $outuri", $pub_id, $PS_EXIT_SYS_ERROR);
 
-        my $command = "$ppMops $file $zp $out";
+        my $command = "$ppMops $file $zp $exp_id $out";
         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
             run(command => $command, verbose => $verbose);
Index: /trunk/ppMops/src/ppMops.c
===================================================================
--- /trunk/ppMops/src/ppMops.c	(revision 25071)
+++ /trunk/ppMops/src/ppMops.c	(revision 25072)
@@ -6,7 +6,7 @@
 int main(int argc, char *argv[])
 {
-    if (argc != 4) {
+    if (argc != 5) {
         fprintf(stderr, "Insufficient arguments.\n");
-        fprintf(stderr, "Usage: %s DETECTIONS ZP OUTPUT\n", argv[0]);
+        fprintf(stderr, "Usage: %s DETECTIONS ZP EXP_ID OUTPUT\n", argv[0]);
         exit(PS_EXIT_CONFIG_ERROR);
     }
@@ -15,5 +15,6 @@
     data->detections = psStringCopy(argv[1]);
     data->zp = atof(argv[2]);
-    data->output = psStringCopy(argv[3]);
+    data->exp_id = atoll(argv[3]);
+    data->output = psStringCopy(argv[4]);
 
     if (!isfinite(data->zp)) {
@@ -120,12 +121,9 @@
         double alt = psMetadataLookupF64(NULL, header, "FPA.ALT");
         double az = psMetadataLookupF64(NULL, header, "FPA.AZ");
-        int imageid = psMetadataLookupS32(NULL, header, "IMAGEID");
+        psS64 imageid = psMetadataLookupS64(NULL, header, "IMAGEID");
         double mjd = psMetadataLookupF64(NULL, header, "MJD-OBS") + exptime / 2.0 / 3600 / 24;
 
         float psf = plateScale * 0.5 * (psMetadataLookupF32(NULL, header, "FWHM_MAJ") +
                                         psMetadataLookupF32(NULL, header, "FWHM_MIN"));
-
-        // XXX This is wrong
-        int fpaid = psMetadataLookupS32(NULL, header, "IMAGEID");
 
 
@@ -140,5 +138,5 @@
         psMetadataAddF64(outHeader, PS_LIST_TAIL, "TEL_AZ", 0, "Telescope azimuth", az);
         psMetadataAddS32(outHeader, PS_LIST_TAIL, "DIFFIMID", 0, "Difference image identifier", imageid);
-        psMetadataAddS32(outHeader, PS_LIST_TAIL, "FPA_ID", 0, "Exposure identifier", fpaid);
+        psMetadataAddS32(outHeader, PS_LIST_TAIL, "FPA_ID", 0, "Exposure identifier", data->exp_id);
         psMetadataAddStr(outHeader, PS_LIST_TAIL, "OBSCODE", 0, "IAU Observatory code", OBSERVATORY_CODE);
         psMetadataAddF32(outHeader, PS_LIST_TAIL, "STARPSF", 0, "Stellar PSF (arcsec)", psf);
Index: /trunk/ppMops/src/ppMops.h
===================================================================
--- /trunk/ppMops/src/ppMops.h	(revision 25071)
+++ /trunk/ppMops/src/ppMops.h	(revision 25072)
@@ -16,4 +16,5 @@
     psString detections;                // Detections filename
     float zp;                           // Magnitude zero point
+    psS64 exp_id;                       // Exposure identifier
     psString output;                    // Output filename
 } ppMopsData;
