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

Home » Public Forums » archive » Re: subsripting array problem
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: subsripting array problem [message #16445] Tue, 27 July 1999 00:00
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Med Bennett wrote:
> I am just wondering why the following does not work correctly:
>
> timeidx = round(traveltime/100.)-1 ;get index of array
> timeidx = timeidx[0]
> if timeidx ge 0 and timeidx le 199 then $
> gwfluxpa[timeidx:*] = gwfluxpa[timeidx:*] + ic*2500.
>
> If I rewrite this code to the following, it works OK:
>
> timeidx = round(traveltime/100.)-1 ;get index of array
> timeidx = timeidx[0]
> if timeidx ge 0 and timeidx le 199 then begin
> junk = fltarr(200)
> junk[timeidx:*] = ic*2500.
> gwfluxpa = gwfluxpa + junk
> endif

I'm guessing the type and/or value of one of your variables is not what
you expect. The HELP procedure can be useful in solving this type of
problem. For example:

help, traveltime & print, traveltime
timeidx = round(traveltime/100.)-1
help, timeidx & print, timeidx
timeidx = timeidx[0]
help, gwfluxpa & print, gwfluxpa
help, ic & print, ic
if timeidx ge 0 and timeidx le 199 then $
gwfluxpa[timeidx:*] = gwfluxpa[timeidx:*] + ic*2500.

Careful examination of the HELP and PRINT output should identify the
problem. I don't recommend coding workarounds *unless* you understand
the problem first.

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
Re: subsripting array problem [message #16450 is a reply to message #16445] Mon, 26 July 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Med Bennett (mbennett@indra.com) writes:

> I am just wondering why the following does not work correctly:
>
> timeidx = round(traveltime/100.)-1 ;get index of array
> timeidx = timeidx[0]
> if timeidx ge 0 and timeidx le 199 then $
> gwfluxpa[timeidx:*] = gwfluxpa[timeidx:*] + ic*2500.
>
> If I rewrite this code to the following, it works OK:
>
> timeidx = round(traveltime/100.)-1 ;get index of array
> timeidx = timeidx[0]
> if timeidx ge 0 and timeidx le 199 then begin
> junk = fltarr(200)
> junk[timeidx:*] = ic*2500.
> gwfluxpa = gwfluxpa + junk
> endif
>
> In the first version, the contents of my gwfluxpa array get reset
> to zero every so often as the procedure executes this section.

!?

> Any ideas?

Something weird, here. Just more evidence that the
world is a mysterious place. :-)

Cheers,

David

P.S. I'm not sure you have shown us the relevant code
to solve this problem. :-(

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: idlwave mode for emacs/xemacs?
Next Topic: combine 2 row-vectors to a matrix

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

Current Time: Sun Oct 12 02:09:22 PDT 2025

Total time taken to generate the page: 0.79681 seconds