IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 5, 2009, 11:13:29 AM (17 years ago)
Author:
beaumont
Message:

Finished ppStack visualization. Unified the way in which visualizations are invoked, plotting windows are closed, etc

Location:
branches/cnb_branches/cnb_branch_20090215
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090215

  • branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/diff_skycell.pl

    r21395 r23197  
    2727use Pod::Usage qw( pod2usage );
    2828
     29# Look for programs we need
     30my $missing_tools;
     31my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
     32my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1);
     33my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     34if ($missing_tools) {
     35    warn("Can't find required tools.");
     36    exit($PS_EXIT_CONFIG_ERROR);
     37}
     38
    2939my ($diff_id, $dbname, $threads, $outroot, $reduction, $verbose, $no_update, $no_op, $redirect);
    3040my ($skycell_id, $diff_skyfile_id);
    3141GetOptions(
    3242    'diff_id=s'         => \$diff_id, # Diff identifier
    33     'skycell_id=s'      => \$skycell_id, # Diff identifier
     43    'skycell_id=s'      => \$skycell_id, # Skycell identifier
    3444    'diff_skyfile_id=s' => \$diff_skyfile_id, # Diff identifier
    3545    'dbname|d=s'        => \$dbname, # Database name
     
    5262    and defined $outroot;
    5363
     64# Unhandled exceptions should be passed on to my_die so they get pushed into the database
     65$SIG{__DIE__} = sub { die @_ if $^S;
     66                      my_die( $_[0], $diff_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR ); };
     67
    5468# XXX camera is not known here; cannot use filerules...
    5569# my $logDest = $ipprc->filename("LOG.EXP", $outroot);
    56 
    5770my $logDest = "$outroot.log";
    5871$ipprc->redirect_output($logDest) if $redirect;
    5972
    6073my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF);
    61 
    62 # Look for programs we need
    63 my $missing_tools;
    64 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
    65 my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1);
    66 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    67 if ($missing_tools) {
    68     warn("Can't find required tools.");
    69     exit($PS_EXIT_CONFIG_ERROR);
    70 }
    7174
    7275# Get list of components for subtraction
     
    8083    unless ($success) {
    8184        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    82         &my_die("Unable to perform difftool -inputskyfile: $error_code", $diff_id, $error_code);
     85        &my_die("Unable to perform difftool -inputskyfile: $error_code", $diff_id, $skycell_id, $error_code);
    8386    }
    8487
    8588    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
    86         &my_die("Unable to parse metadata config doc", $diff_id, $PS_EXIT_PROG_ERROR);
     89        &my_die("Unable to parse metadata config doc", $diff_id, $skycell_id, $PS_EXIT_PROG_ERROR);
    8790    $files = parse_md_list($metadata) or
    88         &my_die("Unable to parse metadata list", $diff_id, $PS_EXIT_PROG_ERROR);
    89 }
    90 
    91 &my_die("Subtraction list does not contain exactly two elements", $diff_id, $PS_EXIT_SYS_ERROR) unless
    92     scalar @$files == 2;
     91        &my_die("Unable to parse metadata list", $diff_id, $skycell_id, $PS_EXIT_PROG_ERROR);
     92}
     93
     94&my_die("Subtraction list does not contain exactly two elements", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless scalar @$files == 2;
    9395
    9496# Identify the input and the template
     
    123125    }
    124126    if (defined $tess_id) {
    125         &my_die("Tesselation identifiers don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless
     127        &my_die("Tesselation identifiers don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless
    126128            $file->{tess_id} eq $tess_id;
    127129    } else {
     
    129131    }
    130132    if (defined $skycell_id) {
    131         &my_die("Skycell identifiers don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless
     133        &my_die("Skycell identifiers don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless
    132134            $file->{skycell_id} eq $skycell_id;
    133135    } else {
     
    135137    }
    136138    if (defined $camera) {
    137         &my_die("Cameras don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera;
     139        &my_die("Cameras don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera;
    138140    } else {
    139141        $camera = $file->{camera};
     
    142144}
    143145
    144 &my_die("Unable to identify template", $diff_id, $PS_EXIT_SYS_ERROR) unless defined $template;
    145 &my_die("Unable to identify input", $diff_id, $PS_EXIT_SYS_ERROR) unless defined $input;
    146 &my_die("Unable to identify camera", $diff_id, $PS_EXIT_SYS_ERROR) unless defined $camera;
     146&my_die("Unable to identify template", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $template;
     147&my_die("Unable to identify input", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $input;
     148&my_die("Unable to identify camera", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $camera;
    147149$ipprc->define_camera($camera);
    148150
     
    152154my $recipe_psphot  = $ipprc->reduction($reduction, 'DIFF_PSPHOT'); # Recipe to use for psphot
    153155unless ($recipe_ppSub and $recipe_psphot) {
    154     &my_die("Couldn't find selected reduction for DIFF_PPSUB and DIFF_PSPHOT: $reduction\n", $diff_id, $PS_EXIT_CONFIG_ERROR);
     156    &my_die("Couldn't find selected reduction for DIFF_PPSUB and DIFF_PSPHOT: $reduction\n", $diff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR);
    155157}
    156158
     
    177179print "templateSources: $templateSources\n";
    178180
    179 &my_die("Couldn't find input: $template", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($template);
    180 &my_die("Couldn't find input: $templateMask", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateMask);
    181 &my_die("Couldn't find input: $templateVariance", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateVariance);
    182 &my_die("Couldn't find input: $input", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);
    183 &my_die("Couldn't find input: $inputMask", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);
    184 &my_die("Couldn't find input: $inputVariance", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);
    185 &my_die("Couldn't find input: $templateSources", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateSources);
     181&my_die("Couldn't find input: $template", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($template);
     182&my_die("Couldn't find input: $templateMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateMask);
     183&my_die("Couldn't find input: $templateVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateVariance);
     184&my_die("Couldn't find input: $input", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);
     185&my_die("Couldn't find input: $inputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);
     186&my_die("Couldn't find input: $inputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);
     187&my_die("Couldn't find input: $templateSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateSources);
    186188
    187189# Get the output filenames
     
    210212    $command .= " -recipe PSPHOT $recipe_psphot";
    211213    $command .= " -recipe PPSTATS WARPSTATS";
     214    $command .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE";
    212215    $command .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF";
     216    $command .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF";
    213217    $command .= " -sources $templateSources";
    214218    $command .= " -photometry";
     
    223227    unless ($success) {
    224228        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    225         &my_die("Unable to perform ppSub: $error_code", $diff_id, $error_code);
    226     }
    227     &my_die("Couldn't find expected output file: $outputName", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
    228     &my_die("Couldn't find expected output file: $outputMask", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
    229     &my_die("Couldn't find expected output file: $outputVariance", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance);
    230 #    &my_die("Couldn't find expected output file: $outputSources", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
    231 #    &my_die("Couldn't find expected output file: $bin1Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);
    232 #    &my_die("Couldn't find expected output file: $bin2Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);
     229        &my_die("Unable to perform ppSub: $error_code", $diff_id, $skycell_id, $error_code);
     230    }
     231    &my_die("Couldn't find expected output file: $outputName", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
     232    &my_die("Couldn't find expected output file: $outputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
     233    &my_die("Couldn't find expected output file: $outputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance);
     234#    &my_die("Couldn't find expected output file: $outputSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
     235#    &my_die("Couldn't find expected output file: $bin1Name",    $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);
     236#    &my_die("Couldn't find expected output file: $bin2Name",    $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);
    233237
    234238    my $outputStatsReal = $ipprc->file_resolve($outputStats);
    235     &my_die("Couldn't find expected output file: $outputStats", $diff_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal;
     239    &my_die("Couldn't find expected output file: $outputStats", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal;
    236240
    237241    # measure chip stats
     
    241245    unless ($success) {
    242246        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    243         &my_die("Unable to perform ppStatsFromMetadata: $error_code", $diff_id, $error_code);
     247        &my_die("Unable to perform ppStatsFromMetadata: $error_code", $diff_id, $skycell_id, $error_code);
    244248    }
    245249    foreach my $line (@$stdout_buf) {
     
    263267        unless ($success) {
    264268            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    265             &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $error_code);
     269            &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $skycell_id, $error_code);
    266270        }
    267271    }
     
    273277    my $msg = shift;            # Warning message on die
    274278    my $diff_id = shift;        # Diff identifier
     279    my $skycell_id = shift;     # Skycell identifier
    275280    my $exit_code = shift;      # Exit code to add
    276281
    277282    warn($msg);
    278     if (defined $diff_id and not $no_update) {
     283    if (defined $diff_id and defined $skycell_id and not $no_update) {
    279284        my $command = "$difftool -adddiffskyfile -diff_id $diff_id -skycell_id $skycell_id -code $exit_code";
    280285        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
Note: See TracChangeset for help on using the changeset viewer.