indexing arrays with arrays [message #2442] |
Thu, 30 June 1994 07:31  |
ljg
Messages: 5 Registered: January 1993
|
Junior Member |
|
|
I have an application where I'm trying to re-bin an array of data sampled
at arbitrary coordinates into an array whose indices indicate sampling
coordinates. (First sum the data into appropriate bins, then average as
necessary, and finally interpolate as appropriate.)
I'm trying to do this "the IDL way" (IMHO) by calculating an index mapping
array and using this map to sum the data into appropriate bins. However,
the behavior isn't what I expect. A simple example:
IDL> a = fltarr(3)
IDL> map = [1, 1, 2]
IDL> a(map) = a(map) + [1.0, 2.0, 3.0]
IDL> print, a
0.00000 2.00000 3.00000
Here "a" will hold the accumulated data and "[1, 1, 2]" is the index re-mapping
array (map the first and second data items to the second destination position
and map the third data item to the third destination position). When I try
to add the data "[1.0, 2.0, 3.0]" I had hoped that "1.0" and "2.0" would
have been summed into a(1) and "3.0" into a(2), resulting in
a = [0.0, 3.0, 3.0].
Why doesn't this work?
larry-granroth@uiowa.edu
|
|
|