Re: array dimensions and subscripts [message #39199] |
Tue, 27 April 2004 08:06  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Benjamin Hornberger <benjamin.hornberger@stonybrook.edu> writes:
> Hi all,
>
> I have a 3d data array A (n_columns, n_rows, n_data) where columns and
> rows make up an image and for each pixel in the image I recorded n_data
> different data values.
>
> Then I have a 1d array B with n_data entries, and I want to subtract B
> from A such that for each element in A, the element from B in the
> corresponding data channel is subtracted. Obviously, A-B won't work. I
This has been covered several times. A good place to start is JD's
dimension juggling tutorial
(http://www.dfanning.com/tips/rebin_magic.html).
REBIN/REFORM, which is what you would need to do, is easy enough.
However, it is also straightforward to use a FOR loop. In my own
opinion, if you can do enough subtractions in a single FOR loop
iteration, then it will be fast.
At that stage, it's up to you to decide which method is more elegant
and maintainable.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|