IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 23, 2010, 11:33:14 AM (16 years ago)
Author:
bills
Message:

Enable the postage stamp server to generate stamps from cleaned up data.
"Works" for chip and warp stages. diff and maybe stack to do.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstamp_request_file

    r26289 r27751  
    187187        for (my $i = 0; $i < scalar @colNames; $i++) {
    188188            my $writeType = $colWriteType[$i];
    189             $outFits->write_col( $writeType, $i + 1, 1, 1, $numRows, $colData->[$i], $status );
     189            my $data = $colData->[$i];
     190            if ($writeType == TULONG) {
     191                die "invalid integer data found in column $i\n" unless validIntegers($data);
     192            } elsif ($writeType == TDOUBLE) {
     193                die "invalid numeric data found in column $i\n" unless validNumbers($data);
     194            }
     195            $outFits->write_col( $writeType, $i + 1, 1, 1, $numRows, $data, $status );
    190196            check_fitsio( $status );
    191197        }
     
    312318}
    313319
     320sub checkValid {
     321    my $aref = shift;
     322    my $float = shift;
     323
     324    return 0 if !defined $aref;
     325
     326    my $valid = 0;
     327    my $row = 0;
     328    foreach my $val (@$aref) {
     329        $row++;
     330        if ($float) {
     331            if (!($val =~  /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/)) {
     332                $valid = 0;
     333                print STDERR "Error on row $row: '$val' is not a valid number\n";
     334                last;
     335            }
     336        } else {
     337            if ($val =~ /\D/) {
     338                $valid = 0;
     339                print STDERR "Error on row $row: '$val' is not a valid integer\n";
     340                last;
     341            }
     342        }
     343        $valid = 1;
     344    }
     345
     346    return $valid;
     347}
     348sub validIntegers {
     349    return checkValid(@_, 0);
     350}
     351
     352sub validNumbers
     353{
     354    return checkValid(@_, 1);
     355}
     356
     357
    314358sub printhelp
    315359{
Note: See TracChangeset for help on using the changeset viewer.