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

Home » Public Forums » archive » Re: Question about storing arrays in pointer array.
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: Question about storing arrays in pointer array. [message #79504] Thu, 08 March 2012 14:44 Go to next message
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
On Thursday, March 8, 2012 3:42:44 PM UTC-6, Ian wrote:
> Hello All,
> I have a question regarding the storage of arrays within arrays. I am
> attempting to read in 14 data files with 5 vectors of 512 elements. I
> have attempted two methods:
>
>
> ;test attempting to read in variety of data and overplot it in a stack
> ;without y-axis and single x-axis
>
> boo=DBLARR(14, 512)
> ;boo=PTRARR(14)
> for x = 0,13,1 do begin
> rdcol, 'iz_diff_rot'+STRCOMPRESS(x,/REMOVE_ALL)
> +'.dat',p1,p2,p3,p4,p5
> print, i, " The dat file is: ", 'iz_diff_rot'+STRCOMPRESS(x,/
> REMOVE_ALL)+'.dat'
>
> ;attempt 1
> ;Fills the pointer array with 14 dbl arrays. Use boo=PTR....
> ; for i=0,13,1 do begin
> ; boo[i]=PTR_NEW(DBLARR(512))
> ; p5=boo[i]
> ; endfor
> ;endfor
>
> ;attempt 2
> ;Creates two dimensional array of 14 columns with 512 elements. Use
> boo=DBL....
> for i = 0,13,1 do begin
> for j = 0,511,1 do begin
> boo[i,j]=p5[j]
> endfor
> print, boo[i,300]
> endfor
> endfor
>
>
> END
>
> Attempt one using the pointer array provides 14 arrays but the values
> are all zero, can anybody give a suggestion on how to store the new p5
> in boo[i]?
>
> Thanks for your time.
> Sincerely
> Ian

What's wrong with a 3D array [14,512,5] ?

What does the pointer business do for you here?

G
Re: Question about storing arrays in pointer array. [message #79506 is a reply to message #79504] Thu, 08 March 2012 14:35 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ian writes:

>
> Hello All,
> I have a question regarding the storage of arrays within arrays. I am
> attempting to read in 14 data files with 5 vectors of 512 elements. I
> have attempted two methods:
>
>
> ;test attempting to read in variety of data and overplot it in a stack
> ;without y-axis and single x-axis
>
> boo=DBLARR(14, 512)
> ;boo=PTRARR(14)
> for x = 0,13,1 do begin
> rdcol, 'iz_diff_rot'+STRCOMPRESS(x,/REMOVE_ALL)
> +'.dat',p1,p2,p3,p4,p5
> print, i, " The dat file is: ", 'iz_diff_rot'+STRCOMPRESS(x,/
> REMOVE_ALL)+'.dat'
>
> ;attempt 1
> ;Fills the pointer array with 14 dbl arrays. Use boo=PTR....
> ; for i=0,13,1 do begin
> ; boo[i]=PTR_NEW(DBLARR(512))
> ; p5=boo[i]
> ; endfor
> ;endfor
>
> ;attempt 2
> ;Creates two dimensional array of 14 columns with 512 elements. Use
> boo=DBL....
> for i = 0,13,1 do begin
> for j = 0,511,1 do begin
> boo[i,j]=p5[j]
> endfor
> print, boo[i,300]
> endfor
> endfor
>
>
> END
>
> Attempt one using the pointer array provides 14 arrays but the values
> are all zero, can anybody give a suggestion on how to store the new p5
> in boo[i]?

Don't you want something like this:

numFiles = 14
boo = PtrArr(numFiles)
FOR j=0,numFiles-1 DO BEGIN
data = Read_Data(files[j])
boo[j] = Ptr_New(Reform(data), /No_Copy)
ENDFOR

Now, each pointer points to an array of 512 columns and 5 rows
(to make accessing each row faster!).

If you want the 5th vector of the 7th pointer:

thisRow = (*boo[6])[*,4]

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Question about storing arrays in pointer array. [message #79589 is a reply to message #79504] Fri, 09 March 2012 08:05 Go to previous message
Ian[2] is currently offline  Ian[2]
Messages: 7
Registered: March 2012
Junior Member
On Mar 8, 2:44 pm, Gianguido Cianci <gianguido.cia...@gmail.com>
wrote:
> On Thursday, March 8, 2012 3:42:44 PM UTC-6, Ian wrote:
>> Hello All,
>> I have a question regarding the storage of arrays within arrays. I am
>> attempting to read in 14 data files with 5 vectors of 512 elements. I
>> have attempted two methods:
>
>> ;test attempting to read in variety of data and overplot it in a stack
>> ;without y-axis and single x-axis
>
>> boo=DBLARR(14, 512)
>> ;boo=PTRARR(14)
>> for x = 0,13,1 do begin
>>   rdcol, 'iz_diff_rot'+STRCOMPRESS(x,/REMOVE_ALL)
>> +'.dat',p1,p2,p3,p4,p5
>>    print, i, " The dat file is: ", 'iz_diff_rot'+STRCOMPRESS(x,/
>> REMOVE_ALL)+'.dat'
>
>> ;attempt 1
>> ;Fills the pointer array with 14 dbl arrays. Use boo=PTR....
>> ;   for i=0,13,1 do begin
>> ;      boo[i]=PTR_NEW(DBLARR(512))
>> ;      p5=boo[i]
>> ;   endfor
>> ;endfor
>
>> ;attempt 2
>> ;Creates two dimensional array of 14 columns with 512 elements. Use
>> boo=DBL....
>>    for i = 0,13,1 do begin
>>       for j = 0,511,1 do begin
>>          boo[i,j]=p5[j]
>>        endfor
>>        print, boo[i,300]
>>     endfor
>> endfor
>
>> END
>
>> Attempt one using the pointer array provides 14 arrays but the values
>> are all zero, can anybody give a suggestion on how to store the new p5
>> in boo[i]?
>
>> Thanks for your time.
>> Sincerely
>> Ian
>
> What's wrong with a 3D array [14,512,5] ?
>
> What does the pointer business do for you here?
>
> G
>
>

I did not want to fill one array with all my data. I figured pointers
might work well and allow faster plotting; however I got it to work
with a 2D array (14,512)as well.
Thanks
Ian
Re: Question about storing arrays in pointer array. [message #79590 is a reply to message #79506] Fri, 09 March 2012 08:01 Go to previous message
Ian[2] is currently offline  Ian[2]
Messages: 7
Registered: March 2012
Junior Member
On Mar 8, 2:35 pm, David Fanning <n...@idlcoyote.com> wrote:
> Ian writes:
>
>> Hello All,
>> I have a question regarding the storage of arrays within arrays. I am
>> attempting to read in 14 data files with 5 vectors of 512 elements. I
>> have attempted two methods:
>
>> ;test attempting to read in variety of data and overplot it in a stack
>> ;without y-axis and single x-axis
>
>> boo=DBLARR(14, 512)
>> ;boo=PTRARR(14)
>> for x = 0,13,1 do begin
>>   rdcol, 'iz_diff_rot'+STRCOMPRESS(x,/REMOVE_ALL)
>> +'.dat',p1,p2,p3,p4,p5
>>    print, i, " The dat file is: ", 'iz_diff_rot'+STRCOMPRESS(x,/
>> REMOVE_ALL)+'.dat'
>
>> ;attempt 1
>> ;Fills the pointer array with 14 dbl arrays. Use boo=PTR....
>> ;   for i=0,13,1 do begin
>> ;      boo[i]=PTR_NEW(DBLARR(512))
>> ;      p5=boo[i]
>> ;   endfor
>> ;endfor
>
>> ;attempt 2
>> ;Creates two dimensional array of 14 columns with 512 elements. Use
>> boo=DBL....
>>    for i = 0,13,1 do begin
>>       for j = 0,511,1 do begin
>>          boo[i,j]=p5[j]
>>        endfor
>>        print, boo[i,300]
>>     endfor
>> endfor
>
>> END
>
>> Attempt one using the pointer array provides 14 arrays but the values
>> are all zero, can anybody give a suggestion on how to store the new p5
>> in boo[i]?
>
> Don't you want something like this:
>
>   numFiles = 14
>   boo = PtrArr(numFiles)
>   FOR j=0,numFiles-1 DO BEGIN
>       data = Read_Data(files[j])
>       boo[j] = Ptr_New(Reform(data), /No_Copy)
>   ENDFOR
>
> Now, each pointer points to an array of 512 columns and 5 rows
> (to make accessing each row faster!).
>
> If you want the 5th vector of the 7th pointer:
>
>    thisRow = (*boo[6])[*,4]
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
>

Great! Thank You!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: using cgSurface to produce a scatter 3D plot with 4th dimension
Next Topic: Re: type conversion in GPULIB

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

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

Total time taken to generate the page: 0.00925 seconds