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

Home » Public Forums » archive » Re: REVERSE even row elements in data array.
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
Re: REVERSE even row elements in data array. [message #12470] Mon, 03 August 1998 00:00
Kevin Ivory is currently offline  Kevin Ivory
Messages: 71
Registered: January 1997
Member
Kevin Ivory wrote:
> result(*, rev) = reverse(data(*, rev), 2) ; reverse every second row

Well, I figure I mixed up the dimensions. This should be correct:

result(*, rev) = reverse(data(*, rev)) ; reverse every second row

Best regards
Kevin
--
Kevin Ivory Tel: +49 5556 979 434
Max-Planck-Institut fuer Aeronomie Fax: +49 5556 979 240
Max-Planck-Str. 2 mailto:Kevin.Ivory@linmpi.mpg.de
D-37191 Katlenburg-Lindau, GERMANY http://www.gwdg.de/~kivory2/
Re: REVERSE even row elements in data array. [message #12471 is a reply to message #12470] Mon, 03 August 1998 00:00 Go to previous message
Kevin Ivory is currently offline  Kevin Ivory
Messages: 71
Registered: January 1997
Member
Jouhahn Lee wrote:
> Would you tell me how can I apply REVERSE only to the even row data in
> 64*32 array?

Henry Throop <throop@colorado.edu> already showed you an algorithm
I find confusing. I would do it like this:

data = indgen(64, 32) ; some test data
ydim = (size(data))[2] ; extract number of data rows
rev = indgen(ydim/2) * 2 ; generate the row indexing array
result = data ; only needed if you want to keep original array
result(*, rev) = reverse(data(*, rev), 2) ; reverse every second row

Voila,
Kevin
--
Kevin Ivory Tel: +49 5556 979 434
Max-Planck-Institut fuer Aeronomie Fax: +49 5556 979 240
Max-Planck-Str. 2 mailto:Kevin.Ivory@linmpi.mpg.de
D-37191 Katlenburg-Lindau, GERMANY http://www.gwdg.de/~kivory2/
Re: REVERSE even row elements in data array. [message #12475 is a reply to message #12470] Sun, 02 August 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Henry Throop (throop2@my-dejanews.com) writes in response
to this question by Jouhahn Lee:

>> Would you tell me how can I apply REVERSE only to the even row data in
>> 64*32 array?

> Try this, with your array to be reversed in the array 'data':
>
> xdim = 64 ; x array dimension
> ydim = 32 ; y array dimension
>
> odds = double(((1+intarr(xdim)) # indgen(ydim)) mod 2)
> ; create a list of integers and a list of 1's,
> ; co-multiply them, and extract last bit.
>
> evens = not odds ; every row of this array which is 1 will be
> ; reversed
>
> result = data*odds + reverse(data*evens)
> ; reverse and extract the appropriate elements

This is very nice. But can you elaborate on why you used
the DOUBLE function in the code above? I get the same result
without it and I am wondering what problem you are trying
to solve by using it.

Thanks for this solution.

David

P.S. I solved the problem in a slightly simpler way, like this:

evens = Indgen(32/2) * 2
data[*, evens] = Reverse( data[*, evens] )

--
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: REVERSE even row elements in data array. [message #12476 is a reply to message #12475] Sun, 02 August 1998 00:00 Go to previous message
throop2 is currently offline  throop2
Messages: 1
Registered: August 1998
Junior Member
In article <35C3E2CB.7F621C0A@maxwell.ph.kcl.ac.uk>,
Jouhahn Lee <jl@maxwell.ph.kcl.ac.uk> wrote:
> Thanks to Mike and Kevin, I could retrieve the microscopic data using
> IDL. Thanks.
>
> Now I can have 64*32 array expandible to 1024* 512 array.
> By the way, in 64*32 array, I need to change the even rows's data
> elements.
> I made a C program for this but I found that subroutine REVERSE in IDL
> can do.
>
> Would you tell me how can I apply REVERSE only to the even row data in
> 64*32 array?
> (ie. keep the odd row, reverse the even row) How can I do that? I am
> still novice using
> IDL so I need to have some help please. Thanks in advance!

When I'm doing things like this, I often create an array of 1's and 0's
to multiply the original array by. This extracts the chosen elements,
and the complement of this array returns all the other, non-chosen elements.

Try this, with your array to be reversed in the array 'data':

xdim = 64 ; x array dimension
ydim = 32 ; y array dimension

odds = double(((1+intarr(xdim)) # indgen(ydim)) mod 2)
; create a list of integers and a list of 1's,
; co-multiply them, and extract last bit.

evens = not odds ; every row of this array which is 1 will be
; reversed

result = data*odds + reverse(data*evens)
; reverse and extract the appropriate elements

- henry

------------------------------------------------------
| Henry Throop throop@colorado.edu (303) 492-1628 |
------------------------------------------------------
| Laboratory for Atmospheric and Space Physics |
| University of Colorado, Boulder 80309-0392 |
------------------------------------------------------


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL limits
Next Topic: Interrupting a widget application

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

Current Time: Thu Oct 09 16:07:18 PDT 2025

Total time taken to generate the page: 0.88286 seconds