-
Notifications
You must be signed in to change notification settings - Fork 66
Contours colored wrong when data has a wide range #851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@dlonie I'm printing the bandedcontour values and colours I get:
Orange seems to be color index "3" any idea what is wrong? Thanks, Pushed a branch with some bug fix to run the following code branch is : issue_851_colors Jeff's sample code:
Data can be found at: |
@dlonie VTK filters gets the same values for indices colours and levels in both case, only the data differ. |
because of this I think it is a VTK issue reassigning to Kitware until they confirm/infirm this. |
|
@dlonie plkease remove the line that comments out "bad" values. In your picture it seems like they have been commented out and hence work.
Make sure it is commented out. Also, which branch are you using? |
Well, this was fun to track down >.< The issue is that How it works is that there is a configurable Trouble is, without masking the data, the scalar range is ~1e36, and tl;dr This patch fixes the issue (line numbers may be off, since I rebased your branch onto master): @@ -857,10 +857,11 @@ class VTKVCSBackend(object):
lut = vtk.vtkLookupTable()
cot = vtk.vtkBandedPolyDataContourFilter()
cot.ClippingOn()
cot.SetInputData(sFilter.GetOutput())
cot.SetNumberOfContours(len(l))
+ cot.SetClipTolerance(0.)
for j,v in enumerate(l):
print "Contour:",j,":",v
cot.SetValue(j,v)
#cot.SetScalarModeToIndex()
cot.Update() Now we get the expected result: |
Wow! Nice detective job here! Do you want to push a branch? Or are you happy with me doing it and merging? |
Nice job @dlonie Shoudl we always set the tolerance to 0? Just wondering about numerical stability of the algorithm (not looked into the code as much). I am wondering if setting it to 0 may cause some some sort of issues in certain cases. |
I'll push a branch in a moment. I wasn't sure if you wanted to lump this in with your other branch, either way works for me. Setting to 0 always should be fine for this usecase, since vcs is generating the contour levels. The tolerance seems to be there for when the levels are automatically generated. |
Good ppint we could turn it off (set to 0) only if delta is greater than the code's default of 1.e20. |
To reproduce this bug you will need a file I have named tmp_AODVIS.nc. Please let me know how to supply it.
This file has one variable on a 180x360 lat-lon grid. The variable's values are mostly in the correct range, between 0 and 1. But about 1/8 of the values are very large, around 1.0e35 (they differ from the fill value and from each other, and they are not masked). This situation arises from an error, but that makes it all the more important that we plot it correctly - so as to reveal the error. (BTW, I didn't do it!)
In fact, the following (reasonable) Python code produces a plot of a uniform color (orange in my case) which implies that all values are between 1.0 and 1.5. As the following code will demonstrate, 88% of the data is less than 1.0
The text was updated successfully, but these errors were encountered: