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

Home » Public Forums » archive » Re: Flow3 procedure and WHERE
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: Flow3 procedure and WHERE [message #39466] Mon, 24 May 2004 17:03
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Adhara writes:

> Hello Dr.Fanning, Thanks for effort in trying to understand my
> program!However, let me clearify some points:
>
> - Yes, my velocity vectors are three dimensional. Meaning that Vx is
> the component of the velocity in the x-direction, Vy is the component
> of the velocity in the y-direction, and Vz is the component of the
> velocity in the z-direction. I expect IDL to plot the resultant of
> these three components starting at the coordiates (sx,sy,sz).

Well, then you might try making your S vectors the same size
as your V vectors and subsetting them with the same index you
are using to find all the non-zero values:

index = Where((vx ne 0) AND (vy ne 0) AND (vz ne 0), count)
vxx = vx[index]
sxx = sx[index]

Note that your arrays are floating point, so instead of
trying to find those values that *exactly* equal zero you
might have to find values that are "pretty close" to zero.

> - I think I will get them to have the same size because Vx,Vy,Vz have
> a value different to zero, all at the same time and at the same
> location. So probably FlOW3 will like it!!

May God grant you long life and fabulous wealth!
I mean, yes, maybe. :-)

> - I also have the exact location at which the vector starts, therefore
> I rather use it as input in FLOW3. My problem has been to *extract*
> these Sx, Sy, Sz coordinates at which Vx,Vy,Vz are different from
> zero. These location vectors will also have the same size as the
> velocity vectors.

OK, this sounds like a plan.

> -From the 32400 data points that I have, only 521 have data different
> from zero. The velocity data is very small, and as you suggested I am
> already using a factor to increase those values. However, this factor
> can not be greater than 20 because:
>
> % Program caused arithmetic error: Floating divide by 0
> % Program caused arithmetic error: Floating overflow
> % Program caused arithmetic error: Floating illegal operand

Humm. Hard to see how this could happen by scaling a small
value by a large value, unless you were using a HUMONGOUS
value! Probably an error in your algorithm, I think.

> - Do my comments clearify my ideas to you?

Uh, well, I'm pretty dense when it comes to this kind of thing. :-)

> I tried to do it as well in 2D as you said. However, I have a simple
> question because I am having an error according to the command
> arguments, due to the size of U and V using VELOVECT.
>
> I am using U as one dimensional vector with Vx, and V as one
> dimensional vector with Vy. What does it mean that it "must be a
> two-dimensional array".??

Well, it means the arguments must have two dimensions.
Humm, let's see, how would I explain this? Suppose
you have a three dimensional array:

IDL> array = Findgen(4, 3, 5)
IDL> Help, array
ARRAY FLOAT = Array[4, 3, 5]

This maybe represents XYZ values. If I want a 2D
slice in the Z direction, I might do this:

IDL> slice = Reform(array[*,*,2])
IDL> Help, slice
SLICE FLOAT = Array[4, 3]

If I want a vector (a 1D array) from the slice:

IDL> vector = Reform(slice[*,1])
IDL> Help, vector
VECTOR FLOAT = Array[4]

Just for fun, I'd try something like this:

VELOCECT, Reform(VX[*,*,40]), Reform(VY[*,*,40])

Or contour those variables. I don't know. *Something*
should work.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Flow3 procedure and WHERE [message #39480 is a reply to message #39466] Mon, 24 May 2004 08:44 Go to previous message
adharac is currently offline  adharac
Messages: 23
Registered: April 2004
Junior Member
Hello Dr.Fanning, Thanks for effort in trying to understand my
program!However, let me clearify some points:

- Yes, my velocity vectors are three dimensional. Meaning that Vx is
the component of the velocity in the x-direction, Vy is the component
of the velocity in the y-direction, and Vz is the component of the
velocity in the z-direction. I expect IDL to plot the resultant of
these three components starting at the coordiates (sx,sy,sz).

- I think I will get them to have the same size because Vx,Vy,Vz have
a value different to zero, all at the same time and at the same
location. So probably FlOW3 will like it!!

- I also have the exact location at which the vector starts, therefore
I rather use it as input in FLOW3. My problem has been to *extract*
these Sx, Sy, Sz coordinates at which Vx,Vy,Vz are different from
zero. These location vectors will also have the same size as the
velocity vectors.

-From the 32400 data points that I have, only 521 have data different
from zero. The velocity data is very small, and as you suggested I am
already using a factor to increase those values. However, this factor
can not be greater than 20 because:

% Program caused arithmetic error: Floating divide by 0
% Program caused arithmetic error: Floating overflow
% Program caused arithmetic error: Floating illegal operand

- Do my comments clearify my ideas to you?
- Should I use instead: IF vx, vy, vz NE 0 then write sx,sy,sz into
the respective arrays. How can I do this?


I tried to do it as well in 2D as you said. However, I have a simple
question because I am having an error according to the command
arguments, due to the size of U and V using VELOVECT.

I am using U as one dimensional vector with Vx, and V as one
dimensional vector with Vy. What does it mean that it "must be a
two-dimensional array".??


openr,q,'VOa.dat',/Get_Lun
;A=fltarr(6,10*5L)
A=fltarr(6,360*90L)
readF,q,A
Free_Lun,q

; The velocity in 2D will be plotted on the plane x-z, however, there
is data for Vy and y, but will be ingored.

Vx=fltarr(360,90)
Vz=fltarr(360,90)

For i = 0, 32399L Do Begin

;(0) first column of the array is z (0<z<90)
;(1) second column of the array is y (constant)
;(2) third column of the array is x (0<x<360)
;(3) fourth column of the array is Vz
;(4) fifth column of the array is Vy
;(5) sixth column of the array is Vx


Vx(A(2,i)-1,A(0,i)-1) = A(5,i)
Vz(A(2,i)-1,A(0,i)-1) = A(3,i)

Endfor

Vxx=WHERE(Vx NE 0,count5)
Vzz=WHERE(Vz NE 0,count6)

Velovect,Vxx,Vzz

end

Thank You very much Dr.Fanning, I hope to hear from you soon,

Adhara
Re: Flow3 procedure and WHERE [message #39484 is a reply to message #39480] Sun, 23 May 2004 18:56 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Adhara writes:

> I updated the program and now I don't have that weird error message.
> Sometimes it helps just logging off and starting again!

Yes, it sometimes helps. This is why this is the *first*
thing a technical support engineer will ask you to do
when you call in. It solves about half the problems
before he even has to do any thinking. :-)

But that said, every time I resort to exiting IDL I
consider it a mortal sin and I head straight for
confession. :-(

> I just sent another message including my updated program because I
> noticed that I am not getting the Sx,Sy,Sz vectors with the values
> that I should. I printed the Sx values and they are just a list of
> numbers from 0 to n, where n coincides with the number of points where
> the velocity is different from zero!
> Do you know how can I define them so that they will only include the
> coordinates at which Vx, Vy and Vz are different from zero?

I have to admit, I am totally confused by your program
and your approach. I would be extremely surprised if it
works. Your three "V" arrays are three dimensional, are
they not? And many of the values are 0. Fair enough. But
you are finding the locations where Vx is not equal to
zero, then the locations where Vy is not equal to zero,
and so forth. While many of these locations will be the
same in all three arrays, presumably, many others will
not. Using your approach you will very likely end up with
three "V" arrays of unequal size. FLOW3 is not going to
like that. :-)

What you want, I think, is where Vx and Vy and Vz are
all three not equal to zero, but then you can still
potentially throw away real data, because surely 0
is a possible vector magnitude. So, I think the
approach is suspect, just from a scientific point
of view.

I've never used FLOW3, but it seems to be a three-
dimensional VELOVECT. Flow lines will be drawn in
the 3D space according to the "forces" a point
source will feel as it moves though the volume.
So probably your "S" vectors are irrelevant to
solving this problem. Eliminating them and allowing
the program to choose random starting coordinates
sounds like a good idea to me. At least I can't
see any obvious benefit from starting the flow
lines on top of the forces the point is suppose
to be feeling, which I take is the gist of your
current approach.

I take it the original problem was that the force
field lines were tiny compared to the volume space.
I believe you concluded this was because the force
vectors were quite small (10^-3 or something, if
I recall). Have you tried just scaling everything
by some factor? Have you tried setting the LEN keyword
to FLOW3?

Or maybe you just need to re-think the entire
problem. Have you tried making stacks of
2D contour plots to see if you can see anything that
way? I don't know which approach might work best.
But I think this one is not heading for a good
result. :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Flow3 procedure and WHERE [message #39485 is a reply to message #39484] Sun, 23 May 2004 15:16 Go to previous message
adharac is currently offline  adharac
Messages: 23
Registered: April 2004
Junior Member
Hello David,
I updated the program and now I don't have that weird error message.
Sometimes it helps just logging off and starting again!

I just sent another message including my updated program because I
noticed that I am not getting the Sx,Sy,Sz vectors with the values
that I should. I printed the Sx values and they are just a list of
numbers from 0 to n, where n coincides with the number of points where
the velocity is different from zero!
Do you know how can I define them so that they will only include the
coordinates at which Vx, Vy and Vz are different from zero?

Here it is: and as always, thank you for any feedback you can give me
on this one!!!

CHEERS, ADHARA


openr,q,'VOa.dat',/Get_Lun ;open files for reading

A=fltarr(6,90*360L) ;create arrays to hold data in files

readf,q,A ;read files into arrays

Free_Lun,q ;close files and clear logical unit assigned to each
file

Vx=fltarr(360,360,90) ;create 3 dimensional arrays to hold vector
data.
Vy=fltarr(360,360,90) ;the indices will be Vx(x,y,z)
Vz=fltarr(360,360,90)

factor = 0

For i = 0, 32399L Do Begin ;change here the number of records
ifneeded.

Vx(A(2,i)-1,A(1,i)-1,A(0,i)-1) = A(3,i)*10.0^factor
Vy(A(2,i)-1,A(1,i)-1,A(0,i)-1) = A(4,i)*10.0^factor
Vz(A(2,i)-1,A(1,i)-1,A(0,i)-1) = A(5,i)*10.0^factor

Endfor

Vxx=WHERE(Vx NE 0,count1)
Vyy=WHERE(Vy NE 0,count2)
Vzz=WHERE(Vz NE 0,count3)

sx=A[2,*]
sy=A[1,*]
sz=A[0,*]

Sx=where(Vxx NE 0)
Sy=where(Vyy NE 0)
Sz=where(Vzz NE 0)


PRINT, 'Subscripts of elements ne 0: ', Sx

vol = FLTARR(360, 360, 90)

WINDOW, XSIZE = 390, YSIZE = 400

Scale3, zr=[0,90], yr=[0,360], xr = [0,360]

flow3, Vx, Vy, Vz,SX=Reform(sx), SY=Reform(sy), SZ=Reform(sz)
END







David Fanning <davidf@dfanning.com> wrote in message news:<MPG.1b1a847abd8523e5989763@news.frii.com>...
> Adhara writes:
>
>> hello, So I followed the advice.... from the 32400 records that I
>> initially had, now all my coordinate arrays (sx,sy,sz) and velocity
>> arrays (vx,vy,vz) are of 521 records each (i.e. sxx, syy, szz and vxx,
>> vyy and vzz).
>>
>>
>> However, I am getting and error message that I have not been able to
>> fix...
>>
>> IDL> .COMPILE "C:\RSI\IDL55\lib\mycount.pro"
>> % Compiled module: $MAIN$.
>> IDL> .CONTINUE
>> % Type of FOR statement index variable <No name> may not be changed.
>> % Execution halted at: $MAIN$ 309
>> C:\RSI\IDL55\lib\mycount.pro
>>
>> How can I fix this?
>
> Well, this error occurs in line 309 of your main program.
> The program you are showing us only has 45 lines (and no
> apparent errors that I can see). Are you sure this is the
> program you are running? :-)
>
> What do you call the file this program is in? How do you
> make it run in IDL? That is, what IDL commands to you
> use to make it run?
>
> Cheers,
>
> David
Re: Flow3 procedure and WHERE [message #39490 is a reply to message #39485] Sun, 23 May 2004 09:51 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Adhara writes:

> hello, So I followed the advice.... from the 32400 records that I
> initially had, now all my coordinate arrays (sx,sy,sz) and velocity
> arrays (vx,vy,vz) are of 521 records each (i.e. sxx, syy, szz and vxx,
> vyy and vzz).
>
>
> However, I am getting and error message that I have not been able to
> fix...
>
> IDL> .COMPILE "C:\RSI\IDL55\lib\mycount.pro"
> % Compiled module: $MAIN$.
> IDL> .CONTINUE
> % Type of FOR statement index variable <No name> may not be changed.
> % Execution halted at: $MAIN$ 309
> C:\RSI\IDL55\lib\mycount.pro
>
> How can I fix this?

Well, this error occurs in line 309 of your main program.
The program you are showing us only has 45 lines (and no
apparent errors that I can see). Are you sure this is the
program you are running? :-)

What do you call the file this program is in? How do you
make it run in IDL? That is, what IDL commands to you
use to make it run?

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Widgets: Menu access through keyboard on Linux
Next Topic: Re: Choice of 64-bit platform for IDL

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

Current Time: Sun Oct 12 12:53:11 PDT 2025

Total time taken to generate the page: 0.71804 seconds