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

Home » Public Forums » archive » Re: reading data into structs (was (no subject))
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 data into structs (was (no subject)) [message #4827] Tue, 08 August 1995 00:00
Sereno A. Barr-Kumara is currently offline  Sereno A. Barr-Kumara
Messages: 7
Registered: August 1995
Junior Member
> Pearson J E <jepear@essex.ac.uk> wrote:
>> A small problem I am having in pvwave.
>>
>> How do you read in values from data files into structs?
>>
>> Any help would be appreciated.
>

Say you have some data

Lat Lon Height
10 10 50
10 10 60
etc 10 lines of data.

Define your stucture as a line

tmp = oneline{lat:0, lon:0, height:0} ; all intger values

;replicate the line for the number of data points create an
;array of structures

data = replicate(tmp,10)

;you can now readin the data in one line

line=''
opeenr, unit1, 'filein', /get_lun
readf, unit1, line ; need to get rid of headers
readf, unit1, data
close, unit1

;you can now access the data eg single line at a time etc

y = data(i).lon

or to fit some criteria of lat

x = data(where (lat gt 20)).height



Sometimes you need to define the structure as in a length wise
manner. (easier for certain types of manipulation).
Then you would need to read each in sequentially
and assign to the variable.

eg; you have a single lat lon followed by 10 height measure,ments
and 12 sets of these

tmp = oneset {lat:0, lon:0, heights:fltarr(10)}
data = replicate(tmp,12)
to read in
dummy =fltarr(10)

for i=0, 11 do begin
readf, unitx, lat, lon
data(i).lat =lat
data(i).lon =lon
readf, unitx, dummy
data(i).heights=dummy
endfor

hope this helps

Regards
barr-kum

____________________________________________________________ ________
| Sereno A. Barr-Kumarakulasinghe | sbarrkum@ic.sunysb.edu |
| Marine Sciences Research Center | |
| State University of New York | |
| Stony Brook, NY 11794-5000 | |
|___________________________________________________________ ________ |
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: pict files
Next Topic: New MacX crashes IDL?

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

Current Time: Wed Oct 08 19:13:43 PDT 2025

Total time taken to generate the page: 0.00509 seconds