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

Home » Public Forums » archive » Gradient of two dimensional field
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: Gradient of two dimensional field [message #8294 is a reply to message #8200] Wed, 19 February 1997 00:00 Go to previous messageGo to previous message
bowman is currently offline  bowman
Messages: 121
Registered: September 1991
Senior Member
In article <brian.jackel.106.19DE53E0@uwo.ca>, brian.jackel@uwo.ca (Brian
Jackel) wrote:

>>> we want to determine the electrical field from a given potential,
>>> i.e. we have to calculate the gradient of a two dimensional array.
>>>
>>> Has anybody a idl-pvwave procedure to do this task?
>
>> I would think that the shift function (used twice)
>> could be used to do this.
>
> Or even just
>
> dx= a(1:*,*) - a
> dy= a(*,1:*) - a
>
> or
>
> dx= a(1:n-1,*) - a(0:n-2,*)
> dy= a(*,1:m-1) - a(*,0:m-2)
>
> if "a" has dimensions of (n,m). When doing it the first way IDL takes
> care of the different array sizes, with no perceptible performance hit.
> The second way is perhaps a bit easier to read. Is this what you (the
> original poster) were after?


You may want to use centered differences, i.e.

dzdx = (SHIFT(z,-1, 0) - SHIFT(z, 1, 0))/(2.0*dx)
dzdy = (SHIFT(z, 0,-1) - SHIFT(z, 0, 1))/(2.0*dy)

(I trust the compiler is smart enough to convert the division to
multiplication.)

Don't forget to fix the edges, i.e., use uncentered differences for the
normal component or whatever is appropriate for your problem.

Ken

--
Kenneth P. Bowman, Assoc. Prof. 409-862-4060
Department of Meteorology 409-862-4132 fax
Texas A&M University bowman@csrp.tamu.edu
College Station, TX 77843-3150
Satellite ozone movies on CD-ROM --> http://www.lenticular.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Printing array on one line
Next Topic: using GET_KBRD

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

Current Time: Wed Dec 03 14:21:37 PST 2025

Total time taken to generate the page: 0.72511 seconds