IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 13, 2012, 1:50:32 PM (14 years ago)
Author:
bills
Message:

check status of components don't pass filter value 'Not Set' to ippTools

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/detectability_respond.pl

    r33141 r33248  
    2020use PS::IPP::PStamp::RequestFile qw( :standard );
    2121use PS::IPP::PStamp::Job qw( :standard );
    22 use PS::IPP::Config qw($PS_EXIT_SUCCESS
    23                        $PS_EXIT_UNKNOWN_ERROR
    24                        $PS_EXIT_SYS_ERROR
    25                        $PS_EXIT_CONFIG_ERROR
    26                        $PS_EXIT_PROG_ERROR
    27                        $PS_EXIT_DATA_ERROR
    28                        $PS_EXIT_TIMEOUT_ERROR
    29                        metadataLookupStr
    30                        metadataLookupBool
    31                        caturi
    32                        );
     22use PS::IPP::Config qw( :standard );
     23use PS::IPP::Metadata::List qw( parse_md_list );
     24
    3325use Astro::FITS::CFITSIO qw( :constants );
    3426Astro::FITS::CFITSIO::PerlyUnpacking(1);
     
    7567
    7668my $ipprc = PS::IPP::Config->new();
     69my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     70
    7771
    7872if (!$dbserver) {
     
    231225        my $mjd_max = $mjd + 1;
    232226       
     227        my $req_filter;
     228        if ($filter ne 'Not_Set') {
     229            $req_filter = $filter . '%';
     230        }
    233231       
    234232        # Call the PStamp code to find the images that contain the target on the given MJD in the specified filter.
     
    238236                                          $fpa_id,undef,undef,
    239237                                          $option_mask,$need_magic,
    240                                           # $ra,$dec,
    241                                           $mjd_min,$mjd_max,$filter . ".00000",undef,$verbose); 
     238                                          $mjd_min,$mjd_max,$req_filter,undef,$verbose); 
    242239       
    243240        foreach my $this_image_ref (@{ $pstamp_images_ref }) {
     
    395392        my $weight= $query{$fpa_id}{WEIGHT}[$index];
    396393        my $stage = $query{$fpa_id}{STAGE}[$index];
    397         # if there's a fault, then we can't process this image.
    398         if (($fault != 0)||($query{$fpa_id}{BAD_COMPONENT}[$index] == 1)) {
    399             $query{$fpa_id}{PROC_ERROR}[$index] = 23;
     394        my $stage_id = $query{$fpa_id}{STAGE_ID}[$index];
     395        my $component = $query{$fpa_id}{COMPONENT_ID}[$index];
     396        # print "Input is from $stage $stage_id $component\n";
     397
     398        # if there's a fault or quality problem, then we can't process this image.
     399        # if (($fault != 0)||($query{$fpa_id}{BAD_COMPONENT}[$index] == 1)) {
     400        if ($fault = check_component($stage, $stage_id, $component, $imagedb)) {
     401            $query{$fpa_id}{PROC_ERROR}[$index] = $fault;
    400402           
    401403            $query{$fpa_id}{NPIX}[$index] = 0;
     
    789791}
    790792
     793sub check_component {
     794    my ($stage, $stage_id, $component, $imagedb) = @_;
     795
     796    print "Checking status of component $stage $stage_id $component\n";
     797
     798    my $command;
     799    if ($stage eq 'diff') {
     800        $command = "difftool -diffskyfile -diff_id $stage_id -skycell_id $component";
     801    } elsif ($stage eq 'stack') {
     802        $command = "stacktool -sumskyfile -stack_id $stage_id";
     803    } elsif ($stage eq 'warp') {
     804        $command = "warptool -warped -warp_id $stage_id -skycell_id $component";
     805    } elsif ($stage eq 'chip') {
     806        $command = "chiptool -processedimfile -chip_id $stage_id -class_id $component";
     807    } else {
     808        die("check_component not implemented for stage $stage yet");
     809    }
     810
     811    $command .= " -dbname $imagedb";
     812
     813    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     814        run(command => $command, verbose => $verbose);
     815    unless ($success) {
     816        my $rc = $error_code >> 8;
     817        carp "$command failed $error_code $rc";
     818        exit $PS_EXIT_UNKNOWN_ERROR;
     819    }
     820    my $output = join "", @$stdout_buf;
     821    my $metadata = $mdcParser->parse($output);
     822    my $results = parse_md_list($metadata);
     823    if (scalar @$results != 1) {
     824        carp "$command returned too many components: " . scalar @$results;
     825        exit $PS_EXIT_UNKNOWN_ERROR;
     826    }
     827    my $it = $results->[0];
     828
     829    if ($stage eq 'stack') {
     830        $it->{data_state} = $it->{state};
     831    }
     832
     833    my $return_status = 0;
     834    if ($it->{quality}) {
     835        print "  Bad quality: $it->{quality}\n";
     836        $return_status = $PSTAMP_GONE;
     837    } elsif ($it->{fault}) {
     838        print "  Faulted: $it->{fault}\n";
     839        $return_status = $PSTAMP_GONE;
     840    } elsif ($it->{data_state} ne 'full') {
     841        # XXX does this work for stack?
     842        carp "  Faulted: $it->{data_state}\n";
     843        $return_status = $PSTAMP_GONE;
     844    } else {
     845        print "  Component ok.\n";
     846    }
     847
     848    return $return_status;
     849}
     850
    791851sub my_die {
    792852    my $message = shift;
Note: See TracChangeset for help on using the changeset viewer.