IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 29, 2011, 11:26:31 AM (15 years ago)
Author:
eugene
Message:

merging changes from trunk

Location:
branches/eam_branches/ipp-20110505/ippScripts/scripts
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110505/ippScripts/scripts/camera_exp.pl

    r30071 r31587  
    153153    }
    154154    chomp $cmdflags;
     155
     156    { # Determine if FWHM is too large to bother continuing.
     157        my $command = "$ppConfigDump -camera $camera -dump-camera -";
     158        my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     159            run(command => $command, verbose => $verbose);
     160        unless ($success) {
     161            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     162            &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_CONFIG_ERROR);
     163        }
     164        my $cameraConfig = $mdcParser->parse(join "", @$stdout_buf) or
     165            &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_CONFIG_ERROR);
     166
     167        my $maxFWHM = metadataLookupStr($cameraConfig, 'MAX_ALLOWED_FWHM');
     168        if ($maxFWHM) {
     169            my $expFWHM;
     170            ($expFWHM) = $cmdflags =~ /-fwhm_major (\d+)/;     
     171           
     172            if ($expFWHM > $maxFWHM) {
     173                print "Setting quality to 4007 due to large FWHM: exposure: $expFWHM  maximum: $maxFWHM\n";
     174                $cmdflags .= " -quality 4007 "; # This corresponds to PSASTRO_ERR_DATA
     175                $no_op = 1;
     176            }
     177        }
     178    }
    155179}
    156180
  • branches/eam_branches/ipp-20110505/ippScripts/scripts/dist_advancerun.pl

    r30489 r31587  
    114114    $tool_cmd = "$staticskytool -sky_id";
    115115    $list_mode = "-result";
    116     $component_key = "";
     116    $component_key = "skycell_id";
    117117} elsif ($stage eq "diff") {
    118118    $tool_cmd = "$difftool -diff_id";
  • branches/eam_branches/ipp-20110505/ippScripts/scripts/dist_bundle.pl

    r30922 r31587  
    6262my $streaksrelease   = can_run('streaksrelease') or (warn "Can't find streaksrelease" and $missing_tools = 1);
    6363my $bgtool   = can_run('bgtool') or (warn "Can't find bgtool" and $missing_tools = 1);
     64my $staticskytool   = can_run('staticskytool') or (warn "Can't find staticskytool" and $missing_tools = 1);
    6465my $file_cmd   = can_run('file') or (warn "can't find program file" and $missing_tools = 1);
    6566my $zcat   = can_run('zcat') or (warn "can't find program zcat" and $missing_tools = 1);
     
    106107    defined $stage_id and
    107108    defined $component and
    108     defined $exp_type and
    109109    defined $path_base and
    110110    defined $outroot;
    111111
     112if ($stage eq 'raw' and !$clean and !$no_magic) {
     113   
     114    # for raw stage need to have exposure type defined and if the type is OBJECT we need
     115    # a chip_path_base so we can find the chip mask file
     116    if (!defined $exp_type or ($exp_type eq 'OBJECT' and !defined $chip_path_base)) {
     117        pod2usage( -msg => "Required options: --chip_path_base --exp_type for raw stage", -exitval => 3);
     118    }
     119}
     120
    112121$ipprc->redirect_output($logfile) if $logfile;
    113122
    114 if ($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     }
    119 }
    120 
    121123$ipprc->define_camera($camera);
    122124
    123125$ipprc->outroot_prepare($outroot);
    124126
     127my $num_sky_inputs;
     128if ($stage eq 'sky') {
     129    $num_sky_inputs = get_num_sky_inputs($stage_id);
     130}
    125131# Get the list of data products for this component
    126132# note: We my_die in get_file_list if something goes wrong.
    127133
    128 my $file_list = get_file_list($stage, $component, $path_base, $clean);
     134my $file_list = get_file_list($stage, $component, $path_base, $clean, $num_sky_inputs);
    129135
    130136if (($stage ne 'raw') and ($stage ne 'fake') and !$poor_quality) {
     
    184190        # it must exist)
    185191        next if $poor_quality;
     192
     193        # skip file stats file. Due to a bug the update process destroys them sometimes
     194        # XXX: perhaps only do this for stages where we know that this happens
     195        next if $file_rule =~ /STATS/;
    186196
    187197        &my_die("failed to resolve  $file_name", $component, $PS_EXIT_DATA_ERROR);
     
    480490    my $path_base = shift;
    481491    my $clean = shift;
     492    my $num_sky_inputs = shift;
    482493
    483494    my @file_list;
     
    531542        $config_file_rule = "PPSTACK.CONFIG";
    532543    } elsif ($stage eq "sky") {
    533         $config_file_rule = "PSPHOT.STACK.CONFIG";
     544        if ($num_sky_inputs > 1) {
     545            $config_file_rule = "PSPHOT.STACK.CONFIG";
     546        } else {
     547            $config_file_rule = "PSPHOT.SKY.CONFIG";
     548        }
    534549    } else {
    535550        &my_die("$stage is not a valid stage", $component, $PS_EXIT_CONFIG_ERROR);
     
    627642    return \@file_list;
    628643}
     644sub get_num_sky_inputs {
     645    my $sky_id = shift;
     646
     647    my $command = "$staticskytool -inputs -sky_id $sky_id -simple";
     648    $command .= " -dbname $dbname" if $dbname;
     649    $command .= " | wc";
     650    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     651        run(command => $command, verbose => $verbose);
     652    unless ($success) {
     653        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     654        &my_die("Unable to perform $command: $error_code", $component, $error_code);
     655    }
     656    my ($num_inputs, $words, $chars) = split " ", (join "", @$stdout_buf);
     657    if (!$num_inputs) {
     658        $num_inputs = "undefined" if !defined $num_inputs;
     659        &my_die("unexpected number of static sky inputs $num_inputs",  $PS_EXIT_PROG_ERROR, $component, $error_code);
     660    }
     661
     662    return $num_inputs;
     663}
    629664
    630665sub my_die
  • branches/eam_branches/ipp-20110505/ippScripts/scripts/ipp_apply_burntool_single.pl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20110505/ippScripts/scripts/lap_science.pl

    r31454 r31587  
    9999    my $status = queue_chips($lap_id);
    100100
    101     if ($status) {
     101    if (!$status) { # This is the culprit.
    102102        my $command = "$laptool -updaterun -lap_id $lap_id";
    103103        $command .= " -dbname $dbname " if defined $dbname;
     
    120120    # This is a puzzler... chiptool doesn't actually return a useful metadata.  We'll just scrape it from the database for now.
    121121
    122     my $command = "$chiptool -listrun -exp_id $exp_id -label $label -data_group $data_group";
     122    my $command = "$chiptool -listrun -pstamp_order -exp_id $exp_id -label $label -data_group $data_group";
    123123    $command .= " -dbname $dbname " if defined $dbname;
    124124
     
    236236        my $comment = $exposure->{comment};
    237237
     238        # This is a hack to fix old exposures that have no object.
     239        unless(defined($comment)) {
     240            $comment = '';
     241        }
     242        if ((!defined($object))||($object eq 'NULL')||($object eq '')) {
     243            if ($comment =~ /3pi_/) {
     244                $object = $comment;
     245                $object =~ s/^.*?(3pi_\d\d_\d\d\d\d).*?$/$1/;
     246            }
     247            elsif ($comment =~ / ps1_/) {
     248                $object = $comment;
     249                $object =~ s/^.*?(ps1_\d\d_\d\d\d\d).*$/$1/;
     250            }
     251            else {
     252                $exposure->{data_state} = 'new';
     253                $exposure->{pairwise} = 0;
     254                $exposure->{private} = 1;
     255                $exposure->{pair_id} = 9223372036854775807;
     256                update_this_exposure($exposure);
     257                $counter++;
     258                next;
     259            }
     260        }
     261
     262
    238263        if (S64_IS_NOT_NULL($chip_id)) { # We already have a defined chip_id
    239264            if (($pairwise) && !($pair_id)) {
     
    255280            $counter++;
    256281        }
     282        print "ZZ: $exp_id $object $comment $matching{$object}{$comment}\n";
    257283    }
    258284
     
    262288        foreach my $comment (keys %{ $matching{$object} }) {
    263289            push @exp_ids_to_diff, $matching{$object}{$comment};
     290            print "$object $comment $matching{$object}{$comment} $indexing{$matching{$object}{$comment}} $exp_ids_to_diff[-1]\n";
    264291        }
    265292        @exp_ids_to_diff = sort { $indexing{$a} <=> $indexing{$b} } @exp_ids_to_diff;
     
    275302            my $exp_A = ${ $exposures }[$indexing{$exp_id_A}];
    276303            my $exp_B = ${ $exposures }[$indexing{$exp_id_B}];
    277 
     304            print "$exp_A $exp_B $exp_id_A $exp_id_B $indexing{$exp_id_A} $indexing{$exp_id_B}\n";
    278305            $exp_A->{pairwise} = 1;
    279306            $exp_A->{private} = 0;
     
    292319    # Scan all exposures, and ensure that pairwise and private are set correctly
    293320    foreach my $exposure (@$exposures) {
     321        print "YY: $exposure\n";
    294322        if ($exposure->{pairwise} && !($exposure->{pair_id})) {
    295323            $exposure->{pairwise} = 0; # We marked it for pairwise diffs, but didn't match it. Probably an error.
     
    299327        }
    300328
    301         $exposure = update_this_exposure($exposure);
    302     }
    303     return(1);
     329        update_this_exposure($exposure);
     330    }
     331    return(0);
    304332}
    305333
     
    432460        my $companion;
    433461
    434         if ($exposure->{pair_id}) { # Load companion exposure information
    435             if (exists($match_hash{$exposure->{chip_id}})) {
     462        if ($exposure->{pairwise}) {
     463            # Load companion exposure information
     464            if (($exposure->{pair_id})&&(exists($match_hash{$exposure->{chip_id}}))) {
    436465                $companion = ${ $exposures }[$match_hash{$exposure->{chip_id}}]; # Match!
     466            }
     467            else { # We claimed to be pairwise, but do not have a valid pair_id.
     468                $exposure->{pairwise} = 0;
     469                $exposure->{private} = 1;
     470                &update_this_exposure($exposure);
    437471            }
    438472        }
     
    446480            $exposure = remake_this_exposure($exposure);
    447481        }
    448         if ($exposure->{cam_quality}) {
    449             $needs_qstack = 1;
    450             $needs_something_private = 1;
    451             if ($companion) {
    452                 $companion->{private} = 1;
    453                 $companion->{pairwise} = 0;
    454                 &update_this_exposure($companion);
     482        # Do quality checks here
     483        my $is_bad_quality = 0;
     484        if ((defined($exposure->{chipRun_state}))&&($exposure->{chipRun_state} eq 'full')&&
     485            ($exposure->{chip_component_count} > 0)&&($exposure->{chip_bad_quality} / $exposure->{chip_component_count} > 0.05)) {
     486            printf("QUALITY: $exposure->{exp_id} has bad chip quality: %d / %d\n",
     487                   $exposure->{chip_bad_quality} , $exposure->{chip_component_count});
     488            $is_bad_quality = 1;
     489        }
     490        elsif ((defined($exposure->{camRun_state}))&&($exposure->{camRun_state} eq 'full')&&
     491               ($exposure->{cam_bad_quality} / $exposure->{cam_component_count} > 0)) {
     492            printf("QUALITY: $exposure->{exp_id} has bad cam quality: %d / %d\n",
     493                   $exposure->{cam_bad_quality} , $exposure->{cam_component_count});
     494            $is_bad_quality = 1;
     495        }
     496        elsif ((defined($exposure->{warpRun_state}))&&($exposure->{warpRun_state} eq 'full')&&
     497               ($exposure->{warp_bad_quality} / $exposure->{warp_component_count} > 0.2)) {
     498            printf("QUALITY: $exposure->{exp_id} has bad warp quality: %d / %d\n",
     499                   $exposure->{warp_bad_quality} , $exposure->{warp_component_count});
     500            $is_bad_quality = 1;
     501        }
     502        elsif ((defined($exposure->{diffRun_state}))&&($exposure->{diffRun_state} eq 'full')&&
     503               ($exposure->{diff_bad_quality} / $exposure->{diff_component_count} > 0.5)) {
     504            printf("QUALITY: $exposure->{exp_id} has bad diff quality: %d / %d\n",
     505                    $exposure->{diff_bad_quality} , $exposure->{diff_component_count});
     506            $is_bad_quality = 1;
     507        }
     508        # If we've detected a bad quality exposure, drop it, and tell the companion.
     509        if ($is_bad_quality) {
     510            unless ((defined($exposure->{diffRun_state}))&&
     511                    ($exposure->{diffRun_state} eq 'full')) {
     512                $needs_qstack = 1;
     513                $needs_something_private = 1;
     514                if ($companion) {
     515                    $companion->{private} = 1;
     516                    $companion->{pairwise} = 0;
     517                    &update_this_exposure($companion);
     518                }
     519                $exposure->{private} = 1;
     520                $exposure->{pairwise} = 0;
    455521            }
    456             $exposure->{private} = 1;
    457             $exposure->{pairwise} = 0;
    458522            $exposure->{data_state} = 'drop';
    459523            &update_this_exposure($exposure);
    460524
    461525        }
    462 #       if ($companion) { # Validate that there are no problems with the companion exposure
    463 #           if ($companion->{cam_quality}) { # Maybe other things here?
    464 #               $exposure->{private} = 1;
    465 #               $exposure->{data_state} = 'drop';
    466 #               &update_this_exposure($exposure);
    467 #               $needs_qstack = 1;
    468 #           }
    469 #       }
     526       
    470527        if  ($exposure->{data_state} eq 'drop') { # This exposure is impossible, so fudge the counts so we get through.
    471528            $can_qstack ++;
     
    564621    }
    565622
     623    my $warps = '';
     624    foreach $exposure (@$exposures) {
     625        if (($exposure->{data_state} != 'drop')&&
     626            (S64_IS_NOT_NULL($exposure->{warp_id}))) {
     627            $warps .= " -warp_id $exposure->{warp_id} ";
     628        }
     629    }
     630
    566631    my @utctime = gmtime();
    567632    $utctime[5] += 1900;
     
    570635    my $workdir_date = sprintf("%4d/%02d/%02d",$utctime[5],$utctime[4],$utctime[3]);
    571636    my $workdir = "neb://\@HOST\@.0/${dbname}/${label}/${workdir_date}";
    572     my $data_group = "${label}.${date}";
     637    my $data_group = "${label}.${proj_cell}.quick.${date}";
    573638
    574639    my $command = "$stacktool ";
     
    576641    $command .= " -dbname $dbname " if defined $dbname;
    577642    $command .= " -definebyquery -select_label $label -select_skycell_id ${proj_cell}.% -select_filter $filter ";
    578     $command .= " -set_label ${label} -set_data_group ${proj_cell}.quick.${date} ";
     643    $command .= " -set_label ${label} -set_data_group $data_group ";
    579644    $command .= "  -set_workdir $workdir  -set_dist_group NODIST ";
    580645    $command .= " -min_num 2 -set_reduction QUICKSTACK ";
     646    $command .= " $warps ";
    581647
    582648    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    589655    $command = "$stacktool ";
    590656    $command .= " -dbname $dbname " if defined $dbname;
    591     $command .= " -sassskyfile -data_group ${proj_cell}.quick.${date} ";
     657    $command .= " -sassskyfile -data_group $data_group ";
    592658    $command .= " -filter $filter -projection_cell ${proj_cell} ";
    593659
     
    632698    unless (defined($label) && defined($filter) && defined($proj_cell)) {
    633699        &my_die("Unable to perform stacktool. Insufficient information.", $lap_id);
     700    }
     701
     702    my $warps = '';
     703    foreach $exposure (@$exposures) {
     704        if (($exposure->{data_state} != 'drop')&&
     705            (S64_IS_NOT_NULL($exposure->{magicked}))&&
     706            (S64_IS_NOT_NULL($exposure->{warp_id}))) {
     707            $warps .= " -warp_id $exposure->{warp_id} ";
     708        }
    634709    }
    635710
     
    640715    my $workdir_date = sprintf("%4d/%02d/%02d",$utctime[5],$utctime[4],$utctime[3]);
    641716    my $workdir = "neb://\@HOST\@.0/${dbname}/${label}/${workdir_date}";
    642     my $data_group = "${label}.${date}";
     717    my $data_group = "${label}.${proj_cell}.final.${date}";
    643718
    644719    my $command = "$stacktool ";
     
    646721    $command .= " -dbname $dbname " if defined $dbname;
    647722    $command .= " -definebyquery -select_label $label -select_skycell_id ${proj_cell}.% -select_filter $filter ";
    648     $command .= " -set_label ${label} -set_workdir $workdir -set_data_group ${proj_cell}.final.${date} ";
    649     $command .= " -min_num 2 -set_reduction THREEPI_STACK ";
     723    $command .= " -set_label ${label} -set_workdir $workdir -set_data_group $data_group ";
     724    $command .= " -min_num 2 -set_reduction THREEPI_STACK -set_dist_group ${label} ";
     725    $command .= " $warps ";
    650726
    651727    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    659735    $command = "$stacktool ";
    660736    $command .= " -dbname $dbname " if defined $dbname;
    661     $command .= " -sassskyfile -data_group ${proj_cell}.final.${date} ";
     737    $command .= " -sassskyfile -data_group $data_group ";
    662738    $command .= " -filter $filter -projection_cell ${proj_cell} ";
    663739
     
    734810            $command .= " -set_dist_group $exposure->{dist_group} ";
    735811        }
    736        
    737         if ($exposure->{pairwise}) { # warpwarp
     812        my $retry_command;
     813        if (($exposure->{pairwise})&&(defined(${ $exposures }[$match_hash{$exposure->{chip_id}}]))) { # warpwarp
    738814            my $companion = ${ $exposures }[$match_hash{$exposure->{chip_id}}];
    739815            $command .= " -definewarpwarp ";
    740             $command .= "-input_label $label -template_label $label -backwards ";
     816            $command .= "-input_label $label -template_label $label ";
    741817            $command .= "-warp_id $exposure->{warp_id} -template_warp_id $companion->{warp_id} ";
     818            $retry_command = $command;
     819            $command .= " -backwards "; # This usually works.
    742820            $already_queued{$exposure->{warp_id}} = 1;
    743821            $already_queued{$companion->{warp_id}} = 1;
     
    763841        my $diff_id = $diff->{diff_id};
    764842        unless (defined($diff_id)) {
    765             $exposure->{data_state} = 'drop';
    766             &update_this_exposure($exposure);
    767         }
    768        
     843            if ($retry_command) {
     844                ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     845                    run(command => $retry_command, verbose => $verbose);
     846                unless ($success) {
     847                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     848                    &my_die("unable to perform difftool -definewarp(warp|stack): $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
     849                }
     850               
     851                $diffs = $mdcParser->parse_list(join "", @$stdout_buf) or
     852                    &my_die("Unable to parse metadata from difftool -definewarp(warp|stack)", $lap_id, "");
     853               
     854                $diff = ${ $diffs }[0];
     855                $diff_id = $diff->{diff_id};
     856            }
     857            unless (defined($diff_id)) {
     858                $exposure->{data_state} = 'drop';
     859                &update_this_exposure($exposure);
     860            }
     861        }
    769862    }
    770863}
     
    872965   
    873966    my $command = "$laptool -updateexp -lap_id $lap_id -exp_id $exp_id ";
     967    $command .= " -dbname $dbname " if defined $dbname;
    874968    if (($exposure->{chip_id})&&(S64_IS_NOT_NULL($exposure->{chip_id}))) {
    875969        $command .= " -set_chip_id  $exposure->{chip_id} ";
  • branches/eam_branches/ipp-20110505/ippScripts/scripts/receive_file.pl

    r30674 r31587  
    224224        $stage = 'sky';
    225225        # XXX: This should be skycell, but the distribution code uses exposure
    226         $comp_name = 'exposure';
    227         $current_component = $comp_name;
     226        $comp_name = 'skycell_id';
     227#        $current_component = $comp_name;
    228228    } else {
    229229        &my_die( "unexpected run type line found in $filename: $runType\n", $file_id, $PS_EXIT_UNKNOWN_ERROR);
     
    237237        $new_workdir_value = "$workdir/$destdir";
    238238    }
     239
     240    if ($stage eq 'sky') {
     241        # the dbinfo file for a skyRun only has one component and it doesn't contain
     242        # skycell_id which is the way components are listed in the dirinfo file.
     243        my @ids = keys %$components;
     244        &my_die( "unexpected number of components scalar @ids found in staticsky dirinfo file\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) if scalar @ids != 1;
     245        $current_component = $ids[0];
     246    }
     247
    239248    my $component_dir;
    240249    if ($current_component) {
  • branches/eam_branches/ipp-20110505/ippScripts/scripts/warp_skycell.pl

    r30825 r31587  
    7272
    7373my ($logDest, $traceDest);
     74my $do_stats;
    7475if ($run_state eq 'new') {
    7576    $logDest = prepare_output("LOG.EXP", $outroot, $skycell_id, 0);
    7677    $traceDest = prepare_output("TRACE.EXP", $outroot, $skycell_id, 1);
     78    $do_stats = 1;
    7779} elsif ($run_state eq 'update')  {
    7880    $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, $skycell_id, 1);
     
    162164my $outputBin1 = prepare_output ("PSWARP.BIN1", $outroot, $skycell_id, 1);
    163165my $outputBin2 = prepare_output ("PSWARP.BIN2", $outroot, $skycell_id, 1);
    164 my $outputStats = prepare_output ("SKYCELL.STATS", $outroot, $skycell_id, 1);
     166my $outputStats;
     167if ($do_stats) {
     168    $outputStats = prepare_output ("SKYCELL.STATS", $outroot, $skycell_id, 1) if $do_stats;
     169}
    165170my $configuration;
    166171
     
    257262# Run pswarp
    258263my $cmdflags;
    259 my $do_stats;
    260264unless ($no_op) {
    261265    my $command = "$pswarp";
     
    279283    if ($run_state eq 'new') {
    280284        $command .= " -dumpconfig $configuration";
    281         $do_stats = 1;
    282285    } else {
    283286        $command .= " -ipprc $configuration";
Note: See TracChangeset for help on using the changeset viewer.