Changeset 33248 for trunk/pstamp/scripts/detectability_respond.pl
- Timestamp:
- Feb 13, 2012, 1:50:32 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/detectability_respond.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/detectability_respond.pl
r33141 r33248 20 20 use PS::IPP::PStamp::RequestFile qw( :standard ); 21 21 use 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 ); 22 use PS::IPP::Config qw( :standard ); 23 use PS::IPP::Metadata::List qw( parse_md_list ); 24 33 25 use Astro::FITS::CFITSIO qw( :constants ); 34 26 Astro::FITS::CFITSIO::PerlyUnpacking(1); … … 75 67 76 68 my $ipprc = PS::IPP::Config->new(); 69 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 70 77 71 78 72 if (!$dbserver) { … … 231 225 my $mjd_max = $mjd + 1; 232 226 227 my $req_filter; 228 if ($filter ne 'Not_Set') { 229 $req_filter = $filter . '%'; 230 } 233 231 234 232 # Call the PStamp code to find the images that contain the target on the given MJD in the specified filter. … … 238 236 $fpa_id,undef,undef, 239 237 $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); 242 239 243 240 foreach my $this_image_ref (@{ $pstamp_images_ref }) { … … 395 392 my $weight= $query{$fpa_id}{WEIGHT}[$index]; 396 393 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; 400 402 401 403 $query{$fpa_id}{NPIX}[$index] = 0; … … 789 791 } 790 792 793 sub 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 791 851 sub my_die { 792 852 my $message = shift;
Note:
See TracChangeset
for help on using the changeset viewer.
