IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 24, 2012, 3:52:04 PM (14 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120905/ippScripts/scripts/publish_file.pl

    r30376 r34566  
    3232my $pubtool = can_run('pubtool') or (warn "Can't find pubtool" and $missing_tools = 1);
    3333my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
     34my $regtool = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1);
    3435my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
    3536my $ppMops = can_run('ppMops') or (warn "Can't find ppMops" and $missing_tools = 1);
     
    4445my ( $pub_id, $camera, $stage, $stage_id, $fileset, $format, $product, $workdir, $need_magic );
    4546my ( $dbname, $verbose, $no_update, $no_op, $save_temps, $redirect );
    46 my ( $output_format );
     47my ( $output_format, $difftype );
    4748
    4849GetOptions(
     
    7273    defined $stage and
    7374    defined $stage_id and
    74     defined $workdir;
     75    defined $workdir and
     76    defined $dbname;
    7577
    7678my $outroot = "$workdir/$product.$pub_id"; # Output root name
     
    166168    my %negative;               # Data for negative diff detections
    167169    foreach my $comp ( @$components ) {
    168         my $path_base = $comp->{path_base}; # Base name for file
     170        my $path_base = $comp->{path_base}; # Base name for file
    169171        if (!$need_magic and $comp->{magicked}) {
    170172            # This client is authorized to receive uncensored detections
     
    194196
    195197        $filename = $resolved;
     198
     199        my $cam_id = $comp->{cam_id_1};
     200        #print "Getting info from camera stage $cam_id\n";
     201        my $cam_command =  "$camtool -processedexp -cam_id $cam_id";
     202        $cam_command .= " -dbname $dbname" if defined $dbname;
     203        my ( $cam_success, $cam_error_code, $cam_full_buf, $cam_stdout_buf, $cam_stderr_buf ) =
     204            run(command => $cam_command, verbose => $verbose);
     205        &my_die( "Unable to retrieve filename", $pub_id, $PS_EXIT_SYS_ERROR) unless $cam_success;
     206        my $cam_metadata = $mdcParser->parse(join "", @$cam_stdout_buf) or
     207            &my_die("Unable to parse metadata config", $pub_id, $PS_EXIT_PROG_ERROR);
     208        my $cam_components = parse_md_list($cam_metadata) or
     209            &my_die("Unable to parse metadata list", $pub_id, $PS_EXIT_PROG_ERROR);
     210        &my_die("More than one entry for cam_id $stage_id", $pub_id, $PS_EXIT_PROG_ERROR) if scalar @$cam_components > 1;
     211        my $cam_comp = $$cam_components[0];
     212
     213        my $exp_id = $comp->{exp_id_1};
     214        #print "Getting info from raw stage $exp_id\n";
     215        my $reg_command =  "$regtool -processedimfile -exp_id $exp_id";
     216        $reg_command .= " -dbname $dbname" if defined $dbname;
     217        my ( $reg_success, $reg_error_code, $reg_full_buf, $reg_stdout_buf, $reg_stderr_buf ) =
     218            run(command => $reg_command, verbose => $verbose);
     219        &my_die( "Unable to retrieve filename", $pub_id, $PS_EXIT_SYS_ERROR) unless $reg_success;
     220        my $reg_metadata = $mdcParser->parse(join "", @$reg_stdout_buf) or
     221            &my_die("Unable to parse metadata config", $pub_id, $PS_EXIT_PROG_ERROR);
     222        my $reg_components = parse_md_list($reg_metadata) or
     223            &my_die("Unable to parse metadata list", $pub_id, $PS_EXIT_PROG_ERROR);
     224        my $reg_comp = $$reg_components[0];
     225
     226        # Now get the difftype value from diff->{diff_mode}
     227        my $difftype = "";
     228        if ($comp->{diff_mode} == 1) {
     229            $difftype = "WW";
     230        } elsif ($comp->{diff_mode} == 2) {
     231            $difftype = "WS";
     232        } elsif ($comp->{diff_mode} == 3) {
     233            $difftype = "SW"; # Not used yet
     234        } elsif ($comp->{diff_mode} == 4) {
     235            $difftype = "SS";
     236        } else {
     237            $difftype = "Unsupported diff_mode value: [" . $comp->{diff_mode} . "]";
     238        }
    196239
    197240        my $data = { zp => $zp,
     
    207250                     output_format => $comp->{output_format},
    208251                     direction => 1,
     252                     comment => $reg_comp->{comment},
     253                     obsmode => $reg_comp->{obs_mode},
     254                     difftype => $difftype,
     255                     sky => $cam_comp->{bg},
     256                     shutoutc => $reg_comp->{dateobs},
    209257        };
    210258
     259        #warn("Checking for positive");
    211260        diff_check(\%positive, $data, "positive");
    212261
     
    239288                         diff_id => $comp->{diff_id},
    240289                         direction => 0,
     290                         comment => $reg_comp->{comment},
     291                         obsmode => $reg_comp->{obs_mode},
     292                         difftype => $difftype,
     293                         sky => $cam_comp->{bg},
     294                         shutoutc => $reg_comp->{dateobs},
    241295            };
    242296
     297            #warn("Checking for negative");
    243298            diff_check(\%negative, $data, "negative");
    244299
     
    288343    &my_die( "Unable to register with data store", $pub_id, $PS_EXIT_SYS_ERROR) unless $success;
    289344}
    290 
    291 
    292345
    293346### Pau.
     
    311364    $data->{diff_id} = $comp->{diff_id} unless defined $data->{diff_id};
    312365    $data->{direction} = $comp->{direction} unless defined $data->{direction};
     366    $data->{comment} = $comp->{comment} unless defined $data->{comment};
     367    $data->{obsmode} = $comp->{obsmode} unless defined $data->{obsmode};
     368    $data->{difftype} = $comp->{difftype} unless defined $data->{difftype};
     369    $data->{sky} = $comp->{sky} unless defined $data->{sky};
     370    $data->{shutoutc} = $comp->{shutoutc} unless defined $data->{shutoutc};
    313371
    314372    &my_die("zp value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{zp} and $comp->{zp} != $data->{zp};
     
    323381    &my_die("diff_id value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{diff_id} and $comp->{diff_id} != $data->{diff_id};
    324382    &my_die("direction value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{direction} and $comp->{direction} != $data->{direction};
     383    &my_die("comment value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{comment} and $comp->{comment} ne $data->{comment};
     384    &my_die("obsmode value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{obsmode} and $comp->{obsmode} ne $data->{obsmode};
     385    &my_die("difftype value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{difftype} and $comp->{difftype} ne $data->{difftype};
     386    &my_die("sky value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{sky} and $comp->{sky} != $data->{sky};
     387    &my_die("shutoutc value for $name doesn't match", $pub_id, $PS_EXIT_SYS_ERROR) if defined $data->{shutoutc} and $comp->{shutoutc} ne $data->{shutoutc};
    325388
    326389    return 1;
     
    350413    $command .= " -astrom_rms " . $data->{astrom} if defined $data->{astrom};
    351414    $command .= " -version " . $data->{output_format} if defined $data->{output_format};
     415    $command .= " -comment \"" . $data->{comment} . "\"" if defined $data->{comment};
     416    $command .= " -obsmode " . $data->{obsmode} if defined $data->{obsmode};
     417    $command .= " -difftype " . $data->{difftype} if defined $data->{difftype};
     418    $command .= " -sky " . $data->{sky} if defined $data->{sky};
     419    $command .= " -shutoutc \"" . $data->{shutoutc} . "\"" if defined $data->{shutoutc};
    352420
    353421    unless ($no_op) {
Note: See TracChangeset for help on using the changeset viewer.