IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 30, 2011, 9:36:02 AM (15 years ago)
Author:
eugene
Message:

merging changes from trunk

Location:
branches/eam_branches/ipp-20110213/ippScripts/scripts
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/diff_skycell.pl

    r30599 r31083  
    6868my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $diff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6969
    70 # XXX camera is not known here; cannot use filerules...
     70my $neb;
     71my $scheme = file_scheme($outroot);
     72if ($scheme and $scheme eq 'neb') {
     73    $neb = $ipprc->nebulous();
     74}
     75
     76# XXX camera is not known here; cannot use filerules...
     77# bills 2011-03-07 This is unfortunate because it prevents us from using prepare_output ...
    7178# my $logDest = $ipprc->filename("LOG.EXP", $outroot);
    7279my $logDest = "$outroot.log";
    73 $logDest .= ".update" if $run_state eq "update";
     80if ($run_state eq 'update') {
     81    $logDest .= '.update';
     82    # ... well we can just do the dirty work here
     83    $ipprc->kill_file($logDest);
     84}
    7485$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;
    7586
     
    137148                $templateVariance = "PPSTACK.UNCONV.VARIANCE";
    138149            }
    139             $templateSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl:161
     150            $templateSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl
    140151            # template is a stack so it doesn't need to be magicked
    141152            $templateMagic = 1;
     
    163174                $inputVariance = "PPSTACK.UNCONV.VARIANCE";
    164175            }
    165             $inputSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl:161
     176            $inputSources = "PSPHOT.OUT.CMF.MEF";  ## this must be consistent with the value in stack_skycell.pl
    166177        } else {
    167178            $input     = "PSWARP.OUTPUT";
     
    249260
    250261# Get the output filenames
    251 my $outputName = $ipprc->filename("PPSUB.OUTPUT", $outroot);
    252 my $outputMask = $ipprc->filename("PPSUB.OUTPUT.MASK", $outroot);
    253 my $outputVariance = $ipprc->filename("PPSUB.OUTPUT.VARIANCE", $outroot);
    254 my $outputSources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $outroot);
    255 my $jpeg1Name = $ipprc->filename("PPSUB.OUTPUT.JPEG1", $outroot);
    256 my $jpeg2Name = $ipprc->filename("PPSUB.OUTPUT.JPEG2", $outroot);
    257 my $configuration = $ipprc->filename("PPSUB.CONFIG", $outroot);
    258 my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot);
    259 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot);
    260 
    261 if ($run_state eq 'update') {
    262     $traceDest .= '.update';
    263     $outputStats .= '.update';
    264 
     262my $configuration;
     263my $outputStats;
     264my $traceDest;
     265my $do_photom = 1;
     266my $dump_config = 1;
     267if ($run_state eq 'new') {
     268    $configuration = prepare_output("PPSUB.CONFIG", $outroot, 1);
     269    $traceDest = prepare_output("TRACE.EXP", $outroot, 1);
     270    $outputStats = prepare_output("SKYCELL.STATS", $outroot, 1);
     271} else {
     272    $do_photom = 0;
     273    $dump_config = 0;
     274    $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, 1);
     275    # we rerun stats because we need the quality value
     276    $outputStats = prepare_output("SKYCELL.STATS.UPDATE", $outroot, 1);
     277    $configuration = $ipprc->filename("PPSUB.CONFIG", $outroot);
     278    if (!$ipprc->file_exists($configuration)) {
     279       print STDERR "WARNING: Config dump file $configuration is missing. Using current recipes and file rules.\n";
     280       $configuration = undef;
     281    }
     282    # use WARPSTATS if we're updating, as we don't care about the new stuff from the STACK and DIFF STATS recipes
    265283    $recipe_ppstats = 'WARPSTATS';
    266284}
     285
     286my $outputName = prepare_output("PPSUB.OUTPUT", $outroot, 1);
     287my $outputMask = prepare_output("PPSUB.OUTPUT.MASK", $outroot, 1);
     288my $outputVariance = prepare_output("PPSUB.OUTPUT.VARIANCE", $outroot, 1);
     289my $outputSources = prepare_output("PPSUB.OUTPUT.SOURCES", $outroot, 1) if $do_photom;
     290my $jpeg1Name = prepare_output("PPSUB.OUTPUT.JPEG1", $outroot, 1);
     291my $jpeg2Name = prepare_output("PPSUB.OUTPUT.JPEG2", $outroot, 1);
    267292
    268293my ($inverseName, $inverseMask, $inverseVariance, $inverseSources);
    269294if ($inverse) {
    270     $inverseName = $ipprc->filename("PPSUB.INVERSE", $outroot);
    271     $inverseMask = $ipprc->filename("PPSUB.INVERSE.MASK", $outroot);
    272     $inverseVariance = $ipprc->filename("PPSUB.INVERSE.VARIANCE", $outroot);
    273     $inverseSources = $ipprc->filename("PPSUB.INVERSE.SOURCES", $outroot);
     295    $inverseName = prepare_output("PPSUB.INVERSE", $outroot, 1);
     296    $inverseMask = prepare_output("PPSUB.INVERSE.MASK", $outroot, 1);
     297    $inverseVariance = prepare_output("PPSUB.INVERSE.VARIANCE", $outroot, 1);
     298    $inverseSources = prepare_output("PPSUB.INVERSE.SOURCES", $outroot, 1) if $do_photom;
    274299}
    275300
     
    289314    $command .= " -stats $outputStats";
    290315    $command .= " -threads $threads" if defined $threads;
    291     if ($run_state eq "new") {
     316    if ($dump_config) {
    292317        $command .= " -dumpconfig $configuration";
    293     } else {
    294         my $configurationReal = $ipprc->file_resolve($configuration) or &my_die("Couldn't resolve configuration file: $configuration", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
    295         $command .= " -ipprc $configurationReal";
     318    } elsif ($configuration) {
     319        $command .= " -ipprc $configuration";
    296320    }
    297321    $command .= " -save-inconv" if defined $saveInConv and $run_state eq "new";
     
    303327    $command .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF";
    304328    $command .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF";
    305     if ($run_state eq "new") {
     329    if ($do_photom) {
    306330        $command .= " -photometry";
    307331    } else {
     
    322346        }
    323347
     348        check_output($outputStats, 1);
    324349        my $outputStatsReal = $ipprc->file_resolve($outputStats);
    325         &my_die("Couldn't find expected output file: $outputStats", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStatsReal);
    326350
    327351        # measure chip stats
     
    341365
    342366        if (!$quality) {
    343             &my_die("Couldn't find expected output file: $outputName", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
    344             &my_die("Couldn't find expected output file: $outputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
    345             &my_die("Couldn't find expected output file: $outputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance);
    346             &my_die("Couldn't find expected output file: $outputSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
    347             &my_die("Couldn't find expected output file: $jpeg1Name",    $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg1Name);
    348             &my_die("Couldn't find expected output file: $jpeg2Name",    $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($jpeg2Name);
     367            check_output($outputName, 0);
     368            check_output($outputMask, 0);
     369            check_output($outputVariance, 0);
     370            check_output($outputSources, 1) if $do_photom;
     371            check_output($jpeg1Name, 1);
     372            check_output($jpeg2Name, 1);
    349373            if ($inverse) {
    350                 &my_die("Couldn't find expected output file: $inverseName", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseName);
    351                 &my_die("Couldn't find expected output file: $inverseMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseMask);
    352                 &my_die("Couldn't find expected output file: $inverseVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseVariance);
    353                 &my_die("Couldn't find expected output file: $inverseSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inverseSources);
     374                check_output($inverseName, 0);
     375                check_output($inverseMask, 0);
     376                check_output($inverseVariance, 0);
     377                check_output($inverseSources, 1) if $do_photom;
    354378                if ($run_state eq 'new') {
    355                     &my_die("Couldn't find expected output file: $configuration", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
     379                    check_output($configuration, 1);
    356380                }
    357381            }
     
    391415    }
    392416}
     417exit 0;
     418
     419
     420# Prepare to write to an output file
     421#   Lookup the filename in the rules.
     422#   Make sure that if file exists and is a nebulous file that there is only one instance
     423#   Deal with files that have been lost.
     424sub prepare_output
     425{
     426    my $filerule = shift;
     427    my $outroot  = shift;
     428    my $delete = shift;
     429    $delete = 0 if !defined $delete;
     430
     431    my $error;
     432    my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error)
     433                    or &my_die("failed to prepare output file for: $filerule", $diff_id, $skycell_id, $error);
     434    return $output;
     435}
     436
     437sub check_output
     438{
     439    my $file = shift;
     440    my $replicate = shift;
     441
     442    if (!defined $file) {
     443        return;
     444    }
     445
     446    &my_die("Couldn't find expected output file: $file",  $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
     447
     448    if ($replicate and $neb) {
     449        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR);
     450    }
     451}
    393452
    394453
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/dist_bundle.pl

    r30676 r31083  
    7070
    7171# Parse the command-line arguments
    72 my ($camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $alt_path_base, $clean);
     72my ($camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $alt_path_base, $clean, $exp_type);
    7373my ($outroot, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix);
    7474my ($dbname, $save_temps, $verbose, $no_update, $logfile);
     
    8989           'alt_path_base=s'=> \$alt_path_base,  # path to alternate inputs
    9090           'outroot=s'      => \$outroot,    # outroot
     91           'exp_type=s'     => \$exp_type,   # exp_type (only used for raw stage
    9192           'prefix=s'       => \$prefix,     # "prefix" to apply to filenames
    9293           'clean'          => \$clean,      # create clean distribution
     
    99100
    100101pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    101 pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --outroot",
     102pod2usage( -msg => "Required options: --camera --stage --stage_id --component --exp_type --path_base --outroot",
    102103           -exitval => 3) unless
    103104    defined $camera and
     
    105106    defined $stage_id and
    106107    defined $component and
     108    defined $exp_type and
    107109    defined $path_base and
    108110    defined $outroot;
     
    110112$ipprc->redirect_output($logfile) if $logfile;
    111113
    112 if (($stage eq 'raw') and !$clean and !defined $chip_path_base) {
    113     pod2usage( -msg => "Required options: --chip_path_base for raw stage", -exitval => 3);
     114if ($stage eq 'raw' and !$clean and !$no_magic) {
     115    # need to be able to find chip mask file
     116    if ($exp_type eq 'OBJECT' and !defined $chip_path_base) {
     117        pod2usage( -msg => "Required options: --chip_path_base for raw stage", -exitval => 3);
     118    }
    114119}
    115120
     
    123128my $file_list = get_file_list($stage, $component, $path_base, $clean);
    124129
    125 if (($stage ne 'raw') and ($stage ne 'fake')) {
     130if (($stage ne 'raw') and ($stage ne 'fake') and !$poor_quality) {
    126131    # If the file list is empty it is an error because we should at least get a config dump file
    127132    # except for fake stage which doesn't do anything yet
     
    493498            push @file_list, \%image;
    494499
    495             my %burntool_table;
    496             $burntool_table{file_rule} = "BURNTOOL.TABLE";
    497             $burntool_table{name} = "$path_base.burn.tbl";
    498             push @file_list, \%burntool_table;
     500            if ($exp_type eq 'OBJECT' and $camera eq 'GPC1') {
     501                my %burntool_table;
     502                $burntool_table{file_rule} = "BURNTOOL.TABLE";
     503                $burntool_table{name} = "$path_base.burn.tbl";
     504                push @file_list, \%burntool_table;
     505            }
    499506        }
    500507        return \@file_list;
     
    541548    my $resolved = $ipprc->file_resolve($config_file);
    542549
     550    if (!$resolved and $poor_quality) {
     551        print STDERR "non config file found but continuing since component has poor quality\n";
     552        return undef
     553    }
    543554    &my_die("failed to resolve name of config dump file: $config_file_rule", $component,
    544555                    $PS_EXIT_CONFIG_ERROR) if (!$resolved);
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/dist_component.pl

    r30489 r31083  
    3737# Parse the command-line arguments
    3838my ($dist_id, $camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $clean, $alt_path_base);
    39 my ($outdir, $run_state, $data_state, $magicked, $no_magic, $poor_quality);
     39my ($outdir, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $exp_type);
    4040my ($dbname, $save_temps, $verbose, $no_update, $logfile);
    4141
     
    5353           'no_magic'       => \$no_magic,   # magic is not required for this distribution run
    5454           'magicked'       => \$magicked,   # magicked state for this component
     55           'exp_type=s'     => \$exp_type,
    5556           'alt_path_base=s'=> \$alt_path_base,  # path to alternate inputs
    5657           'outdir=s'       => \$outdir,     # "directory" for outputs
     
    8182$temproot = "/tmp" if !defined $temproot;
    8283
    83 if (($stage eq 'raw') and !$clean and !defined $chip_path_base) {
    84     pod2usage( -msg => "Required options: --chip_path_base for raw stage", -exitval => 3);
     84if (($stage eq 'raw') and !$clean and !(defined $chip_path_base and defined $exp_type)) {
     85    pod2usage( -msg => "Required options: --chip_path_base --exp_type for raw stage", -exitval => 3);
    8586}
    8687
     
    105106    $command .= " --magicked" if defined $magicked;
    106107    $command .= " --alt_path_base $alt_path_base" if defined $alt_path_base;
     108    $command .= " --exp_type $exp_type" if defined $exp_type;
    107109    $command .= " --clean" if defined $clean;
    108110    $command .= " --save-temps" if defined $save_temps;
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/ipp_apply_burntool_single.pl

    r30812 r31083  
    131131        run ( command => $regtool_status_cmd, verbose => $verbose );
    132132    unless ($success) {
     133        print "Unsuccessful at running regtool -checkstatus, aborting continue\n";
    133134        $continue = 0;
    134135    }
     
    237238        $command .= " -set_state full ";
    238239    }
     240       
    239241    $status = vsystem ($command, $REALRUN);
    240242    if ($status) {
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/ipp_cleanup.pl

    r30676 r31083  
    130130        $status = 0 unless defined $path_base and $path_base ne "NULL";
    131131
     132        my $poor_quality = $imfile->{quality} > 0;
     133
    132134        # don't clean up unless the data needed to update is available
    133135        # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent
    134136        # goto_scrubbed now requires the config file to not exist.
    135         if ($status) {
     137        if ($status and !$poor_quality) {
    136138            if ($mode eq "goto_cleaned") {
    137139                my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
     
    19021904
    19031905    foreach my $file (@$files) {
    1904         print STDERR "unlinking $stage $stage_id $file";
     1906        print STDERR "unlinking $stage $stage_id $file\n";
    19051907
    19061908        my $error_code = $ipprc->kill_file($file);
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak_revert.pl

    r30812 r31083  
    204204
    205205    # only revert sources if this is a new run, not one being updated
    206     if ($run_state eq 'new') {
     206    if (($run_state eq 'new') or ($run_state eq 'goto_restored')) {
    207207        $sources = $ipprc->filename("PSPHOT.OUTPUT", $path_base, $class_id);
    208208        $bsources = $ipprc->filename("PSPHOT.OUTPUT", $backup_path_base, $class_id);
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/minidvodb_merge.pl

    r28311 r31083  
    1616my $dtime_relphot;
    1717my $dtime_merge;
     18my $dtime_verify;
     19my $dtime_script;
    1820
    1921use vars qw( $VERSION );
     
    3638my $relphot = can_run('relphot') or (warn "Can't find relphot" and $missing_tools = 1);
    3739my $relastro = can_run('relastro') or (warn "Can't find relastro" and $missing_tools = 1);
     40my $dvoverify = can_run('dvoverify') or (warn "Can't find dvoverify" and $missing_tools = 1);
     41
     42
    3843if ($missing_tools) {
    3944    warn("Can't find required tools.");
     
    8792unless ($no_op) {
    8893    if (defined $mergedvodbReal) {
     94
     95        #this is chopped into several parts:  addstar, relphot, dvoverify, merge
     96
     97
     98        #addstar
    8999        {
    90100            my $command  = "$addstar -resort";
     
    105115            print "addstar -resort time $dtime_addstar\n";
    106116        }
     117
     118        #relphot
    107119
    108120        {
     
    124136            print "relphot time $dtime_relphot\n";
    125137        }
     138        #dvoverify
     139        {
     140            my $command  = "$dvoverify -s $minidvodb";
     141            print "$command\n";
     142            my $mjd_dvoverify_start = DateTime->now->mjd;   # MJD of starting script
     143
     144            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     145                run(command => $command, verbose => $verbose);
     146            unless ($success) {
     147                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     148                &my_die("Unable to perform dvoverify: $error_code", $mergedvodb, $error_code);
     149            }
     150            $dtime_verify = 86400.0*(DateTime->now->mjd - $mjd_dvoverify_start);   # MJD of starting script
     151            print "dvoverify time $dtime_verify\n";
     152        }
     153
     154
     155        #Merge
    126156
    127157        my $this_is_the_first;
     
    190220
    191221        {
     222
     223            $dtime_script = 86400.0*(DateTime->now->mjd - $mjd_start);
     224
     225
    192226            my $command = "addtool -minidvodb_id $minidvodb_id";
    193227            $command .= " -addminidvodbprocessed";
     
    197231            $command .= " -dtime_resort $dtime_resort" if defined $dtime_resort;
    198232            $command .= " -dtime_merge $dtime_merge" if defined $dtime_merge;
    199             $command .= " -dbname $dbname" if defined $dbname;
     233            $command .= " -dtime_script $dtime_script" if defined $dtime_script;
     234            $command .= " -dtime_verify $dtime_verify" if defined $dtime_verify;
     235            $command .= " -dbname $dbname" if defined $dbname;
    200236            #print $command;
    201237
     
    236272        $command .= " -dtime_resort $dtime_resort" if defined $dtime_resort;
    237273        $command .= " -dtime_merge $dtime_merge" if defined $dtime_merge;
     274    $command .= " -dtime_script $dtime_script" if defined $dtime_script;
     275    $command .= " -dtime_verify $dtime_verify" if defined $dtime_verify;
    238276        $command .= " -dbname $dbname" if defined $dbname;
    239277
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/register_exp.pl

    r30553 r31083  
    189189
    190190    if ($exptype ne 'OBJECT') {
    191         print "Aborting because exptype doesn't claim to be OBJECT: $exptype\n";
     191        print "Skipping because exptype doesn't claim to be OBJECT: $exptype\n";
    192192        return(undef,undef,undef,"reg",undef,undef,undef);
    193193    }
    194194    if ($obsmode eq 'ENGINEERING') {
    195         print "Aborting because we don't queue engineering data to chip\n";
     195        print "Skipping because we don't queue engineering data to chip\n";
    196196        return(undef,undef,undef,"reg",undef,undef,undef);
    197197    }
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/register_imfile.pl

    r30812 r31083  
    267267
    268268if ((abs($burntoolStateCurrent) != $burntoolStateTarget)&&
    269     (!is_daytime($dateobs,$sunrise,$sunset))) {
     269    (!is_daytime($dateobs,$sunrise,$sunset))&&
     270    (!is_ccim($tmp_exp_name,$exp_type))) {
    270271    my $mdcParser  = PS::IPP::Metadata::Config->new;
    271272
     
    389390    my $exp_name = shift;
    390391    my $exp_type = shift;
    391  
     392    $exp_type =~ s/'//g;
    392393    # needs to match regtool.c checks for "is_ccim".
    393394    if ($exp_name =~ /c/) {
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/stack_skycell.pl

    r30676 r31083  
    6565    and defined $run_state;
    6666
     67# lists of file rules which we expect to produce output output
     68my @outputList = qw(
     69PPSTACK.OUTPUT
     70PPSTACK.OUTPUT.MASK
     71PPSTACK.OUTPUT.VARIANCE
     72PPSTACK.OUTPUT.EXP         
     73PPSTACK.OUTPUT.EXPNUM       
     74PPSTACK.OUTPUT.EXPWT
     75PPSTACK.TARGET.PSF         
     76PPSTACK.OUTPUT.JPEG1       
     77PPSTACK.OUTPUT.JPEG2       
     78PPSTACK.CONFIG             
     79);
     80# produced if we run photometry
     81my @outputListPhotom = qw(
     82PSPHOT.OUT.CMF.MEF
     83);
     84# extra outputs when convolving
     85my @outputListUnconv = qw(
     86PPSTACK.UNCONV
     87PPSTACK.UNCONV.MASK
     88PPSTACK.UNCONV.VARIANCE
     89PPSTACK.UNCONV.EXP         
     90PPSTACK.UNCONV.EXPNUM       
     91PPSTACK.UNCONV.EXPWT
     92);
     93
    6794my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6895$| = 1;
     
    73100my $logDest = "$outroot.log";
    74101
    75 my $do_stats;
    76 if ($run_state eq 'new') {
    77     $do_stats = 1;
    78 } else {
     102if ($run_state eq 'update') {
    79103    $logDest .= ".update";
    80104}
    81105
    82106$ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $stack_id, $PS_EXIT_SYS_ERROR ) if $redirect;
     107
     108my $neb;
     109my $scheme = file_scheme($outroot);
     110if ($scheme and $scheme eq 'neb') {
     111    $neb = $ipprc->nebulous();
     112}
     113
    83114
    84115my $temp_images_exist = 0;
     
    173204my $output_nocomp = metadataLookupBool($recipe, 'OUTPUT.NOCOMP'); # change filerules to produced uncompressed output images
    174205my $output_logflux = metadataLookupBool($recipe, 'OUTPUT.LOGFLUX'); # change filerules to produce logflux compressed output images.
    175 
     206my $replicate_outputs = (defined($neb) and metadataLookupBool($recipe, 'OUTPUT.REPLICATE')); # replicate output images
    176207if ($output_nocomp and $output_logflux) {
    177208    &my_die("Unable to not compress and logflux compress simultaneously. Check config.",$stack_id, $PS_EXIT_CONFIG_ERROR);
     
    212243print "I've checked everything: $stack_id\n";
    213244
    214 # Get the output filenames
    215 my $outputName = $ipprc->filename("PPSTACK.OUTPUT", $outroot);
    216 my $outputMask = $ipprc->filename("PPSTACK.OUTPUT.MASK", $outroot);
    217 my $outputWeight = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $outroot);
    218 my $outputSources = $photometry ? $ipprc->filename("PSPHOT.OUT.CMF.MEF", $outroot) : undef; ## this must be consistent with the value in diff_skycell.pl:101
     245# Prepare the output files
     246my @outputFiles;
     247prepare_outputs(\@outputFiles, \@outputList, $outroot);
     248prepare_outputs(\@outputFiles, \@outputListPhotom, $outroot) if $photometry;
     249prepare_outputs(\@outputFiles, \@outputListUnconv, $outroot) if $convolve;
     250
     251# we need the output image name for the database
     252my $outputName = $outputFiles[0];
    219253
    220254## use an explicit stack name for psphot output objects
    221 #my $bin1Name =  $ipprc->filename("PPSTACK.BIN1", $outroot);
    222 #my $bin2Name =  $ipprc->filename("PPSTACK.BIN2", $outroot);
    223 my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot);
    224 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot);
    225 $traceDest .= ".update" if $run_state eq 'update';
    226 my $configuration = $ipprc->filename("PPSTACK.CONFIG", $outroot);
     255my $do_stats = 1;   
     256my $outputStats;
     257my $traceDest;
     258my $configuration = prepare_output("PPSTACK.CONFIG", $outroot, 1);
     259if ($run_state eq 'new') {
     260    $outputStats = prepare_output("SKYCELL.STATS", $outroot, 1);
     261    $traceDest = prepare_output("TRACE.EXP", $outroot, 1);
     262    push @outputFiles, $configuration;
     263    push @outputFiles, $outputStats;
     264} else {
     265    # we need to do stats regardless because we need the quality flag
     266    # $do_stats = 0;
     267    $outputStats = prepare_output("SKYCELL.STATS.UPDATE", $outroot, 1) if $do_stats;
     268    $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, 1);
     269}
     270
    227271$temp_images_exist = 1;  # failures after this point should attempt to delete the temp images
    228272
    229 # for update we need to resolve the config filename here because the code that reads it
    230 # doesn't know how to resolve paths. (The information is stored in the configuration file)
    231 $configuration = $ipprc->file_resolve($configuration) if ($run_state eq 'update');
    232 
    233273my $cmdflags;
    234 
    235274
    236275# Perform stacking
    237276unless ($no_op) {
    238277    my $command = "$ppStack -input $listName $outroot";
    239     $command .= " -stats $outputStats" if $do_stats;;
     278    $command .= " -stats $outputStats" if $do_stats;
    240279    $command .= " -recipe PPSTACK $recipe_ppStack";
    241280    $command .= " -recipe PPSUB $recipe_ppSub";
     
    311350
    312351    if (!$quality) {
    313         &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);
    314         &my_die("Couldn't find expected output file: $outputMask", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
    315         &my_die("Couldn't find expected output file: $outputWeight", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
    316         if ($photometry) {
    317             &my_die("Couldn't find expected output file: $outputSources", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
    318         }
    319         if ($run_state eq 'new') {
    320             &my_die("Couldn't find expected output file: $configuration", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
    321         }
    322 #       &my_die("Couldn't find expected output file: $bin1Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);
    323 #       &my_die("Couldn't find expected output file: $bin2Name",    $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);
     352        check_outputs(\@outputFiles, $replicate_outputs);
    324353    }
    325354
     
    357386}
    358387
    359 print "I've updated teh database: $stack_id\n";
     388print "I've updated the database: $stack_id\n";
    360389
    361390
     
    423452    }
    424453}
     454sub prepare_output
     455{
     456    my $filerule = shift;
     457    my $outroot  = shift;
     458    my $delete = shift;
     459    $delete = 0 if !defined $delete;
     460
     461    my $error;
     462    my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error)
     463                    or &my_die("failed to prepare output file for: $filerule", $stack_id, $error);
     464    return $output;
     465}
     466
     467sub prepare_outputs
     468{
     469    my $fileList = shift;
     470    my $ruleList = shift;
     471    my $outroot = shift;
     472   
     473    foreach my $rule (@$ruleList) {
     474        push @$fileList, prepare_output($rule, $outroot, 1);
     475    }
     476}
     477
     478sub check_output
     479{
     480    my $file = shift;
     481    my $replicate = shift;
     482
     483    if (!defined $file) {
     484        return;
     485    }
     486
     487    &my_die("Couldn't find expected output file: $file",  $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);
     488
     489    if ($replicate and $neb) {
     490        $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n",  $stack_id, $PS_EXIT_SYS_ERROR);
     491    }
     492}
     493
     494sub check_outputs
     495{
     496    my $fileList = shift;
     497    my $replicate = shift;
     498    foreach my $file (@$fileList) {
     499        check_output($file, $replicate);
     500    }
     501}
    425502
    426503print "I've reached the end of processing with a code of $?: $stack_id\n";
     
    432509}
    433510
     511
    434512__END__
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/summit_copy.pl

    r25418 r31083  
    2222
    2323# Parse the command-line arguments
    24 my ( $uri, $filename, $compress, $bytes, $md5, $nebulous, $exp_name, $inst, $telescope, $class, $class_id,
     24my ( $uri, $filename, $compress, $bytes, $md5, $nebulous, $summit_id, $exp_name, $inst, $telescope, $class, $class_id,
    2525     $dbname, $verbose, $no_update, $no_op, $timeout, $copies );
    2626GetOptions(
     
    3131       'md5=s'          => \$md5,       # reported md5 checksum
    3232       'nebulous'       => \$nebulous,  # use nebulous for the target file
     33       'summit_id=s'    => \$summit_id, # summit_id for this exposure
    3334       'exp_name=s'     => \$exp_name,  # Exposure name
    3435       'inst=s'         => \$inst,      # Instrument
     
    4546
    4647pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    47 pod2usage( -msg => "Required options: --uri --filename --exp_name --inst --telescope --class --class_id",
     48pod2usage( -msg => "Required options: --uri --filename --summit_id --exp_name --inst --telescope --class --class_id",
    4849       -exitval => 3)
    4950    unless defined $uri
    5051    and defined $filename
     52    and defined $summit_id
    5153    and defined $exp_name
    5254    and defined $inst
     
    110112$command  = "$pztool -copydone";
    111113$command .= " -row_lock";
     114$command .= " -summit_id $summit_id";
    112115$command .= " -exp_name $exp_name";
    113116$command .= " -inst $inst";
     
    236239        my $command;
    237240        $command  = "$pztool -copydone";
     241        $command .= " -summit_id $summit_id";
    238242        $command .= " -exp_name $exp_name";
    239243        $command .= " -inst $inst";
     
    246250
    247251        system ($command);
     252
     253        if ($exit_code == 110) {
     254            $command = "$pztool -updatepzexp";
     255            $command .= " -exp_name $exp_name";
     256            $command .= " -camera $inst";
     257            $command .= " -telescope $telescope";
     258            $command .= " -set_state drop";
     259            $command .= " -dbname $dbname" if defined $dbname;
     260
     261            system ($command);
     262        }
     263
    248264    }
    249265
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/warp_skycell.pl

    r30590 r31083  
    7676    $traceDest = prepare_output("TRACE.EXP", $outroot, $skycell_id, 1);
    7777} elsif ($run_state eq 'update')  {
    78     $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, $skycell_id, 0);
     78    $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, $skycell_id, 1);
    7979    $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, $skycell_id, 1);
    8080} else {
     
    318318
    319319        if (!$quality) {
    320         #    &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
    321         #    &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
    322         #    &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
    323         #    &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);
    324         #    &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) if metadataLookupBool($recipe, 'PSF') and not $ipprc->file_exists($outputPSF);
    325 
    326320            check_output($outputImage, 0);
    327321            check_output($outputMask, 0);
     
    331325            if ($dump_config)  {
    332326                check_output($configuration, 1);
    333 #                &my_die("Couldn't find expected output file: $configuration", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration);
    334327            }
    335328        }
Note: See TracChangeset for help on using the changeset viewer.