Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.
Hi Patrick- Patrick Koethur wrote:
I have a rather general question about the use of the "applyToRangeValues(function,data)" Jython method.What is meant by the function argument? What should it look like? Can anyone give an example? Thanks a lot.
The function argument is the name of the function that you want to apply to each timestep in the field. An example might be: def changeRange(d): return applyToRangeValues('testApplyToRange2',d); def testApplyToRange(d,**args): r = d.getFloats(0) total = 0 for i in xrange(len(r[0])): total= total+r[0][i] avg = total/len(r[0]) for i in xrange(len(r[0])): if(r[0][i]<avg): r[0][i] = 0; d.setSamples(r) return d This avoids having to have the code like: if (GridUtil.isTimeSequence(newData)): for t in range(newData.getDomainSet().getLength()): rangeValue = newData.getSample(t) XXX do something newData.setSample(t,result,0) else: rangeValue = newData XXX do something when you might have a time sequence or just a single timestep. 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 *************************************************************
idvusers
archives: