Both vorticity and divergence are defined in terms of partial derivatives.
You can compute these derivatives using the `grad' function in
"numDeriv"
package.
U <- function(X) { your U function}
V <- function(X) { your V function}
# where X = c(x,y)
library(numDeriv)
grU <- function(X) grad(X, func=U)
grV <- function(X) grad(X, func=V)
# For a 2-dimensional vector field
vortivcity <- function(X) grV(X)[2] - grU(X)[1]
divergence <- function(X) grU(X)[1] + grV(X)[2]
# Here is an example:
U <- function(X) X[1]^2 + X[1] * X[2]
V <- function(X) X[2]^2 - X[1] * X[2]
> vorticity(c(2,1))
[1] -5> divergence(c(2,1))
[1] 5>
Does this help?
Ravi.
----------------------------------------------------------------------------
-------
Ravi Varadhan, Ph.D.
Assistant Professor, The Center on Aging and Health
Division of Geriatric Medicine and Gerontology
Johns Hopkins University
Ph: (410) 502-2619
Fax: (410) 614-9625
Email: rvaradhan at jhmi.edu
Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
----------------------------------------------------------------------------
--------
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
Behalf Of Igor Oliveira
Sent: Monday, September 08, 2008 11:37 AM
To: r-help at r-project.org
Subject: [R] Vorticity and Divergence
Hi all,
I have some wind data (U and V components) and I would like to compute
Vorticity and Divergence of these fields. Is there any R function that can
easily do that?
Thanks in advance for any help
Igor Oliveira
CSAG, Dept. Environmental & Geographical Science, University of Cape Town,
Private Bag X3, Rondebosch 7701. Tel.: +27 (0)21 650 5774
South Africa Fax: +27 (0)21 650 5773
http:///www.csag.uct.ac.za/~igor
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.