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

Home » Public Forums » archive » Re: array dimension change
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: array dimension change [message #63136] Wed, 29 October 2008 06:59 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Oct 28, 6:57 pm, xiao <littledd...@gmail.com> wrote:
> Hi~ guys~ I have a question here. I wrote a small program like the
> following, but why the two print statement print out the same thing?
> It is suppose to print out the different elements because i know the
> contents are different in the original array.  I can name another
> array with same dimension and do the same thing , then it works, the
> elements changed , but why it did not change as the following?
>       Many Thanks~
>
> soilw00 = Read_Binary('/nas/rstor6/xzhang/RAMS/build/60/soil/AVNdat/fh .
> 0024_tl.press_gr.onedeg.SoilW', Data_Type = 4, Data_Dims =
> [360,181,4])
>
> help,soilw00
>
> print, soilw00(265:325,110:130,0)
>
>  for kk=0,4-1 do begin
>     for jj=0,181-1 do begin
>          for ii=0,360-1 do begin
>          soilw00(ii,jj,kk)=soilw00(359-ii,jj,kk)
>          endfor
>          endfor
>      endfor

First of all, the loops through jj and kk are really expensive. Get
rid of them!

for ii=0,360-1 do begin
soilw00[ii,*,*]=soilw00[359-ii,*,*]
endfor

Secondly, I think what you really wanted was:

for ii=0,360/2-1 do begin
soilw00[ii,*,*]=soilw00[359-ii,*,*]
endfor

In your original case, you first reverse the structure and then
reverse it back again to get what you started with!

Finally, why don't you just use the built-in REVERSE function?

soilw00 = reverse(soilw00, 1)

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Ayuda para utilizar MCTK para imagenes LST :MOD11A2
Next Topic: Re: what to make of read_interfile.pro ?

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

Current Time: Fri Oct 10 23:01:18 PDT 2025

Total time taken to generate the page: 0.31958 seconds