IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28092


Ignore:
Timestamp:
May 25, 2010, 1:39:21 PM (16 years ago)
Author:
eugene
Message:

build staticsky.pl; updates to ippScripts

Location:
trunk/ippScripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/Build.PL

    r27504 r28092  
    5555        scripts/diff_skycell.pl
    5656        scripts/stack_skycell.pl
     57        scripts/staticsky.pl
    5758        scripts/magic_tree.pl
    5859        scripts/magic_process.pl
  • trunk/ippScripts/scripts/staticsky.pl

    r27964 r28092  
    2929my $missing_tools;
    3030my $staticskytool = can_run('staticskytool') or (warn "Can't find staticskytool" and $missing_tools = 1);
    31 my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1);
     31my $psphotStack = can_run('psphotStack') or (warn "Can't find psphotStack" and $missing_tools = 1);
    3232my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    3333if ($missing_tools) {
     
    101101    print $listFile "INPUT   METADATA\n";
    102102
    103     $path_base = $file->{path_base};
    104     my $imageCnv  = $ipprc->filename("PPSTACK.OUTPUT", $file->{path_base} ); # Mask name
    105     my $maskCnv   = $ipprc->filename("PPSTACK.OUTPUT.MASK", $file->{path_base} ); # Mask name
    106     my $weightCnv = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $file->{path_base} ); # Weight name
    107     my $psfCnv    = $ipprc->filename("PSPHOT.PSF.SKY.SAVE", $file->{path_base} ); # PSF name
    108 
    109     my $imageRaw  = $ipprc->filename("PPSTACK.UNCONV", $file->{path_base} ); # Mask name
    110     my $maskRaw   = $ipprc->filename("PPSTACK.UNCONV.MASK", $file->{path_base} ); # Mask name
    111     my $weightRaw = $ipprc->filename("PPSTACK.UNCONV.VARIANCE", $file->{path_base} ); # Weight name
    112 
    113     my $sources   = $ipprc->filename("PSPHOT.OUT.CMF.MEF", $file->{path_base}); # Sources name
    114 
    115     &my_die("Image $image does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $image );
    116     &my_die("Mask $mask does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $mask );
    117     &my_die("Weight $weight does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $weight );
    118     &my_die("PSF $psf does not exist", $stack_id, $PS_EXIT_SYS_ERROR) if ($convolve and not $ipprc->file_exists( $psf ));
    119     &my_die("Sources $sources does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $sources );
    120 
    121     print $listFile "  RAW:IMAGE     STR  " . $imageRaw  . "\n";
    122     print $listFile "  RAW:MASK      STR  " . $maskRaw   . "\n";
    123     print $listFile "  RAW:VARIANCE  STR  " . $weightRaw . "\n";
    124 
    125     print $listFile "  CNV:IMAGE     STR  " . $imageCnv  . "\n";
    126     print $listFile "  CNV:MASK      STR  " . $maskCnv   . "\n";
    127     print $listFile "  CNV:VARIANCE  STR  " . $weightCnv . "\n";
    128     print $listFile "  CNV:PSF       STR  " . $psfCnv    . "\n";
    129 
    130     print $listFile "  SOURCES       STR  " . $sources   . "\n";
    131 
    132     print $listFile "END\n\n";
    133 
     103    # XXX if we take the input from 'warp', we will need to make different selections here
     104    my $path_base = $file->{path_base};
     105    my $imageCnv  = $ipprc->filename("PPSTACK.OUTPUT",          $path_base ); # Image name
     106    my $maskCnv   = $ipprc->filename("PPSTACK.OUTPUT.MASK",     $path_base ); # Mask name
     107    my $weightCnv = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $path_base ); # Weight name
     108
     109    my $imageRaw  = $ipprc->filename("PPSTACK.UNCONV",          $path_base ); # Image name
     110    my $maskRaw   = $ipprc->filename("PPSTACK.UNCONV.MASK",     $path_base ); # Mask name
     111    my $weightRaw = $ipprc->filename("PPSTACK.UNCONV.VARIANCE", $path_base ); # Weight name
     112
     113    my $sources   = $ipprc->filename("PSPHOT.OUT.CMF.MEF",      $path_base ); # Sources name
     114
     115    # XXX is this the correct PSF file?
     116    my $psfCnv    = $ipprc->filename("PPSTACK.TARGET.PSF",      $path_base ); # PSF name
     117
     118    # XXX we could make some different choices if some inputs do not exist...
    134119    &my_die("Couldn't find input: $imageRaw",  $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$imageRaw");
    135120    &my_die("Couldn't find input: $maskRaw",   $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$maskRaw");
     
    140125    &my_die("Couldn't find input: $psfCnv",    $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$psfCnv");
    141126    &my_die("Couldn't find input: $sources",   $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists("$sources");
     127
     128    print $listFile "  RAW:IMAGE     STR  " . $imageRaw  . "\n";
     129    print $listFile "  RAW:MASK      STR  " . $maskRaw   . "\n";
     130    print $listFile "  RAW:VARIANCE  STR  " . $weightRaw . "\n";
     131
     132    print $listFile "  CNV:IMAGE     STR  " . $imageCnv  . "\n";
     133    print $listFile "  CNV:MASK      STR  " . $maskCnv   . "\n";
     134    print $listFile "  CNV:VARIANCE  STR  " . $weightCnv . "\n";
     135    print $listFile "  CNV:PSF       STR  " . $psfCnv    . "\n";
     136
     137    print $listFile "  SOURCES       STR  " . $sources   . "\n";
     138
     139    print $listFile "END\n\n";
    142140}
    143141
     
    149147}
    150148
    151 print "reduction: $reduction\n";
     149print "reduction:     $reduction\n";
    152150print "recipe_psphot: $recipe_psphot\n";
    153 
    154 # Get the output filenames
    155 my $outputName = $ipprc->filename("PPSUB.OUTPUT", $outroot);
    156 my $outputMask = $ipprc->filename("PPSUB.OUTPUT.MASK", $outroot);
    157 my $outputVariance = $ipprc->filename("PPSUB.OUTPUT.VARIANCE", $outroot);
    158 my $outputSources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $outroot);
    159 my $jpeg1Name = $ipprc->filename("PPSUB.OUTPUT.JPEG1", $outroot);
    160 my $jpeg2Name = $ipprc->filename("PPSUB.OUTPUT.JPEG2", $outroot);
    161 my $configuration = $ipprc->filename("PPSUB.CONFIG", $outroot);
    162 my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot);
    163 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot);
    164 
    165 if ($run_state eq 'update') {
    166     $traceDest .= '.update';
    167     $outputStats .= '.update';
    168 }
    169 
    170 my ($inverseName, $inverseMask, $inverseVariance, $inverseSources);
    171 if ($inverse) {
    172     $inverseName = $ipprc->filename("PPSUB.INVERSE", $outroot);
    173     $inverseMask = $ipprc->filename("PPSUB.INVERSE.MASK", $outroot);
    174     $inverseVariance = $ipprc->filename("PPSUB.INVERSE.VARIANCE", $outroot);
    175     $inverseSources = $ipprc->filename("PPSUB.INVERSE.SOURCES", $outroot);
    176 }
    177151
    178152my $cmdflags;
     
    180154# Perform subtraction
    181155{
    182     my $command = "$ppSub $outroot";
    183     $command .= " -inimage $input";
    184     $command .= " -refimage $template";
    185     $command .= " -inmask $inputMask";
    186     $command .= " -refmask $templateMask";
    187     $command .= " -invariance $inputVariance";
    188     $command .= " -refvariance $templateVariance";
    189     $command .= " -insources $inputSources";
    190     $command .= " -refsources $templateSources";
    191     $command .= " -stats $outputStats";
     156    my $command = "$psphotStack $outroot";
     157    $command .= " -input $listName";
    192158    $command .= " -threads $threads" if defined $threads;
    193     if ($run_state eq "new") {
    194         $command .= " -dumpconfig $configuration";
    195     } else {
    196         my $configurationReal = $ipprc->file_resolve($configuration) or &my_die("Couldn't resolve configuration file: $configuration", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    197         $command .= " -ipprc $configurationReal";
    198     }
    199     $command .= " -save-inconv" if defined $saveInConv;
    200     $command .= " -save-refconv" if defined $saveRefConv;
    201     $command .= " -recipe PPSUB $recipe_ppSub";
    202159    $command .= " -recipe PSPHOT $recipe_psphot";
    203     $command .= " -recipe PPSTATS WARPSTATS";
    204     $command .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE";
    205     $command .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF";
    206     $command .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF";
    207     if ($run_state eq "new") {
    208         $command .= " -photometry";
    209     }
    210     $command .= " -inverse" if $inverse;
    211     $command .= " -tracedest $traceDest -log $logDest";
    212     $command .= " -dbname $dbname" if defined $dbname;
    213     $command .= " -image_id $diff_skyfile_id" if defined $diff_skyfile_id;
    214     $command .= " -source_id $source_id" if defined $source_id;
     160    # $command .= " -dumpconfig $configuration";
     161    # $command .= " -tracedest $traceDest -log $logDest";
     162    # $command .= " -dbname $dbname" if defined $dbname;
     163    # $command .= " -image_id $diff_skyfile_id" if defined $diff_skyfile_id;
     164    # $command .= " -source_id $source_id" if defined $source_id;
    215165
    216166    unless ($no_op) {
     
    219169        unless ($success) {
    220170            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    221             &my_die("Unable to perform ppSub: $error_code", $sky_id, $skycell_id, $error_code);
    222         }
    223 
    224         my $outputStatsReal = $ipprc->file_resolve($outputStats);
    225         &my_die("Couldn't find expected output file: $outputStats", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStatsReal);
     171            &my_die("Unable to perform ppSub: $error_code", $sky_id, $error_code);
     172        }
     173
     174        # my $outputStatsReal = $ipprc->file_resolve($outputStats);
     175        # &my_die("Couldn't find expected output file: $outputStats", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStatsReal);
    226176
    227177        # measure chip stats
    228         $command = "$ppStatsFromMetadata $outputStatsReal - DIFF_SKYCELL";
    229         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    230             run(command => $command, verbose => $verbose);
    231         unless ($success) {
    232             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    233             &my_die("Unable to perform ppStatsFromMetadata: $error_code", $sky_id, $skycell_id, $error_code);
    234         }
    235         foreach my $line (@$stdout_buf) {
    236             $cmdflags .= " $line";
    237         }
    238         chomp $cmdflags;
     178        # $command = "$ppStatsFromMetadata $outputStatsReal - DIFF_SKYCELL";
     179        # ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     180        #     run(command => $command, verbose => $verbose);
     181        # unless ($success) {
     182        #     $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     183        #     &my_die("Unable to perform ppStatsFromMetadata: $error_code", $sky_id, $error_code);
     184        # }
     185        # foreach my $line (@$stdout_buf) {
     186        #     $cmdflags .= " $line";
     187        # }
     188        # chomp $cmdflags;
    239189
    240190        my ($quality) = $cmdflags =~ /-quality (\d+)/; # Quality flag
    241191
    242192        if (!$quality) {
    243             &my_die("Couldn't find expected output file: $outputName", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
    244             &my_die("Couldn't find expected output file: $outputMask", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
    245             &my_die("Couldn't find expected output file: $outputVariance", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance);
    246             &my_die("Couldn't find expected output file: $outputSources", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
    247             &my_die("Couldn't find expected output file: $jpeg1Name",    $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg1Name);
    248             &my_die("Couldn't find expected output file: $jpeg2Name",    $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg2Name);
    249             if ($inverse) {
    250                 &my_die("Couldn't find expected output file: $inverseName", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseName);
    251                 &my_die("Couldn't find expected output file: $inverseMask", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseMask);
    252                 &my_die("Couldn't find expected output file: $inverseVariance", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseVariance);
    253                 &my_die("Couldn't find expected output file: $inverseSources", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseSources);
    254                 if ($run_state eq 'new') {
    255                     &my_die("Couldn't find expected output file: $configuration", $sky_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
    256                 }
    257             }
     193
     194            # Get the output filenames
     195            # we have one set of output files per input file set
     196            for (my $i = 0; $i < @$files; $i++) {
     197                my $outputName     = $ipprc->filename("PSPHOT.STACK.OUTPUT.IMAGE", $outroot);
     198                my $outputMask     = $ipprc->filename("PSPHOT.STACK.OUTPUT.MASK", $outroot);
     199                my $outputVariance = $ipprc->filename("PSPHOT.STACK.OUTPUT.VARIANCE", $outroot);
     200                my $outputSources  = $ipprc->filename("PSPHOT.STACK.OUTPUT", $outroot);
     201
     202                &my_die("Couldn't find expected output file: $outputName", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
     203                &my_die("Couldn't find expected output file: $outputMask", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
     204                &my_die("Couldn't find expected output file: $outputVariance", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance);
     205                &my_die("Couldn't find expected output file: $outputSources", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
     206            }
     207
     208            #my $configuration  = $ipprc->filename("PPSUB.CONFIG", $outroot);
     209            #my $outputStats    = $ipprc->filename("SKYCELL.STATS", $outroot);
     210            #my $traceDest      = $ipprc->filename("TRACE.EXP", $outroot);
     211
     212            # if ($run_state eq 'update') {
     213            #   $traceDest .= '.update';
     214            #   $outputStats .= '.update';
     215            # }
     216
     217            my $chisqName     = $ipprc->filename("PSPHOT.CHISQ.IMAGE", $outroot);
     218            my $chisqMask     = $ipprc->filename("PSPHOT.CHISQ.MASK", $outroot);
     219            my $chisqVariance = $ipprc->filename("PSPHOT.CHISQ.VARIANCE", $outroot);
     220
     221            &my_die("Couldn't find expected output file: $chisqName",     $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqName);
     222            &my_die("Couldn't find expected output file: $chisqMask",     $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqMask);
     223            &my_die("Couldn't find expected output file: $chisqVariance", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($chisqVariance);
    258224        }
    259225    } else {
     
    266232    # Add the subtraction result
    267233    {
    268         my $command = "$difftool -sky_id $sky_id -skycell_id $skycell_id";
    269         $command .= " -magicked $magicked" if $magicked;
    270         if ($run_state eq 'new') {
    271             $command .= " -adddiffskyfile -path_base $outroot";
    272             $command .= " $cmdflags";
    273             $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
    274             $command .= " -hostname $host" if defined $host;
    275         } else {
    276             $command .= " -tofullskyfile";
    277         }
     234        my $command = "$staticskytool -sky_id $sky_id";
     235        # if ($run_state eq 'new') {
     236        $command .= " -addresult -path_base $outroot";
     237        $command .= " $cmdflags";
     238        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
     239        $command .= " -hostname $host" if defined $host;
     240        # } else {
     241        #     $command .= " -tofullskyfile";
     242        # }
    278243        $command .= " -dbname $dbname" if defined $dbname;
    279244
     
    285250                "Unable to perform difftool -adddiffskyfile" :
    286251                "Unable to perform difftool -tofullskyfile";
    287             &my_die("$err_message: $error_code", $sky_id, $skycell_id, $error_code);
     252            &my_die("$err_message: $error_code", $sky_id, $error_code);
    288253        }
    289254    }
     
    300265
    301266    warn($msg);
    302     if (defined $sky_id and defined $skycell_id and not $no_update) {
    303         my $command = "$difftool -sky_id $sky_id -skycell_id $skycell_id -fault $exit_code";
     267    if (defined $sky_id and not $no_update) {
     268        my $command = "$staticskytool -sky_id $sky_id -fault $exit_code";
    304269        if ($run_state eq 'new') {
    305270            $command .= " -adddiffskyfile";
Note: See TracChangeset for help on using the changeset viewer.