comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Cleaver 2d reverse indicies?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Cleaver 2d reverse indicies? [message #63311] Mon, 03 November 2008 12:54
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
All,

I am using hist_nd.pro from J.D. Smith to find the indices that are in
each bin of a 2d mapping of data.

I have 3 arrays:
THEMIS> help, theta, lshell, pxxm
THETA DOUBLE = Array[282576]
LSHELL DOUBLE = Array[282576]
PXXM FLOAT = Array[282576]

I want the mean pxxm in each of the theta-lshell 2d space.

This is accomplished with:
nd = hist_nd(transpose([[theta],[lshell]]), $
[size_theta_bin, size_l_bin], $
min = [min(theta) > min_theta, min(lshell) > min_lshell],
$
max = [max(theta) < max_theta, max(lshell) < max_lshell],
$
reverse_indices = ri)

OK so here is the part where I want some cleverness. I have not
figured out how to do this without nested for loops and those are evil
(as we all know).

bins_mean = fltarr(size(nd, /dim))
nx = (size(nd, /dim))[0]
ny = (size(nd, /dim))[1]
FOR i = 0UL, nx-1 DO BEGIN
FOR j = 0UL, ny-1 DO BEGIN
ind_ri = [i+nx*j]
IF ri[ind_ri] EQ ri[ind_ri+1] THEN CONTINUE ; nothing to do in
this iteration
ri_sel = ri[ri[ind_ri]:ri[ind_ri+1]-1]
bins_mean[i, j] = mean(pxxm(ri_sel), /nan)
ENDFOR
ENDFOR

Is there some other/better way to do this? I am wondering if I am
missing a trick, or just thinking about this wrong, or I have it
right. The reverse indices is always cool and always a bit of voodoo
for me.

Thanks all,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
http://people.bu.edu/balarsen/Home/IDL
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL hilbert() function
Next Topic: Starting an old IDL version

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:14:56 PDT 2025

Total time taken to generate the page: 0.00509 seconds