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

Home » Public Forums » archive » Re: Make_array() and using arrays as subscripts
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: Make_array() and using arrays as subscripts [message #46857 is a reply to message #46856] Mon, 09 January 2006 13:19 Go to previous messageGo to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Sheldon wrote:
> Hi everyone,
>
> I have a problem with the function MAKE_ARRAY() that I hope someone can
> help me with.
> I created a string array with the dimension (3, 344) and performed some
> basic assignment operations.
> Now I know that when I am finished with the operations I will perform
> on the array, the length 344 will be too long. Let's say that only the
> first 120 elements will be needed. Now I assigned that entire array the
> string '9999' and then when I am ready to reduce the size of the array
> I used the WHERE() function to find the indices where each element is
> not equal to '9999'. All went well until I form this array-as-subscript
> operation:
>
> my_array = my_array[good_indices]
>
> The dimensions all disappear and all I get is an array with the
> elements equalling the number of elements of good_indices, i.e.,
>
> print, size(my_array,/dimensions)
>
> IDL> 120
>
> Now I have used this type of array-as-subscript before on other types
> of array and I have never had this problem before. Does anyone know why
> this happens or how can I cut my_array without losing my 3 dimensions?
>

Hi,

You will want to keep tabs on the dimension(s) that WHERE operates since
a call to WHERE operates on the entire array unless restricted. For the
sake of simplicity you might try a loop. You haven't said if the 99999
flag could be in any one of the columns. If true then you must check
each column for the 99999 flag.


dims = SIZE(my_array, /DIM)
flag = MAKE_ARRAY(dims[1], VALUE = 0B)

For i = 0L, dims[0]-1 Do Begin

A = WHERE(my_array[i,*] NE 9999, nA) ;check the ith column
if nA GT 0 then flag[A] = flag[A] + 1B ;increment the ok values

EndFor

;any flag LT 3 must have had a 99999 somewhere
A = WHERE(flag EQ 3B, nA)
if nA GT 0 then my_array = my_array[*,A]

Hope that helps,
Ben

PS In about 2 minutes you'll hear a chorus of other (better) methods
from people more knowledgable than I about these things.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: making multiple histogram plots
Next Topic: Re: Mac Version Structure

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

Current Time: Wed Oct 08 19:30:41 PDT 2025

Total time taken to generate the page: 0.00494 seconds