IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 21, 2014, 5:42:34 AM (12 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ps2-tc3-20130727
Files:
13 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ps2-tc3-20130727

  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts

    • Property svn:mergeinfo deleted
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/Makefile.am

    r33324 r36680  
    1111        pstampparse.pl \
    1212        pstamp_parser_run.pl \
     13        pstamp_queue_cleanup.pl \
    1314        pstamp_queue_requests.pl \
    1415        pstamp_request_file \
     
    2122        pstamp_get_image_job.pl \
    2223        psmkreq \
     24        psgetcalibinfo \
    2325        psstatus \
    2426        pstampstopfaulted \
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/dqueryparse.pl

    r34331 r36680  
    502502    $command .= " -need_magic" if $need_magic;
    503503
    504     my $rlabel = "dq_ud_" . $label if $label;
     504    my $rlabel = "ps_ud_" . $label if $label;
    505505    $command .= " -rlabel $rlabel" if $rlabel;
    506506
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/psmkreq

    r35438 r36680  
    3939my $job_type     = 'stamp';
    4040my $req_type     = 'bycoord';
    41 my $stage        = 'chip';
     41my $stage        = 'stack';
    4242my $option_mask;
    4343my $width        = $default_size;
    4444my $height       = $default_size;
     45my $whole_file   = 0;
    4546my $project      = 'gpc1';
    4647my $coord_mask;
     
    8182    'width=i'           => \$width,
    8283    'height=i'          => \$height,
     84    'whole-file'        => \$whole_file,
    8385    'pixcenter'         => \$pixcenter,
    8486    'arcseconds'        => \$arcseconds,
     
    141143        pod2usage( -msg => "--ra --dec --x --y are not used with --list", -exitval =>1 )
    142144            if defined $x or defined $y;
    143     } elsif (!$pixcenter) {
    144         pod2usage( -msg => "Required options for stamp requests: --ra and --dec or --list", -exitval =>1 )
    145             unless (defined $ra and defined $dec);
    146         # to simplify code we just use $x and $y from here
    147         $x = $ra;
    148         $y = $dec;
    149145    } else {
    150         pod2usage( -msg => "Required options for stamp requests: --x and --y or --list", -exitval =>1 )
    151                 unless (defined $x and defined $y);
     146        if ($whole_file) {
     147            $pixcenter = 1;
     148            $x = 0;
     149            $y = 0;
     150            $width = 0;
     151            $height = 0;
     152        }
     153        if (!$pixcenter) {
     154            pod2usage( -msg => "Required options for stamp requests: --ra and --dec or --list", -exitval =>1 )
     155                unless (defined $ra and defined $dec);
     156            # to simplify code we just use $x and $y from here
     157            $x = $ra;
     158            $y = $dec;
     159        } else {
     160            pod2usage( -msg => "Required options for stamp requests: --x and --y or --list", -exitval =>1 )
     161                    unless (defined $x and defined $y);
     162        }
    152163    }
    153164} else {
     
    177188$id = 0 if !$id;
    178189
    179 unless ($stage eq 'raw' or $stage eq 'chip' or $stage eq 'warp' or $stage eq 'diff' or $stage eq 'stack') {
     190unless ($stage eq 'raw' or $stage eq 'chip' or $stage eq 'warp' or $stage eq 'diff' or $stage eq 'stack'
     191    or $stage eq 'stack_summary') {
    180192    die "$stage is not a valid value for stage\n";
    181193}
     
    208220        $option_mask |= $PSTAMP_SELECT_PSF      if $psf;
    209221        $option_mask |= $PSTAMP_SELECT_BACKMDL  if $backmdl;
     222        $option_mask |= $PSTAMP_SELECT_UNCOMPRESSED if $uncompressed;
    210223        $option_mask |= $PSTAMP_SELECT_UNCONV   if $unconvolved;
    211224        $option_mask |= $PSTAMP_USE_IMFILE_ID   if $use_imfile_id;
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_checkdependent.pl

    r35827 r36680  
    2727my $IPP_DIFF_MODE_STACK_STACK = 4;
    2828
    29 my ($dep_id, $stage, $stage_id, $component, $imagedb, $rlabel, $need_magic, $fault_count, $max_fault_count, $logfile);
     29my ($dep_id, $stage, $stage_id, $component, $imagedb, $label, $rlabel, $need_magic, $fault_count, $max_fault_count, $logfile);
    3030my ($dbname, $ps_dbserver, $verbose, $save_temps, $no_update);
    3131
     
    3636    'component=s'   =>  \$component,
    3737    'imagedb=s'     =>  \$imagedb,      # dbname for images lookups.
    38     'rlabel=s'      =>  \$rlabel,
     38    'label=s'       =>  \$label,        # request's label
     39    'rlabel=s'      =>  \$rlabel,       # pstampDependent.rlabel (deprecated)
    3940    'need_magic'    =>  \$need_magic,
    4041    'fault_count=i' =>  \$fault_count,
     
    7374}
    7475
     76if ($label) {
     77    # rlabel is deprecated. Use one based on the supplied label parameter which is the current label
     78    # for the request, which may be different than the one given to the dependent when the job was parsed.
     79    # XXX: having the convention that update label is 'ps_ud_' . $label of request embedded here
     80    # (and formerly in pstampparse.pl) is not particularly clean but it's simple.
     81    my $new_rlabel = 'ps_ud_' . $label;
     82    if ($new_rlabel ne $rlabel) {
     83        print "Notice: using $new_rlabel instead of $rlabel for update label.\n";
     84        $rlabel = $new_rlabel;
     85    }
     86}
     87
     88
    7589if (!$ps_dbserver) {
    7690    $ps_dbserver =  metadataLookupStr($ipprc->{_siteConfig}, 'PS_DBSERVER');
     
    304318            }
    305319            $queued_update = 1;
     320        } elsif ($chip->{state} eq 'cleaned' and $chip->{data_state} eq 'update') {
     321            # we've had a number of runs in this limbo state
     322
     323            my $command = "$chiptool -updaterun -set_state update -chip_id $chip_id";
     324            $command .= " -set_label $rlabel" if $rlabel;
     325
     326            if (!$no_update) {
     327                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     328                            run(command => $command, verbose => $verbose);
     329                unless ($success) {
     330                    my_die("failed to change ${stage}Run $stage_id $component from goto_cleaned to update", $PS_EXIT_UNKNOWN_ERROR);
     331                }
     332            } else {
     333                print "skipping $command\n";
     334            }
     335            $queued_update = 1;
    306336        } elsif ($chip->{fault}) {
    307337            $fault_count++;
     
    438468            $chips_ready = 0;
    439469            $chip->{fault} = $chip->{chip_fault};
     470            $chip->{data_group} = $chip->{chip_data_group};
    440471            push @chipsToUpdate, $chip;
    441472        } else {
     
    459490            print "skipping $command\n";
    460491        }
     492    } elsif ($chips_ready and $skycell->{data_state} eq 'update' and $skycell->{state} ne 'update') {
     493        my $command = "$warptool -updaterun -warp_id $warp_id -set_state update";
     494        $command .= " -set_label $rlabel" if $rlabel;
     495
     496        if (!$no_update) {
     497            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     498                        run(command => $command, verbose => $verbose);
     499            unless ($success) {
     500                my_die("failed to change state of ${stage}Run $stage_id to update", $PS_EXIT_UNKNOWN_ERROR);
     501            }
     502        } else {
     503            print "skipping $command\n";
     504        }
     505
    461506    } elsif (scalar @chipsToUpdate > 0) {
    462507        my $fault = check_states_chip($chip_id, \@chipsToUpdate, $rlabel, $need_magic);
     
    528573            }
    529574            return $warp_status;
     575        } elsif ($warp->{quality} != 0) {
     576            print STDERR "input warp has quality error\n";
     577            faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
     578            return $PSTAMP_GONE;
    530579        }
    531580        # warps are ready fall through and queue the diff update
     
    575624    } elsif ($diff_mode == $IPP_DIFF_MODE_STACK_STACK ) {
    576625        # check the state of the input stack
    577         my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}";
     626        my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack1}";
    578627        my $stack1 = runToolAndParseExpectOne($command, $verbose);
    579         my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack1;
     628        my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack1}", $PS_EXIT_UNKNOWN_ERROR) if !$stack1;
    580629
    581630        if ($stack1->{state} ne 'full') {
    582             print STDERR "input stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
     631            print STDERR "input stack $skycell->{stack1} for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
    583632            faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
    584633            return $PSTAMP_GONE;
     
    590639
    591640        if ($stack2->{state} ne 'full') {
    592             print STDERR "template stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
     641            print STDERR "template stack $skycell->{stack2} for diffRun $diff_id $skycell_id is not in full state faulting jobs\n";
    593642            faultComponent('diff', $diff_id, $skycell_id, $PSTAMP_GONE);
    594643            return $PSTAMP_GONE;
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_cleanup.pl

    r35396 r36680  
    8080}
    8181
     82if (0) {
    8283my_die("Cleanup not yet supported for reqType: $reqType", $req_id, $PS_EXIT_UNKNOWN_ERROR)
    8384    if ($reqType ne "pstamp") and ($reqType ne "NULL") and ($reqType ne "dquery");
     85}
    8486
    8587my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_get_image_job.pl

    r33015 r36680  
    6565my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6666
    67 my $data = $mdcParser->parse(join "", (<INPUT>)) or my_die("failed to parse metadata config doc", $PS_EXIT_UNKNOWN_ERROR);
     67my $data = $mdcParser->parse(join "", (<INPUT>))
     68    or my_die("failed to parse metadata config doc", $PS_EXIT_UNKNOWN_ERROR);
     69
    6870my $components = parse_md_list($data);
    6971my $n = scalar @$components;
     
    8385    print STDERR "stage_id is $stage_id\n";
    8486    print STDERR "path_base is $path_base\n";
    85     print STDERR "path_base is $path_base\n";
    8687    print STDERR "CAMERA is $camera\n";
    8788    print STDERR "magicked is " . (defined $magicked ? $magicked : "undefined") . "\n";
     
    8990
    9091if (!$camera or !$path_base or !$component or !$stage_id or !$stage) {
    91        my_die("failed to parse params from: $params_file", $PS_EXIT_UNKNOWN_ERROR);
     92       my_die("One or more parameters are missing in: $params_file", $PS_EXIT_UNKNOWN_ERROR);
    9293}
    9394
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_insert_request.pl

    r35487 r36680  
    4545my $pstamptool = can_run('pstamptool')  or (warn "Can't find pstamptool"  and $missing_tools = 1);
    4646my $fields = can_run('fields')  or (warn "Can't find fields"  and $missing_tools = 1);
     47my $fhead = can_run('fhead')  or (warn "Can't find fhead"  and $missing_tools = 1);
    4748
    4849if ($missing_tools) {
     
    5657    # Note that if it's a pstamp request then REQ_NAME should be defined.
    5758    # if it's a detectability query it will not have a REQ_NAME but will have a QUERY_ID
    58     my $command = "echo $tmp_req_file | $fields -x 0 EXTNAME EXTVER REQ_NAME QUERY_ID";
     59    # my $command = "echo $tmp_req_file | $fields -x 0 EXTNAME EXTVER REQ_NAME QUERY_ID";
     60    my $command = "$fhead -x 0 $tmp_req_file";
    5961    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    6062        run(command => $command, verbose => $verbose);
    61 if (0) {
    62     # stoopid fields doesn't set exit status to zero when it works
    6363    unless ($success) {
    6464        print STDERR @$stderr_buf;
    6565        exit $error_code >> 8;
    6666    }
    67 }
    6867    my $output = join "", @$stdout_buf;
    69     (undef, $extname, $extver, $req_name) = split " ", $output;
     68
     69
     70    my $makehash = 0;
     71    my %hash;
     72    foreach my $line (split "\n", $output) {
     73        chomp $line;
     74        # split lines inte left and right using equals sign. left is the keyword
     75        my ($key, $right) = split "=", $line;
     76            # skip if there was no '='
     77        next if !$right;
     78
     79        $key =~ s/ //g;
     80
     81        # separate value from comment
     82        my ($value, $comment) = split "/", $right;
     83        # remove ' and space characters from key and value
     84        $value =~ s/'//g;
     85        $value =~ s/ //g;
     86
     87        #    print "$key $value\n";
     88
     89        # extract the values that we are looking for
     90        $extname  = $value if ($key eq "EXTNAME");
     91        $extver   = $value if ($key eq "EXTVER");
     92        $req_name = $value if ($key eq "REQ_NAME");
     93        $req_name = $value if ($key eq "QUERY_ID");
     94
     95        # optionally build hash. Duplicate keys get the last value seen
     96        if ($makehash) {
     97            $hash{$key} = $value;
     98        }
     99    }
     100
     101    # (undef, $extname, $extver, $req_name) = split " ", $output;
     102
    70103    if (!$extname or ! (($extname eq "PS1_PS_REQUEST") or ($extname eq "MOPS_DETECTABILITY_QUERY"))) {
    71104        print STDERR "invalid request file\n";
     105        print "invalid request file\n";
    72106        exit $PS_EXIT_DATA_ERROR;
    73107    }
     108
    74109    if (!defined $req_name) {
    75110        print STDERR "invalid request file no REQ_NAME or QUERY_ID\n";
     111        print "invalid request file no REQ_NAME or QUERY_ID\n";
     112        exit $PS_EXIT_DATA_ERROR;
     113    }
     114    if (!defined $extver) {
     115        print STDERR "invalid request file no EXTVER found\n";
     116        print "invalid request file no EXTVER found\n";
    76117        exit $PS_EXIT_DATA_ERROR;
    77118    }
     
    119160
    120161exit 0;
     162
    121163# Ask the database for the next web request number
    122164sub get_webreq_num
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_job_run.pl

    r35609 r36680  
    5757my_die("output_base is required", $job_id, $PS_EXIT_PROG_ERROR) if !$outputBase;
    5858
    59 $options = 1 if !$options;
    60 
    61 # We don't need to muggle anymore. Ignore those options
    62 $options &=  ~($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED);
     59# ppstamp requires an input file
     60$options = $PSTAMP_SELECT_IMAGE if !$options;
    6361
    6462my $ipprc = PS::IPP::Config->new(); # IPP Configuration
     
    7876my $ppstamp    = can_run('ppstamp') or (warn "Can't find ppstamp" and $missing_tools = 1);
    7977my $pstamp_get_image_job    = can_run('pstamp_get_image_job.pl') or (warn "Can't find pstamp_get_image_job.pl" and $missing_tools = 1);
     78my $psgetcalibinfo    = can_run('psgetcalibinfo') or (warn "Can't find psgetcalibinfo" and $missing_tools = 1);
    8079my $dquery_job_run = can_run('dquery_job_run.pl') or (warn "Can't find dquery_job_run.pl" and $missing_tools = 1);
    81 my $streaksreplace = can_run('streaksreplace')  or (warn "Can't find streaksreplace"  and $missing_tools = 1);
    82 my $magicdstool = can_run('magicdstool')  or (warn "Can't find magicdstool"  and $missing_tools = 1);
    8380my $whichnode = can_run('whichnode') or (warn "can't find whichnode" and $missing_tools = 1);
    8481
     
    9693    my $argString;
    9794    $argString = $params->{job_args};
     95   
     96    my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString;
     97
    9898    my $stage = $params->{stage};
    99 
    100     # XXX: should we do any other sanity checking?
    101     my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString;
    102 
    103     my $nan_masked = 1;
    104     my $muggle = 0;
    105     if (!$params->{magicked}) {
    106         $nan_masked = 0;
    107     } elsif ($params->{magicked} and ($options & ($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED))) {
    108         # Attempt to find or create a muggle image
    109         $nan_masked = 0;
    110         $muggle = 1;
    111     }
     99    my_die("stage is not defined", $job_id, $PS_EXIT_DATA_ERROR) if !$stage;
     100
     101    if ($stage eq 'stack_summary') {
     102
     103        # remove options not supported by stack summary
     104        $options &= ~($PSTAMP_SELECT_SOURCES | $PSTAMP_SELECT_BACKMDL | $PSTAMP_SELECT_INVERSE
     105            | $PSTAMP_RESTORE_BACKGROUND);
     106
     107        # stackSummary outputs do not follow the usual IPP conventions for file names.
     108        # The parser (actually Job.pm) has deferred handling this until here
     109        update_stack_summary_filenames($params);
     110
     111    } elsif ($stage ne 'stack') {
     112        # ignore options only supported by stack and stack_summary
     113        $options &= ~($PSTAMP_SELECT_EXP | $PSTAMP_SELECT_NUM);
     114    }
     115   
    112116
    113117    if ($stage eq "raw") {
     
    122126    my @file_list = ($params->{image});
    123127   
    124     if ($nan_masked or ($options & $PSTAMP_SELECT_MASK)) {
     128    if ($options & $PSTAMP_SELECT_MASK) {
    125129        $mask = $params->{mask};
    126130        $fileArgs .= " -mask $mask";
     
    162166    # find our output directory
    163167    my $outdir = dirname($outputBase);
    164     my ($tmpImage, $tmpMask, $tmpVariance, $tmproot);
    165    
    166     if ($muggle) {
    167         # first see if the original uncensored images are around
    168         if (check_for_backups($params, \$fileArgs)) {
    169             # We're good to go. fileArgs has been edited to contain the paths for the original uncensored images
    170             print "Making stamps from backup images\n";
    171         } elsif (($options & $PSTAMP_REQUIRE_UNCENSORED) and ($stage ne 'chip')) {
    172             # user required uncensored but since stage isn't chip we can't rebuild them
    173             my_die("uncensored inputs not available for job $job_id", $job_id, $PSTAMP_NOT_AVAILABLE, 'stop');
    174         } elsif (($options & $PSTAMP_REQUEST_UNCENSORED) and ($params->{state} ne 'full') and ($stage ne 'chip')) {
    175             # we can only restore pixels for chip stage images if the data has been updated.
    176             # the data will have been updated if the params->{state} the state when the job was queued is not 'full' (
    177             # XXX: we should probably be looking explicitly at the job and checking for a dep_id
    178             print "Run state was $params->{state}: will make stamps from destreaked $stage images.\n";
    179             # make stamps from uncensored images
    180             $muggle = 0;
     168
     169    my ($calib_fd, $calibfile);
     170    if ($stage eq 'chip' or $stage eq 'warp') {
     171        my $cam_id = $params->{cam_id};
     172        if (!$cam_id) {
     173            carp "no cam_id found in job params\n";
     174            exit $PS_EXIT_PROG_ERROR;
     175        }
     176        ($calib_fd, $calibfile) = tempfile ("$outdir/calib.XXXX", UNLINK => !$save_temps);
     177        close $calib_fd;
     178
     179        my $command = "$psgetcalibinfo --cam_id $cam_id --output $calibfile --dbname $params->{imagedb}";
     180        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     181            run(command => $command, verbose => $verbose);
     182
     183        my $exitStatus;
     184        if (WIFEXITED($error_code)) {
     185            $exitStatus = WEXITSTATUS($error_code);
    181186        } else {
    182             # Try and replace the streaks from the recovery images
    183 
    184             my $temp_dir = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR") or &my_die("Unable to find temporary directory in site configuration", $job_id, $PS_EXIT_CONFIG_ERROR);
    185             $tmproot = tempdir("$temp_dir/psjob.$job_id.XXXX", CLEANUP => !$save_temps);
    186             my $muggle_command = "$streaksreplace -stage $stage -tmproot $tmproot";
    187             # find the "directory" of the input path_base
    188             my $inputdir = dirname($image);
    189             my $base = basename($image);
    190             $tmpImage = "$tmproot/$base";
    191 
    192             @file_list = ();
    193 
    194             # XXX: We should get the recovery_path_base from the magicDSFile but that requires a bunch of file rule and
    195             # stage work. Import the rule here.
    196             my $recImage = "$inputdir/REC_$base";
    197             my $newFileArgs = " -file $tmpImage";
    198             $muggle_command .= " -image $image -recimage $recImage";
    199             push @file_list, $recImage;
    200 
    201             if ($mask) {
    202                 $base = basename($mask);
    203                 $tmpMask = "$tmproot/$base";
    204                 $newFileArgs .= " -mask $tmpMask";
    205                 my $recMask = "$inputdir/REC_$base";
    206                 $muggle_command .= " -mask $mask -recmask $recMask";
    207                 push @file_list, $recMask;
    208             }
    209 
    210             if ($variance) {
    211                 $base = basename($variance);
    212                 $tmpVariance = "$tmproot/$base";
    213                 $newFileArgs .= " -variance $tmpVariance";
    214                 my $recVariance = "$inputdir/REC_$base";
    215                 $muggle_command .= " -weight $variance -recweight $recVariance";
    216                 push @file_list, $recVariance;
    217             }
    218             if (check_files(0, @file_list)) {
    219                 # recovery files exist and are accessible restore the excised pixels
    220 
    221                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    222                     run(command => $muggle_command, verbose => $verbose);
    223                 unless ($success) {
    224                     my $exitStatus = WEXITSTATUS($error_code);
    225                     my_die( "streaksreplace failed with error code: $exitStatus", $job_id, $exitStatus);
    226                 }
    227 
    228                 # set the ppstamp file arguments
    229                 $fileArgs = $newFileArgs;
    230             } else {
    231                 if ($options & $PSTAMP_REQUIRE_UNCENSORED) {
    232                     my_die( "unable to restore uncensored images", $job_id, $PSTAMP_NOT_AVAILABLE);
    233                 }
    234                 # just make stamps from the censored images
    235                 print "Unable to restore uncensored images, will extract stamps from censored images\n";
    236                 # these files won't be used so zap them
    237                 ($tmpImage, $tmpMask, $tmpVariance, $tmproot) = (undef, undef, undef, undef);
    238             }
    239         }
    240     }
    241 
    242     # MAGIC IS DEAD
    243     $nan_masked = 0;
    244 
    245     my $command = "$ppstamp $outputBase $argString $fileArgs";
    246     $command .= " -write_jpeg" if ($options & $PSTAMP_SELECT_JPEG);
    247     $command .= " -nocompress" if ($options & $PSTAMP_SELECT_UNCOMPRESSED);
    248     $command .= " -stage $stage";
    249     $command .= " -censor_masked" if $nan_masked;
    250     $command .= " -dbname $dbname" if $dbname;
    251     $command .= " -dbserver $dbserver" if $dbserver;
    252     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    253         run(command => $command, verbose => $verbose);
     187            print STDERR "psgetcalibinfo failed error_code: $error_code\n";
     188            $exitStatus = $PS_EXIT_SYS_ERROR;
     189        }
     190        exit $exitStatus if $exitStatus;
     191
     192        if (-s $calibfile == 0) {
     193            print "no calibration information found for $cam_id\n";
     194            $calibfile = undef;
     195        }
     196    }
     197
     198    # unless the stage is stack_summary we use ppstamp to make postage stamps (including -wholefile)
     199    # otherwise we make copies of the input files to the outputs
     200    my $use_ppstamp = ($stage ne 'stack_summary');
    254201
    255202    my $exitStatus;
    256     if (WIFEXITED($error_code)) {
    257         $exitStatus = WEXITSTATUS($error_code);
    258     } else {
    259         print STDERR "ppstamp failed error_code: $error_code\n";
    260         $exitStatus = $PS_EXIT_SYS_ERROR;
     203    if ($use_ppstamp) {
     204        my $command = "$ppstamp $outputBase $argString $fileArgs";
     205        $command .= " -write_jpeg" if ($options & $PSTAMP_SELECT_JPEG);
     206        $command .= " -nocompress" if ($options & $PSTAMP_SELECT_UNCOMPRESSED);
     207        $command .= " -stage $stage";
     208        $command .= " -forheader $calibfile" if $calibfile;
     209        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     210            run(command => $command, verbose => $verbose);
     211
     212        if (WIFEXITED($error_code)) {
     213            $exitStatus = WEXITSTATUS($error_code);
     214        } else {
     215            print STDERR "ppstamp failed error_code: $error_code\n";
     216            $exitStatus = $PS_EXIT_SYS_ERROR;
     217        }
     218        # XXX: if stage is stack deal with EXP and NUM images if selected
     219    } else {
     220        $exitStatus = justCopyFiles($outputBase, \$options, $params);
    261221    }
    262222
     
    270230
    271231        # Note: we are assuming the contents of the PSTAMP filerules here.
    272         my %extensions = ( $PSTAMP_SELECT_IMAGE    => "fits",
    273                            $PSTAMP_SELECT_MASK     => "mk.fits",
    274                            $PSTAMP_SELECT_VARIANCE => "wt.fits",
    275                            $PSTAMP_SELECT_SOURCES  => "cmf",
    276                            $PSTAMP_SELECT_JPEG     => "jpg");
    277 
    278         my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE | $PSTAMP_SELECT_JPEG | $PSTAMP_SELECT_SOURCES);
     232        my %extensions = ( $PSTAMP_SELECT_IMAGE    => 'fits',
     233                           $PSTAMP_SELECT_MASK     => 'mk.fits',
     234                           $PSTAMP_SELECT_VARIANCE => 'wt.fits',
     235                           $PSTAMP_SELECT_SOURCES  => 'cmf',
     236                           $PSTAMP_SELECT_JPEG     => 'jpg',
     237                           $PSTAMP_SELECT_EXP      => 'exp.fits',
     238                           $PSTAMP_SELECT_NUM      => 'num.fits',
     239                           $PSTAMP_SELECT_EXPJPEG  => 'exp.jpg',
     240                           $PSTAMP_SELECT_NUMJPEG  => 'num.jpg');
     241
     242        my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE
     243            | $PSTAMP_SELECT_JPEG | $PSTAMP_SELECT_SOURCES
     244            | $PSTAMP_SELECT_EXP | $PSTAMP_SELECT_NUM
     245            | $PSTAMP_SELECT_EXPJPEG | $PSTAMP_SELECT_NUMJPEG);
     246
    279247
    280248        foreach my $key (keys (%extensions)) {
     
    298266        close $F;
    299267        $jobStatus = $PS_EXIT_SUCCESS;
    300     } elsif ($exitStatus == $PSTAMP_NO_OVERLAP) {
    301         $jobStatus = $PSTAMP_NO_OVERLAP;
     268    } elsif ($exitStatus == $PSTAMP_NO_OVERLAP || $exitStatus == $PSTAMP_NO_VALID_PIXELS) {
     269        $jobStatus = $exitStatus;
    302270    } else {
    303271        my_die( "ppstamp failed with error code: $exitStatus", $job_id, $exitStatus);
     
    419387        my $backmdl_file = $params->{backmdl} if ($options & $PSTAMP_SELECT_BACKMDL);
    420388        my $pattern_file = $params->{pattern} if ($options & $PSTAMP_SELECT_BACKMDL);
     389        my $filter = $params->{filter};
     390        $filter = ' ' if !$filter;
     391        $filter = substr $filter, 0, 1;
    421392        my $cmf_file;
    422393#        if ($stage ne 'chip') {
     
    431402            if (!$therest or !$rownum or !$jobnum);
    432403
    433         my $prefix = "${rownum}_${jobnum}_";
     404        # XXX: Here we are assuming the form of the output file names
     405        # if we change this in pstampparse we'll need to remember ....
     406        # (the last time I forgot)
     407        my $prefix = "${rownum}_${jobnum}_${filter}_";
    434408
    435409        if ($cmf_file) {
     
    523497}
    524498
    525 sub check_for_backups {
    526     my $params = shift;
    527     my $r_fileArgs = shift;
    528 
    529     my $command = "$magicdstool -destreakedfile -stage $params->{stage} -stage_id $params->{stage_id} -component $params->{component} -dbname $params->{imagedb}";
    530     my $results = runToolAndParse($command, $verbose);
    531     my $dsComponent  = $results->[0];
    532 
    533     if ($dsComponent and ($dsComponent->{data_state} eq 'full')) {
    534 
    535         print "magicDSFile state is full. Backup images should exist\n";
    536 
    537         # replace the file names with the backup paths
    538         # fileArgs has the form:  -file imagename [-mask maskname] [-weight weightname]
    539         my @args = split " ", $$r_fileArgs;
    540 
    541         my $newFileArgs;
    542         while (@args) {
    543             my $a = shift @args;
    544             my $f = shift @args;
    545             my_die( "unexpected fileArg list $$r_fileArgs", $job_id, $PS_EXIT_PROG_ERROR, 'run') if !$a or !$f;
    546 
    547             my $backup_image_name = $ipprc->destreaked_filename($f);
    548             my_die( "failed to extract backup image name from $f", $job_id, $PS_EXIT_PROG_ERROR, 'run') if !$backup_image_name;
    549             $newFileArgs .= " $a $backup_image_name";
    550         }
    551         $$r_fileArgs = $newFileArgs;
    552 
    553         return 1;
    554     }
    555 
    556     return 0;
    557 }
    558 
    559499my $neb;
    560500sub storage_object_exists
     
    630570}
    631571
     572# stack_summary stage does not currently use proper file rules.
     573# The parser defers handlint this to us..
     574
     575sub update_stack_summary_filenames {
     576    my $params  = shift;
     577
     578    my $path_base = $params->{path_base};
     579
     580    $params->{image}  = $path_base . ".image.b1.fits";
     581    $params->{mask}   = $path_base . ".mask.b1.fits";
     582    $params->{weight} = $path_base . ".variance.b1.fits";
     583    $params->{jpeg}   = $path_base . ".image.0.b1.jpeg";
     584    $params->{exp}    = $path_base . ".exp.b1.fits";
     585    $params->{num}    = $path_base . ".num.b1.fits";
     586    $params->{expjpeg} = $path_base . ".exp.0.b1.jpeg";
     587    $params->{numjpeg} = $path_base . ".num.0.b1.jpeg";
     588}
     589
     590sub myCopy {
     591    my ($dest, $src, $type, $dieOnFail) = @_;
     592
     593    my $result;
     594    my $resolved = $ipprc->file_resolve($src);
     595    if ($resolved and $ipprc->file_exists($resolved)) {
     596        print "Copying $src to $dest\n" if $verbose;;
     597        $result = copy($resolved, $dest);
     598    } else {
     599        my $msg = "Specified source $type image $src not found.";
     600        if ($dieOnFail) {
     601            $msg .= "\n";
     602        } else {
     603            $msg .= " ignoring\n";
     604        }
     605        carp $msg;
     606        $result = 0;
     607    }
     608   
     609    if (!$result and $dieOnFail) {
     610        &my_die("Unable to copy $type image", $job_id, $PS_EXIT_SYS_ERROR, 'run');
     611    }
     612    return $result;
     613}
     614
     615sub justCopyFiles {
     616    my ($outputBase, $r_options, $params) = @_;
     617
     618    print "Just copying files for $job_id.\n";
     619
     620    my $options = $$r_options;
     621    if ($options & $PSTAMP_SELECT_IMAGE) {
     622        myCopy("$outputBase.fits", $params->{image}, 'image', 1);
     623    }
     624    if ($options & $PSTAMP_SELECT_MASK) {
     625        if (!myCopy("$outputBase.mk.fits", $params->{mask}, 'mask', 0)) {
     626            $options &= ~$PSTAMP_SELECT_MASK;
     627        }
     628    }
     629    if ($options & $PSTAMP_SELECT_VARIANCE) {
     630        if (!myCopy("$outputBase.wt.fits", $params->{weight}, 'variance', 0)) {
     631            $options =  ~$PSTAMP_SELECT_VARIANCE;
     632        }
     633    }
     634    if ($options & $PSTAMP_SELECT_JPEG) {
     635        if (!myCopy("$outputBase.jpg", $params->{jpeg}, 'jpeg', 0)) {
     636            $options &= ~$PSTAMP_SELECT_JPEG;
     637        }
     638    }
     639    if ($options & $PSTAMP_SELECT_EXP) {
     640        if (!myCopy("$outputBase.exp.fits", $params->{exp}, 'exp', 0)) {
     641            $options &= ~$PSTAMP_SELECT_EXP;
     642        }
     643    }
     644    if ($options & $PSTAMP_SELECT_NUM) {
     645        if (!myCopy("$outputBase.num.fits", $params->{num}, 'num', 0)) {
     646            $options &= ~$PSTAMP_SELECT_NUM;
     647        }
     648    }
     649    if ($options & $PSTAMP_SELECT_EXPJPEG) {
     650        if (!myCopy("$outputBase.exp.jpg", $params->{expjpeg}, 'exp', 0)) {
     651            $options &= ~$PSTAMP_SELECT_EXPJPEG;
     652        }
     653    }
     654    if ($options & $PSTAMP_SELECT_NUMJPEG) {
     655        if (!myCopy("$outputBase.num.jpg", $params->{numjpeg}, 'num', 0)) {
     656            $options &= ~$PSTAMP_SELECT_NUMJPEG;
     657        }
     658    }
     659
     660    $$r_options = $options;
     661
     662    print "Done with copy.\n";
     663
     664    return 0;
     665}
     666
    632667sub my_die
    633668{
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_save_server_status.pl

    r35570 r36680  
    6161    $year, $month, $mday, $hour, $min, $sec;
    6262
    63 my $command = "pstamp_server_status > $file";
     63my $command = "pstamp_server_status --workdir $pstamp_workdir > $file";
     64#my $command = "pstamp_server_status > $file";
    6465my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    6566    run(command => $command, verbose => $verbose);
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstamp_server_status

    r35486 r36680  
    1515
    1616
    17 my ($rundir, $verbose, $save_temps);
     17my ($rundir, $workdir, $verbose, $save_temps);
    1818my $br = '<br />';
    1919
    2020GetOptions(
    2121    'rundir=s'      => \$rundir,
     22    'workdir=s'     => \$workdir,
    2223    'verbose'       => \$verbose,
    2324    'save-temps'    => \$save_temps,
     
    155156    }
    156157}
     158if ($workdir) {
     159    # get the space available in the working directory file system
     160    my $df_output = `df -h $workdir`;
     161    my @lines = split "\n", $df_output;
     162    foreach my $line (@lines) {
     163        next unless $line =~ /data/;
     164        my ($total, $used, $free, $percent, $part) = split " ", $line;
     165        print "<br><b>Server Working Directory:</b>&nbsp;&nbsp;$percent full. $free free out of $total total.<br>\n";
     166    }
     167
     168}
    157169
    158170# now run the script psstatus to check the status of running requests and finished requests
  • branches/eam_branches/ps2-tc3-20130727/pstamp/scripts/pstampparse.pl

    r35828 r36680  
    3131my $no_update;
    3232my $dest_requires_magic;
     33my $dump_params = 0;
    3334
    3435# set this to true to disable update processing
     
    4849    'save-temps'=>  \$save_temps,
    4950    'no-update' =>  \$no_update,
     51    'dump-params' => \$dump_params,
    5052);
    5153
    5254die "invalid mode '$mode'" unless ($mode eq "list_uri") or ($mode eq "queue_job");
    53 die "--file is required"     if !defined($request_file_name);
     55die "--file is required"   unless defined($request_file_name);
    5456
    5557if ($mode ne "list_uri") {
    56     die "req_id is required"   if !$req_id;
     58    die "req_id is required"  if !$req_id;
    5759    die "outdir is required"  if !$outdir;
    58     die "product is required"  if !$product;
     60    die "product is required" if !$product;
    5961} else {
    60     $req_id = 0;
    61     $outdir = "nowhere";
     62    # mode eq 'list_uri' (used for parser testing)
     63    # these values won't be used for anything but should be defined to avoid errors
     64    $req_id  = 0;
     65    $outdir  = "nowhere";
    6266    $product = "dummy";
    6367}
     
    7680my $pstamptool  = can_run('pstamptool')  or (warn "Can't find pstamptool"  and $missing_tools = 1);
    7781my $pstampdump  = can_run('pstampdump') or (warn "Can't find pstampdump" and $missing_tools = 1);
    78 my $fields  = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1);
     82my $fields      = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1);
    7983
    8084if ($missing_tools) {
     
    116120if ($extver >= 2) {
    117121    # We have a version 2 file. Require that the new keywords be supplied.
    118     my_die("action not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless defined $action;
    119 
    120     my_die("invalid action: $action supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless (uc($action) eq 'PROCESS' or uc($action) eq 'PREVIEW');
    121 
    122     my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless $email;
     122    my_die("action not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST)
     123        unless defined $action;
     124
     125    my_die("invalid action: $action supplied in version $extver request file $request_file_name\n",
     126        $PSTAMP_INVALID_REQUEST)
     127        unless (uc($action) eq 'PROCESS' or uc($action) eq 'PREVIEW');
     128
     129    my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST)
     130        unless $email;
     131
    123132    # XXX check for "valid" $email
    124133} else {
    125134    # for version 1 file the action is process and email is not used
    126135    $action = 'PROCESS';
    127     $email = 'null';
     136    $email  = 'null';
    128137}
    129138
     
    175184
    176185
    177 if ($req_id and !$no_update) {
     186{
    178187    # update the database with the request name. This will be used as the
    179     # the output data store's product name
     188    # the fileset name in the output data store
    180189    my $command = "$pstamptool -updatereq -req_id $req_id  -set_name $req_name";
    181190    $command .= " -set_username $email" if $email ne 'null';
    182191    $command .= " -set_outProduct $product";
    183192    $command .= " -set_label $label" if $label_changed;
    184     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    185         run(command => $command, verbose => $verbose);
    186     unless ($success) {
    187         my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
    188     }
    189 }
     193    unless ($no_update) {
     194        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     195            run(command => $command, verbose => $verbose);
     196        unless ($success) {
     197            my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     198        }
     199    } else {
     200        print "skipping $command\n";
     201    }
     202}
     203
    190204if ($duplicate_req_name) {
    191205    exit 0;
     
    212226}
    213227
    214 my $nRows = scalar @$rows;
     228my $nRows = $rows ? scalar @$rows : 0;
    215229print "\n$nRows rows read from request file\n";
    216230
     231unless ($nRows) {
     232    # pstamp_job_run was invoked so the request file must have contained a valid header
     233    # a request file with no rows is invalid.
     234    # The print above will let the log file know a bit more.
     235    # Insert a faulted fake job and exit this program successfully.
     236    print STDERR "Invalid request file.\n";
     237    insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST);
     238    exit 0;
     239}
     240
     241
     242# if label is for one of the high priority channels, watch for big requests
     243my $watch_for_big_requests = (!($label =~ /BIG/) and ($label =~ /PSI/ or $label =~ /WEB/));
     244
     245# XXX: these should be in a configuration file somewhere not hard coded
     246my $big_limit = 100;
     247my $job_big_limit = 400;
     248
     249if ($watch_for_big_requests and $nRows > $big_limit) {
     250    $label = change_to_lower_priority_label($label);
     251    $watch_for_big_requests = 0;
     252}
    217253
    218254my $num_jobs = 0;
    219 my $imageList;
    220 my $stage;
     255
    221256foreach my $row (@$rows) {
    222 
    223     if ($label eq 'WEB.UP' and ($nRows > 500 or $num_jobs > 500) and $req_id and !$no_update) {
    224         # this is a big request and it came from the upload page and doesn't have a specific label assigned
    225         # change it to the generic one that has lower with lower priority
    226         $label = 'WEB.BIG';
    227         print "\nChanging label for big WEB.UP request to $label\n";
    228 
    229         my $command = "$pstamptool -updatereq -req_id $req_id  -set_label $label";
    230         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    231             run(command => $command, verbose => $verbose);
    232         unless ($success) {
    233             my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
    234         }
    235     }
    236257
    237258    # validate the paramaters
     
    246267
    247268    $num_jobs += processRow($action, $row);
     269
     270    # see whether number of jobs limit for high priority request was exceeded
     271    if ($watch_for_big_requests and $num_jobs > $job_big_limit) {
     272        $label = change_to_lower_priority_label($label);
     273        $watch_for_big_requests = 0;
     274    }
    248275}
    249276
    250277if (($action eq 'LIST' or $mode eq "queue_job") and ($num_jobs eq 0)) {
    251     print STDERR "no jobs created for $req_name\n" if $verbose;
    252     insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST);
     278    # this should not happen. The function above is required to insert a fake job for any
     279    # rows that did not yield any jobs.
     280    print STDERR "ERROR: zero jobs created for $req_name\n";
     281    insertFakeJobForRow(undef, 0, $PS_EXIT_PROG_ERROR);
    253282}
    254283
    255284exit 0;
     285
     286# end of main function
     287
     288sub change_to_lower_priority_label {
     289    my $label = shift;
     290    my $old_label = $label;
     291    $label = ($label =~ /WEB/) ? 'WEB.BIG' : 'PSI.BIG';
     292    print "\nChanging label for big $old_label request to $label\n";
     293
     294    my $command = "$pstamptool -updatereq -req_id $req_id  -set_label $label";
     295    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     296        run(command => $command, verbose => $verbose);
     297    unless ($success) {
     298        my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     299    }
     300    return $label;
     301}
    256302
    257303sub checkRow {
     
    267313    my $rownum   = $row->{ROWNUM};
    268314    if (!validID($rownum)) {
     315        $rownum = 'NULL' if !defined $rownum;
    269316        print STDERR "$rownum is not a valid ROWNUM\n";
    270317        insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
     
    272319    }
    273320    my $job_type = $row->{JOB_TYPE};
    274     if (($job_type ne "stamp") and ($job_type ne "get_image")) {
     321    if (!defined $job_type || (($job_type ne "stamp") and ($job_type ne "get_image"))) {
     322        $job_type = 'NULL' if !defined $job_type;
    275323        print STDERR "$job_type is not a valid JOB_TYPE\n";
    276324        insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
     
    281329    if (($req_type ne "byid") and ($req_type ne "bycoord") and ($req_type ne "byexp") and
    282330        ($req_type ne "byskycell") and ($req_type ne "bydiff")) {
     331        $req_type = 'NULL' if !defined $req_type;
    283332        print STDERR "$req_type is not a valid REQ_TYPE\n";
    284333        insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
     
    286335    }
    287336    if ($job_type eq 'get_image') {
    288         unless ($req_type eq 'byid' or $req_type eq 'byexp' or ($req_type eq 'byskycell' and $stage eq 'stack')) {
    289             print STDERR "REQ_TYPE must be 'byid' or 'byexp' or byskcyell for stacks for JOB_TYPE 'get_image'\n";
     337        # get_image jobs are quite expensive in terms of space so we are currently restricting them
     338        unless ($req_type eq 'byid' or $req_type eq 'byexp'
     339            or ($req_type eq 'byskycell' and $stage eq 'stack')
     340            or ($stage eq 'stack_summary')) {
     341            print STDERR "REQ_TYPE must be 'byid' or 'byexp' JOB_TYPE 'get_image' for IMG_TYPE $stage\n";
    290342            insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
    291343            return 0;
     
    295347    my $component = $row->{COMPONENT};
    296348    if (!defined $component or (lc($component) eq "null") or (lc($component) eq "all")) {
    297         if ($job_type eq 'get_image') {
     349        if ($job_type eq 'get_image' and ! ($stage eq 'stack' or $stage eq 'stack_summary')) {
    298350            $row->{COMPONENT} = 'all';
    299351        } else {
     
    384436    }
    385437
    386     if (($req_type eq "byexp") and ($stage eq "stack")) {
    387         print STDERR "byexp not implemented for stack stage. row: $rownum\n";
     438    if (($req_type eq "byexp") and ($stage eq "stack" or $stage eq 'stack_summary')) {
     439        print STDERR "byexp not implemented for $stage stage. row: $rownum\n";
    388440        insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);
    389441        return 0;
     
    457509    my $start_locate = gettimeofday();
    458510
    459     print "\nCalling new_locate_images for row: $rownum\n";
    460 
    461     $imageList = locate_images_for_row($ipprc, $image_db, $camera, $row, $verbose);
     511    print "\nCalling locate_images_for_row for row: $rownum\n";
     512
     513    my $imageList = locate_images_for_row($ipprc, $image_db, $camera, $row, $verbose);
    462514
    463515    my $dtime_locate = gettimeofday() - $start_locate;
     
    521573    my $image_db   = $proj_hash->{dbname};
    522574    my $camera     = $proj_hash->{camera};
    523     my $need_magic    = $proj_hash->{need_magic};
     575    my $need_magic = $proj_hash->{need_magic};
    524576    # Since user can get unmagicked data "by coordinate" requests can go back in time
    525577    # to dredge unusable data from the "dark days"...
     
    532584    $need_magic = 0 if $stage eq 'stack';
    533585
    534     if ($need_magic) {
    535 
    536         # this project requires that postage stamps be extracted from destreaked images
    537 
    538         if ($option_mask & ($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED)) {
    539             # The user has requested uncensored stamps
    540 
    541             if (!$dest_requires_magic) {
    542                 # and this user's data store destination is allowed uncensored stamps, so accept the request
    543                 $need_magic = 0;
    544             } else {
    545                 print STDERR "Error row $rownum: User not authorized to to request uncensored stamps.\n";
    546                 if ($option_mask & $PSTAMP_REQUIRE_UNCENSORED) {
    547                     # user required uncensored stamps. Can't do it so fail.
    548                     foreach my $r (@$rowList) {
    549                         insertFakeJobForRow($r, 1, $PSTAMP_NOT_AUTHORIZED);
    550                         $num_jobs++;
    551                     }
    552                     return $num_jobs;
    553                 }
    554 
    555                 # user will accept censored stamps. alter OPTION_MASK and continue
    556 
    557                 print STDERR "    Will attempt to make destreaked stamps\n";
    558                 # zap the offending bit in the option mask
    559                 $option_mask = $option_mask ^ ($PSTAMP_REQUEST_UNCENSORED);
    560                 foreach my $r (@$rowList) {
    561                     $r->{OPTION_MASK} = $option_mask;
    562                 }
    563             }
    564         }
    565     }
    566    
     586    # XXX: magic is dead
     587    $need_magic = 0;
     588
    567589    my $numRows = scalar @$rowList;
    568590
     
    581603    # information required is contained there
    582604
    583     $imageList = locate_images($ipprc, $image_db, $rowList, $req_type, $stage, $id, $tess_id, $component,
     605    my $imageList = locate_images($ipprc, $image_db, $rowList, $req_type, $stage, $id, $tess_id, $component,
    584606                $option_mask, $need_magic, $mjd_min, $mjd_max, $filter, $data_group, $verbose);
    585607
     
    701723    }
    702724    $base =~ s/.fits$//;
     725
     726    my $filter = $image->{filter};
     727    if (!$filter) {
     728        if ($stage eq 'diff') {
     729            $filter = $image->{filter_1};
     730        }
     731        if (!$filter) {
     732            # XXX: perhaps this should be a programming error...
     733            print STDERR "missing filter using 'X'\n";
     734            $filter = 'X';
     735        }
     736    }
     737    # use first character of filter
     738    $filter = substr($filter, 0, 1);
    703739           
    704     my $output_base = "$outdir/${rownum}_${job_num}_${base}";
     740    my $output_base = "$outdir/${rownum}_${job_num}_${filter}_${base}";
    705741    write_params($output_base, $image);
    706742
     
    758794            print "$image->{image}\n";
    759795            ++$firstRow->{job_num};
     796            if ($dump_params) {
     797                my $rownum = $firstRow->{ROWNUM};
     798                my $jobnum = $firstRow->{job_num};
     799                my $filter = substr $image->{filter}, 0, 1;
     800                my $output_base = "${rownum}_${jobnum}_${filter}";
     801                write_params($output_base, $image);
     802            }
    760803        }
    761804    } elsif ($job_type eq "get_image") {
     
    11631206    }
    11641207    if (($img_type eq "raw") or ($img_type eq "chip") or ($img_type eq "warp") or
    1165         ($img_type eq "stack") or ($img_type eq "diff")) {
     1208        ($img_type eq "stack") or ($img_type eq 'stack_summary') or ($img_type eq "diff")) {
    11661209        return 1;
    11671210    } else {
Note: See TracChangeset for help on using the changeset viewer.