NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Kevin- Kevin Manross wrote:
I got the ((lat,lon) -> value) method to work, but the output looks very "blocky" even with "high resolution". Please see:http://www.cimms.ou.edu/~kmanross/VCPRPE/KIWA-APMap_compareHiRes.gifIs there a way to make this smoother? Better yet, could I contour the outter edge and fill in that countour?
Did you try mapping value to IsoContour and setting it to color fill? Since all your values are the same, it might not contour too well.
Below is part of the code that I used to perform the ((lat,lon) -> value) ################################################################# Gridded2DSet gridSet = (Gridded2DSet) terrainData_FF.getDomainSet(); float[] lonFloat = new float[lonVect.size()]; float[] latFloat = new float[latVect.size()]; float[][] apFloat = new float[1][gridSet.getLength()]; if (lonVect.size() != latVect.size()) { System.out.println("LatLon sampling error. No AP map available"); return null; } for (int e = 0; e < lonVect.size(); e++) { Real ln = (Real) lonVect.get(e); Real lt = (Real) latVect.get(e); lonFloat[e] = (float) ln.getValue(); latFloat[e] = (float) lt.getValue(); } float[][] apLonLat = {lonFloat, latFloat}; int[] valueIndicies = gridSet.valueToIndex(apLonLat); double[][] apDoubles = new double[1][valueIndicies.length]; RealTupleType apLonLat_rtt = new RealTupleType(lon, lat); RealType value = RealType.getRealType("value"); FunctionType ap_func = new FunctionType(apLonLat_rtt, value); FlatField apFF = new FlatField(ap_func, gridSet); // First set all the range values to NaN for (int g = 0; g < apFloat[0].length; g++) { apFloat[0][g] = Float.NaN; } apFF.setSamples(apFloat); // Now set specific range values for (int g = 0; g < apDoubles[0].length; g++) { apDoubles[0][g] = 14000.0; } apFF.setSamples(valueIndicies, apDoubles); return apFF; ################################################################# Thanks!
Just a couple of suggestions. I would create just one array with NaN's and values: float[][] apFloat = new float[1][gridSet.getLength()]; Arrays.fill(apFloat[0], Float.NaN); for (int i = 0; i < indices.length; i++) { apFloat[0][valueIndices[i]] = 14000.f; } apFF.setSamples(apFloats, false); When you call setSamples, use the signature that allows the copy flag. Setting that to false will keep FlatField from making a defensive copy of the data. Since you won't be modifying apFloat, it's not an issue if no copy is done. To decrease your blockiness, try adding a ConstantMap to CurvedSize to your DataReference with a value < ten (min of 1). You'll need the latest visad.jar to do that, otherwise use GraphicsModeControl.setCurvedSize() for previous versions (which will affect all texture displays). You'll probably have to experiment with the value. You could also try using visad.bom.ImageRendererJ3D() for a quicker rendering and it also seems to handle texturing better. Or, turn TextureEnable off (ConstantMap or trhough GraphicsModeControl) and see what effect that has. Good luck. Don ************************************************************* Don Murray UCAR Unidata Program dmurray@xxxxxxxxxxxxxxxx P.O. Box 3000 (303) 497-8628 Boulder, CO 80307 http://www.unidata.ucar.edu/staff/donm *************************************************************
visad
archives: