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.
Hi Kevin, > I am trying to optimize my code a bit. I have two FlatFields of the > same type (range->height) which produce two curves on the same display. > > (Please see the right panel of: > http://www.cimms.ou.edu/~kmanross/VCPRPE/VCPRPE_terrainAndBeamPath.gif) > > I want to obtain all the ranges where the smooth curve lies below the > jagged curve. Currently, I am looping through the range points, > obtaining the values for each curve (smooth, jagged) at each point and > determine which is greater (saving those range points where the jagged > curve is greater than the smooth curve), and moving on to the next range > point. > > This works sufficiently, but 1) depending on the resolution I want (low > = 400, high = 1600) along the range, I am making that many comparisons > each time I move the red line on the left panel. 2) To calculate for > the entire circle on the left panel (720 red lines), that means I am > making between 288,000 and 1,152,000 comparisons. On my machine (1.2 > GHz CPU, 1 Gb RAM) this takes about 40 seconds to do. > > Is there a better way to find the intersection of two FlatFields? What you want is the set of samples where the values of one FlatField is larger than the values of another, which is a bit more specialized than an intersection. VisAD enables you to compute the MAX and MIN of two FlatFields (including implicit resampling of one FlatField to the samples of the other). You can play arithmetical games with MAX and MIN like: (a - b) / (MAX(a, b) - MIN(a, b)) which is +1 where a > b and -1 where a < b (and possibly NaN where a == b). But this can't be used to return the Set where a > b. Furthermore, even if there were a nice short expression for returning such a Set, it wouldn't use less computation than your own explicit approach (in fact, it would probably use more). Bottom line, you're best off to do it yourself. > On another performance topic, I have noticed that the smaller I shrink > my VisAD displays, the more responsive the DirectManipulationRenderers > are, and vice versa. I believe this is a somewhat common behavior that > deals with rendering as I have seen similar retardation with expanding > an .mpg or video game. Is this slowness vs. size tradeoff just > something to live with, or is there a way that I can speed things up? Shrinking displays should primarily speed up rendering by Java3D or Java2D, but have little effect on any code running in VisAD. There probably isn't much you can do about. But screen sizes are growing much slower than processor speeds, so at some point in the future we will cease to notice or care about this problem. > Many thanks to those who have responded to my questions. I keep hoping > that I will become proficient enough to return the favor. ;-) _From the screen shot of your application, it looks like you're doing pretty well. Cheers, Bill
visad
archives: