This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
The following shows the modifications to the original processImage routine. The idea is to clone the incoming data object and then set its range values with the setSample call.I followed your instructions and it seems to work. And yes, I would like to visualize the results of this processing. Tried various options but couldn't get it to display properly. Could you tell us how the outputs of the routine (new image data set?) can be displayed?
-Jeff def processImage (d): domain = d.getDomainSet() cs = domain.getCoordinateSystem() len = domain.getLength() #Note: we want a copy of the range values so we don't pass in 0 (false) here rangeValues = d.getFloats() #Pass in 0 as false so we don't copy the values samples = domain.getSamples(0) #Get the latlon points of the spatial domain latlon = cs.toReference(samples) #Clone the incoming data object newd = d.clone() for i in xrange(len): value = rangeValues[0][i] #Just for kicks multiply the range values by 2 rangeValues[0][i] = value*2 lat = latlon[0][i] lon = latlon[1][i] #Set the new range values newd.setSamples(rangeValues) #return the new data object return newd