Bridget,
If I understand correctly, I think you want to turn x into a 1D
array, so you can sort it and grab the first 30 minimum values, along
with the indexes that represent the first 30 values.
You can then use this to subscript your y array accordingly
This is untested:
x1d = ndtooned(x)
ii = dim_pqsort(x1d,1) ; Sort x and return the permutation
vector. "x" will not be changed.
y1d = ndtooned(y) ; Convert to 1D array so we can reshape to 3D
; Reshape 1D array to 3D array, 59*91 x nlats x nlon
dims = dimsizes(y)
y3d = onedtond(y1d,(/dims(0)*dims(1),dims(2),dims(3)/)) ;
Assuming y was 4D
ynew = y3d(ii(0:29),:,:) ; Grab only the first 30 indexes that
correspond to the minimum values of X
--Mary
On Feb 16, 2010, at 3:04 PM, Bridget Thrasher wrote:
> I have 2 arrays sized as follows: x = (/50,91/) and y = (/
> 50,91,nlats,nlons/). I want to pull out the 30 "maps" from array y
> that correspond to the 30 smallest values in array x (repeats
> possible) so that I end up with an array sized as z = (/
> 30,nlats,nlons/).
>
> I can't figure out how to translate the indexing from the small
> array to the large array after sorting. Or maybe that's not the
> right way to go about it? Any help would be appreciated...
>
> -Bridget
>
> --
> Bridget Thrasher, PhD
> Postdoctoral Researcher
> Climate Central
> www.climatecentral.org
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 16 15:33:32 2010
This archive was generated by hypermail 2.1.8 : Thu Feb 18 2010 - 10:33:29 MST