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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: array dimension change [message #63136] Wed, 29 October 2008 06:59 Go to next 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.
Re: array dimension change [message #63162 is a reply to message #63136] Tue, 28 October 2008 17:15 Go to previous messageGo to next message
russell.grew is currently offline  russell.grew
Messages: 74
Registered: February 2005
Member
Possibly because soilw00 is a structure and not your typical fltarr.

There be special rules with structures.
Re: array dimension change [message #63260 is a reply to message #63136] Wed, 29 October 2008 13:17 Go to previous message
xiao zhang is currently offline  xiao zhang
Messages: 81
Registered: June 2008
Member
On Oct 29, 8:59 am, Jeremy Bailin <astroco...@gmail.com> wrote:
> 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.

Thank you ~~~ the reverse works~~~ :)
  Switch to threaded view of this topic Create a new topic Submit Reply
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 01:28:51 PDT 2025

Total time taken to generate the page: 0.80283 seconds