Index: /trunk/pstamp/test/pstamp_req_create
===================================================================
--- /trunk/pstamp/test/pstamp_req_create	(revision 18739)
+++ /trunk/pstamp/test/pstamp_req_create	(revision 18739)
@@ -0,0 +1,265 @@
+#!/usr/bin/env perl
+
+# create a Postage Stamp Request file from a textual description
+
+use warnings;
+use strict;
+
+use Astro::FITS::CFITSIO qw( :constants );
+Astro::FITS::CFITSIO::PerlyUnpacking(1);
+
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+use Pod::Usage qw( pod2usage );
+
+use constant EXTNAME => 'PS1_PS_REQUEST'; # Extension name for output table
+
+my ( $input,			# Name of input text file
+     $output,			# Name of output table
+     $req_name, 
+     );
+
+GetOptions(
+	   'input|i=s'    => \$input,
+	   'output|o=s'   => \$output,
+	   'req_name|q=s'  => \$req_name,
+) or pod2usage( 2 );
+
+pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
+pod2usage( -msg => "Required options: --input --output",
+           -exitval => 3) unless defined $input and defined $output;
+
+# The header kewords
+my $header = [
+        { name =>  'REQ_NAME', 
+                    writetype => TSTRING, 
+                    comment => 'Postage Stamp request name',
+                    value => undef
+        },
+        { name =>  'EXTVER', 
+                    writetype => TSTRING, 
+                    comment => 'Extension version',
+                    value => undef
+        },
+];
+
+# Specification of columns to write
+my $columns = [ 
+        { name => 'ROWNUM',     type => 'J',   writetype => TULONG }, 
+        { name => 'PROJECT',    type => '16A', writetype => TSTRING },
+        { name => 'JOB_TYPE',   type => '16A', writetype => TSTRING },
+
+        { name => 'STAMP_NAME', type => '16A', writetype => TSTRING },
+        { name => 'OPTION_MASK',type => 'J',   writetype => TULONG },
+
+        # image selection parameters
+        { name => 'REQ_TYPE',   type => '16A', writetype => TSTRING },
+        { name => 'IMG_TYPE',   type => '16A', writetype => TSTRING },
+        { name => 'ID',         type => '16A', writetype => TSTRING },           
+        { name => 'CLASS_ID',   type => '16A', writetype => TSTRING },
+
+
+        # 2 bits in COORD_MASK indicate what units of roi coords are
+        { name => 'COORD_MASK', type => 'J',  writetype => TULONG },
+
+        { name => 'CENTER_X',   type => 'D',  writetype => TDOUBLE },
+        { name => 'CENTER_Y',   type => 'D',  writetype => TDOUBLE },
+        { name => 'WIDTH',      type => 'D',  writetype => TDOUBLE },
+        { name => 'HEIGHT',     type => 'D',  writetype => TDOUBLE },
+
+        { name => 'FILTER',    type => '16A', writetype => TSTRING },
+        { name => 'MJD_MIN',   type => 'D',   writetype => TDOUBLE },
+        { name => 'MJD_MAX',   type => 'D',   writetype => TDOUBLE },
+];
+
+my $in;
+if ($input eq '-') {
+    $in = \*STDIN;
+} else {
+    open $in, "<$input" or die "cannot open $input for reading";
+}
+
+my @colData;
+foreach (@$columns) {
+    push @colData, [];
+}
+
+
+my $numRows = read_data_for_table($in,'\s+', \@colData, $header); 
+if (!$numRows) {
+    print STDERR "no data in $input\n";
+    exit 1;
+}
+
+# overwrite the REQ_NAME value from the input file with the command
+# line argument
+
+if ($req_name) {
+    $header->[0]->{value} = $req_name;
+}
+
+my $status = make_fits_table($output, EXTNAME, $numRows, \@colData, $columns, $header);
+
+exit $status;
+
+# XXXXX: This should be in a module
+# two utility functions that may be used to create a FITS binary
+# table from hashes describing the header keywords and columns
+
+# read_table_description reads the data for a table from a simple text file
+# make_fits_table writes out the table to a named file
+
+
+# A function to build a fits binary table from supplied data 
+# 
+sub make_fits_table {
+        my $output = shift;     # name of output file
+        my $extname = shift;    # extension name
+        my $numRows = shift;    # number of rows in the table
+        my $colData = shift;    # ref to array of arrays containing the data for each column
+        my $columns = shift;    # ref to array of column descriptions (each a hash)
+                                # with keys: name, type, and writetype
+        my $header = shift;     # ref to array of header keyword descriptions - each a hash
+                                # with keys: name, name, writetype, comment, and value
+        my $status = 0;
+
+        die "incorrect arguments" if !defined($columns);
+        # note $header can be nil
+
+        # build arrays for cfitsio
+        my @colNames;			# Names of columns
+        my @colTypes;			# Types of columns
+        my @colWriteType;               # type to use to write
+
+        foreach my $colSpec ( @$columns) {
+            push @colNames, $colSpec->{name};
+            push @colTypes, $colSpec->{type};
+            push @colWriteType, $colSpec->{writetype};
+        }
+
+        if (-e $output) {
+            unlink "$output" or die "failed to remove existing $output";
+        }
+
+        my $outFits = Astro::FITS::CFITSIO::create_file( $output, $status ); # Output file handle
+        check_fitsio( $status );
+
+        $outFits->create_img( 16, 0, undef, $status );
+        check_fitsio( $status );
+
+        # Create the table
+
+        $outFits->create_tbl( BINARY_TBL(), $numRows, scalar @colNames,
+                                \@colNames, \@colTypes, undef, $extname, $status );
+        check_fitsio( $status );
+
+        # if header keyword descriptions were provided add them
+        if ($header) {
+            foreach my $headerword ( @$header ) {
+                my $value = $headerword->{value};
+                unless (defined $value) {
+                    print "Can't find header keyword $headerword\n";
+                    next;
+                }
+                # zap quotation marks
+                $value =~ s/\'//g;
+                my $name    = $headerword->{name};
+                my $type    = $headerword->{writetype};
+                my $comment = $headerword->{comment};
+                $outFits->write_key( $type, $name, $value, $comment, $status );
+                check_fitsio( $status );
+            }
+        }
+
+
+        for (my $i = 0; $i < scalar @colNames; $i++) {
+            my $writeType = $colWriteType[$i];
+            $outFits->write_col( $writeType, $i + 1, 1, 1, $numRows, $colData->[$i], $status );
+            check_fitsio( $status );
+        }
+
+        $outFits->close_file( $status );
+
+        return 0;
+
+} # end of sub make_fits_table
+
+
+
+# read the table contents from a file
+#
+# input text file format:
+#   lines that begin with '#' are comment lines and are skipped.
+#   other lines are data. Each data line is split into fields with the
+#   provided separator
+#
+# if $header is not null header the first non-commented line is read to
+# fill the value for each header keyword. The number of fields must match
+# the number of keywords.
+#
+# Following the optional header data, each data line contains data for each
+# row in the table. The number of fields must match the number of column
+# arrays provided.
+
+sub read_data_for_table {
+    my $in      = shift;    # input file handle
+    my $sep     = shift;    # string containing field separator
+    my $colData = shift;    # reference to an array of arrays for the data
+    my $header  = shift;    # rerence to array of header keyword descriptions
+
+    my $line_num = 0;
+
+    # read data for header if any data is expected
+    if ($header) {
+        my $nhead = @$header;
+        while (my $line = <$in>) {
+            $line_num++;
+            chomp $line;
+            next if !$line;             # skip blank lines
+            next if ($line =~ /^#/);    # skip comment lines
+            my @vals = split /$sep/, $line;
+            my $nvals = @vals;
+            die "number of header columns in input $nvals does not equal expected number of header words $nhead"
+                    if (@vals != @$header);
+
+            for (my $i=0; $i < @$header; $i++) {
+                $header->[$i]->{value} = $vals[$i];
+            }
+
+            last; # only one header line
+        }
+    }
+
+    my $row_num = 0;
+    my $ncols = @$colData;
+    while (my $line = <$in>) {
+        chomp $line;
+        $line_num++;
+        next if !$line;             # skip blank lines
+        next if ($line =~ /^#/);    # skip comment lines
+
+        my @vals = split /$sep/, $line;
+        my $nvals = @vals;
+        die "number of columns $nvals in input does not equal expected number of header "
+                . " words $ncols on line $line_num" if ($nvals != $ncols);
+
+        for (my $col = 0; $col < @$colData; $col++) {
+            $colData->[$col]->[$row_num] = $vals[$col];
+        }
+        $row_num++;
+    }
+
+    # we return the number of rows read
+    return $row_num;
+}
+
+# From Astro::FITS::CFITSIO demo
+sub check_fitsio
+{
+    my $status = shift;		# Status of FITSIO calls
+
+    if ($status != 0) {
+	my $msg;		# Message to output
+	Astro::FITS::CFITSIO::fits_get_errstatus( $status , $msg );
+	die "CFITSIO error: $msg\n";
+    }
+}
Index: /trunk/pstamp/test/sample_pstamp.txt
===================================================================
--- /trunk/pstamp/test/sample_pstamp.txt	(revision 18739)
+++ /trunk/pstamp/test/sample_pstamp.txt	(revision 18739)
@@ -0,0 +1,23 @@
+# Sample Postage stamp request description file
+# This can be parsed by the program pstamp_req_create to build a 
+# PS1_PSTAMP_REQUEST binary table
+
+# First line of data is for the extension header
+# The order of keywords follows TABLE 6 of ICD
+#
+# Note that value for REQ_NAME may be overriden by a command line
+# argument to pstamp_req_create.
+# Blank and comment lines are ignored
+
+# REQ_NAME EXTVER
+PSREQ00001     1
+
+# subsequent lines define the rows in the table
+
+# ROWNUM PROJECT       JOB_TYPE STAMP_NAME OPTION_MASK REQ_TYPE IMG_TYPE ID     CLASS_ID COORD_MASK CENTER_X CENTER_Y WIDTH HEIGHT FILTER MJD_MIN MJD_MAX
+1        megacam-mops   stamp    null       1           byid     chip      419       null        3   1500    1500     100    100     null   0    0
+2        megacam-mops   stamp    null       1           byid     chip      419       null        3   1600    1500     100    100     null   0    0
+3        megacam-mops   stamp    null       1           byid     chip      419       null        3   1700    1500     100    100     null   0    0
+
+# the following row will create several jobs
+4        megacam-mops   stamp    null       1           byexp    stack     906043p   null        3   400      400     100    200     null   0    0
Index: /trunk/pstamp/test/sample_query.txt
===================================================================
--- /trunk/pstamp/test/sample_query.txt	(revision 18738)
+++ /trunk/pstamp/test/sample_query.txt	(revision 18739)
@@ -1,11 +1,15 @@
-# Sample Detectability Query descriptor file used by the program
+# Sample Detectability Query description file used by the program
 # detect_query_create
 
-# First line of data is for the HEADER
-# order of keywords follows TABLE 6 of ICD (note the QUERY_ID may
-# be overriden by a command line argument to detect_query_create
+# First line of data is for the extension header
+# The order of keywords follows TABLE 6 of ICD
+# Note that value for QUERY_ID may be overriden by a command line
+# argument to detect_query_create.
+# Blank and comment lines are ignored
 
 # QUERY_ID EXTVER FPA_ID       MJD-OBS FILTER OBSCODE
 QUERY42       1   o4608g0103o   54608     g     566
+
+# subsequent lines define the rows in the table
 
 # ROWNUM     RA1_DEG        DEC1_DEG    RA2_DEG     DEC2_DEG     MAG
Index: unk/pstamp/test/testdquery.pl
===================================================================
--- /trunk/pstamp/test/testdquery.pl	(revision 18738)
+++ 	(revision )
@@ -1,161 +1,0 @@
-#!/bin/env  perl
-
-# program to create a sample detectability query file and
-# register it in a Data Store
-
-# defaults for local configuration
-# dsreg also needs IPP site configuration to connect to the database
-my $dbname  = "DataStore";
-my $product = "detectability_query";
-
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use Pod::Usage qw( pod2usage );
-use IPC::Cmd 0.36 qw( can_run run );
-use File::Temp qw(tempfile);
-
-
-my ($query_id, $input, $fs_name, $verbose, $save_temps);
-
-GetOptions(
-    'input|i=s'     => \$input,
-    'query_id|q=s'  => \$query_id,
-    'verbose|v'     => \$verbose,
-    'save-temps'    => \$save_temps,
-    'dbname=s'      => \$dbname,
-    'product=s'     => \$product,
-) or pod2usage( 2 );
-
-die "--query_id is required\n" if ! $query_id;
-
-my $dsreg = can_run("dsreg") or die "cant'f find dsreg";
-my $detect_query_create = can_run("./detect_query_create") or die "cant'f find detect_query_create";
-
-$fs_name = $query_id;
-
-my $req_file;
-my $RFH;
-my $datapath;
-if ($save_temps) {
-    $req_file = "${query_id}.fits";
-    $datapath = ".";
-} else {
-    ($RFH, $req_file) = tempfile("/tmp/${query_id}.fits.XXXX", UNLINK => 1);
-    die "failed to create tempfile" if !$RFH;
-    $datapath = "/";
-}
-
-
-my $query_txt_file;
-my $FH;
-# if no query file is supplied make one from the Here document in the subroutine make_default_query
-if ($input) {
-    $query_txt_file = $input;
-} else {
-    ($FH, $query_txt_file) = tempfile("/tmp/dquery.txt.XXXX", UNLINK => !$save_temps);
-    die "failed to create tempfile" if !$FH;
-    make_default_query($FH);
-}
-
-die "can't find request description file $query_txt_file" 
-    if (!-e $query_txt_file);
-
-my $create_cmd = "$detect_query_create -i $query_txt_file -o $req_file -q $query_id";
-
-my $reg_cmd = "echo '$req_file|||table|' | $dsreg --dbname $dbname";
-   $reg_cmd .= " --product $product --type MOPS_DETECTABILITY_QUERY";
-   $reg_cmd .= " --add $fs_name --copy --datapath $datapath --list -";
-
-print "$create_cmd\n" if $verbose;
-print "$reg_cmd\n" if $verbose;
-
-{
-    my $command = "$create_cmd";
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
-    unless ($success) {
-        print STDERR "command failed error code: $error_code\nstderr:\n\t";
-        print STDERR @$stderr_buf;
-        print "\n";
-
-        my $exit_status = $error_code >> 8;
-        print STDERR "exiting with status $exit_status\n" if $verbose;
-        exit $exit_status;
-    }
-}
-{
-    my $command = "$reg_cmd";
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
-    unless ($success) {
-        print STDERR "command failed error code: $error_code\nstderr:\n\t"
-            if $verbose;
-        print STDERR @$stderr_buf;
-        print "\n" if $verbose;
-
-        my $exit_status = $error_code >> 8;
-        print STDERR "exiting with status $exit_status\n" if $verbose;
-        exit $exit_status;
-    }
-}
-exit 0;
-
-sub make_default_query()
-{
-    my $FH = shift;
-    my $data = <<'THE_END';
-# Sample data
-# First line of data is for the HEADER
-# order of keywords follows TABLE 6 of ICD
-# QUERY_ID EXTVER FPA_ID       MJD-OBS FILTER OBSCODE
-QUERY42       1   o4608g0103o   54608     g     566
-#
-# ROWNUM     RA1_DEG        DEC1_DEG    RA2_DEG     DEC2_DEG     MAG
-1            312.44049389 30.54022727  312.44051968 30.54024139  18.4228     
-2            313.03337881 31.01317194  313.03344194 31.01324268  18.3961     
-3            312.91159232 30.95195459  312.91153476 30.95190113  18.1110     
-4            312.26742527 30.95207284  312.26744769 30.95206300  17.0908     
-5            313.20263734 30.62317841  313.20266984 30.62310935  18.2890     
-6            312.85365023 30.45667552  312.85358645 30.45661659  16.9252     
-7            312.86257534 30.73005531  312.86264564 30.73012644  16.5870     
-8            312.62651492 30.28398046  312.62654595 30.28390213  16.6911     
-9            312.30703743 30.99927709  312.30708709 30.99927981  17.4722     
-10           312.95440987 30.21452885  312.95434880 30.21444691  18.5156     
-11           313.09947609 30.93800421  313.09940219 30.93795549  17.8855     
-12           312.97417836 31.11301952  312.97423473 31.11296140  16.9911     
-13           313.11781918 30.37359317  313.11784695 30.37360958  16.7468     
-14           312.76927925 30.53972354  312.76933224 30.53976126  16.8949     
-15           313.14717536 30.25958068  313.14710913 30.25951218  16.8300     
-16           312.30604633 30.88958513  312.30599425 30.88959415  18.2257     
-17           312.43565662 30.43038293  312.43560908 30.43037934  19.0005     
-18           312.55589195 30.81649562  312.55594584 30.81655133  18.6992     
-19           312.48925222 30.79092013  312.48924050 30.79087193  19.2099     
-20           312.94560207 31.15170816  312.94554641 31.15162988  17.2162     
-21           313.19589134 30.74674862  313.19594142 30.74682054  16.6793     
-22           312.70278940 30.52926292  312.70271911 30.52926109  19.0436     
-23           312.56015422 30.77354938  312.56021167 30.77360353  19.2750     
-24           312.87989916 30.78926857  312.87996776 30.78920032  18.2502     
-25           312.81101394 30.65212801  312.81096654 30.65215390  18.5487     
-26           312.55607541 30.23260894  312.55612602 30.23263745  17.2404     
-27           312.47366234 31.02186968  312.47372919 31.02192895  18.9959     
-28           312.90062087 31.13704835  312.90061590 31.13697785  17.5652     
-29           313.01177949 31.16629118  313.01181621 31.16626516  17.0270     
-30           312.40371494 30.98672316  312.40366292 30.98677392  19.1234     
-31           312.56662477 31.01082034  312.56665651 31.01078413  17.6238     
-32           312.61398923 30.64616956  312.61399907 30.64618259  18.5522     
-33           313.07268041 30.96857880  313.07272131 30.96859005  17.7002     
-34           312.36144521 30.43367984  312.36146205 30.43373589  16.6557     
-35           312.74549146 30.89623741  312.74554546 30.89630365  18.8037     
-36           312.49256362 30.78465056  312.49260740 30.78459825  16.7909     
-37           312.92641571 30.76107785  312.92634812 30.76111408  17.2734     
-38           312.84561663 30.38510072  312.84561100 30.38515538  18.3349     
-39           312.48297202 31.08290934  312.48297374 31.08290383  17.6822     
-40           312.27670734 30.89704117  312.27664961 30.89698871  17.4518     
-41           312.82856967 30.65880493  312.82859245 30.65878537  18.8543     
-42           313.05680974 30.97207965  313.05672748 30.97211785  16.6627     
-THE_END
-
-    print $FH $data;
-
-    close $FH;
-}
-
Index: /trunk/pstamp/test/testrequest
===================================================================
--- /trunk/pstamp/test/testrequest	(revision 18739)
+++ /trunk/pstamp/test/testrequest	(revision 18739)
@@ -0,0 +1,182 @@
+#!/bin/env  perl
+
+# program to create a sample detectability query or postage stamp request file
+# and register it in a Data Store
+
+#  defaults for local configuration
+
+my $dquery_product = "detectability_query";
+my $pstamp_product = "pstamprequests";
+
+# note: dsreg also needs IPP site configuration to connect to the database
+
+
+use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
+use Pod::Usage qw( pod2usage );
+use IPC::Cmd 0.36 qw( can_run run );
+use File::Temp qw(tempfile);
+
+
+my ($query_id, $req_name, $product, $input, $fs_name, $verbose, $save_temps);
+
+GetOptions(
+    'input|i=s'     => \$input,
+    'query_id|q=s'  => \$query_id,
+    'req_name|r=s'  => \$req_name,
+    'verbose|v'     => \$verbose,
+    'save-temps'    => \$save_temps,
+    'dbname=s'      => \$dbname,
+    'product=s'     => \$product,
+) or pod2usage( 2 );
+
+die "--query_id or --req_name is required\n" if ((!$query_id) && (!$req_name));
+die "only one of --query_id or --req_name is allowed\n" if ($query_id && $req_name);
+
+my $dsreg = can_run("dsreg") or die "cant'f find dsreg";
+my $detect_query_create = can_run("detect_query_create") or die "cant'f find detect_query_create";
+my $pstamp_req_create = can_run("pstamp_req_create") or die "cant'f find pstamp_req_create";
+
+my $fileset_type;
+my $create_cmd;
+
+# if query_id is supplied we make a detectability query
+if ($query_id) {
+    $create_prog = $detect_query_create;
+    $req_name = $query_id;
+    $product = $dquery_product if !$product;
+    $fileset_type = "MOPS_DETECTABILITY_QUERY";
+    $create_cmd = "$detect_query_create --query_id $query_id";
+} else {
+    die "must supply input request decription file\n" if !$input;
+    $product = $pstamp_product if !$product;
+    $fileset_type = "PSREQUEST";
+    $create_cmd = "$pstamp_req_create --req_name $req_name";
+}
+$fs_name = $req_name;
+
+# request fits table
+my $req_file;
+my $RFH;
+my $datapath;
+if ($save_temps) {
+    $req_file = "${req_name}.fits";
+    $datapath = ".";
+} else {
+    ($RFH, $req_file) = tempfile("/tmp/${req_name}.fits.XXXX", UNLINK => 1);
+    die "failed to create tempfile" if !$RFH;
+
+    $datapath = "/";
+}
+
+
+my $query_txt_file;
+my $FH;
+# if no query file is supplied make one from the Here document in the subroutine make_default_query
+if ($input) {
+    $query_txt_file = $input;
+} else {
+    ($FH, $query_txt_file) = tempfile("/tmp/dquery.txt.XXXX", UNLINK => !$save_temps);
+    die "failed to create tempfile" if !$FH;
+    make_default_dquery($FH);
+}
+
+die "can't find request description file $query_txt_file" if (!-e $query_txt_file);
+
+$create_cmd .= " --input $query_txt_file --output $req_file";
+
+my $reg_cmd = "echo '$req_file|||table|'"
+            . " | $dsreg --product $product --type $fileset_type"
+            . " --add $fs_name --copy --datapath $datapath --list -"
+            . " --dbname $dbname" if $dbname;
+
+{
+    my $command = "$create_cmd";
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        print STDERR "command failed error code: $error_code\nstderr:\n\t";
+        print STDERR @$stderr_buf;
+        print "\n";
+
+        my $exit_status = $error_code >> 8;
+        print STDERR "exiting with status $exit_status\n" if $verbose;
+        exit $exit_status;
+    }
+}
+{
+    my $command = "$reg_cmd";
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        print STDERR "command failed error code: $error_code\nstderr:\n\t"
+            if $verbose;
+        print STDERR @$stderr_buf;
+        print "\n" if $verbose;
+
+        my $exit_status = $error_code >> 8;
+        print STDERR "exiting with status $exit_status\n" if $verbose;
+        exit $exit_status;
+    }
+}
+exit 0;
+
+sub make_default_dquery()
+{
+    my $FH = shift;
+    my $data = <<'THE_END';
+# Sample data
+# First line of data is for the HEADER
+# order of keywords follows TABLE 6 of ICD
+# QUERY_ID EXTVER FPA_ID       MJD-OBS FILTER OBSCODE
+QUERY42       1   o4608g0103o   54608     g     566
+#
+# ROWNUM     RA1_DEG        DEC1_DEG    RA2_DEG     DEC2_DEG     MAG
+1            312.44049389 30.54022727  312.44051968 30.54024139  18.4228     
+2            313.03337881 31.01317194  313.03344194 31.01324268  18.3961     
+3            312.91159232 30.95195459  312.91153476 30.95190113  18.1110     
+4            312.26742527 30.95207284  312.26744769 30.95206300  17.0908     
+5            313.20263734 30.62317841  313.20266984 30.62310935  18.2890     
+6            312.85365023 30.45667552  312.85358645 30.45661659  16.9252     
+7            312.86257534 30.73005531  312.86264564 30.73012644  16.5870     
+8            312.62651492 30.28398046  312.62654595 30.28390213  16.6911     
+9            312.30703743 30.99927709  312.30708709 30.99927981  17.4722     
+10           312.95440987 30.21452885  312.95434880 30.21444691  18.5156     
+11           313.09947609 30.93800421  313.09940219 30.93795549  17.8855     
+12           312.97417836 31.11301952  312.97423473 31.11296140  16.9911     
+13           313.11781918 30.37359317  313.11784695 30.37360958  16.7468     
+14           312.76927925 30.53972354  312.76933224 30.53976126  16.8949     
+15           313.14717536 30.25958068  313.14710913 30.25951218  16.8300     
+16           312.30604633 30.88958513  312.30599425 30.88959415  18.2257     
+17           312.43565662 30.43038293  312.43560908 30.43037934  19.0005     
+18           312.55589195 30.81649562  312.55594584 30.81655133  18.6992     
+19           312.48925222 30.79092013  312.48924050 30.79087193  19.2099     
+20           312.94560207 31.15170816  312.94554641 31.15162988  17.2162     
+21           313.19589134 30.74674862  313.19594142 30.74682054  16.6793     
+22           312.70278940 30.52926292  312.70271911 30.52926109  19.0436     
+23           312.56015422 30.77354938  312.56021167 30.77360353  19.2750     
+24           312.87989916 30.78926857  312.87996776 30.78920032  18.2502     
+25           312.81101394 30.65212801  312.81096654 30.65215390  18.5487     
+26           312.55607541 30.23260894  312.55612602 30.23263745  17.2404     
+27           312.47366234 31.02186968  312.47372919 31.02192895  18.9959     
+28           312.90062087 31.13704835  312.90061590 31.13697785  17.5652     
+29           313.01177949 31.16629118  313.01181621 31.16626516  17.0270     
+30           312.40371494 30.98672316  312.40366292 30.98677392  19.1234     
+31           312.56662477 31.01082034  312.56665651 31.01078413  17.6238     
+32           312.61398923 30.64616956  312.61399907 30.64618259  18.5522     
+33           313.07268041 30.96857880  313.07272131 30.96859005  17.7002     
+34           312.36144521 30.43367984  312.36146205 30.43373589  16.6557     
+35           312.74549146 30.89623741  312.74554546 30.89630365  18.8037     
+36           312.49256362 30.78465056  312.49260740 30.78459825  16.7909     
+37           312.92641571 30.76107785  312.92634812 30.76111408  17.2734     
+38           312.84561663 30.38510072  312.84561100 30.38515538  18.3349     
+39           312.48297202 31.08290934  312.48297374 31.08290383  17.6822     
+40           312.27670734 30.89704117  312.27664961 30.89698871  17.4518     
+41           312.82856967 30.65880493  312.82859245 30.65878537  18.8543     
+42           313.05680974 30.97207965  313.05672748 30.97211785  16.6627     
+THE_END
+
+    print $FH $data;
+
+    close $FH;
+}
+
