IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32537


Ignore:
Timestamp:
Oct 12, 2011, 10:41:16 AM (15 years ago)
Author:
bills
Message:

For warp destreaking check whether the tess_id for the diffs used in the
streak detection stage matches the tess_id of the warp. If not pass the diff_tess_id
to magic_destreak.pl and compute the overlap using dvoImageOverlaps

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/magic_destreak.pl

    r32402 r32537  
    3535my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3636my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     37my $dvoImageOverlaps = can_run('dvoImageOverlaps') or (warn "Can't find dvoImageOverlaps" and $missing_tools = 1);
    3738if ($missing_tools) {
    3839    warn("Can't find required tools.");
     
    4546my ($outroot, $recoveryroot, $magicked);
    4647my ($replace, $release);
     48my ($diff_tess_id, $mismatched_tess);
    4749my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
    4850
     
    6062           'stage_id=s'     => \$stage_id,   # exp_id, chip_id, warp_id, or diff_id
    6163           'component=s'    => \$component,  # the class_id or skycell_id
     64           'mismatched_tess'=> \$mismatched_tess, # true if tess_id of input does not match tess_id of the diff used for magic
     65           'diff_tess_id=s' => \$diff_tess_id, # tess_id of diffRun used to compute the streaks
    6266           'uri=s'          => \$uri,        # uri of the input image
    6367           'path_base=s'    => \$path_base,  # path_base of the input
     
    106110if (($stage eq "raw") or ($stage eq "chip") or $stage eq "chip_bg") {
    107111    $class_id = $component;
    108     $skycell_args = " -class_id $component";
     112    $skycell_args = " -class_id";
    109113} elsif ($stage eq "warp" or $stage eq "warp_bg") {
    110114    $skycell_id = $component;
    111     $skycell_args = " -skycell_id $component";
     115    $skycell_args = " -skycell_id";
    112116} elsif ($stage eq "diff") {
    113117    $skycell_id = $component;
     
    215219    my ($sfh, $skycell_list);
    216220    if ($skycell_args) {
    217         my $command = "$magicdstool -magic_ds_id $magic_ds_id -getskycells $skycell_args";
    218         $command .= " -dbname $dbname" if defined $dbname;
    219         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    220             run(command => $command, verbose => $verbose);
    221         unless ($success) {
    222             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    223             &my_die("Unable to perform magicdstool -diffskyfile $skycell_args: $error_code", $magic_ds_id, $component, $error_code);
    224         }
    225 
    226         my $getskycells_output = join "", @$stdout_buf;
    227         if ($getskycells_output) {
    228             my $metadata = $mdcParser->parse($getskycells_output) or
    229                 &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR);
    230 
    231             my $skycells = parse_md_list($metadata) or
    232                     &my_die("Unable to parse metadata list", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR);
    233 
    234             ($sfh, $skycell_list) = tempfile( "/tmp/skycell_list.XXXX", UNLINK => !$save_temps);
    235 
    236             foreach my $skycell (@$skycells) {
    237                 my $skycell_uri;
    238                 if ($skycell->{data_state} eq "full" and $skycell->{quality} = 0) {
    239                     $skycell_uri = $ipprc->filename("PPSUB.OUTPUT", $skycell->{path_base});
    240                 } else {
    241                     # diff run must have been cleaned up, need to create this skycell file on the fly
    242                     if (!defined $temp_dir ) {
    243                         $temp_dir = tempdir( CLEANUP => !$save_temps);
     221        my $command = "$magicdstool -magic_ds_id $magic_ds_id -getskycells";
     222        $command .= " $skycell_args";
     223        my @diff_components;
     224        if ($mismatched_tess) {
     225            # tessellation for this skycell does not match the tessellation used for the magic analysis
     226            # used to calculate the streaks file
     227            @diff_components = get_overlaps($path_base, $component, $diff_tess_id);
     228        } else {
     229            @diff_components = ($component);
     230        }
     231
     232        # hash of uris by skycell.
     233        my %diff_skycells;
     234        foreach my $component (@diff_components) {
     235            my $this_command = "$command $component";
     236            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     237                run(command => $this_command, verbose => $verbose);
     238            unless ($success) {
     239                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     240                &my_die("Unable to perform magicdstool -diffskyfile $skycell_args: $error_code", $magic_ds_id, $component, $error_code);
     241            }
     242
     243            my $getskycells_output = join "", @$stdout_buf;
     244            if ($getskycells_output) {
     245                my $metadata = $mdcParser->parse($getskycells_output) or
     246                    &my_die("Unable to parse metadata config doc", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR);
     247
     248                my $skycells = parse_md_list($metadata) or
     249                        &my_die("Unable to parse metadata list", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR);
     250
     251                foreach my $skycell (@$skycells) {
     252                    my $skycell_uri;
     253                    if ($skycell->{data_state} eq "full" and $skycell->{quality} == 0) {
     254                        $skycell_uri = $ipprc->filename("PPSUB.OUTPUT", $skycell->{path_base});
     255                        $diff_skycells{$skycell_id} = $skycell_uri;
     256                    } else {
     257                        # diff run must have been cleaned up, need to create this skycell file on the fly
     258                        if (!defined $temp_dir ) {
     259                            $temp_dir = tempdir( CLEANUP => !$save_temps);
     260                        }
     261                        my $skycell_id = $skycell->{skycell_id};
     262                        if (!$diff_skycells{$skycell_id}) {
     263                            $skycell_uri = "$temp_dir/$skycell_id";
     264                            $ipprc->skycell_file($skycell->{tess_id}, $skycell_id, $skycell_uri, $verbose) or
     265                                &my_die("failed to create skycell file for $skycell_id", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR);
     266                        }
     267                        $diff_skycells{$skycell_id} = $skycell_uri;
    244268                    }
    245                     my $skycell_id = $skycell->{skycell_id};
    246                     $skycell_uri = "$temp_dir/$skycell_id";
    247                     $ipprc->skycell_file($skycell->{tess_id}, $skycell_id, $skycell_uri, $verbose) or
    248                         &my_die("failed to create skycell file for $skycell_id", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR);
    249269                }
    250                 print $sfh "$skycell_uri\n";
    251             }
    252             close $sfh
    253         }
     270            }
     271        }
     272        # write the skycell list file
     273        ($sfh, $skycell_list) = tempfile( "/tmp/skycell_list.XXXX", UNLINK => !$save_temps);
     274        foreach my $skycell_id (keys %diff_skycells) {
     275            print $sfh $diff_skycells{$skycell_id} . "\n";
     276        }
     277        close $sfh
    254278    }
    255279
     
    590614}
    591615
     616            # @diff_components = get_overlaps($path_base, $component, $tess_id, $diff_tess_id);
     617sub get_overlaps {
     618    my $path_base = shift;
     619    my $component = shift;
     620    my $diff_tess_id = shift;
     621
     622    my $tess_dir = $ipprc->tessellation_catdir( $diff_tess_id );
     623    my $catdir = $ipprc->convert_filename_absolute($tess_dir);
     624
     625    my $cmf = $ipprc->file_resolve("$path_base.cmf");
     626    &my_die("Unable to resolve $path_base.$cmf", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR) unless $cmf;
     627
     628    my $command = "$dvoImageOverlaps -D CATDIR $catdir -accept-astrom $cmf";
     629    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     630        run(command => $command, verbose => $verbose);
     631    unless ($success) {
     632        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     633        &my_die("Unable to perform dvoImageOverlaps $error_code", $magic_ds_id, $component,
     634            $error_code);
     635    }
     636    my @list;
     637    my $output = join "\n", @$stdout_buf;
     638    if ($output) {
     639        foreach my $line (split "\n", $output) {
     640            my (undef, undef, $skycell_id) = split " ", $line;
     641            push @list, $skycell_id;
     642        }
     643    }
     644    return @list
     645}
     646
    592647
    593648sub my_die
  • trunk/ippTasks/destreak.pro

    r30855 r32537  
    206206    book getword magicToDS $pageName magicked -var MAGICKED
    207207    book getword magicToDS $pageName dbname -var DBNAME
    208 
     208    book getword magicToDS $pageName diff_tess_id -var DIFF_TESS_ID
     209    book getword magicToDS $pageName mismatched_tess -var MISMATCHED_TESS
    209210
    210211    substr $COMPONENT 0 3 COMP_HEAD
     
    224225    $run = magic_destreak.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --exp_id $EXP_ID --streaks_path_base $STREAKS_PATH_BASE --inv_streaks_path_base $INV_STREAKS_PATH_BASE --streaks $STREAKS --inv_streaks $INV_STREAKS --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --uri $URI --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --cam_reduction $CAM_REDUCTION --outroot $WORKDIR --logfile $logfile --recoveryroot $RECROOT --replace $REPLACE --magicked $MAGICKED --run-state $RUN_STATE
    225226
     227    if ($MISMATCHED_TESS)
     228        book getword magicToDS $pageName diff_tess_id -var DIFF_TESS_ID
     229        $run = $run --mismatched_tess --diff_tess_id $DIFF_TESS_ID
     230    end
    226231    add_standard_args run
    227232
Note: See TracChangeset for help on using the changeset viewer.