IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32972 for trunk/ippScripts


Ignore:
Timestamp:
Dec 19, 2011, 1:23:22 PM (15 years ago)
Author:
bills
Message:

add code to search for inputs which do not have the stack id in the file name
Stats file needs to be resolved for ppStatsFromMetadata

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/skycalibration.pl

    r32959 r32972  
    4848    print "  --outroot (root)        : Output root name\n";
    4949    print "  --path_base (path_base) : path_base of input\n";
     50    print "  --filter (filter)       : filter of input\n";
     51    print "  --singlefilter          : the input is the result of a single filter analysis";
    5052    print "  --reduction (class)     : Reduction class\n";
    5153    print "  --verbose               : Be extra verbose\n";
     
    5860}
    5961
    60 my ($skycal_id, $stack_id, $camera, $dbname, $threads, $outroot, $path_base, $filter, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);
     62my ($skycal_id, $stack_id, $camera, $dbname, $threads, $outroot, $path_base, $filter, $singlefilter, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);
    6163GetOptions(
    6264    'skycal_id=s'       => \$skycal_id, # sky calibration run id
     
    6971    'filter=s'          => \$filter,    # filter for input stack
    7072    'reduction=s'       => \$reduction, # Reduction class
     73    'singlefilter'      => \$singlefilter, # input was from single filter analysis
    7174    'verbose'           => \$verbose,   # Print to stdout
    7275    'no-update'         => \$no_update, # Don't update the database?
     
    111114my $recipe_psastro  = $ipprc->reduction($reduction, 'STATICSKY_CALIBRATION'); # Recipe to use for psastro
    112115unless ($recipe_psastro) {
    113     # XXX: ADD to reduction: hard code recipe for now
    114     $recipe_psastro = 'STATICSKY_CAL';
    115 #            &my_die("Couldn't find selected reduction for STACKPHOT: $reduction\n", $skycal_id, $PS_EXIT_CONFIG_ERROR);
     116    &my_die("Couldn't find selected reduction for STATICSKY_CALIBRATION: $reduction\n", $skycal_id, $PS_EXIT_CONFIG_ERROR);
    116117}
    117118
     
    123124# find input file
    124125# First check the expected file name where the stack_id is the FILE_ID
    125 my $file  = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $stack_id);
    126 if (! $ipprc->file_resolve($file)) {
    127     # XXX: Beginning of section that can go eventually
    128 
    129     # no file with the expected name found
    130     # assume that the input is from an early staticsky run that did not use stack_id as the FILE_ID
    131     # but instead used FILE_ID = [0 .. num_filters-1]
    132     print "\nfailed to resolve $file\n";
    133     if (!$filter) {
    134         &my_die("filter not supplied unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR);
    135     }
    136     print "Trying old FILE_ID\n";
    137     my $max_filters = 5;
    138     for (my $i=0; $i < $max_filters; $i++) {
    139         my $file_id = sprintf "%03d", $i;
    140         $file  = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $file_id);
    141         my $resolved = $ipprc->file_resolve($file);
    142         if (!$resolved) {
    143             # we fail here assumming that if file_id N doesn't exist, neither to N+1
    144             print "\nfailed to resolve $file\n\n";
    145             &my_die("unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR);
    146         }
    147         # Check the filter id for this file
    148         my $command = "$fhead $resolved | grep FILTERID";
    149         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    150             run(command => $command, verbose => 0);
    151         unless ($success) {
    152             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    153             &my_die("Unable to perform $command: $error_code", $skycal_id, $PS_EXIT_SYS_ERROR);
    154         }
    155         # Expected output: HIERARCH FPA.FILTERID = 'r.00000 ' / Filter used (parsed, abstract name)
    156         my ($undef, undef, undef, $filt) = split " ", join("", @$stdout_buf);
    157         my $this_filter = substr $filt, 1, 7;
    158 
    159         # if it matches we're done
    160         last if $this_filter eq $filter;
    161 
    162         # nope loop around to try the next one
    163         print "Input file for $filter is not $file ($this_filter)\n";
    164         $file = undef;
    165     }
    166     print "\nInput file for $stack_id filter: $filter: $file\n";
    167 
    168     # XXX: End of section that can go eventually
     126my $file;
     127if (!$singlefilter) {
     128    $file = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $stack_id);
     129    if (! $ipprc->file_resolve($file)) {
     130        # XXX: Beginning of section that can be removed eventually
     131
     132        # no file with the expected name found
     133        # assume that the input is from an early staticsky run that did not use stack_id as the FILE_ID
     134        # but instead used FILE_ID = [0 .. num_filters-1]
     135        print "\nfailed to resolve $file\n";
     136        if (!$filter) {
     137            &my_die("filter not supplied unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR);
     138        }
     139        print "Trying old style FILE_ID\n";
     140        my $max_filters = 5;
     141        for (my $i=0; $i < $max_filters; $i++) {
     142            my $file_id = sprintf "%03d", $i;
     143            $file  = $ipprc->filename('PSPHOT.STACK.OUTPUT', $path_base, $file_id);
     144            my $resolved = $ipprc->file_resolve($file);
     145            if (!$resolved) {
     146                # we fail here assumming that if file_id N doesn't exist, neither to N+1
     147                print "\nfailed to resolve $file\n\n";
     148                &my_die("unable to identify appropriate staticsky input.", $skycal_id, $PS_EXIT_SYS_ERROR);
     149            }
     150            # Check the filter id for this file
     151            my $command = "$fhead $resolved | grep FILTERID";
     152            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     153                run(command => $command, verbose => 0);
     154            unless ($success) {
     155                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     156                &my_die("Unable to perform $command: $error_code", $skycal_id, $PS_EXIT_SYS_ERROR);
     157            }
     158            # Expected output: HIERARCH FPA.FILTERID = 'r.00000 ' / Filter used (parsed, abstract name)
     159            my ($undef, undef, undef, $filt) = split " ", join("", @$stdout_buf);
     160            my $this_filter = substr $filt, 1, 7;
     161
     162            # if it matches we're done
     163            last if $this_filter eq $filter;
     164
     165            # nope loop around to try the next one
     166            print "Input file for $filter is not $file ($this_filter)\n";
     167            $file = undef;
     168        }
     169        print "\nInput file for $stack_id filter: $filter: $file\n";
     170
     171        # XXX: End of section that can be removed eventually
     172    }
     173} else {
     174    # input is from a single filter static sky run use a different file rule
     175    # XXX: can't we just make staticsky.pl use the same file rule?
     176    $file = $ipprc->filename('PSPHOT.OUT.CMF.MEF', $path_base);
     177    &my_die("Unable to find input for $stack_id $filter", $skycal_id, $PS_EXIT_SYS_ERROR)
     178        unless $ipprc->file_exists($file);
     179}
     180
     181if (!$file) {
     182    &my_die("Unable to find input for $stack_id $filter", $skycal_id, $PS_EXIT_SYS_ERROR);
    169183}
    170184
     
    192206
    193207        {
    194             my $command = "$ppStatsFromMetadata $stats - STATICSKY_CAL";
     208            my $resolved = $ipprc->file_resolve($stats)
     209                or  &my_die("failed to resolve stats file: $stats", $skycal_id, $PS_EXIT_SYS_ERROR) ;
     210            my $command = "$ppStatsFromMetadata $resolved - STATICSKY_CAL";
    195211            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
    196212            unless ($success) {
Note: See TracChangeset for help on using the changeset viewer.