Beruflich Dokumente
Kultur Dokumente
January, 2001
updated: December, 2004
Contents.
Introduction
I. Text File Formats
II. Line 1
IIa. 2-D arrays
IIb. 1,2, or 3-D points
III. Line2
IIIa. for 2-D arrays
IIIb. for 1,2,or 3-D points
IV. Examples
Introduction
The VisAD TextAdapter is designed to allow you to quickly read in data
that are in the form of an ASCII text file. We fully expect this
class to continue to grow to accommodate other, common variations of
text file formats that might be encountered.
Two example files are also contained in the release. It is most
convenient to test these using the VisAD Spreadsheet or the Jython
(Python) interface. Fire up either the visad.python.JPythonFrame, or
simply start it from the command line and use a sequence like:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
Or simply load these files into the SpreadSheet, and then experiment
with the mappings!
I. Text file formats
The text files usually consist of 2 header lines and then data.
Optional comment lines may be interspersed throughout. The data
portion of the file may be either blank-, comma-, semicolon- or
tab-separated values. At present only numeric data can be read. The
model for these files is spreadsheet (Excel, etc) output -- that is,
column-oriented values.
Comment lines are any line that starts with either #, !, or %.
The file extensions recognized by the VisAD DefaultFamily and the
TextAdapter:
.bsv -> blank-separated values
.tsv -> tab-separated values
.csv -> comma-separated values
In addition, the VisAD DefaultFamily will recognize the extension .txt
file.
2-D arrays are implied when:
* there are 2 domain components
* there is only one range component
* there is more than one domain sampling value for the first
domain component (that is, more than one data value on a line
in the text file)
IIb. 1,2,or 3-D points
Just about every other form of a text file falls into this category.
Examples of VisAD functional descriptions:
(x)->(temperature, dewpoint, speed)
(x,y,z)->(temperature, speed)
At least one of the domain variables (x,y,z) _must_ be defined
by data in the file. See Examples #1, #3, #4 and #5, below.
You may also use Text types for these data. For example:
(Latitude,Longitude)->(City(Text))
Strictly speaking, you may have a domain with more than
3 components. If you do this, however, the TextAdapter
will not be able to optimize the construction of the
sampling set, and will use either a LinearNDSet (if
you supply simple ranges for all domain components) or
an IrregularSet (if one or more of the domain components
has values specified in the file).
III. Line 2 (ignoring any comment lines that might come before)
The second line of the text files defines which column of the data
portion contains what parameters. (Note that, as with the "Line 1",
an alternate form of the constructor is available so this information
can be passed as an argument rather than being read from the file.)
If you have other information that you need to specify for a parameter,
you should use a blank-separated sequence of phrases in the form
"key=value", to specify what you need. Here are the possible keys:
key
---unit
value
--------------name of Unit (default = no unit)
miss
scale
offset
error
pos
fmt
value
.
i.e., if you had 5 parameters defined in Line 2 (e.g., p1,p2,p3,p4,
p5)
and one of them (e.g., p3) had a value attribute then the data line
s
would only contain the values for the other parameters, e.g.:
p1,p2,p4,p5
p1,p2,p4,p5
...
When using the value attribute you can also include in any subseque
nt lines a:
name=value
Where name is one of the parameter names. This allows you to reset
the fixed value
that is used.
For example, this facility could be used if you had a set of observ
ations from
a single station:
(index) -> (Longitude,Latitude,Time,T)
Longitude[unit="degrees west" value="110"],Latitude[unit="deg" val
ue="40"],Time[fmt="yyyy-MM-dd HH:mm:ss z"],T[unit="celsius"]
2007-02-20 11:00:00 MST,13.3
2007-02-20 11:00:00 MST,-2.0
Latitude=30
Longitude=100
2007-02-20 11:00:00 MST,5.0
...
Note: You don't have to have the value attribute in Line 2. You ca
n just do:
(index) -> (Longitude,Latitude,Time,T)
Longitude[unit="degrees west" ],Latitude[unit="deg"],Time[fmt="yyy
y-MM-dd HH:mm:ss z"],T[unit="celsius"]
Longitude=110
Latitude=40
2007-02-20 11:00:00 MST,13.3
2007-02-20 11:00:00 MST,-2.0
Latitude=30
Longitude=100
2007-02-20 11:00:00 MST,5.0
...