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

Home » Public Forums » archive » Re: Reading files with unknown amount of dat
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: Reading files with unknown amount of dat [message #1449] Fri, 05 November 1993 05:10
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
oet@sma.ch (Thomas Oettli) writes:

> In Perl exists a function 'push' to dynamically grow up arrays. Some times
> ago I wrote a similiar function in IDL. The function requires the function
> datatype.pro from the JHUAPL-IDL-Library.
> Both functions are included below.

(rest deleted)

Isn't the effect of PUSH identical to the following IDL statement?

NEW_ARRAY = [ OLD_ARRAY, APPENDED_ARRAY ]

Bill Thompson
Re: Reading files with unknown amount of dat [message #1450 is a reply to message #1449] Fri, 05 November 1993 04:51 Go to previous message
zawodny is currently offline  zawodny
Messages: 121
Registered: August 1992
Senior Member
In article <2bd2qgINNkpn@maz4.sma.ch> oet@sma.ch writes:
> In Perl exists a function 'push' to dynamically grow up arrays. Some times
> ago I wrote a similiar function in IDL. The function requires the function
> datatype.pro from the JHUAPL-IDL-Library.
> Both functions are included below.
>
> --Thomas

Stuff deleted

>
> type = datatype(oldarr,3)
> newdim=n_elements(oldarr)+n_elements(newvals)
> old_last=n_elements(oldarr)-1
> new_last=newdim-1
>
> CASE type of
> 'UND': print, 'Could not evaluate datatype!'
> 'BYT': newarr=make_array(newdim,1, /BYTE)
> 'INT': newarr=make_array(newdim,1, /INT)
> 'LON': newarr=make_array(newdim,1, /LON)
> 'FLT': newarr=make_array(newdim,1, /FLOAT)
> 'DBL': newarr=make_array(newdim,1, /DOUBLE)
> 'COMPLEX': newarr=make_array(newdim,1, /COMPLEX)
> 'STR': newarr=make_array(newdim,1, /STRING)
> 'STC': newarr=replicate(oldarr(0),newdim)
> ENDCASE
>
> newarr(0:old_last)=oldarr(*)
>
> newarr(old_last+1:new_last) = newvals(*)
>
> return, newarr

More stuff deleted

>

Why bother with all of this when a single statement such as

newarr = [oldarr,newvals]

works just fine. It even works for structures (to my surprise). IDL already
knows how to do all of these calculations so let it do it. If there are
problems with mixing variable types then the insertion of the proper function
(fix, long, float, double, ...) should cure things. Also the occasional
generation of a multidimensional array could be cured with the use of the (*)
array subscripting. Seems like the previous post is doing alot of work for no
good reason, or am I missing something obvious (afterall it is Friday morning
and I have not had any coffee yet)?

--
Joseph M. Zawodny (KO4LW) NASA Langley Research Center
Internet: zawodny@arbd0.larc.nasa.gov MS-475, Hampton VA, 23681-0001
Packet: ko4lw@n4hog.va.usa
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Reading files with unknown amount of data
Next Topic: WANTED: New IDL-FAQ editor

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

Current Time: Wed Oct 08 15:36:36 PDT 2025

Total time taken to generate the page: 0.00570 seconds