IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27596 for trunk


Ignore:
Timestamp:
Apr 5, 2010, 10:16:10 AM (16 years ago)
Author:
Paul Price
Message:

Merging branches/pap_delete/ into trunk after successful testing. This provides automatic deletion of the convolved images from the diff stage.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana/src/relastro

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/ippScripts/scripts/diff_skycell.pl

    r27215 r27596  
    102102my $camera;                     # Camera
    103103my ($inputMagic, $templateMagic); # Are the inputs been magicked?
     104my ($saveInConv, $saveRefConv);   # Save the input or reference convolved images?
    104105# Prescan to decide if this is or is not a stack stack diff. The check above confirms we only have two entries.
    105106if ((${ $files }[0]->{warp_id} == 0)&&
     
    140141            $templateSources = "PSWARP.OUTPUT.SOURCES";
    141142            $templateMagic = $file->{magicked};
     143            $saveRefConv = 1;
    142144        }
    143145    } else {
     
    162164            $inputVariance = "PSWARP.OUTPUT.VARIANCE";
    163165            $inputSources = "PSWARP.OUTPUT.SOURCES";
     166            $saveInConv = 1;
    164167        }
    165168    }
     
    284287        $command .= " -ipprc $configurationReal";
    285288    }
     289    $command .= " -save-inconv" if defined $saveInConv;
     290    $command .= " -save-refconv" if defined $saveRefConv;
    286291    $command .= " -recipe PPSUB $recipe_ppSub";
    287292    $command .= " -recipe PSPHOT $recipe_psphot";
  • trunk/ippScripts/scripts/magic_process.pl

    r27240 r27596  
    3030my $missing_tools;
    3131my $magictool      = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
     32my $difftool       = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
     33my $ppSubConvolve = can_run('ppSubConvolve') or (warn "Can't find ppSubConvolve" and $missing_tools = 1);
    3234my $detectstreaks = can_run('DetectStreaks') or (warn "Can't find DetectStreaks" and $missing_tools = 1);
    3335my $VerifyStreaks = can_run('VerifyStreaks') or (warn "Can't find VerifyStreaks, will not produce png images");
     
    8082$baseroot = $ipprc->file_resolve($baseroot);
    8183my $outroot = "$baseroot.$node";
     84$ipprc->outroot_prepare($outroot);
    8285
    8386my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    116119    $command .= " --threshold 2.35";
    117120
     121    my @deletions;          # Files to delete
    118122    if (scalar @$inputs == 1 and $node ne "root") {
    119123        #
     
    135139        }
    136140
    137         my $template = resolve_template($innode);
    138         &my_die("failed to resolve template", $magic_id, $node, $PS_EXIT_DATA_ERROR)
    139             unless defined $template;
     141        my $diff_base = $innode->{diff_path_base}; # Base name for diff
     142        my $tempName = $innode->{inverse} ? "PPSUB.INPUT.CONV" : "PPSUB.REF.CONV"; # File rule of interest
     143        my $template = $ipprc->file_resolve($ipprc->filename($tempName, $diff_base));
     144        &my_die("failed to resolve template", $magic_id, $node, $PS_EXIT_DATA_ERROR) unless defined $template;
     145
     146        # Delete the convolved products when done (we can recreate them as we need)
     147        push @deletions, $template;
     148        push @deletions, $ipprc->filename($tempName . ".MASK", $diff_base);
     149        push @deletions, $ipprc->filename($tempName . ".VARIANCE", $diff_base);
     150
     151        unless ($ipprc->file_exists($template)) {
     152            # Template doesn't exist (or can't be found); try to recreate it
     153            my $tempPath = "/tmp/magic.$magic_id.$node.template";
     154
     155            my $kernel = $ipprc->filename("PPSUB.OUTPUT.KERNELS", $diff_base); # Name of kernel file
     156            &my_die("Unable to find kernel file", $magic_id, $node, $PS_EXIT_DATA_ERROR) unless $ipprc->file_exists($kernel);
     157
     158            my ($image, $mask);   # Image and mask
     159            {
     160                my $command = "$difftool -inputskyfile -diff_id $diff_id -skycell_id $node"; # Command to run
     161                $command .= " -dbname $dbname" if defined $dbname;
     162                if ($innode->{inverse}) {
     163                    # Want the input because we're magicking the reference
     164                    $command .= " -input";
     165                } else {
     166                    # Want the reference because we're magicking the input
     167                    $command .= " -template";
     168                }
     169
     170                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     171                    run(command => $command, verbose => $verbose);
     172                unless ($success) {
     173                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     174                    &my_die("Unable to determine convolution inputs: $error_code", $magic_id, $node, $error_code);
     175                }
     176
     177                my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     178                    &my_die("Unable to parse metadata config doc", $magic_id, $node, $PS_EXIT_PROG_ERROR);
     179
     180                my $inputs = parse_md_list($metadata) or
     181                    &my_die("Unable to parse metadata list", $magic_id, $node, $PS_EXIT_PROG_ERROR);
     182                &my_die("Unexpected number of outputs", $magic_id, $node, $PS_EXIT_PROG_ERROR) unless scalar @$inputs == 1;
     183                my $input = $$inputs[0];
     184                my $path = $input->{path_base}; # Path of interest
     185                if (defined $input->{warp_id} and $input->{warp_id} > 0) {
     186                    $image = $ipprc->filename("PSWARP.OUTPUT", $path);
     187                    $mask = $ipprc->filename("PSWARP.OUTPUT.MASK", $path);
     188                } elsif (defined $input->{stack_id} and $input->{stack_id} > 0) {
     189                    $image = $ipprc->filename("PPSTACK.UNCONV", $path);
     190                    $mask = $ipprc->filename("PPSTACK.UNCONV.MASK", $path);
     191                }
     192                &my_die("Unable to determine image and mask name", $magic_id, $node, $PS_EXIT_PROG_ERROR) unless defined $image and defined $mask;
     193            }
     194
     195            {
     196                &my_die("Unable to find image and mask", $magic_id, $node, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($image) and $ipprc->file_exists($mask);
     197
     198                my $command = "$ppSubConvolve $tempPath -image $image -mask $mask -kernel $kernel";
     199                $command .= " -reference" unless $innode->{inverse};
     200                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     201                    run(command => $command, verbose => $verbose);
     202                unless ($success) {
     203                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     204                    &my_die("Unable to create template image: $error_code", $magic_id, $node, $error_code);
     205                }
     206
     207                $template = $ipprc->filename("PPSUB.INPUT.CONV", $tempPath) or &my_die("Unable to determine filename for created template", $magic_id, $node, $PS_EXIT_PROG_ERROR);
     208                $template = $ipprc->file_resolve($template) or &my_die("Unable to resolve filename for created template", $magic_id, $node, $PS_EXIT_PROG_ERROR);
     209                &my_die("Unable to find created template", $magic_id, $node, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($template);
     210                push @deletions, $template;
     211            }
     212        }
    140213
    141214        $command .= " --detect --image $image --mask $mask --weight $weight -k $template";
     
    223296            file_check( $output );
    224297        }
     298
     299        foreach my $file (@deletions) {
     300            print "Deleting $file...\n";
     301            $ipprc->file_delete($file);
     302        }
     303
    225304    } else {
    226305        print "Skipping command: $command\n";
    227306    }
     307
    228308}
    229309
     
    387467}
    388468
    389 sub resolve_template
    390 {
    391     my $node = shift;
    392 
    393     my $path_base = $node->{diff_path_base}; # Base name for name
    394     my $image = $node->{inverse} ? "PPSUB.INPUT.CONV" : "PPSUB.REF.CONV"; # File rule of interest
    395 
    396     $image = $ipprc->file_resolve($ipprc->filename($image, $path_base));
    397 
    398     return $image
    399 }
    400 
    401469sub file_check
    402470{
  • trunk/ippScripts/scripts/magic_tree.pl

    r26186 r27596  
    171171    if ($xi == 0 and $eta == 0) {
    172172        $phi = 0;
    173         $eta = 0;
     173        $theta = 0;
    174174    } else {
    175175        $phi = atan2($eta,$xi) + pi/2;
  • trunk/ippconfig/recipes/ppSub.config

    r26902 r27596  
    7676INVERSE         BOOL    FALSE           # Generate inverse subtraction?
    7777PHOTOMETRY      BOOL    FALSE           # Perform photometry?
    78 SAVE.CONVOLVED  BOOL    TRUE            # Save convolved images?
    7978
    8079
  • trunk/ppSub/src/ppSub.h

    r27109 r27596  
    4545    bool photometry;                    // Perform photometry?
    4646    bool inverse;                       // Output inverse subtraction as well?
     47    bool saveInConv;                    // Save convolved input?
     48    bool saveRefConv;                   // Save convolved reference?
    4749    psString stamps;                    // Stamps file
    4850    pmPSF *psf;                         // Point Spread Function
  • trunk/ppSub/src/ppSubArguments.c

    r27143 r27596  
    8787    psMetadataAddBool(arguments, PS_LIST_TAIL, "-photometry", 0, "Perform photometry?", NULL);
    8888    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp", 0, "Zero point for photometry", NAN);
    89     psMetadataAddBool(arguments, PS_LIST_TAIL, "-inverse", 0, "Generate inverse subtractions?", NULL);
     89    psMetadataAddBool(arguments, PS_LIST_TAIL, "-inverse", 0, "Generate inverse subtractions?", false);
     90    psMetadataAddBool(arguments, PS_LIST_TAIL, "-save-inconv", 0, "Save input convolved images?", false);
     91    psMetadataAddBool(arguments, PS_LIST_TAIL, "-save-refconv", 0, "Save reference convolved images?", false);
    9092    psMetadataAddBool(arguments, PS_LIST_TAIL, "-visual", 0, "Show diagnostic plots", NULL);
    9193
     
    154156    }
    155157
     158    data->saveInConv = psMetadataLookupBool(NULL, arguments, "-save-inconv");
     159    data->saveRefConv = psMetadataLookupBool(NULL, arguments, "-save-refconv");
     160
    156161    if (psMetadataLookupBool(NULL, arguments, "-visual")) {
    157162        pmVisualSetVisual(true);
  • trunk/ppSub/src/ppSubCamera.c

    r27040 r27596  
    219219    data->photometry = psMetadataLookupBool(NULL, recipe, "PHOTOMETRY");
    220220
    221     bool mdok;                          // Status of MD lookup
    222     bool saveConv = psMetadataLookupBool(&mdok, recipe, "SAVE.CONVOLVED"); // Save convolved images?
    223 
    224221    // Convolved input image
    225222    pmFPAfile *inConvImage = defineOutputFile(config, input, true, "PPSUB.INPUT.CONV", PM_FPA_FILE_IMAGE);
     
    230227        return false;
    231228    }
    232     if (saveConv) {
    233         inConvImage->save = true;
    234         inConvMask->save = true;
    235     }
     229    inConvImage->save = data->saveInConv;
     230    inConvMask->save = data->saveInConv;
    236231    if (inVar) {
    237232        pmFPAfile *inConvVar = defineOutputFile(config, inConvImage, false, "PPSUB.INPUT.CONV.VARIANCE",
     
    241236            return false;
    242237        }
    243         if (saveConv) {
    244             inConvVar->save = true;
    245         }
     238        inConvVar->save = data->saveInConv;
    246239    }
    247240
     
    254247        return false;
    255248    }
    256     if (saveConv) {
    257         refConvImage->save = true;
    258         refConvMask->save = true;
    259     }
     249    refConvImage->save = data->saveRefConv;
     250    refConvMask->save = data->saveRefConv;
    260251    if (refVar) {
    261252        pmFPAfile *refConvVar = defineOutputFile(config, refConvImage, false, "PPSUB.REF.CONV.VARIANCE",
     
    265256            return false;
    266257        }
    267         if (saveConv) {
    268             refConvVar->save = true;
    269         }
     258        refConvVar->save = data->saveRefConv;
    270259    }
    271260
  • trunk/ppSub/src/ppSubData.c

    r27061 r27596  
    3333    data->photometry = false;
    3434    data->inverse = false;
     35    data->saveInConv = false;
     36    data->saveRefConv = false;
    3537    data->stamps = NULL;
    3638    data->psf = NULL;
Note: See TracChangeset for help on using the changeset viewer.