IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 18, 2012, 3:52:27 PM (14 years ago)
Author:
bills
Message:

Start working on version 2 of the postage stamp fits interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstamp_request_file

    r29673 r34447  
    4949                    value => undef
    5050        },
     51        { name => 'ACTION',
     52                    writetype => TSTRING,
     53                    comment => 'Action to perform: LIST or PROCESS',
     54                    value => undef
     55        },
     56        { name => 'USERNAME',
     57                    writetype => TSTRING,
     58                    comment => 'username for request (optional)',
     59                    value => undef
     60        },
     61        { name => 'EMAIL',
     62                    writetype => TSTRING,
     63                    comment => 'email for submittor (optional)',
     64                    value => undef
     65        },
    5166];
    5267
    5368# Specification of columns to write
    5469my $columns = [
     70        { name => 'ROWNUM',     type => 'J',   writetype => TULONG },
     71
     72        { name => 'CENTER_X',   type => 'D',  writetype => TDOUBLE },
     73        { name => 'CENTER_Y',   type => 'D',  writetype => TDOUBLE },
     74        { name => 'WIDTH',      type => 'D',  writetype => TDOUBLE },
     75        { name => 'HEIGHT',     type => 'D',  writetype => TDOUBLE },
     76        # 2 bits in COORD_MASK indicate what units of roi coords are
     77        { name => 'COORD_MASK', type => 'J',  writetype => TULONG },
     78
     79        { name => 'JOB_TYPE',   type => '16A', writetype => TSTRING },
     80        { name => 'OPTION_MASK',type => 'J',   writetype => TULONG },
     81
     82        # image selection parameters
     83        { name => 'PROJECT',    type => '16A', writetype => TSTRING },
     84        # new in version 2
     85        { name => 'SURVEY_NAME',type => '16A', writetype => TSTRING },
     86        { name => 'IPP_RELEASE', type => '16A', writetype => TSTRING },
     87        # end of new in version 2
     88        { name => 'REQ_TYPE',   type => '16A', writetype => TSTRING },
     89        { name => 'IMG_TYPE',   type => '16A', writetype => TSTRING },
     90        { name => 'ID',         type => '16A', writetype => TSTRING },           
     91        { name => 'TESS_ID',    type => '64A', writetype => TSTRING },
     92        { name => 'COMPONENT',  type => '64A', writetype => TSTRING },
     93
     94        { name => 'DATA_GROUP ',type => '64A', writetype => TSTRING },
     95
     96        { name => 'REQFILT',    type => '16A', writetype => TSTRING },
     97        { name => 'MJD_MIN',    type => 'D',   writetype => TDOUBLE },
     98        { name => 'MJD_MAX',    type => 'D',   writetype => TDOUBLE },
     99        { name => 'RUN_TYPE',   type => '16A', writetype => TSTRING },
     100
     101        { name => 'COMMENT ',   type => '64A', writetype => TSTRING },
     102];
     103my $columns_v1 = [
    55104        { name => 'ROWNUM',     type => 'J',   writetype => TULONG },
    56105
     
    89138}
    90139
     140# build array of arrays for the column data. Note if the input file is version 1 then
     141# some of thes will get dropped
    91142my @colData;
    92143foreach (@$columns) {
     
    96147
    97148my $minimum_cols = 6;
    98 my $numRows = read_data_for_table($in,'\s+', \@colData, $header, $minimum_cols);
     149my $extver = 2;
     150my $numRows = read_data_for_table($in,'\s+', \@colData, $header, $minimum_cols, \$extver);
    99151if (!$numRows) {
    100152    print STDERR "no data in $input\n";
     
    115167$output = $req_name . ".fits" if !$output;
    116168
    117 my $status = make_fits_table($output, EXTNAME, $numRows, \@colData, $columns, $header);
     169my $status = make_fits_table($output, EXTNAME, $numRows, \@colData, $extver > 1 ? $columns : $columns_v1, $header);
    118170
    119171exit $status;
     
    230282    my $header  = shift;    # rerence to array of header keyword descriptions
    231283    my $minimum_required_vals = shift;
     284    my $r_extver = shift;   # reference to extension version
    232285
    233286    my $line_num = 0;
     
    243296            my @vals = split /$sep/, $line;
    244297            my $nvals = @vals;
    245             die "number of header columns in input $nvals does not equal expected number of header words $nhead"
     298            die "two few columns $nvals in header definition. Require at least 2" if @vals < 2;
     299
     300            $$r_extver = $vals[1];
     301            if ($extver > 1) {
     302                die "number of header columns in input $nvals does not equal expected number of header words $nhead"
    246303                    if (@vals != @$header);
    247 
    248             for (my $i=0; $i < @$header; $i++) {
    249                 $header->[$i]->{value} = $vals[$i];
    250             }
    251 
    252             last; # only one header line
    253         }
     304            } else {
     305                # drop header keywords not used in version 1
     306                for (my $i = @$header - 1; $i >= $nvals; $i--) {
     307                    pop @$header;
     308                }
     309            }
     310
     311            for (my $i=0; $i < $nvals; $i++) {
     312                my $val = $vals[$i];
     313                if (defined $val) {
     314                    $header->[$i]->{value} = $val;
     315                } else {
     316                    $header->[$i]->{value} = 'null';
     317                }
     318            }
     319
     320            last; # one line defines the header
     321        }
     322    }
     323    if ($$r_extver == 1) {
     324        # pop off the colData arrays to account for the unused columns
     325        pop @colData;
     326        pop @colData;
     327        pop @colData;
    254328    }
    255329
     
    271345            exit 1;
    272346        }
     347        # trim leading whitespace from comment
     348        $comment =~ s/^\s+//;
    273349        if ($comment) {
    274350            if ($comment =~ /#/) {
     
    381457    print "If --output is omitted the output file name is set to REQ_NAME.fits\n\n";
    382458    print "Header 1 Line.  Format:\n\n";
    383     print "  REQ_NAME EXTVER\n\n";
     459    print "REQ_NAME EXTVER ACTION USERNAME EMAIL\n\n";
    384460    print "REQUEST specification (1 or more lines). Format:\n\n";
    385     print "  ROWNUM CENTER_X CENTER_Y WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT REQ_TYPE IMG_TYPE ID TESS_ID COMPONENT DATA_GROUP REQFILT MJD_MIN MJD_MAX | COMMENT\n\n";
     461    print "ROWNUM CENTER_X CENTER_Y WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT SURVEY_NAME IPP_RELEASE REQ_TYPE IMG_TYPE ID TESS_ID COMPONENT DATA_GROUP REQFILT MJD_MIN MJD_MAX RUN_TYPE | COMMENT\n\n";
    386462
    387463    exit 0;
Note: See TracChangeset for help on using the changeset viewer.