If your data more naturally comes in arrays, you can still use the OPeNDAP FreeForm ND Data Handler to serve your data. The FreeForm ND format for sequence data is somewhat simpler than the format for array data, so you may find it easier to begin with the example in the previous section.
Here is a data file, called
ffarr1.dat, containing
four ten-element vectors:
123456789012345678901234567 1.00 50.00 0.1000 1.1000 2.00 61.00 0.3162 0.0953 3.00 72.00 0.5623 -2.3506 4.00 83.00 0.7499 0.8547 5.00 94.00 0.8660 -0.1570 6.00 105.00 0.9306 -1.8513 7.00 116.00 0.9647 0.6159 8.00 127.00 0.9822 -0.4847 9.00 138.00 0.9910 -0.7243 10.00 149.00 0.9955 -0.3226
Here is a format file to read this data
(ffarr1.fmt):
ASCII_input_data "simple array format" index 1 5 ARRAY["line" 1 to 10 sb 23] OF float 1 data1 6 12 ARRAY["line" 1 to 10 sb 21] OF float 1 data2 13 19 ARRAY["line" 1 to 10 sb 21] OF float 1 data3 20 27 ARRAY["line" 1 to 10 sb 20] OF float 1 ASCII_output_data "simple array output" index 1 7 ARRAY["line" 1 to 10] OF float 0 /data1 6 12 ARRAY["line" 1 to 10 sb 21] OF float 1 /data2 13 19 ARRAY["line" 1 to 10 sb 21] OF float 4 /data3 20 27 ARRAY["line" 1 to 10 sb 20] OF float 4
The output section is not essential for the OPeNDAP FreeForm ND Data Handler, but is included so
you can check out the data with the newform command.
Download the files from the OPeNDAP web site, and try typing:
> newform ffarr1.dat
You should see the index array printed out. Uncomment different
lines in the output section of the example file to see different data
vectors.
Now look a little closer at the input section of the file:
index 1 5 ARRAY["line" 1 to 10 sb 23] OF float 1
This line says that the array in question--called "index"--starts in column one of the first line, and each element takes up five bytes. The first element starts in column one and goes into column five. The array has one dimension, "line", and is composed of floating point data. The remaining elements of this array are found by skipping the next 23 bytes (the newline counts as a character), reading the following five bytes, skipping the next 23 bytes, and so on.
Of course, the 23 bytes skipped in between the index array
elements also contain data from other arrays. The second array,
data1, starts in column 6 of line one, and has 21 bytes between
values. The third array starts in column 13 of the first line, and
the fourth starts in column 20.
Move the ffarr1.* files into your data directory:
> cp ffarr1.* /export/home/http/htdocs/data
Now you can look at this data the same way you looked at the sequence data. Request the DDS for the dataset with a URL like this one:
http://test.opendap.org/opendap/nph-dods/data/ffarr1.dat.dds
You can see that the dataset is a collection of one-dimensional vectors. You can see the individual vectors with a URL like this:
http://test.opendap.org/opendap/nph-dods/data/ffarr1.dat.asc?index
Here's another example, with a two-dimensional array.
(ffarr2.dat):
1 2 3 4
1234567890123456789012345678901234567890
1.00 2.00 3.00 4.00 5.00 6.00
7.00 8.00 9.00 10.00 11.00 12.00
13.00 14.00 15.00 16.00 17.00 18.00
19.00 20.00 21.00 22.00 23.00 24.00
25.00 26.00 27.00 28.00 29.00 30.00
There are no spaces between the data columns within an array row, but in
order to skip reading the newline character, we have to skip one
character at the end of each row. Here is a format file to read this
data (ffarr2.fmt):
ASCII_input_data "one" data 1 6 ARRAY["y" 1 to 5 sb 1]["x" 1 to 6] OF float 1 ASCII_output_data "two" data 1 4 ARRAY["x" 1 to 6 sb 2]["y" 1 to 5] OF float 1
Again, the output section is only for using with the newform
tool. Put these data files into your htdocs directory, and look
at the DDS as you did with the previous example.
You can use the OPeNDAP FreeForm ND Data Handler to serve data with multi-dimensional arrays and
one-dimensional vectors interspersed among one another. Here's a file
containing this kind of data
(ffarr3.dat):
1 2 3 4
1234567890123456789012345678901234567890123
XXXX 1.00 2.00 3.00 4.00 5.00 6.00YY
XXXX 7.00 8.00 9.00 10.00 11.00 12.00YY
XXXX 13.00 14.00 15.00 16.00 17.00 18.00YY
XXXX 19.00 20.00 21.00 22.00 23.00 24.00YY
XXXX 25.00 26.00 27.00 28.00 29.00 30.00YY
In order to read this file successfully, we define three vectors to
read the "XXXX", the "YY", and the newline. Here is a format file
that does this
(ffarr3.fmt):
dBASE_input_data "one" headers 1 4 ARRAY["line" 1 to 5 sb 39] OF text 0 data 5 10 ARRAY["y" 1 to 5 sb 7]["x" 1 to 6] OF float 1 trailers 41 42 ARRAY["line" 1 to 5 sb 41] OF text 0 newline 43 43 ARRAY["line" 1 to 5 sb 42] OF text 0 ASCII_output_data "two" data 1 4 ARRAY["x" 1 to 6 sb 2]["y" 1 to 5] OF float 0 /headers 1 6 ARRAY["line" 1 to 5] OF text 0 /trailers 1 4 ARRAY["line" 1 to 5] OF text 0 /newline 1 4 ARRAY["line" 1 to 5] OF text 0
The following chapters offer more detailed information about how exactly to create a format description file.