Data Extreme Values

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Data Extreme Values

Post by joleenf »

Is there a quick way to get the 10 smallest and 10 largest values from data arrays in McV?

Thanks,
Joleen
User avatar
bobc
Posts: 988
Joined: Mon Nov 15, 2010 5:57 pm

Re: Data Extreme Values

Post by bobc »

Hi Joleen -

Here's one way I found of doing this:

Code: Select all

# create a data object
addeParms = dict(
    server = 'adde.ucar.edu',
    dataset = 'RTIMAGES',
    descriptor = 'GE-IR',
    coordinateSystem = LATLON,
    location = (40,-80),
    size = (20,20),
    unit = 'TEMP',
    )
data = loadADDEImage(**addeParms)

# get values of data, this is an array
dataValues = data.getValues()

# print the original dataValues array
print dataValues[0]

# sort the array values into a list
sortedDataValues = sorted(dataValues[0])
print sortedDataValues

# use slicing to extract the 10 lowest values
tenMinVals = sortedDataValues[0:10]
print tenMinVals

# use slicing to extract the 10 highest values
tenMaxVals = sortedDataValues[-10:]
print tenMaxVals

Is this along the lines of what you are looking for?

Thanks -
Bob Carp
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: Data Extreme Values

Post by joleenf »

Bob,

That should work.

Thanks,
Joleen
Post Reply