IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 13, 2009, 12:37:33 PM (17 years ago)
Author:
Paul Price
Message:

Merging branches/pap_magic@24173 into trunk. One conflict in dbconfig/changes.txt resolved easily.

Location:
trunk
Files:
1 deleted
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ippScripts/scripts/diff_skycell.pl

    r23740 r24174  
    3535}
    3636
    37 my ($diff_id, $dbname, $threads, $outroot, $reduction, $verbose, $no_update, $no_op, $redirect);
     37my ($diff_id, $dbname, $threads, $outroot, $reduction, $inverse, $verbose, $no_update, $no_op, $redirect);
    3838my ($skycell_id, $diff_skyfile_id);
    3939GetOptions(
     
    4444    'threads=s'         => \$threads,   # Number of threads to use
    4545    'outroot=s'         => \$outroot, # Output root name
     46    'inverse'           => \$inverse, # Make inverse subtraction?
    4647    'reduction=s'       => \$reduction, # Reduction class
    4748    'verbose'           => \$verbose,   # Print to stdout
     
    9697my $camera;                     # Camera
    9798my ($inputMagic, $templateMagic); # Are the inputs been magicked?
    98 my $inverse = 1;                # Generate inverse subtraction if warp-warp
    9999foreach my $file (@$files) {
    100100    if (defined $file->{template} and $file->{template}) {
     
    107107            # template is a stack so it doesn't need to be magicked
    108108            $templateMagic = 1;
    109             $inverse = 0;
    110109            ## use an explicit stack name for psphot output objects
    111110        } else {
     
    123122            $inputVariance = "PPSTACK.OUTPUT.VARIANCE";
    124123            $inputSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl:161
    125             $inverse = 0;
    126124        } else {
    127125            $inputMask = "PSWARP.OUTPUT.MASK";
  • trunk/ippScripts/scripts/magic_definerun.pl

    r23186 r24174  
    164164&my_die("failed to retrieve new magic run information", $PS_EXIT_CONFIG_ERROR) if !$magic_id;
    165165
     166### This is left over from when diffs were composed of a single skycell
     167### When we're not too busy, it should be deleted in favour of:
     168### magicRun JOIN diffSkyfile USING(diff_id) WHERE diffSkyfile.fault = 0 AND diffSkyfile.quality = 0
    166169foreach my $diff_skyfile (@$inputs) {
    167170    my $skycell_id = $diff_skyfile->{skycell_id};
     
    171174    }
    172175    my $diff_id = $diff_skyfile->{diff_id};
    173     my $command = "$magictool -addinputskyfile -magic_id $magic_id -diff_id $diff_id";
    174     $command .= "  -node $skycell_id";
     176    my $command = "$magictool -addinputskyfile";
     177    $command .= " -magic_id $magic_id";
     178    $command .= " -node $skycell_id";
    175179    $command .= " -dbname $dbname" if $dbname;
    176180
  • trunk/ippScripts/scripts/magic_destreak.pl

    r23909 r24174  
    3535
    3636# Parse the command-line arguments
    37 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base);
     37my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $inverse, $cam_path_base);
    3838my ($outroot, $recoveryroot);
    3939my ($replace, $remove, $release);
     
    4949           'uri=s'          => \$uri,        # uri of the input image
    5050           'path_base=s'    => \$path_base,  # path_base of the input
     51           'inverse'        => \$inverse,    # Inverse subtraction?
    5152           'cam_path_base=s'=> \$cam_path_base,  # path_base of the associated camera run
    5253           'outroot=s'      => \$outroot,     # "directory" for temporary images (may be nebulous)
     
    183184my $image = $uri;
    184185
    185 my ($mask, $ch_mask, $weight, $astrom);
     186my ($image, $mask, $ch_mask, $weight, $astrom);
    186187
    187188if ($stage eq "raw") {
     189    $image = $uri;
    188190    $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base);
    189191    $mask   = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id) if $release ;
     
    191193    # we use the mask output from the camera stage for input and replace
    192194    # the output of the chip stage with that mask as well.
     195    $image  = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id);
    193196    $mask   = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
    194197    $ch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
     
    196199    $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base);
    197200} elsif ($stage eq "warp") {
     201    $image  = $ipprc->filename("PSWARP.OUTPUT", $path_base);
    198202    $mask   = $ipprc->filename("PSWARP.OUTPUT.MASK", $path_base);
    199203    $weight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $path_base);
    200204} elsif ($stage eq "diff") {
    201     $mask   = $ipprc->filename("PPSUB.OUTPUT.MASK", $path_base);
    202     $weight = $ipprc->filename("PPSUB.OUTPUT.VARIANCE", $path_base);
     205    my $name = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT"; # Base name for images
     206    $image  = $ipprc->filename($name, $path_base);
     207    $mask   = $ipprc->filename("$name.MASK", $path_base);
     208    $weight = $ipprc->filename("$name.VARIANCE", $path_base);
    203209}
    204210
  • trunk/ippScripts/scripts/magic_process.pl

    r24166 r24174  
    3737
    3838# Parse the command-line arguments
    39 my ($magic_id, $node, $camera, $dbname, $outroot, $template_uri, $save_temps, $verbose, $no_update, $no_op, $logfile);
     39my ($magic_id, $node, $camera, $dbname, $outroot, $save_temps, $verbose, $no_update, $no_op, $logfile);
    4040
    4141GetOptions(
     
    4545           'dbname=s'        => \$dbname,     # Database name
    4646           'outroot=s'       => \$outroot,    # Output root name
    47            'template_uri=s'  => \$template_uri,# uri of diff template
    4847           'save-temps'      => \$save_temps, # Save temporary files?
    4948           'verbose'         => \$verbose,    # Print stuff?
     
    5958    defined $node and
    6059    defined $camera and
    61     defined $outroot and
    62     defined $template_uri;
     60    defined $outroot;
    6361
    6462my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $node, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     
    138136        }
    139137
    140         my $template = $ipprc->file_resolve($template_uri);
    141         &my_die("failed to resolve template_uri: $template_uri", $magic_id, $node, $PS_EXIT_DATA_ERROR)
    142             if !($template);
     138        my $template = resolve_template($innode);
     139        &my_die("failed to resolve template", $magic_id, $node, $PS_EXIT_DATA_ERROR)
     140            unless defined $template;
    143141
    144142        $command .= " --detect --image $image --mask $mask --weight $weight -k $template";
     
    189187            foreach my $innode (@$inputs) {
    190188                # root for inputs from previous stage
    191                 my $in_uri = $innode->{uri};
    192                 print $sfh "$in_uri\n";
    193 
    194                 cat_list_to_list($in_fh, $in_uri, "input.list");
     189                my $in_path_base = $innode->{magic_path_base};
     190                print $sfh "$in_path_base\n";
     191
     192                cat_list_to_list($in_fh, $in_path_base, "input.list");
    195193                # build input lists by combining the lists from
    196194                # previous stages
    197                 cat_list_to_list($ifh, $in_uri, "image.list");
    198                 cat_list_to_list($mfh, $in_uri, "mask.list");
    199                 cat_list_to_list($wfh, $in_uri, "weight.list");
     195                cat_list_to_list($ifh, $in_path_base, "image.list");
     196                cat_list_to_list($mfh, $in_path_base, "mask.list");
     197                cat_list_to_list($wfh, $in_path_base, "weight.list");
    200198            }
    201199            close $in_fh;
     
    243241    $command   .= " -magic_id $magic_id";
    244242    $command   .= " -node $node";
    245     $command   .= " -uri $outroot";
     243    $command   .= " -path_base $outroot";
    246244    $command   .= " -dbname $dbname" if defined $dbname;
    247245
     
    262260    my $resolved = $ipprc->file_resolve($streaks_file);
    263261
    264     my $fh;
    265     open $fh, "<$resolved" or
    266         &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
    267     # the first line in the streaks file contains the number of streaks found
    268     my $num_streaks = <$fh>;
    269     chomp $num_streaks;
    270     close $fh;
    271     print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose;
     262    my $num_streaks = -1;
     263    unless ($no_op) {
     264        my $fh;
     265        open $fh, "<$resolved" or
     266            &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
     267        # the first line in the streaks file contains the number of streaks found
     268        $num_streaks = <$fh>;
     269        chomp $num_streaks;
     270        close $fh;
     271        print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose;
     272    }
    272273
    273274    my $command = "$magictool -addmask";
     
    309310sub cat_list_to_list   {
    310311    my $out = shift;        # output file handle
    311     my $uri = shift;        # uri to append ...
     312    my $path_base = shift;  # path_base to append ...
    312313    my $extension = shift;  # ... the extension to
    313314
    314     my $filename = "$uri.$extension";
     315    my $filename = "$path_base.$extension";
    315316
    316317    my $in;
     
    321322}
    322323
    323 sub resolve_inputs {
    324 
     324sub resolve_inputs
     325{
    325326    my $node = shift;
    326     my $input_base = $node->{path_base};
    327 
    328     my $image = $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT", $input_base));
    329     my $mask = $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT.MASK", $input_base));
    330     my $weight= $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT.VARIANCE", $input_base));
    331 
    332     return ($image, $mask, $weight);
     327    my $input_base = $node->{diff_path_base};
     328
     329    my ($image, $mask, $variance); # Names to return
     330    if ($node->{inverse}) {
     331        $image = "PPSUB.INVERSE";
     332        $mask = "PPSUB.INVERSE.MASK";
     333        $variance = "PPSUB.INVERSE.VARIANCE";
     334    } else {
     335        $image = "PPSUB.OUTPUT";
     336        $mask = "PPSUB.OUTPUT.MASK";
     337        $variance = "PPSUB.OUTPUT.VARIANCE";
     338    }
     339
     340    $image = $ipprc->file_resolve($ipprc->filename($image, $input_base));
     341    $mask = $ipprc->file_resolve($ipprc->filename($mask, $input_base));
     342    $variance= $ipprc->file_resolve($ipprc->filename($variance, $input_base));
     343
     344    return ($image, $mask, $variance);
     345}
     346
     347sub resolve_template
     348{
     349    my $node = shift;
     350
     351    my $image;                  # Name of template to return
     352    my $path_base;              # Base name for name
     353    if (defined $node->{warp_path_base} and $node->{warp_path_base} ne "NULL") {
     354        $path_base = $node->{warp_path_base};
     355        $image = "PSWARP.OUTPUT";
     356    } elsif (defined $node->{stack_path_base} and $node->{stack_path_base} ne "NULL") {
     357        $path_base = $node->{stack_path_base};
     358        $image = "PPSTACK.OUTPUT";
     359    } else {
     360        return undef;
     361    }
     362
     363    $image = $ipprc->file_resolve($ipprc->filename($image, $path_base));
     364
     365    return $image
    333366}
    334367
  • trunk/ippScripts/scripts/magic_tree.pl

    r23688 r24174  
    7373my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    7474
    75 ### Get a list of warpSkyfiles
    76 ### This is a workaround to allow processing with older diffSkyfiles that don't have
    77 ### a wcs. If warp_id is provided, we get the wcs from there
    78 my %warpSkyfiles;                   # hash of warps
    79 if ($warp_id) {
    80     my $command = "$warptool -warped -warp_id $warp_id"; # Command to run
    81     $command .= " -dbname $dbname" if defined $dbname;
    82     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    83         run(command => $command, verbose => $verbose);
    84     unless ($success) {
    85         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    86         &my_die("Unable to perform warptool -warped: $error_code", $magic_id, $error_code);
    87     }
    88 
    89     my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    90         &my_die("Unable to parse metadata config doc", $magic_id, $PS_EXIT_PROG_ERROR);
    91 
    92     my $warps = parse_md_list($metadata) or
    93         &my_die("Unable to parse metadata list", $magic_id, $PS_EXIT_PROG_ERROR);
    94 
    95     # make a hash indexed by skycell_id
    96     foreach my $warp ( @$warps ) {
    97         my $skycell_id = $warp->{skycell_id};
    98         die "failed to lookup skycell_id from warp" if !$skycell_id;
    99         $warpSkyfiles{$skycell_id} = $warp;
    100     }
    101 }
    10275### Get a list of skycells
    10376my @skycells;                   # List of skycells
     
    12699my @fields;
    127100foreach my $input ( @skycells ) {
    128     # the filename method doesn't add the $skycell_id
    129 
    130     # my $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id );
    131     #my $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id );
    132 
    133 #    my $skycellBase = "$outroot/$skycell_id";
    134 #    my $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $skycellBase);
    135 #    $ipprc->skycell_file($tess_id, $skycell_id, $skyfile, $verbose) or &my_die("Unable to generate skycells $skycell_id", $magic_id, $PS_EXIT_PROG_ERROR);
    136 
    137     my $skyfile;
    138     my $skycell_id = $input->{node};
    139     if ($warp_id) {
    140         # Applying the workaround
    141         my $warp = $warpSkyfiles{$skycell_id};
    142         die "warpSkyfile for $skycell_id not found" if !$warp;
    143         my $skyfileBase = $warp->{path_base};
    144         $skyfile = $ipprc->filename("SKYCELL.TEMPLATE", $skyfileBase);
    145     } else {
    146         # using the diffSkyfile
    147         $skyfile = $input->{uri};
    148     }
    149     my $skyfileResolved = $ipprc->file_resolve( $skyfile );
    150 
    151 #    my ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $skyfileResolved );
    152 #    &my_die("Unable to read skycell header: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status;
     101    # We use the WCS in the diff image
     102    my $name = "PPSUB.OUTPUT"; # Name of file
     103    my $skycell_id = $input->{node}; # Name of skycell
     104    my $skyfile = $ipprc->filename($name, $input->{path_base}, $skycell_id); # Filename for diff
     105    my $skyfileResolved = $ipprc->file_resolve( $skyfile ); # Resolved filename
    153106
    154107    my ($header, $status) = (undef, 0);
     
    162115
    163116    # Get the useful header keywords
    164 #    my $naxis1 = $$header{'NAXIS1'} or &my_die("Can't find NAXIS1", $magic_id, $PS_EXIT_SYS_ERROR);
    165117    my $naxis1 = $$header{'NAXIS1'};
    166118    my $naxis2;
     
    181133        $naxis2 = $$header{'ZNAXIS2'} or &my_die("Can't find ZNAXIS2", $magic_id, $PS_EXIT_SYS_ERROR);
    182134    }
    183     my $ctype1 = $$header{'CTYPE1'} or &my_die("Can't find CTYPE1", $magic_id, $PS_EXIT_SYS_ERROR);
    184     my $ctype2 = $$header{'CTYPE2'} or &my_die("Can't find CTYPE2", $magic_id, $PS_EXIT_SYS_ERROR);
    185     my $cdelt1 = $$header{'CDELT1'} or &my_die("Can't find CDELT1", $magic_id, $PS_EXIT_SYS_ERROR);
    186     my $cdelt2 = $$header{'CDELT2'} or &my_die("Can't find CDELT2", $magic_id, $PS_EXIT_SYS_ERROR);
    187     my $crval1 = $$header{'CRVAL1'} or &my_die("Can't find CRVAL1", $magic_id, $PS_EXIT_SYS_ERROR);
    188     my $crval2 = $$header{'CRVAL2'} or &my_die("Can't find CRVAL2", $magic_id, $PS_EXIT_SYS_ERROR);
    189     my $crpix1 = $$header{'CRPIX1'} or &my_die("Can't find CRPIX1", $magic_id, $PS_EXIT_SYS_ERROR);
    190     my $crpix2 = $$header{'CRPIX2'} or &my_die("Can't find CRPIX2", $magic_id, $PS_EXIT_SYS_ERROR);
    191     my $pc11 = $$header{'PC001001'} or &my_die("Can't find PC001001", $magic_id, $PS_EXIT_SYS_ERROR);
    192     my $pc12 = $$header{'PC001002'} or &my_die("Can't find PC001002", $magic_id, $PS_EXIT_SYS_ERROR);
    193     my $pc21 = $$header{'PC002001'} or &my_die("Can't find PC002001", $magic_id, $PS_EXIT_SYS_ERROR);
    194     my $pc22 = $$header{'PC002002'} or &my_die("Can't find PC002002", $magic_id, $PS_EXIT_SYS_ERROR);
     135    my $ctype1 = $$header{'CTYPE1'} or &my_die("Can't find CTYPE1 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     136    my $ctype2 = $$header{'CTYPE2'} or &my_die("Can't find CTYPE2 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     137    my $cdelt1 = $$header{'CDELT1'} or &my_die("Can't find CDELT1 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     138    my $cdelt2 = $$header{'CDELT2'} or &my_die("Can't find CDELT2 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     139    my $crval1 = $$header{'CRVAL1'} or &my_die("Can't find CRVAL1 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     140    my $crval2 = $$header{'CRVAL2'} or &my_die("Can't find CRVAL2 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     141    my $crpix1 = $$header{'CRPIX1'} or &my_die("Can't find CRPIX1 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     142    my $crpix2 = $$header{'CRPIX2'} or &my_die("Can't find CRPIX2 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     143    my $pc11 = $$header{'PC001001'} or &my_die("Can't find PC001001 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     144    my $pc12 = $$header{'PC001002'} or &my_die("Can't find PC001002 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     145    my $pc21 = $$header{'PC002001'} or &my_die("Can't find PC002001 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
     146    my $pc22 = $$header{'PC002002'} or &my_die("Can't find PC002002 in $skyfile", $magic_id, $PS_EXIT_SYS_ERROR);
    195147    my $crota1 = $$header{'CROTA1'};
    196148    my $crota2 = $$header{'CROTA2'};
Note: See TracChangeset for help on using the changeset viewer.