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

Home » Public Forums » archive » defining structure after ascii template
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: defining structure after ascii template [message #85884 is a reply to message #85882] Mon, 16 September 2013 10:51 Go to previous messageGo to previous message
spluque is currently offline  spluque
Messages: 33
Registered: September 2013
Member
On Monday, September 16, 2013 12:24:29 PM UTC-5, David Fanning wrote:
> spluque@gmail.com writes:
>
>
>
>>
>
>> On Monday, September 16, 2013 11:02:11 AM UTC-5, David Fanning wrote:
>
>>> spluque@gmail.com writes:
>
>>>
>
>>>
>
>>>
>
>>>> As far as I can see, it is not possible to define a structure using a template as the one built via ascii_template(). Essentially, extract a sub-structure from the template returned by ascii_template, containing the column names as tags and the field type. What is the proper way to do this?
>
>>>
>
>>>
>
>>>
>
>>> I honestly have no idea what this question means. Why don't you explain
>
>>>
>
>>> to us what you are trying to do.
>
>>
>
>> Sorry for the terse initial post. Here is what I am trying to do:
>
>>
>
>> 1. I've prepared a template with ascii_template() for reading in an ASCII file via read_ascii().
>
>>
>
>> 2. Before reading the data with read_ascii(), I need to prepare an *array* of structures, where each element is a record (row) in a number of files to be read with the template in (1).
>
>>
>
>> 3. read_ascii() creates a structure that looks like this:
>
>>
>
>> help, data, /structures
>
>> ** Structure <57e3008>, 23 tags, length=7800864, data length=7800864, refs=1:
>
>> FIELD01 LONG Array[84792]
>
>> FIELD02 FLOAT Array[84792]
>
>> FIELD03 LONG Array[84792]
>
>> ...[many more fields]
>
>>
>
>> So the array of structures to be created would like this (abbreviating the number of fields for brevity here):
>
>>
>
>> p={'foo', FIELD01:0L, FIELD02:0.0, FIELD03:0L}
>
>> replicate(p, n_recs)
>
>>
>
>> where n_recs is the total number of records expected.
>
>>
>
>> So the question is how can p be created from the information already there in the template created in (1)?
>
>
>
> Well, p *is* the structure you obtained. I guess I don't see the
>
> problem:
>
>
>
> IDL> struct = ascii_template()
>
> IDL> help, struct
>
> ** Structure <701c24d0>, 10 tags, length=320, data length=313, refs=1:
>
> VERSION FLOAT 1.00000
>
> DATASTART LONG 0
>
> DELIMITER BYTE 32
>
> MISSINGVALUE FLOAT NaN
>
> COMMENTSYMBOL STRING ''
>
> FIELDCOUNT LONG 10
>
> FIELDTYPES LONG Array[10]
>
> FIELDNAMES STRING Array[10]
>
> FIELDLOCATIONS LONG Array[10]
>
> FIELDGROUPS LONG Array[10]
>
> IDL> data = Replicate(struct, 100)


Thanks for your patience David. The problem is that the template structure is not quite the same as the one created by read_ascii(); compare the output you got with the one in point (2) of my previous message. In other words, what I need to replicate is an element of the output of read_ascii(), but without having to call it first. Hopefully, this is clearer.

Cheers,
Seb
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Merits of different ways of 'extending' arrays
Next Topic: Import data in IDL from other source

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

Current Time: Wed Oct 08 17:25:14 PDT 2025

Total time taken to generate the page: 0.00416 seconds