IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18983 for trunk/pstamp/scripts


Ignore:
Timestamp:
Aug 8, 2008, 3:45:45 PM (18 years ago)
Author:
bills
Message:

add request parameters from request file to the results file

File:
1 edited

Legend:

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

    r18640 r18983  
    1818use PS::IPP::Metadata::List qw( parse_md_list );
    1919
    20 use PS::IPP::Config qw($PS_EXIT_SUCCESS
    21                        $PS_EXIT_UNKNOWN_ERROR
    22                        $PS_EXIT_SYS_ERROR
    23                        $PS_EXIT_CONFIG_ERROR
    24                        $PS_EXIT_PROG_ERROR
    25                        $PS_EXIT_DATA_ERROR
    26                        $PS_EXIT_TIMEOUT_ERROR
    27                        metadataLookupStr
    28                        metadataLookupBool
    29                        caturi
    30                        );
    31 
    32 
    33 my ( $req_id, $req_name, $product, $dbname, $verbose, $save_temps );
     20use PS::IPP::Config qw( :standard );
     21use PStamp::RequestFile qw( :standard );
     22
     23my ( $req_id, $req_name, $req_file, $product, $dbname, $verbose, $save_temps );
    3424
    3525# the char to the right of the bar may be used as a single - alias for the longer name
     
    3828           'req_id=s'   => \$req_id,
    3929           'req_name=s' => \$req_name,
     30           'req_file=s' => \$req_file,
    4031           'product=s'  => \$product,
    4132           'dbname=s'   => \$dbname,
     
    4536
    4637pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     38
     39die "usage: --req_id id --req_name name --req_file file --product product [--dbname dbname --verbose]\n"
     40    if !$req_id or !$req_name or !$req_file or !$product;
    4741
    4842my $missing_tools;
     
    8882    }
    8983
     84
     85                        # this function is PStamp::RequestFile::read_request_file
     86    my ($header, $rows) = read_request_file($req_file);
     87
     88    die "failed to read request_file $req_file" if !$header or !$rows;
    9089
    9190    # at this point we need to find out what kind of request type it is and
     
    145144        my $rownum = $job->{rownum};
    146145        my $fault = $job->{fault};
     146
     147        my $row_info = get_request_info($rows, $rownum);
    147148        # rownum fault img_name job_id
    148149        if (($job_type eq "stamp") || ($job_type eq "get_image")) {
     
    157158                    my ($img_name, undef) = split '\|', $line;
    158159
     160                    # XXX TODO: need to get these from somewhere. Maybe the stamp.
     161                    #
     162                    # ra_deg and dec_deg are the coordinates of center of the stamp
     163                    # the rest of the metadata come from the original FPA.
     164                    # we could get these out of the rawExp table in the database....
     165                    #
     166                    # Much of those data do not apply to stamps from Stack images.
     167                    my ($ra_deg, $dec_deg, $mjd_obs, $ra_obs, $dec_obs, $filter, $exp_time, $fpa_id) =
     168                        (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
     169
    159170                    # add line to the table definition file
    160171                    print $tdf "$rownum|$fault|$img_name|$job_id|";
    161                     # XXX TODO: need to lookup the rest of this stuff
    162                     print $tdf "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|\n";
     172                    print $tdf "$ra_deg|$dec_deg|$mjd_obs|$ra_obs|$dec_obs|$filter|$exp_time|$fpa_id|";
     173                    print $tdf "$row_info";
     174                    print $tdf "\n";
    163175                }
    164176                close JRL;
     
    166178                print STDERR "no reglist file for job $job_id\n" if $verbose;
    167179                print $tdf "$rownum|$fault|0|$job_id|";
    168                 print $tdf "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|\n";
     180                print $tdf "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|\n";
    169181            }
    170182        } else {
     183            # XXX do list jobs
    171184            print STDERR "Unknown jobType: $job_type";
    172185            next;
     
    227240    }
    228241}
     242
     243sub get_request_info {
     244    my $rows = shift;
     245    my $rownum = shift;
     246
     247    my $row = $rows->{$rownum};
     248
     249    # This is ugly, error prone and hard to change.
     250    # Create a results file module and provide a list of the names (we have the data in the columns)
     251    my $rowinfo = "$row->{PROJECT}|$row->{JOB_TYPE}|$row->{REQ_TYPE}|$row->{IMG_TYPE}|";
     252    $rowinfo   .= "$row->{ID}|$row->{CLASS_ID}|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|";
     253    $rowinfo   .= "$row->{REQFILT}|$row->{COORD_MASK}|$row->{CENTER_X}|$row->{CENTER_Y}|";
     254    $rowinfo   .= "$row->{WIDTH}|$row->{HEIGHT}|";
     255
     256    return $rowinfo;
     257}
Note: See TracChangeset for help on using the changeset viewer.