Hello, everyone
I have a problem which I have half-solved, but it appears to me that I am
abusing the framework to get there, rather than working with it. Hints as
to a better/more elegant way to do what I want would be greatly appreciated.
I have a 3D domain data set (altitude - lat - lon) of 1-D data
(temperature). I need to make and display 2-D horizontal slices out of
this data.
To date, I:
1) Convert my data from it's native format (ASCII vectors) to a VisAD data
structure more or less as follows
// declare the data types to be used
RealTupleType domainType = new RealTupleType(altitude, latitude,
longitude);
RealTupleType rangeType = new RealTupleType(domainType,temp);
// parse the input file to create appropriately ordered temperature and
coordinate ranges
float geoSamples[][] = getCoords);
float tempSamples[][] = getTemps();
// make the domain set
Gridded3DSet domain3DSet = new Gridded3DSet(domainType, geoSamples,
numAlts, numLats, numLons);
// create the flatfield, and populate it with the observations
FlatField dataItem = new FlatField(rangeType, domain3DSet);
dataItem.setSamples(tempSamples);
2) To get, say, the surface level temperatures, I need to get this data
structure into a 2D field, because I can't make a 2D ScalarMap to a 3D
field. So I make a new 2D domain set and 2D Flatfield of the k-th level by
\
// create data structures to hold new samples
float newGeoSamples[][] = new float[2][numLats*numLons];
float newTemperatures[][] = new float[1][numLats*numLons];
// extract the lats and lons we need to make a 2D set
for (i=0; i<numLon; i++) {
for (j=0; j < numLon; j++) {
index3D = level + numLevel*j + numLevel*numLat*i;
index2D = j + numLat*i;
newGeoSamples[0][index2D] = geoSamples[1][index3D];
newGeoSamples[1][index2D] = geoSamples[2][index3D];
newTemperatures[0][index2D]
}
}
// create the appropriate 2D data type descriptors
domainTuple2D = new RealTuple Type(latitude, longitude);
functionType2D = new FunctionType(domainTuple2D, temperature);
// create the 2D flat field
Gridded2DSet domain2DSet = new Gridded2DSet(domainTuple2D, newGeoSamples,
numLats, numLons);
FlatField field2D = new FlatField(functionType2D, domain2DSet);
3) Now I can create ScalarMaps, DataReferences, and plot my data in the
normal satisfactory manner.
So why do I think I'm missing something? Well,
A) I'm creating two entirely duplicative arrays in step two, at a
considerable memory loss.
B) I'm entirely avoiding using any of resample's built-in interpolation
features, which seems highly counterintuitive.
C) GriddedSets can't handle missing data, if any. Which can happen in my
problem domain.
I can't be the first person to want to do this, so I'm sure there's a more
straightforward, efficient way. What am I missing? Correct use of
Coordinate Systems? Correct use of IrregularSets? Can anyone point me to
some example code I should have been looking at?
Edward