Hi Rob,
I missed this little problem because I normally use the
IDV to test changes/enhancements to the Contour classes
and most of the time there's an alpha component used.
In your case, there wasn't, and hence the Exception.
If your application can be distributed, I'd be happy to
test changes against it as well.
Tom
Rob Hackett wrote:
Hi
I've had a look at the new release of the source code and I noticed
what seems like a minor bug relating to the message from James Kelly
which I have quoted below.
The new version of the source code solves James' problem, but shortly
afterwards fails with the following error ...
java.lang.ArrayIndexOutOfBoundsException: 3
at visad.Contour2D.contour(Contour2D.java: )
at visad.Gridded3DSet.makeIsoLines(Gridded3DSet.java:2180)
at visad.ShadowType.makeContour(ShadowType.java:3846)
at visad.java3d.ShadowTypeJ3D.makeContour(ShadowTypeJ3D.java:473)
at
visad.ShadowFunctionOrSetType.doTransform(ShadowFunctionOrSetType.java:2141)
at
visad.java3d.ShadowFunctionOrSetTypeJ3D.doTransform(ShadowFunctionOrSetTypeJ3D.java:159)
at
visad.java3d.DefaultRendererJ3D.doTransform(DefaultRendererJ3D.java:134)
at visad.java3d.RendererJ3D.doAction(RendererJ3D.java:181)
at visad.DisplayImpl.doAction(DisplayImpl.java:1711)
at visad.ActionImpl.run(ActionImpl.java:364)
at visad.util.ThreadPool$ThreadMinnow.run(ThreadPool.java:95)
Looking at the source for Contour2D.java I can see that this
corresponds to the following line ...
auxLevels1[3] = new byte[numv1[0]+cnt];
In this case, auxLevels is defined as having a length of 3, hence the
array exception.
I notice that in the preceding lines of Contour2D.java, references to
auxLevels[3] are all protected by an "if statement" which ensures that
the array is big enough. And when I add a similar "if statement" to
line 1340 the problem disappears.
Can you confirm that this is a safe solution to this problem?
thanks,
Rob
From James Kelly ...
Hi,
Under some circumstances, I'm having trouble contouring a simple 2D
FlatField, using the latest visad release. It works ok with a release
from last year ( size 4444712 bytes, Apr 2006).
Here are the details in brief:
I want to contour an atmospheric pressure field (P: mean sea level
pressure) at 2hPa intervals. If I load a field that has a size of 80x104
rows and columns it works ok. If I load the same field, but with a
larger domain (112x120) it fails with the exception below:
java.lang.ArrayIndexOutOfBoundsException: 21
at visad.ContourQuadSet.add(Contour2D.java:2968)
at visad.ContourStripSet.add(Contour2D.java:3456)
at visad.Contour2D.contour(Contour2D.java:1239)
at visad.Gridded3DSet.makeIsoLines(Gridded3DSet.java:2180)
at visad.ShadowType.makeContour(ShadowType.java:3805)
It does work if I don't specify the 2hPa contour interval, and use a
default interval. Also, as mentioned, it works with an earlier version
of visad.
Here's how to reproduce the problem:
Download the following 2 files to your working directory:
ftp://ftp.ssec.wisc.edu/pub/incoming/usmodel.nc
ftp://ftp.ssec.wisc.edu/pub/incoming/usmodel_works.nc
Save the jython program at the end of this email to your working
directory (eg as test_contour.py).
Run it using "./jy test_contour.py"
[comment out the line "ci.setContourInterval(2.0, 0.0, 1050.0, 0.0)" and
it works]
Thanks for any help,
James
Jython program:
from visad.python.JPythonMethods import *
from visad import ScalarMap, Display
from visad.data.netcdf import Plain
import subs, graph, sys
width = 800
height = 600
filename_works = "usmodel_works.nc"
filename = "usmodel.nc"
print "reading from netCDF..."
netCDFReader = Plain()
model = netCDFReader.open(filename)
model_works = netCDFReader.open(filename_works)
dom = domainType(model)
dom_1 = dom.getComponent(0)
dom_2 = dom.getComponent(1)
rng = rangeType(model)
rngMap = ScalarMap(rng, Display.IsoContour)
xMap = ScalarMap(dom_1, Display.XAxis)
yMap = ScalarMap(dom_2, Display.YAxis)
maps = (xMap, yMap, rngMap)
disp = subs.makeDisplay(maps)
subs.addData("contours", model_works, disp)
ci = rngMap.getControl()
ci.enableLabels(1)
ci.enableContours(1)
ci.setContourInterval(2.0, 0.0, 1050.0, 0.0)
subs.setBoxSize(disp, .80)
subs.setAspectRatio(disp, float(width)/float(height))
subs.showDisplay(disp,width,height,"contour test")
# now show second model field which doesn't work:
subs.addData("contours don't work", model, disp)
==============================================================================
To unsubscribe visad, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================